[FRPythoneers] With statement

Sean Reifschneider jafo at tummy.com
Fri Aug 9 15:19:46 MDT 2002

On Fri, Aug 09, 2002 at 01:59:41PM -0600, Bob Gailer wrote:
>WITH has saved me thousands of extra characters, made my programs much more 
>readable and reduced the effect of typos.

I'm unconvinced about it...  Having a "with" block makes programmers and
maintainers keep track of what the current environment is, and the only way
to really tell what with you're in is by hunting back through the code
looking for the relavent with...  If you mis-remember what with you're in,
or miss the ending of a with/starting of another, it can lead to subtle

Why is "with" better than "_ =" for example?  Or using cut-and-paste (my
pate button is right below my space key, for example)?  Would it be
syntactic sugar that would just map back to the full string, or would it
actually do something like mapping to local names (like in . removal in
tight loops)?

If you really have some nasty-to-type identifiers, and you want with to cut
down that typing load, there are some options I think are better.  For
looking for mis-spellings, it should be fairly simple to write something
that pulls out symbols and looks for pairs with common mis-spellings like
transposition and dropped/dupped characters, and generates a report of

In general, if Python had "with", I'd probably avoid using them.

 Get your data structures correct first, and the rest of the program will
 write itself.  -- David Jones
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python

More information about the FRPythoneers mailing list