[Python-Dev] Explicit Lexical Scoping (pre-PEP?) (original) (raw)

K.S.Sreeram sreeram at tachyontech.net
Tue Jul 11 10:56:54 CEST 2006


Talin wrote:

def x(): scope = object() scope.x = 1 def y(): scope.x = 2

'object' doesn't let you set custom attributes. Here's what I normally use in my code...

class Data : pass

def x() : d = Data() d.x = 1 def y() : d.x += 1

Regards Sreeram

-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-dev/attachments/20060711/eb5ca5be/attachment.pgp



More information about the Python-Dev mailing list