|
|
|
|
|
by reinhardt
5303 days ago
|
|
The isinstance() criticism is in principle outdated after PEP 3119 [1] but in practice it is indeed mis(/over)-used more often than not. Compiling strings is usually a code smell but at least in the case of namedtuple I'm pretty sure it is justified for at least one reason: performance. It's certainly possible to be implemented in more idiomatic python but the result would probably be less efficient compared to, say, dicts or regular objects. [1] http://www.python.org/dev/peps/pep-3119/#abcs-vs-duck-typing |
|