[Python-ideas] Enums
Bruce Leban
bruce at leapyear.org
Thu Jul 28 20:25:48 CEST 2011
On Thu, Jul 28, 2011 at 10:41 AM, Guido van Rossum <guido at python.org> wrote:
>
> Nice, but it still hides the definitions from static analyzers.
>
> It seems I am almost unique in my insistence that Python's dynamic
> features be used very sparingly. :-)
Having worked recently on a project that made extensive use of dynamics, I
am on your side. In that project, I found it completely impossible to trace
a path between any two points in the program short of stepping through it
with a debugger. There are classes and functions that are never explicitly
referenced anywhere that are found via reflection and then instantiated and
called and it is a nightmare.
On the other hand, I love dynamic features for writing tests.
On Thu, Jul 28, 2011 at 10:12 AM, Barry Warsaw <barry at python.org> wrote:
>
> Ezio had a very nice suggestion, which I've implemented in my experimental
> branch, e.g.:
>
> >>> foo = sys.modules['foo']
> >>> Colors.inject(foo)
>
> .inject() takes anything that implements the setattr() protocol. So that
> you
> could then do:
>
> >>> import foo
> >>> foo.red
> Colors.red
So in this example, how would I figure out where foo.red is set? I can't do
it by looking at the source unless I know about Colors.inject.
And what happens if my Weather class has a value Snow and then someone adds
that to the Colors enum and clobbers Weather.Snow. I didn't change my class
but suddenly I can't make it Snow.
--- Bruce
Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110728/bdaf9b47/attachment.html>
More information about the Python-ideas
mailing list