injecting "set" into 2.3's builtins?
Pete Forman
pete.forman at westerngeco.com
Mon Mar 14 05:04:22 EST 2005
Skip Montanaro <skip at pobox.com> 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
pete.forman at westerngeco.com -./\.- opinion of Schlumberger, Baker
http://petef.port5.com -./\.- Hughes or their divisions.
More information about the Python-list
mailing list