element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum What is the best way to learn Python?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 38 replies
  • Answers 2 answers
  • Subscribers 680 subscribers
  • Views 4440 views
  • Users 0 members are here
  • learn
  • python
Related

What is the best way to learn Python?

peterjcs23
peterjcs23 over 10 years ago

I have written software in C for embedded processors. Raspberry Pi uses Python, so what is the best way to learn it? What is the best book? What about a web based tutorial?

 

C has a standard core and suppliers of compilers add functions. Is Python similar, do I need to learn the Raspberry Pi version?

 

Thanks, Peter

  • Sign in to reply
  • Cancel
Parents
  • royleith
    0 royleith over 10 years ago

    I suggest 'Learning Python' by Mark Lutz and David Ascher and published by O'Reilly as it often explains the Python way of dealing with c programming tasks. There are lots of examples and exercises (with solutions). Once you get to grips with the Python objects, the very best resource is the wonderful,

     

    https://www.python.org/

     

    In fact, browse the site, first, and see if the downloads and on-line references, tutorials and other documentation are enough to get you going. Once you get functions, strings,  tuples, lists, classes, dictionaries and the like, the documentation should make lots of sense.

     

    Imports are to Python as includes are to c. Python imports are modules which add functionality, but most of the ones you want are included by default when Python is installed (by default in the Pi). The Pi also has the IDLE IDE installed for both the current Python 2.7 (widely used across many platforms) and Python 3 (the future). I have written Python programs on the Pi which access the command line, use COM ports and the Tkinter GUI module and they run with minor changes on Microsoft Windows by installing the same modules.

     

    As Michael says, you can program in most languages using the Pi. However, Python on the Raspberry Pi comes as standard with a module to access the GPIO features (although the more complex issues such as I2C, serial and PWM have yet to be added). The Broadcom chip is complex and many of its features are entwined with the Linux operating system. It may not be that straight forward to use every GPIO feature. Also, the Pi2 puts its control and read registers at different addresses. The joy of using the Python modules is that the ins and outs of Linux and Broadcom are already sorted. There are plenty of examples of PWM and I2C programs written in Python just using the simple I/O pins rather than the dedicated Broadcom pins. However, C would be the way to go if you want precise time dependant programming as Python is interpreted and has the occasional mid-program tidy-up. Even pre-compiled Python may be a problem.

     

    I just checked with the Synaptic Package Manager and GCC is already installed in the Pi. Java is in the repository as is Fortran, Ada, Objective C, C++, Cobol... you get the idea! There are lots of others such as Ruby and Forth. However, if you want to use c or c++ you will have to do a fair amount of research to drive the GPIO hardware to the full without killing the operating system. All the usual OS stuff is available to C and C++.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • royleith
    0 royleith over 10 years ago

    I suggest 'Learning Python' by Mark Lutz and David Ascher and published by O'Reilly as it often explains the Python way of dealing with c programming tasks. There are lots of examples and exercises (with solutions). Once you get to grips with the Python objects, the very best resource is the wonderful,

     

    https://www.python.org/

     

    In fact, browse the site, first, and see if the downloads and on-line references, tutorials and other documentation are enough to get you going. Once you get functions, strings,  tuples, lists, classes, dictionaries and the like, the documentation should make lots of sense.

     

    Imports are to Python as includes are to c. Python imports are modules which add functionality, but most of the ones you want are included by default when Python is installed (by default in the Pi). The Pi also has the IDLE IDE installed for both the current Python 2.7 (widely used across many platforms) and Python 3 (the future). I have written Python programs on the Pi which access the command line, use COM ports and the Tkinter GUI module and they run with minor changes on Microsoft Windows by installing the same modules.

     

    As Michael says, you can program in most languages using the Pi. However, Python on the Raspberry Pi comes as standard with a module to access the GPIO features (although the more complex issues such as I2C, serial and PWM have yet to be added). The Broadcom chip is complex and many of its features are entwined with the Linux operating system. It may not be that straight forward to use every GPIO feature. Also, the Pi2 puts its control and read registers at different addresses. The joy of using the Python modules is that the ins and outs of Linux and Broadcom are already sorted. There are plenty of examples of PWM and I2C programs written in Python just using the simple I/O pins rather than the dedicated Broadcom pins. However, C would be the way to go if you want precise time dependant programming as Python is interpreted and has the occasional mid-program tidy-up. Even pre-compiled Python may be a problem.

     

    I just checked with the Synaptic Package Manager and GCC is already installed in the Pi. Java is in the repository as is Fortran, Ada, Objective C, C++, Cobol... you get the idea! There are lots of others such as Ruby and Forth. However, if you want to use c or c++ you will have to do a fair amount of research to drive the GPIO hardware to the full without killing the operating system. All the usual OS stuff is available to C and C++.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • peterjcs23
    0 peterjcs23 over 10 years ago in reply to royleith

    Hi Roy thanks for the advice and comprehensive reply.

     

    Learning Python looks like a pretty good book, generally I like O'Reilly books, I use their C Pocket Reference all the time.

     

    python.org is a great resource as you say.

     

    As you may have guessed I am interested in access functions like SPI and interrupts, that look like more of a challenge. I have got used to using PSoC processors and the extensive C support from Cypress.

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube