'with' statement in python ?

Guido van Rossum guido at python.org
Fri Jul 6 07:28:39 EDT 2001


"Steve Holden" <sholden at holdenweb.com> writes:

> I'm beginning to suffer from a PEPtic ulcer. The "PEP scepticism" thread has
> been ploughing on (in my opinion with the only progress being a better
> understanding of various individuals' and groups' positions) for quite some
> time now, without too many people standing up and volunteeering to improve
> things.

Nevertheless, that thread implicitly explains one of the good reasons
why Python doesn't have a 'with' statement: we have to be very careful
with adding new features, because many folks appreciate Pythonr
precisely because of its relative feature sparsity.

The other reason why I haven't added 'with' (because believe me, this
has been suggested many times before) has been explained by others: it
is the problem of assignments.  About the only choice would be to make
every unqualified assignment inside a with statement an attribute
assignment to the object mentioned in the with clause, and that seems
counterproductive.  The VB solution (use a '.' prefix to reference the
object from the with clause) would be reasonable too, but requires a
lot of syntactic changes and makes me refer back to the first reason
above.

> I do, of course, have my own opinions about where PythonLabs should be
> spending its time improving things, but I by and large try to keep these
> opinions to myself as I'm not in a position to contribute to many of these
> activities.

I would like to hear what's important to you!  I get irritated when
people say "PythonLabs should do this or that" (only Digital Creations
can tell us what we *should* do, since they pay us), but I *do* want
to know what kind of things people need.

> If you aren't part of the answer, you're part of the problem ...
> and you do seem to take input from many sources. I'm quite happy offering
> input when it's solicited, but try to move on after a "battle" has been
> fought, whether I "won" or "lost" (I use quotes to indicate that I don't
> regard these matters as appropriate for a high level of emotional
> involvement).

Sorry, I have no idea what you are referring to here any more...

> So, I tend to restrict my activities to the practical things I *can* do to
> help, like maintaining the FAQ (even though many questions indicate that a
> large proportion of newbies either aren't aware of it or don't read it). At
> least that way there's a corpus of knowledge that individual questioners can
> be pointed to. As a for-profit activity I am also writing a book, but this
> isn't the place to publicize that. Just the same, I hope it will help people
> to make better use of Python, and improve the S/N ratio on this group. The
> post you responded to, by the way, was simply to indicate that I had changed
> the FAQ in line with a previous poster's suggestion.

Ah, the FAQ.  Only the bible has more information that was once useful
but is now just confusing.  I would love to see its maintenance being
picked up -- but it takes more than adding an entry explaining the
lack with statement (thanks, BTW).

> A practical step, which some groups already use, is to publicize the FAQ and
> the charter of the newsgroup periodically. Maybe we could arrange this? I'd
> be happy to make the postings, say every seven or fourteen days, once a
> suitable message was composed. Anyone? I'm not sure it will increase the S/N
> ratio, but every little helps.

Yeah, I've seen those posts in other groups.  Everybody seems to
ignore them.  Let's put the good info on the website, that's where
newbies should go.

> The PEP process is a good idea, but not enough people are willing to get
> involved. Perhaps some feel they aren't knowledgable enough, others would
> rather make their comments on c.l.py. Since I don't have the time myself
> (yet) to write PEPs, I try to refrain from throwing rocks at those who have,
> since at least they have stood up to be counted. So I offer opinions, but
> when changes go against my inclination I try not to bitch and moan.

Comments on c.l.py rarely reach me...  If you want my attention,
propose a PEP.

> Except I still don't like "print >>" ;^)

You don't have to like it, as logn as you use it when appropriate. ;-)

> just-to-retain-some-bolshevik-credibility-ly y'rs  - steve

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list