On Tue, Jul 15, 2014 at 5:05 PM, anatoly techtonik <techto...@gmail.com> wrote:
> Is it possible at all to define a class in Python that > can read name of variable it is assigned to on init? > > >>> MyObject = SomeClass() > >>> print(MyObject) > 'MyObject' This feature would be useful for things like namedtuple, where we currently have to write the name twice: record = namedtuple('record', 'a b c d') But I'm not sure why Anatoly is asking here. It would be a change in semantics of Python, and while I suppose it's possible for PyPy to lead the way with a semantic change for Python 3.5 or higher, or even an implementation-specific feature that other Python's don't offer, I would expect that normally this idea should go through CPython first. -- Steven _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev