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 gvanrossum
Recipients arsatiki, georg.brandl, gvanrossum
Date 2009-07-11.16:45:54
SpamBayes Score 7.241863e-11
Marked as misclassified No
Message-id <1247330756.73.0.850899198968.issue1921@psf.upfronthosting.co.za>
In-reply-to
Content
I'm guessing you weren't ready for learning about metaclasses if you
didn't get the fact that 'name' was the loop control variable in the two
different loops.  The example is only 11 lines long!

Still, I'm fine with the two suggested renames.

I'm not fine with rewriting the example using modern constructs, since
it is part of the docs for Python 2.2.  Perhaps the doc is still useful
but then it should be first moved into the regular doc tree and *then*
adapted to modern times (and we can't really release that version until
2.7 and 3.2 are released).

Unfortunately I do not have a checkout of the website handy any more (or
I can't remember where I put it).  Maybe one of the webmasters can make
the suggested fixes?

The fixed code that I agree with is:

class autoprop(type):
    def __init__(cls, name, bases, dict):
	super(autoprop, cls).__init__(name, bases, dict)
	props = {}
	for member in dict.keys():
            if member.startswith("_get_") or member.startswith("_set_"):
		props[member[5:]] = 1
	for prop in props.keys():
            fget = getattr(cls, "_get_%s" % prop, None)
            fset = getattr(cls, "_set_%s" % prop, None)
            setattr(cls, prop, property(fget, fset))
History
Date User Action Args
2009-07-11 16:45:56gvanrossumsetrecipients: + gvanrossum, georg.brandl, arsatiki
2009-07-11 16:45:56gvanrossumsetmessageid: <1247330756.73.0.850899198968.issue1921@psf.upfronthosting.co.za>
2009-07-11 16:45:55gvanrossumlinkissue1921 messages
2009-07-11 16:45:54gvanrossumcreate