setattr and variable names: bug or feature?
Michael Hudson
mwh21 at cam.ac.uk
Fri Feb 25 11:55:41 EST 2000
Gerrit Holl <gerrit.holl at pobox.com> writes:
> Dear bottomless information source,
>
> >>> class Foo:
> ... pass
> ...
> >>> setattr(Foo, '', '')
> >>> setattr(Foo, '`', '')
> >>> setattr(Foo, '\'', '')
> >>> setattr(Foo, '!@#{}\0\0\0', '')
> >>> dir(Foo)
> ['', '!@#{}\000\000\000', "'", '__doc__', '__module__', '`']
>
> Is this a bug or a feature, or None of both?
Feature, I'd say. I've used names like this when I've been playing
silly buggers with setattr & getattr methods, for example.
Cheers,
M.
--
very few people approach me in real life and insist on proving they are
drooling idiots. -- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list