[Tutor] Tips

Steven D'Aprano steve at pearwood.info
Thu Jun 19 14:42:21 CEST 2014


On Tue, Jun 17, 2014 at 02:52:33PM -0400, keith papa wrote:
> 
> Hi, I want to no what some tips or information you can give me to 
> remember some of the rules of python, when you first start learning 
> programming?

Questions about memory (that is, *human* memory, in the brain) are not
really on-topic for this list. We're not likely to be experts on how
memory works. (I'm a little dubious that *anyone* is an expert on how
memory works, but that's another story.)

But having said that, what worked for me was, practice practice and even
more practice. I have spent *years* writing little bits of Python code.
99.9% of that code was junk, and either never finished, or thrown away
but it's still good practice. If you want to be a master carpenter, you
have to expect to spend a lot of time making rubbish before you make
your masterpiece. Same applies to programming.

Get used to *reading* Python code. (It's easier to read something than
to write it.) You will find huge amounts of Python code on the Internet,
on Wikipedia, on the Activestate cookbook, on the tutor archives, in the
Python standard library, and more:

https://en.wikipedia.org/wiki/Python_%28programming_language%29

http://code.activestate.com/recipes/langs/python/

https://mail.python.org/pipermail/tutor/

http://hg.python.org/cpython/file/cf70f030a744/Lib/

https://wiki.python.org/moin/SimplePrograms

http://rosettacode.org/wiki/Category:Python


To learn to program in Python, you need to spend time writing Python
code as well as reading it. You'll make mistakes. That's *good*. Every
time you make a mistake:

py> for i = 1 to 20:
  File "<stdin>", line 1
    for i = 1 to 20:
          ^
SyntaxError: invalid syntax


that's an opportunity for learning something. The great thing about
making mistakes is that you never run out of opportunities to learn!

When you make a mistake, try to match what you've written to something
you've read. In the above, I've tried to write a for-loop, but I've
written it almost the way I'd write it in Pascal, not Python. Naturally
it doesn't work. Where have I seen something with a for loop in Python?

http://rosettacode.org/wiki/Flow-control_structures#Loops

https://wiki.python.org/moin/ForLoop

The more code you have read, the more likely you will have seen
something similar to what you are trying to do. And the more you write 
it, the more it will sink in to your memory and become second nature.


-- 
Steven


More information about the Tutor mailing list