Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Re: Sets: elt in dict, lst.include

Eric S. Raymondesr@thyrsus.com
Tue, 23 Jan 2001 15:38:39 -0500


Ka-Ping Yee <ping@lfw.org>:> The only change that needs to be made to support sets of immutable> elements is to provide "in" on dictionaries.  The rest is then all> quite natural:>>     dict[key] = 1>     if key in dict: ...>     for key in dict: ...Independently of implementation issues about sets, I think this is adamn fine idea. +1.> (Then we can also get rid of the ugly has_key method.)>> For those that need mutable set elements badly enough to sacrifice> a little speed, we can add two methods to lists:>>     lst.include(elt)   # same as - if elt not in lst: lst.append(elt)>     lst.exclude(elt)   # same as - while elt in lst: lst.remove(elt)+1 on the concept, -0 on the names.-- <a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>[The disarming of citizens] has a double effect, it palsies the handand brutalizes the mind: a habitual disuse of physical forces totallydestroys the moral [force]; and men lose at once the power ofprotecting themselves, and of discerning the cause of theiroppression.        -- Joel Barlow, "Advice to the Privileged Orders", 1792-93


[8]ページ先頭

©2009-2025 Movatter.jp