with as J2 keyword (WAS: Re: J2 0-2-6 is available)
steven.bethard at gmail.com
Wed Aug 25 06:36:37 CEST 2004
Doug Holton <insert <at> spam.here> writes:
> .author = "François Pinard"
> def foo(cls):
> def bar():
> with bar:
> .version = "0.2.4"
Note that one of the common decorator examples has been something like:
So for functions, people already want to put classmethod and the author
attribute in the same place. So when "with" blocks come along, and people get
used to writing
.x = 3
they're going to wonder why they have to move their metadata to after the
function if they want to use the .xxx syntax.
That aside, I tend to agree with you. I think mixing the .xxx assignments
(which are statements) with things like "classmethod" and "memoize" (which are
expressions) is bound to be confusing, e.g. your example:
> with self:
> .version = 3
> Is that supposed to mean:
> self.version = 3?
Presumably anyone who was pushing for "with" as the keyword would, at the
least, disallow this sort of syntax for non-funcdefs, but this is certainly a
great example of how horrible it could be. =)
More information about the Python-list