In article mailman.4097.1324877003.27778.python-l...@python.org,
Devin Jeanpierre jeanpierr...@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
GZ zyzhu2...@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
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~
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 24 Dec 2011 23:09:50 -0800, GZ wrote:
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)
The problem is that == is not implemented sometimes for values in a
and c, causing an exception
On 12/25/2011 08:38 PM, Nobody wrote:
nothing should compare equal to None except for None itself, so x is None
and x == None shouldn't produce different results unless there's a
bug in the comparison method.
not necessarily, for example:
import random
class OddClass:
def __eq__(self,
In article mailman.4061.1324811442.27778.python-l...@python.org,
Lie Ryan lie.1...@gmail.com wrote:
Now, whether doing something like that is advisable or not, that's a
different question; however nothing in python states that you couldn't
have something that compare equal to None whether
On Mon, Dec 26, 2011 at 12:17 AM, Roy Smith r...@panix.com wrote:
Just for fun, I tried playing around with subclassing NoneType and
writing an __eq__ for my subclass. Turns out, you can't do that:
Traceback (most recent call last):
File ./none.py, line 5, in module
class
On Mon, 26 Dec 2011 00:35:46 +1100, Chris Angelico wrote:
[...]
TypeError: Error when calling the metaclass bases
type 'NoneType' is not an acceptable base type
Yes; unfortunately quite a few Python built-in classes can't be
subclassed.
I can't think of any other un-subclassable
On Mon, Dec 26, 2011 at 12:48 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
I can't think of any other un-subclassable classes other than NoneType.
Which ones are you thinking of?
I don't remember, but it was mentioned in a thread a little while ago.
Experimentation shows that
In article mailman.4066.1324820148.27778.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
On Mon, Dec 26, 2011 at 12:17 AM, Roy Smith r...@panix.com wrote:
Just for fun, I tried playing around with subclassing NoneType and
writing an __eq__ for my subclass. Turns out, you
On Mon, Dec 26, 2011 at 1:13 AM, Roy Smith r...@panix.com wrote:
If you were designing the interface from scratch, you would probably
represent that with an exception hierarchy
Or possibly with returns a False value, giving the option of None
for none available, False for none will ever be
On 12/26/2011 01:13 AM, Roy Smith wrote:
In articlemailman.4066.1324820148.27778.python-l...@python.org,
Chris Angelicoros...@gmail.com wrote:
On Mon, Dec 26, 2011 at 12:17 AM, Roy Smithr...@panix.com wrote:
Just for fun, I tried playing around with subclassing NoneType and
writing an
On 12/24/2011 11:09 PM, 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)
...
At first glance this looked like it should be a simple boolean and, but then I realized that
when a and c
At first glance this looked like it should be a simple boolean and, but
then I realized that when a and c are both unequal to None, the result would
also be True. This implies the logical approach would be exclusive-or (^).
Among booleans, != is exclusive or and == is its negation. I don't
In article mailman.4082.1324858055.27778.python-l...@python.org,
Devin Jeanpierre jeanpierr...@gmail.com wrote:
The issue here is that == None is being used instead of is None,
but I believe that's been covered. Your response doesn't include it,
so maybe it's worth restating.
Which of course
Am 25.12.2011 15:04, schrieb Chris Angelico:
I think there are certain types that are actually not implemented as
classes, and hence cannot be subclassed. This is almost certainly an
implementation detail though; my testing was done in Py3.2 (on Windows
fwiw).
Some extension types are not
On Sun, 25 Dec 2011 15:45:10 -0800, Larry Hudson wrote:
On 12/24/2011 11:09 PM, 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)
...
At first glance this looked like it should be
Which of course leads to a SillyPEP for a new keyword, are, which
would allow you to write:
a and c are None
instead of the much more verbose
a is None and c is None
How about:
a is b is None
;)
-- Devin
On Sun, Dec 25, 2011 at 7:27 PM, Roy Smith r...@panix.com wrote:
In article
On Sun, Dec 25, 2011 at 2:38 AM, Nobody nob...@nowhere.com wrote:
On Sat, 24 Dec 2011 23:09:50 -0800, GZ wrote:
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)
The problem is that == is not
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~
--
Nobody wrote:
nothing should compare
equal to None except for None itself, so x is None and x == None
shouldn't produce different results unless there's a bug in the comparison
method.
Why wouldn't you want other types that can compare equal to None? It
could be useful for a Null type to ==
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 et...@stoneleaf.us wrote:
GZ wrote:
Hi,
I run into a weird problem. I have a piece of code that looks
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)
The problem is that == is not implemented sometimes for values in a
and c, causing an exception NotImplementedError.
I ended up doing assert (not
GZ zyzhu2...@gmail.com writes:
assert (a==None)==(c==None)...
So how do I reliably test if a value is None or not?
Equality is the wrong comparison to start with. Use a is None.
--
http://mail.python.org/mailman/listinfo/python-list
24 matches
Mail list logo