[PATCH 2 of 4] Provide a version independent way to use the set datatype

Eric Hopper hopper at omnifarious.org
Mon Jun 18 22:26:07 CDT 2007


On Sun, Jun 17, 2007 at 02:19:05PM +0200, Thomas Arendsen Hein wrote:
> try:
>     set, frozenset
> except NameError:
>     from sets import Set as set, ImmutableSet as frozenset
> 
> As there is nothing special about this sets, they should not be
> called hgset.

This doesn't work.  On a system where set and frozenset actually exist,
it just pulls the values from the __builtins__ module but that code
doesn't put them into the util module's namespace.

So, instead you have to do:

try:
    set = set
    frozenset = frozenset
except NameError:
    from sets import Set as set, ImmutableSet as frozenset

and that looks a bit weird, but it does work.  :-)

Have fun (if at all possible),
-- 
"It does me no injury for my neighbor to say there are twenty gods or no God.
It neither picks my pocket nor breaks my leg."  --- Thomas Jefferson
"Go to Heaven for the climate, Hell for the company."  -- Mark Twain
-- Eric Hopper (http://www.omnifarious.org/~hopper) --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070618/1b285099/attachment.pgp 


More information about the Mercurial-devel mailing list