__dict__ attribute for built-in types
alex23
wuwei23 at gmail.com
Thu Oct 27 22:48:32 EDT 2011
On Oct 28, 8:52 am, candide <cand... at free.invalid> wrote:
> No but I'm expecting from Python documentation to mention the laws of
> Python ...
It's not a "law", it's an _implementation detail_. The docs don't tend
to mention every such decision made because that's what the source is
for.
> But beside this, how to recognise classes whose object doesn't have a
> __dict__ attribute ?
The better question is: why do you need to be able to?
> Is it possible in the CPython implementation to write something like this :
> "foo".bar = 42
> without raising an attribute error ?
Why are you trying to modify an immutible object?
If you really want to assign attributes to string objects, subclass
str.
More information about the Python-list
mailing list