__qualname__ exposed as a local variable: standard?

2016-07-09 Thread carlosjosepita
Hi all,

I noticed __qualname__ is exposed by locals() while defining a class. This is 
handy but I'm not sure about its status: is it standard or just an artifact of 
the current implementation? (btw, the pycodestyle linter -former pep8- rejects 
its usage). I was unable to find any reference to this behavior in PEP 3155 nor 
in the language reference.

Thank you in advance
--
Carlos
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Namespaces are one honking great idea

2016-07-09 Thread carlosjosepita
Hi all,

although it doesn't fit the bill 100%, I sometimes use this extremely simple 
function as a decorator:

def new(call):
return call()


For example:

@new
class MySingleton:
x = 2
y = 2
def sum(self, x, y):
return x + y


@new
def my_obj():
x = 2
y = 2
def sum(x, y):
return x + y
return Bundle(locals())


where Bundle is a simple subclass of dict implementing __xxxattr__ dunder 
methods.

Cheers
--
Carlos


 
-- 
https://mail.python.org/mailman/listinfo/python-list