Jorgen Grahn <[EMAIL PROTECTED]> wrote:
>> >> - the wildcard object, which compares equal to everything else
>>
> [Paul]
>> Paul> class MatchAny(object):
>> Paul> def __cmp__(self,other):
>> Paul> return 0
>>
>> Paul> wild = MatchAny()
>
> FWIW, I define __eq
On Mon, 16 Oct 2006 09:21:11 -0500, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
[me]
> >> - the wildcard object, which compares equal to everything else
>
[Paul]
> Paul> class MatchAny(object):
> Paul> def __cmp__(self,other):
> Paul> return 0
>
> Pau
On 10/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> You're at the mercy of the comparison machinery implemented by individual
> classes.
Plus, if you put a wildcard object into a set (or use it as a
dictionary key) you'll confuse yourself horribly.
I know I did. ;-)
--
Cheers,
Simon B
>> - the wildcard object, which compares equal to everything else
Paul> class MatchAny(object):
Paul> def __cmp__(self,other):
Paul> return 0
Paul> wild = MatchAny()
...
You're at the mercy of the comparison machinery implemented by individual
classes. Exec
"Jorgen Grahn" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Yes. But note that being able to write it yourself is one thing, having it
> in the Standard Library and known to anyone is another.
>
Perhaps you could compile the submissions in this thread into an entry in
the Python
> - the wildcard object, which compares equal to everything else
class MatchAny(object):
def __cmp__(self,other):
return 0
wild = MatchAny()
print wild == 1000
print 1000 == wild
print wild == (1,2,3)
print wild == 'abck'
print wild == wild
print wild != 1000
print 1000 != wild
prin
On 10/4/06, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
> Jorgen Grahn wrote:
> > - the wildcard object, which compares equal to everything else
> > - infinite xrange()s
> > - the black hole function 'def f(*args): pass'
> > - the identity function 'def f(x): return x'
>
> Any use cases for th
On Thu, 05 Oct 2006 00:02:51 +0200, Wildemar Wildenburger <[EMAIL PROTECTED]>
wrote:
> Jorgen Grahn wrote:
> Any use cases for these?
>> - the wildcard object, which compares equal to everything else
Like someone else wrote, for quick-and-dirty comparisons or lists and
dictionaries where I don'
On Wed, 04 Oct 2006 11:00:28 -0400, Leif K-Brooks <[EMAIL PROTECTED]> wrote:
> Jorgen Grahn wrote:
>> - infinite xrange()s
>
> itertools.count()?
Oops! You're right. The itertools documentation even refers to the SML and
Haskell languages. And it contains itertools.izip(), another thing on my
wis
Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
> Jorgen Grahn wrote:
>> - the wildcard object, which compares equal to everything else
>> - infinite xrange()s
>> - the black hole function 'def f(*args): pass'
>> - the identity function 'def f(x): return x'
>
> Any use cases for these?
>
I gue
Jorgen Grahn wrote:
> - the wildcard object, which compares equal to everything else
> - infinite xrange()s
> - the black hole function 'def f(*args): pass'
> - the identity function 'def f(x): return x'
Any use cases for these?
--
http://mail.python.org/mailman/listinfo/python-list
Jorgen Grahn wrote:
> I have been craving for some similar things for a while, and I'm still not
> sure if they are good ideas, or brain damage caused by studying functional
> programming at Uni.
This is a self correcting situation, as ayone who understands why they
need this can surely write th
Jean-Paul Calderone wrote:
> On Wed, 04 Oct 2006 11:00:28 -0400, Leif K-Brooks <[EMAIL PROTECTED]>
> wrote:
>>Jorgen Grahn wrote:
>>> - infinite xrange()s
>>
>>itertools.count()?
>
> Not quite:
>
> >>> import sys, itertools
> >>> c = itertools.count(sys.maxint)
> >>> c.next()
> 2
"Jorgen Grahn" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> - the black hole function 'def f(*args): pass'
> - the identity function 'def f(x): return x'
>
Also not so farfetched.
See the disable and enable decorators at
http://wiki.python.org/moin/PythonDecoratorLibrary#head-8
Jorgen Grahn wrote:
> - infinite xrange()s
Fun. How about in-memory objects which use no memory, and
self-referential anonymous functions, and object states without
objects...
Regards,
Jordan
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 04 Oct 2006 11:00:28 -0400, Leif K-Brooks <[EMAIL PROTECTED]> wrote:
>Jorgen Grahn wrote:
>> - infinite xrange()s
>
>itertools.count()?
Not quite:
>>> import sys, itertools
>>> c = itertools.count(sys.maxint)
>>> c.next()
2147483647
>>> c.next()
-2147483648
>>>
Jorgen Grahn wrote:
> - infinite xrange()s
itertools.count()?
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 03 Oct 2006 23:13:08 -0500, Robert Kern <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> Has the addition of a Universe Set object ever been suggested. Like U
>> = set(0), so that any object was a member of U?
>
> In [61]: class UniverseSet(objec
[EMAIL PROTECTED] wrote:
> Has the addition of a Universe Set object ever been suggested. Like U
> = set(0), so that any object was a member of U? Maybe this gets into
> some crazy Cantorian stuff since U is in U. But it seems like it would
> be useful and would have a nice s
[EMAIL PROTECTED] wrote:
> Has the addition of a Universe Set object ever been suggested. Like U
> = set(0), so that any object was a member of U?
In [61]: class UniverseSet(object):
: def __contains__(self, x):
: return True
:
In [
Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U? Maybe this gets into
some crazy Cantorian stuff since U is in U. But it seems like it would
be useful and would have a nice symmetry with emptyset:set([]), that
is:
for any
21 matches
Mail list logo