Draft Pep (was: Re: Let's Talk About Lambda Functions!)

Bryan Olson fakeaddress at nowhere.org
Wed Aug 7 08:27:11 CEST 2002


John Roth wrote:
 > "Bryan Olson" wrote:
[...]
 >>Pure Python modules don't get their names from
 >>Python code, but from the file in which they're stored.  As for the
 >>assignment to a variable, I would rather use:
 >>
 >>     varname = import filename
 >>
 >>to make the semantics clear.
 >
 > The trouble with this is that Python maintains an internal dictionary
 > of modules, by name. So
 >
 > import filename
 >
 > not only puts filename in the current module namespace,
 > but also puts it in the dictionary. That's not at all the same
 > thing as
 >
 > foobar = import snafu

I don't see that.  What the import does is the internal stuff, and
it returns a module.  That value, the module, gets stored in foobar,
just as any other type of value gets assigned to a variable.

[...]
 >>Using a special construct suggests something else is
 >>going on.
 >
 > As has been discussed, there is something else going on. The name
 > is bound to the module so it can be accessed by introspection. Never
 > having used this feature, I'm not certain of how essential it is.

That something else is irrelevent to the assignment of a value to a
variable.  Do the something else in the special construct.  Do the
assignment with the assignment operator.


 >>I've never seen a
 >>Python-based text on the level of Abelson and Sussman's /Structure and
 >>Interpretation of Computer Programs/ or Friedman, Wand and Haynes'
 >>/Essentials of Programming Languages/.
 >
 > I think the point here is that of usability for teaching computer
 > science in general, not for the ability to teach Python.

Yes, absolutely.  That's the point I've been trying to make.

[...]
 >> Who said adding list comprehensions was wrong?  The point is that
 >> 'need' is not really the issue.  I could just as easily say that recent
 >> additions to Perl alleviate the need for Python.  The language would
 >> be better with a full lambda, that's all.
 >
 > I don't think that list comprehensions have anything to do with the
 > matter.

Once again we find ourselves in agreement.  I don't think the recent
additions have any impact on the importance of a full lambda.


 > Extending lambda has been discussed many times, and has never gotten
 > past the discussion stage because implementing def in expression format
 > is simply too much of a change to the language. Just to mention one
 > of the issues: how do you do a clean if/else/elif syntax in an
 > expression format?

That seems like a silly issue.  Either don't require lambda to operate
only on expressions, as in, for example, Perl, or make the construct an
expression, as in, for example, various Lisps.


--Bryan




More information about the Python-list mailing list