Two minor syntactic proposals

Alex Martelli aleaxit at yahoo.com
Mon Jun 18 04:07:52 EDT 2001


"Barry A. Warsaw" <barry at digicool.com> wrote in message
news:mailman.992844567.4921.python-list at python.org...
    ...
> def Thing.new_method(self, x):
    ...
> It never caught on, but this was in the (way) pre-PEP days.  If
> there's interest, I could write up a PEP on this.

FWIW, I'd *LOVE* it if there was some relaxation of the
current constraint that binding-statements (except assignment,
and package-related import) can only affect 'bare' (unqualified)
identifiers.  It *IS* (from my POV) a wart (albeit a minor one)
that, to rebind anything BUT a bare identifier by class/def/import/
from I must do a three-step -- first use the statement to bind a
'temporary' bare-identifier, then assign the bare-identifier
to what I *really* want to bind, finally del the temp id.

I understand that packages mean "import x.y" has very special
meaning, of course -- but "import x as y.z", "from x import
y as z.t", "def x.y", and "class x.y" all seem so natural to
me, so typically Pythonic, that I do not really understand
why they are currently forbidden in favour of, e.g.:
    from x import y as temporaryname
    z.t = temporaryname
    del temporaryname
and the like.  Where's the added-value in this restriction...?

So, yes, I'd *LOVE* it if a PEP could remove at least SOME
of these constraints -- I just hope it doesn't have to be
as narrowly-worded as "allowing def x.y iff x is specifically
a bare identifier that is bound to a class-object and is
also the class's classname"...:-).  That may be the TYPICAL
use, of course, but hopefully it need not be so tightly
restricted again...?


Alex






More information about the Python-list mailing list