[Python-ideas] global and nonlocal with atributes
João Bernardo
jbvsmo at gmail.com
Sun May 5 18:46:35 CEST 2013
>
> This is just an example and there are many other use cases.
>>
>
> Great! Let's hear what those other use-cases are. Maybe some of them are
> more compelling.
>
> - Being able to identify more easily the variable.
- UnboundLocalError is too confusing for starters
- This is a counterpart for "from foo import bar". Did you never scrolled
up 500 lines of code in a module to see what this "do_weird_stuff()"
function came from?
- Maybe "big function" I wrote is not just what you're thinking:
If you're reading a diff output, 10 lines could be enough to hide the
information.
If you're on 80x25 terminal window, 30 lines could be too much.
If you have a critical security bug at 3am after drinking two liters of
coffee, 1 line can be too much.
And, if you're one of the people my boss hire to "help" the project, I
won't even guess what is too much for your twisted mind. :)
Yes, there are use cases, you can probably think of others too.
>> Well, I didn't proposed them to become objects... There's nothing wrong
>> with some keywords behaving *partially* like objects.
>>
>
> Of course there is something wrong with keywords behaving partially like
> objects. It is bad design that makes it harder to reason about what code
> does. It makes it harder to learn the language. It complicates the
> execution model. It complicates the parser.
>
> Good programming languages must be consistent. Things which are similar
> should look similar. Things which are different should look different. In
> your proposal, things which are different (the global keyword, and objects)
> look similar. That makes Python less consistent, which makes it a worse
> language.
>
>
The form of "super" without arguments is super inconsistent. It is just
black magic, but it works.
Another point is that your text editor (usually) will color the word
"global" differently, so it's easy to accept this may not be an object like
others.
Also, I would argue it is more consistent to use namespaces than to declare
the variable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130505/53b81c02/attachment.html>
More information about the Python-ideas
mailing list