[PATCH 2 of 4] Provide a version independent way to use the set datatype
Eric Hopper
hopper at omnifarious.org
Sun Jun 17 22:49:19 CDT 2007
On 6/17/07, Thomas Arendsen Hein <thomas at intevation.de> wrote:
>
> * Eric Hopper <hopper at omnifarious.org> [20070614 18:26]:
> > # HG changeset patch
> > # User Eric Hopper <hopper at omnifarious.org>
> > # Date 1181836913 25200
> > # Node ID f98ca5c0c43c4aacddbd147d7b854f280c827653
> > # Parent 75a66022a47337f481799e25ec4933166ef8e5d0
> > Provide a version independent way to use the set datatype.
> >
> > diff --git a/mercurial/util.py b/mercurial/util.py
> > --- a/mercurial/util.py
> > +++ b/mercurial/util.py
> > @@ -15,6 +15,13 @@ from i18n import _
> > from i18n import _
> > import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
> > import os, threading, time, calendar, ConfigParser, locale, glob
> > +
> > +try:
> > + hgset = set
> > + hgfrozenset = frozenset
> > +except NameError, e:
>
> We don't need to waste a variable 'e' here (and if we would have
> needed it, the name 'inst' or 'why' would have been better).
>
> > + from sets import Set as hgset
> > + from sets import ImmutableSet as hgfrozenset
>
> I have only tried it with python2.3 and 2.4 and only in the
> interactive interpreter, but what about this:
>
> 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.
Your Python-fu is stronger than mine, and it makes me vaguely uncomfortable
to not put the exception in a variable when I catch it. Indeed I did not
really like calling them hgset and hgfrozenset myself. I will do it as you
suggest.
Thanks,
--
Please only send email to this account that you consider public enough to be
published on a public web page.
Eric Hopper -- http://www.omnifarious.org/~hopper/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20070617/5a0b84fb/attachment.htm
More information about the Mercurial-devel
mailing list