Python Newbie

Terry Reedy tjreedy at
Sat Feb 23 02:04:21 CET 2013

On 2/22/2013 4:37 PM, piterrr.dolinski at wrote:

Yours is the first post here, that I know of, from someone 'forced' to 
learn and use Python at their job. Several people have instead 
complained about being prohibited from using Python at work. I am sorry 
that you have been introduced to it in such a poor way.

I am doubly sorry that your first Python job is to work with a monstrous 
script that most of us would likely also hate. I am sure anyone 
responding here would have split 2000 lines into multiple  testable 
functions even if every function was called just once (other than in the 
test code).

I came to Python from C. It took me about 2 weeks to grok the difference 
between being object based and memory-block based. I am glad someone who 
knows something of C# could say more.

About 'if obj: pass'. Simplifying just a bit, the interpreter executes 
that internally as 'if obj.__bool__() ...'. It adds the implicit call so 
you do not have to write it, or an equivalent expression. For each 
class, the method gives an appropriate default classification. For 
numbers, 'if x' means 'if x != 0'. For collections, 'if c' means 'if 
len(c) != 0'. Once one gets used to it, it is a great saving in writing 
and reading. If the default classification is not the one you want, you 
write an explicit expression that is the one you want.

I too would have preferred fun or func, but I live with def.

As for function calling, forget 'pass by value' versus 'pass by 
reference'. Both mislead in certain situations.

x = y+3

computes an object from 'y+3', looking up name 'y' in the current 
namespaces, and associates the object with name 'x' in the current local 
namespace. (This assumes the default situation with no 'global x' or 
'nonlocal x' declarations.)

def f(x): return 2*x

computes an object from 'y+3' looking up name 'y' in the current 
namespaces, makes the local namespace of f the current local namespace, 
and associates the object with the name 'x' in the new local namespace.

Toy? I think the first 'killer app' for Python was nuclear weapon 
calculations at U.S. National Labs (Livermore and Los Alamos), where 
numerical python started. The current version, numpy, along with scipy 
and many other packages, is used throughout the sciences.

On the other hand, Python is the most fun language for most of us, so in 
that sense it's a great toy. And I also think it a great replacement for 

Terry Jan Reedy

More information about the Python-list mailing list