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
  • LenReinhart
    0 LenReinhart over 10 years ago

    If you haven't found it yet, http://www.themagpi.com/ is a free magazine about all things RPi. There are many projects in python as well as other languages. All the issues are available for download. There are 30 issues now plus some specials.

     

    Python is a high level language and it allows fast problem solving. If it turns out that the problem needs more speed, there are linkages to "C" so the low level stuff can go fast.

     

    I took a free course taught by the Google self driving car guy from https://www.coursera.org/   The course was great, but I don't think a complete python novice would appreciate it (unless fairly fluent in some other languages). There are other courses that are a bit more basic.

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

    If you haven't found it yet, http://www.themagpi.com/ is a free magazine about all things RPi. There are many projects in python as well as other languages. All the issues are available for download. There are 30 issues now plus some specials.

     

    Python is a high level language and it allows fast problem solving. If it turns out that the problem needs more speed, there are linkages to "C" so the low level stuff can go fast.

     

    I took a free course taught by the Google self driving car guy from https://www.coursera.org/   The course was great, but I don't think a complete python novice would appreciate it (unless fairly fluent in some other languages). There are other courses that are a bit more basic.

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

    Hi Leonard, thanks for the tips. MagPi is now at Welcome to the MagPi | Raspberry Pi...There is plenty to go at there, I'm sure I'll learn a lot.

     

    Interesting that so say one can mix C and Python. Sounds like I'll need C to access fast interfaces like SPI and interrupts.

     

    The https://www.coursera.org/ ;  some stuff looks sophisticated as you say. There is a Programming for Everyone (Python) course starting in June, that may be suitable.

    https://www.coursera.org/course/pythonlearn

     

    Peter.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago in reply to peterjcs23

    Actually you can easily access SPI with Python as all the hi speed stuff is done in hardware, you just output to a register and watch the magic happen (well a file from pythons perspective)

     

    Sent from my iPhone

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • peterjcs23
    0 peterjcs23 over 10 years ago in reply to Robert Peter Oakes

    ...okay Peter, it has been a bit confusing over SPI. When I buy a RaspPi does python come with these fast functions documented? They sound like a RaspPi specific function. Is the documentation online, I did have a look but failed to find how to use SPI? ...Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 10 years ago in reply to peterjcs23

    peterjcs23

      You may want to check this out for a discussion on SPI and Raspberry Pi using Memory: http://www.element14.com/community/thread/39396/l/comments-for-using-rpi-with-spi-memory

    Cheers,

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 10 years ago in reply to clem57

    As a bonus, it uses Python too!image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • peterjcs23
    0 peterjcs23 over 10 years ago in reply to clem57

    I picked up some useful GPOI/SPI links from element14 on twitter...

     

    Raspberry Pi 3 Model B GPIO 40 Pin Block Pinout

     

    http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/

     

    https://pypi.python.org/pypi/RPi.GPIO

     

    ...sounds like RPi is not ideal for real time work.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • LenReinhart
    0 LenReinhart over 10 years ago in reply to peterjcs23

    It all depends on how fast you need to respond; Linux by default is nonpreemptive. The Beagle Bone Black, which I have in addition to the RPi B, B+ and Pi2, has two additional processors on  to respond to real time events. Exploring Beagle Bone by Derek Molloy (564 pages) is the best guide I’ve found for it. I got it for $10 more than the Pi, but it has on board storage for the OS and twice as many I/O pins, so I believe it is worth it. The Pi is good for many types of embedded systems though. Someone even used it as a brains for a DLP printer, but he is probably not using the default Linux on it.

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

    The RPi is fine for real-time work, but you have to use common sense. Linux is specifically NOT a real time operating system. It is common for serial ports, ethernet ports and other protocols to be set up for debugging purposes. I seem to remember that the hardware I2C pins on the Raspi default to reading any connected I2C memory (and, yes, I've got a couple of cheap 4k chips to play with at some time). Python, even on a true, real-time operating system is interpreted and has automatic housekeeping that can hit timing.

     

    However, raw, non-pre-compiled Python can still be used, for instance, to create an I2C interface on GPIO I/O pins. In-line C code can be embedded in Python objects as a formal part of the language. The I2C and SPI hardware GPIO interfaces are fast and real-time as long as you stop Linux interfering (that is the complexity of providing real-time access to those hardware functions via Python modules).

     

    One of the tricks with Python to improve speed and timing is to 'pre-compile' the object tree and names. I don't do that with the wolfmixer because it obfuscates the code and I want other folk to use my code and ideas, if they want. Pre-compiling certainly reduces all the time taken to reduce the object names to table pointers and code to addresses.

     

    Next, there is a software platform called SWIG 2 for Python that permits C (and C++, IIRC) libraries to be presented as Python objects. I have used it to compile a bit-banging Python program for the FDTI chip on the Raspi. It worked very well, but all the hard work had already been done for me and I had no idea what I was about.

     

    Finally, I have bought a handful of Arduino Mono Chinese clones for a couple of quid each. The Arduino IDE works on the Raspi and any challenging real-time requirements can be dealt with by the tiny Mono for the price of a couple of TI 555 timers. I see this as handy for hobbyist stuff, but any professional use of the Pi should not need additional controllers, just an understanding of what it takes to get real-time functions or real-time hardware working on a complex operating system.

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

    Has anyone thought about loading FreeRTOS on the PI?

    • 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