Python Newbie

Steven D'Aprano steve+comp.lang.python at
Mon Feb 25 02:04:43 CET 2013

On Sun, 24 Feb 2013 16:08:06 -0800, piterrr.dolinski wrote:

>> For example (I believe it's already been mentioned) "declaring" intX
>> with some integer value does *nothing* to maintain
>> X as an integer:
>> --> intX = 32
>> --> intX = intX / 3.0
>> --> intX
>> 10.6666666666
> Yes I did see that it is possible to redefine the type of a variable.

Variables do not have types in Python.

Reset your thinking. Python is a dynamic language with name bindings and 
strongly-typed objects, not a static language with strongly-typed 
variables. If you don't understand the difference, ask. But so long as 
you make the wrong assumptions about the language, you will have a bad 

You will find programming much easier, and more pleasant, if you learn 
the semantics and idioms of the language you are using, instead of trying 
to treat every language as the same.

> But I don't think I would ever do this intentionally; need to be really
> careful with Python.

Not at all. The only difference is whether you get a compiler error or a 
runtime error. Instead of:

10 Write code.
20 Compile.
30 If compiler error, GO TO 10.
40 REM code compiles, but it still needs to be tested
50 Test code.
60 If error, GO TO 10.
70 Deploy.

we have:

10 Write code.
20 Test code.
30 If error, GO TO 10.
40 Deploy.


More information about the Python-list mailing list