On Wed, Dec 4, 2013 at 3:35 PM, Piotr Dobrogost
<[email protected]> wrote:
> Right. If there's already a way to have attributes with these "non-standard"
> names (which is a good thing) then for uniformity with dot access to
> attributes with "standard" names there should be a variant of dot access
> allowing to access these "non-standard" named attributes, too.
Given the follow code, what do you think should print?
class My_Class(object):
pass
bar = 1
my_object = My_Class()
setattr(my_object, 'foo', 10)
setattr(my_object, 'bar', 100)
setattr(my_object, 'foo-bar', 1000)
print(my_object.foo-bar)
Today (in python 3.3), it prints 9, because my_object.foo is 10, the
local variable bar is equal to 1, and 10 minus 1 is 9.. Under your
new proposal, it would print 1000, right? Is there any way for your
proposal to be backwards compatible?
--
Jerry
--
https://mail.python.org/mailman/listinfo/python-list