Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17877 > unrolled thread

Test None for an object that does not implement ==

Started byGZ <zyzhu2000@gmail.com>
First post2011-12-24 23:09 -0800
Last post2011-12-26 09:14 -0800
Articles 4 on this page of 24 — 13 participants

Back to article view | Back to comp.lang.python


Contents

  Test None for an object that does not implement == GZ <zyzhu2000@gmail.com> - 2011-12-24 23:09 -0800
    Re: Test None for an object that does not implement == Paul Rubin <no.email@nospam.invalid> - 2011-12-24 23:28 -0800
    Re: Test None for an object that does not implement == Nobody <nobody@nowhere.com> - 2011-12-25 09:38 +0000
      Re: Test None for an object that does not implement == Lie Ryan <lie.1296@gmail.com> - 2011-12-25 22:10 +1100
        Re: Test None for an object that does not implement == Roy Smith <roy@panix.com> - 2011-12-25 08:17 -0500
          Re: Test None for an object that does not implement == Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:35 +1100
            Re: Test None for an object that does not implement == Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 13:48 +0000
              Re: Test None for an object that does not implement == Chris Angelico <rosuav@gmail.com> - 2011-12-26 01:04 +1100
              Re: Test None for an object that does not implement == Christian Heimes <lists@cheimes.de> - 2011-12-26 01:37 +0100
            Re: Test None for an object that does not implement == Roy Smith <roy@panix.com> - 2011-12-25 09:13 -0500
              Re: Test None for an object that does not implement == Chris Angelico <rosuav@gmail.com> - 2011-12-26 01:23 +1100
              Re: Test None for an object that does not implement == Lie Ryan <lie.1296@gmail.com> - 2011-12-26 04:13 +1100
      Re: Test None for an object that does not implement == Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-25 19:02 -0700
      Re: Test None for an object that does not implement == Ethan Furman <ethan@stoneleaf.us> - 2011-12-25 20:26 -0800
    Re: Test None for an object that does not implement == Larry Hudson <orgnut@yahoo.com> - 2011-12-25 15:45 -0800
      Re: Test None for an object that does not implement == Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-12-25 19:06 -0500
        Re: Test None for an object that does not implement == Roy Smith <roy@panix.com> - 2011-12-25 19:27 -0500
          Re: Test None for an object that does not implement == Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-12-25 19:58 -0500
      Re: Test None for an object that does not implement == Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-26 00:52 +0000
    Re: Test None for an object that does not implement == Ethan Furman <ethan@stoneleaf.us> - 2011-12-25 20:27 -0800
    Re: Test None for an object that does not implement == Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-12-26 00:22 -0500
      Re: Test None for an object that does not implement == Roy Smith <roy@panix.com> - 2011-12-26 08:43 -0500
    Re: Test None for an object that does not implement == Paul Rudin <paul.nospam@rudin.co.uk> - 2011-12-26 14:33 +0000
    Re: Test None for an object that does not implement == Ethan Furman <ethan@stoneleaf.us> - 2011-12-26 09:14 -0800

Page 2 of 2 — ← Prev page 1 [2]


#17949

FromDevin Jeanpierre <jeanpierreda@gmail.com>
Date2011-12-26 00:22 -0500
Message-ID<mailman.4097.1324877003.27778.python-list@python.org>
In reply to#17877
> Um -- if you don't want a and c being passed in, why put them in the
> function signature?

He wants both or neither to be passed in.

-- Devin

On Sun, Dec 25, 2011 at 11:27 PM, Ethan Furman <ethan@stoneleaf.us> wrote:
> GZ wrote:
>>
>> Hi,
>>
>> I run into a weird problem. I have a piece of code that looks like the
>> following:
>>
>> f(...., a=None, c=None):
>>    assert  (a==None)==(c==None)
>
>
>
> Um -- if you don't want a and c being passed in, why put them in the
> function signature?
>
> ~Ethan~
> --
> http://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#17957

FromRoy Smith <roy@panix.com>
Date2011-12-26 08:43 -0500
Message-ID<roy-D2B588.08433426122011@news.panix.com>
In reply to#17949
In article <mailman.4097.1324877003.27778.python-list@python.org>,
 Devin Jeanpierre <jeanpierreda@gmail.com> wrote:

> > Um -- if you don't want a and c being passed in, why put them in the
> > function signature?
> 
> He wants both or neither to be passed in.

assert sum(foo is None for foo in [a, c]) % 2 == 0

[toc] | [prev] | [next] | [standalone]


#17961

FromPaul Rudin <paul.nospam@rudin.co.uk>
Date2011-12-26 14:33 +0000
Message-ID<boqv5rnv.fsf@no-fixed-abode.cable.virginmedia.net>
In reply to#17877
GZ <zyzhu2000@gmail.com> writes:


> I run into a weird problem. I have a piece of code that looks like the
> following:
>
> f(...., a=None, c=None):
>     assert  (a==None)==(c==None)
>

There is only one 'None' - so use 'a is None' rather than 'a == None'.

(In common lisp there is a particular language construct that allows you
do determine whether an argument was passed in or was defaulted.)

[toc] | [prev] | [next] | [standalone]


#17965

FromEthan Furman <ethan@stoneleaf.us>
Date2011-12-26 09:14 -0800
Message-ID<mailman.4103.1324920875.27778.python-list@python.org>
In reply to#17877
Devin Jeanpierre wrote:
>> Um -- if you don't want a and c being passed in, why put them in the
>> function signature?
> 
> He wants both or neither to be passed in.

Ah -- right.

~Ethan~

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web