Language design

diverman pavel at schon.cz
Tue Sep 10 02:59:49 EDT 2013


No exactly bad, but can suprise

>>> foo=([],)
>>> foo[0] += ['bar']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> foo
(['bar'],)



Dne úterý, 10. září 2013 8:09:25 UTC+2 Steven D'Aprano napsal(a):
> Some time ago, Tom Christiansen wrote about the "Seven Deadly Sins of 
> 
> Perl":
> 
> 
> 
> http://www.perl.com/doc/FMTEYEWTK/versus/perl.html
> 
> 
> 
> 
> 
> What design mistakes, traps or gotchas do you think Python has? Gotchas 
> 
> are not necessarily a bad thing, there may be good reasons for it, but 
> 
> they're surprising.
> 
> 
> 
> To get started, here are a couple of mine:
> 
> 
> 
> 
> 
> - Python is so dynamic, that there is hardly anything at all that can be 
> 
> optimized at compile time.
> 
> 
> 
> - The behaviour of mutable default variables is a gotcha.
> 
> 
> 
> - Operators that call dunder methods like __add__ don't use the same 
> 
> method resolution rules as regular methods, they bypass the instance and 
> 
> go straight to the type, at least for new-style classes.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven




More information about the Python-list mailing list