Tips for learning Python

I’m starting my first University Course on programming this summer semester and it’s in python. What are some tips or resources I can look at over the next few weeks to help prime myself for this course? I have a small bit of experience in C++ but I know next to nothing about python aside from it being based on indentation rather than brackets.

I believe Codecademy has a course on Python. While it’s probably not the best thing out there it’s certainly a good start. Also, check out the official Python documentation if you haven’t.

Important Note: Python is whitespace sensitive so watch your spacing (It can be a bitch)

Docs: https://docs.python.org/3/
Codecademy: https://www.codecademy.com/

Edit: I forgot to mention the Python 3 is not backwards compatible with Python 2.

2 Likes

You should check out the #noobsofpython series by @Hammerhead_Corvette here on the forums. goes in-depth into many areas of python programming and should be good to get you started.

3 Likes

If you already have programming experience, then it should be easy.
You can try this site also, pretty basic, but you’ll get the idea:
http://www.learnpython.org/

I find practicing it is the key. I have “learned” python a few times, but don’t “know” it because I have never used it to make anything.

For a shell, get IDLE. Its free and works good.

1 Like

Assuming you’re familiar with c++ and already have some sources

  • forget about managing memory (there’s garbage collection)
  • forget about destructors / finalizers / del in Python
  • forget about header files: concepts of namespaces in c++ translates into Python modules
  • modules are interpreted (run) at import time and they’re imported only once
  • public/private/protected translate into whether you start a name with _ or not (__ is some interpreter magic you can learn about later
  • use tuples instead of e.g. std::pair or for x,y,z coordinates and similar
  • python standard library gives you lists, sets, and dicts
  • use list/set/dict comprehensions, or if you don’t want a container with rendered contents in order to save some malloc performance, just use “generator expressions” instead
  • learn what MRO is (classes and inheritance related)
  • learn how iterators work in Python
  • use exceptions (instead of returning errors in C), by defining a module level class Error(Exception): ...docstring underneath
  • skip metaclasses for now, … they’re usually more complicated than they’re useful, most python users have issues

Post code here for review and we can advise

3 Likes

I think there is also a Peter Norvig’s Python course on Udacity. While I can’t recall how sophisticated it is, it might be worth browsing through these sessions.

I think it was this one:

One issue that have had learning Python is distinguishing version 2 and version 3 syntax. If you’re following a guide, make sure you’re aware which version is being used. ‘print’ is a keyword in one, and a function in the other.

While it isn’t necessary to have, I’ve been using the PyCharm IDE to write code with. It has features that completes writing for you, and it looks neat.

Is it for Windows and Linux? I’m running Windows 10 on my home desktop and I’m running Linux Antergos on my school laptop. Also is a shell better than an IDE? ( Apologies, I’m still very new to the scene. When I said a small bit I meant a very small bit.)

I runs fine on Windows.

1 Like

Thank you @MichaelLindman More tutorials are coming @The.Hipster.Lemon so be on the look out.

2 Likes