This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author arsatiki
Recipients arsatiki
Date 2008-01-24.13:35:46
SpamBayes Score 0.050018758
Marked as misclassified No
Message-id <1201181747.66.0.31684496906.issue1921@psf.upfronthosting.co.za>
In-reply-to
Content
Guido's document "Unifying types and classes in Python 2.2" (descrintro)
contains a confusing example for metaclass newbies. 
<http://www.python.org/download/releases/2.2.3/descrintro/#metaclass_examples>

The example in question is autoprop, which uses the variable "name" in
three different contexts. First, it is the name of the class being
created. Second, it is used in a for loop to denote the keys of the
class dict. And thirdly, it is used to denote substrings of a subset of
those keys.

Upon my first encounter with the example, I found myself staring at the
getattr and setattr lines in disbelief. I associated "name" as the
parameter given to the __init__ function.

I'd propose changing the first for-loop name to "member" or similar
and the second to "propname" or "prop". 

Furthermore, a modern version of the same example could use sets and set
comprehensions instead of dict.keys():
props = {member[5:] for member in dict if member.startswith...}
History
Date User Action Args
2008-01-24 13:35:47arsatikisetspambayes_score: 0.0500188 -> 0.050018758
recipients: + arsatiki
2008-01-24 13:35:47arsatikisetspambayes_score: 0.0500188 -> 0.0500188
messageid: <1201181747.66.0.31684496906.issue1921@psf.upfronthosting.co.za>
2008-01-24 13:35:46arsatikilinkissue1921 messages
2008-01-24 13:35:46arsatikicreate