dictionary initialization

Batista, Facundo FBatista at uniFON.com.ar
Fri Nov 26 15:40:40 EST 2004


[Caleb Hattingh]
#- > (x not existing yet)
#- > x+=1
#- >
#- > And have x = 1, while in Python you have to do
#- >
#- > (x not existing yet)
#- > x=0
#- > x+=1
#- >
#- > And then have x=1?   Is this the question of debate here?  
#- One line of 
#- > initialisation to specify the type?


[Dan Perl]

#- Yes, 2 lines instead of 1 is an issue.  And it is not the 
#- only example where 
#- the "explicit is better than implicit" principle shows a 
#- downside.  However, 

You're missing a point. Remember that even dynamic typed, Python is strong
typed.

If Python should deal with the user not binding the name to an object, what
the type of that object should be?

Suppose I put:

>>> del x
>>> x *= 5

x should be bound to an object of what type?

- 0 because x initialized to 0 by default and 0*5==0?
- '' because x initialized to '' by default and ''*5==''?
- [] because....

I think this is NOT a problem of explicit/implicit, is just a problem where
Python can not guess what the user wants...

.	Facundo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20041126/c77754d7/attachment.html>


More information about the Python-list mailing list