Hacker News new | past | comments | ask | show | jobs | submit login
Code Like a Pythonista: Idiomatic Python (python.net)
49 points by iamelgringo on Jan 31, 2009 | hide | past | favorite | 8 comments



I had no idea that "_" stores the last printed expression in the interactive interpreter. That little tip, and the wonderful visual description of Python's "names," were worth more than enough to cover the cost of reading the whole article.


Try using ipython [http://ipython.scipy.org] for much more stuff like _ . e.g. using using _n to get the output of the n'th line you typed in the interpreter.


I actually got confused by the "names" illustrations, even though I know Python. And the illustration doesn't really explain what is the observable difference between Python and "other languages".

I suppose the point is that Python doesn't support "pass by referece"-semantics, and that assignment never copies mutable values. However, AFAIK this is exactly the same as at least Java and JavaScript, and probably other languages too (I would guess Ruby and Lisp also, although I'm not sure).


I think the "names" illustration refers to dynamic typing and points out that assignment creates an association between a name and a value. Differs from C where a name represents a fixed size and location in memory.


The article seems to be missing the key example that cements the concept in your mind.

->

seems to be a TODO place holder. I would expect that the example would be: a = some_object; change a member field in some_object; notice that a gets changed also. The example is really needed, because using only constants it's a distinction without a difference.


Turns out there is a repository of python modules out there:

http://pypi.python.org/pypi?%3Aaction=index

Don't reinvent the wheel if you can use someone else's.


Every language should have a style guide like this.

I suppose for Java and C++ they are Effective Java and Effective C++.


This does get posted a lot, but I still like it.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: