injecting "set" into 2.3's builtins?

From: Skip Montanaro (skip_at_pobox.com)
Date: 03/10/05


Date: Wed, 9 Mar 2005 19:49:36 -0600
To: python-list@python.org


I use sets a lot in my Python 2.3 code at work and have been using this
hideous import to make the future move to 2.4's set type transparent:

    try:
        x = set
    except NameError:
        from sets import Set as set
    else:
        del x

Of course, while it's transparent at one level (where sets are used) it's
not really transparent at another level (where the set object is defined).

I'm toying with the idea of adding this to the sitecustomize module at work:

    import sets
    import __builtin__
    __builtin__.set = sets.Set
    del sets, __builtin__

I'm wondering if others have tried it. If so, did it cause any problems?
I've not noticed any incompatibilities between the 2.3 and 2.4 versions of
set objects, but my use of them has been pretty straightforward.

Thanks,

Skip



Relevant Pages

  • Re: injecting "set" into 2.3s builtins?
    ... > I use sets a lot in my Python 2.3 code at work and have been using this ... > except NameError: ... while it's transparent at one level it's ... > not really transparent at another level (where the set object is defined). ...
    (comp.lang.python)
  • Re: Another way to do x^n
    ... I'm seeing a lot of Python in the sort of instrument control applications where I would have seen Forth in the past. ... cleverness as a Forth programmer is exceeded only by my ... The median score on quizes in that class was often in the single digits: problems that were transparent to the professor were murky to the students. ...
    (comp.lang.forth)
  • Re: Validating an A-Weighted filter
    ... cumbersome, and not very transparent). ... I've also been toying with Python ... If that is not adequate, ...
    (comp.dsp)
  • Re: Using XML w/ Python...
    ... ActivePython is same as Standard Python distribution but with a few ... "As far as it should work since their both transparent, umm, well its ... I have ActivePython 2.4 here and it loads amara fine. ... installing Python modules from command line? ...
    (comp.lang.python)
  • Re: Enso or Launchy like UI from Python
    ... I want to make transparent/launcher-like window application using python. ... (similar as Enso, Launchy, etc. ... transparent or completely transparent and I would assume that the ...
    (comp.lang.python)