Skip Montanaro <[EMAIL PROTECTED]> writes:

 >     Stephen> I have:
 >     Stephen> try:
 >     Stephen>     set
 >     Stephen> except NameError:
 >     Stephen>     from sets import Set as set
>
 >     Stephen> in my code in a few places.
>
 > Yes, but then pychecker complains about a statement with no apparent effect,
 > hence the extra verbiage.
>
 > My question wasn't about a less ugly way to type what I type now.  It was
 > about whether injecting "set" into the builtins (so I can dispense with the
 > above cruft altogether) is likely to cause problems.  I think not, certainly
 > based on what little surveying I've done at work.  I was hoping someone else
 > had already tried this and could report on their experience.

This is what I use to allow my 2.4 code to run on 2.3.

if not 'set' in dir(__builtins__):
    from sets import Set as set, ImmutableSet as frozenset

-- 
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
[EMAIL PROTECTED]    -./\.-   opinion of Schlumberger, Baker
http://petef.port5.com           -./\.-   Hughes or their divisions.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to