Erik Max Francis wrote:
Antoon Pardon wrote:
[responding to me]
Maybe I'm going to be pedantic here, but I fear that your code won't
work with matrices. The problem is that multiplication is not
commutative with matrices. This means that matrices have two divisions
a right
and a left divisi
Antoon Pardon wrote:
Maybe I'm going to be pedantic here, but I fear that your code won't
work with matrices. The problem is that multiplication is not
commutative with matrices. This means that matrices have two divisions a right
and a left division. A far as I know the "/" operator usaly imple
On 2008-08-01, Terry Reedy <[EMAIL PROTECTED]> wrote:
>> Nevertheless, I think this is probably the best example of the
>> enhanced polymorphism of "if x" yet. I'm kind of surprised no one
>> came up with it.)
>
> I think of Python code as 'generic' rather than 'polymorphic'. I am not
> sure if
On Aug 1, 4:45 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Aug 1, 3:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> > In general, asking code to apply across numeric, container, and other
> > classes is asking too much. Python code can be generic only within
> > protocol/interface categories su
On Aug 1, 4:45 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Aug 1, 3:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
>
>
> > > Nevertheless, I think this is probably the best example of the
> > > enhanced polymorphism of "if x" yet. I'm kind of surprised no one
> > > came up with it.)
>
> > I th
On Aug 1, 3:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> > Nevertheless, I think this is probably the best example of the
> > enhanced polymorphism of "if x" yet. I'm kind of surprised no one
> > came up with it.)
>
> I think of Python code as 'generic' rather than 'polymorphic'. I am not
> su
Carl Banks wrote:
On Aug 1, 8:49 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
Carl Banks wrote:
On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
[snip excellent explanation of why it's hard to for "if x" to be
extensively polymorphic]
By the way, one thing I forgot to mention is
Nevertheless, I think this is probably the best example of the
enhanced polymorphism of "if x" yet. I'm kind of surprised no one
came up with it.)
I think of Python code as 'generic' rather than 'polymorphic'. I am not
sure if that is a real difference or not, since I am a bit fuzzy on the
m
Anders J. Munch wrote:
Ethan Furman wrote:
> Even if we find out that C.__nonzero__ is called, what was it that
> __nonzero__ did again?
reinforce the impression that he is unaware of the double-underscore
functions and what they do and how they work.
Only if your newsreader malfunctio
On Aug 1, 8:49 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> > [snip excellent explanation of why it's hard to for "if x" to be
> > extensively polymorphic]
>
> > By the way, one thing I forgot to mention is M
Ethan Furman wrote:
> Even if we find out that C.__nonzero__ is called, what was it that
> __nonzero__ did again?
reinforce the impression that he is unaware of the double-underscore
functions and what they do and how they work.
Only if your newsreader malfunctioned and refused to let you
On 2008-08-01, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
> Antoon Pardon wrote:
>> On 2008-08-01, Erik Max Francis <[EMAIL PROTECTED]> wrote:
>>> Antoon Pardon wrote:
>>>
I now have the following question for people who argue that "if x"
is more polymorphic. I could subclass list, so
Matthew Fitzgibbons wrote:
'if x' strikes me as better for this case because you might want to
accept a non-empty list (or some other objects) but reject non-empty
lists. 'if x is None' would not work. It still may be susceptible to the
empty iterator problem, depending on what prep_func does.
Carl Banks wrote:
On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
[snip excellent explanation of why it's hard to for "if x" to be
extensively polymorphic]
By the way, one thing I forgot to mention is Matt Fitzgibbons' filter
example.
As I said, it's hard to write code that works fo
Antoon Pardon wrote:
On 2008-08-01, Erik Max Francis <[EMAIL PROTECTED]> wrote:
Antoon Pardon wrote:
I now have the following question for people who argue that "if x"
is more polymorphic. I could subclass list, so that instances
of this new sequence would always behave as true, even if they a
On 2008-08-01, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Antoon Pardon wrote:
>
>> I now have the following question for people who argue that "if x"
>> is more polymorphic. I could subclass list, so that instances
>> of this new sequence would always behave as true, even if they are
>> empty.
Antoon Pardon wrote:
I now have the following question for people who argue that "if x"
is more polymorphic. I could subclass list, so that instances
of this new sequence would always behave as true, even if they are
empty. I could then rewrite my loop as follows:
while 1:
extra = produce()
On 2008-08-01, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Jul 31, 1:27 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>> I'm really not sure where you're going with this or what you're trying
>> to prove. "if x" is a duck-type test for a boolean value. Obviously if
>> you know the type and want a mo
Carl Banks wrote:
If you recall, I agreed with his statement. Would you like to claim
that I don't understand the fundamentals of Python?
Since you've invented this connection out of nowhere, not particularly.
I've never said anything about _anyone_ not understanding the
fundamentals of Py
On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
[snip excellent explanation of why it's hard to for "if x" to be
extensively polymorphic]
By the way, one thing I forgot to mention is Matt Fitzgibbons' filter
example.
As I said, it's hard to write code that works for both numeric and
c
On Jul 30, 10:05 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> >> Russ P. wrote:
> >>> Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
> &g
On Jul 31, 12:13 am, Ethan Furman <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > So I stand by the point I was trying to make: for your average day-to-
> > day programming, the main benefit of "if x" is to save keystrokes. It
> > doesn't help your code become more polymophic in practice. A li
On Jul 31, 1:27 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> I'm really not sure where you're going with this or what you're trying
> to prove. "if x" is a duck-type test for a boolean value. Obviously if
> you know the type and want a more *specific* test, then you can use an
> explicit one. An
Steven D'Aprano wrote:
>On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote:
>> The point is that if you tell people that "if x" is the standard way to
>> check for emptiness, and also support a general principle along the
>> lines of "write your function using the interfaces you expect, an
On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote:
> Steven D'Aprano wrote:
>>On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote:
>
>>> On the other hand, iterators provide a clear example of problems with
>>> "if x": __nonzero__ for iterators (in general) returns True even if
Steven D'Aprano wrote:
>On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote:
>> On the other hand, iterators provide a clear example of problems with
>> "if x": __nonzero__ for iterators (in general) returns True even if they
>> are 'empty'.
> How do you propose telling whether an iterato
Matthew Fitzgibbons wrote:
Steven D'Aprano wrote:
On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote:
If you're expecting a list (and only a list)
then your point makes sense. 'if x' can get you into trouble if you
_don't_ want its polymorphism.
"if x" is hardly unique in that way
Steven D'Aprano wrote:
On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote:
If you're expecting a list (and only a list)
then your point makes sense. 'if x' can get you into trouble if you
_don't_ want its polymorphism.
"if x" is hardly unique in that way. If you're expecting a list
Steven D'Aprano wrote:
On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote:
If you're expecting a list (and only a list)
then your point makes sense. 'if x' can get you into trouble if you
_don't_ want its polymorphism.
"if x" is hardly unique in that way. If you're expecting a list
On Tue, Jul 29, 2008 at 3:37 AM, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED]
> cybersource.com.au> wrote:
>> On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote:
>> > On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTED]
>> > cybersource.com.au>
On Jul 31, 7:08 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> On Jul 30, 10:43 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
>
>
>
> > Russ P. wrote:
> > > On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> > >> You're sure going on about a distinction without a difference for a guy
>
On Jul 30, 10:43 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> >> You're sure going on about a distinction without a difference for a guy
> >> who childishly likes to call other people names. A reasonable pers
Russ P. wrote:
On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
You're sure going on about a distinction without a difference for a guy
who childishly likes to call other people names. A reasonable person
would have long ago moved on instead of blaming others for not
immediately
On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > I don't know if you can read minds, but you seem to have a lot of
> > trouble reading words.
>
> > Can you read "it would be nice to be able to write ..."? Can you
> > understand what it means? Can you understand t
Ethan Furman wrote:
> If that's really what you want, go join Dave Parker and Flaming Thunder.
Best recommendation in this thread to date :)
--
http://mail.python.org/mailman/listinfo/python-list
Russ P. wrote:
I don't know if you can read minds, but you seem to have a lot of
trouble reading words.
Can you read "it would be nice to be able to write ..."? Can you
understand what it means? Can you understand that it does *not* mean,
"one *should* be able to write ..."?
You're sure going
On Jul 30, 8:24 pm, "Russ P." <[EMAIL PROTECTED]> wrote:
> On Jul 30, 8:03 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
>
> > Russ P. wrote:
> > > The reason I wrote that "it would be nice to be able to write"
>
> > > if x is not empty:
>
> > > is that it reads naturally. It was not an actual pr
Russ P. wrote:
[snippers]
The reason I wrote that "it would be nice to be able to write"
if x is not empty:
is that it reads naturally.
[and more snippers]
Reads naturally? For whom? "Readability counts" does not mean "make it
sound like english as much as possible". There are good rea
On Thu, 31 Jul 2008 02:41:08 +, Steven D'Aprano wrote:
> On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote:
...
>> Although, if my function is expecting a list, my preference is to do:
>>
>> if not isinstance(x, list):
>> raise SomeMeaningfulException()
>> # do stuff with the
On Jul 30, 8:03 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > The reason I wrote that "it would be nice to be able to write"
>
> > if x is not empty:
>
> > is that it reads naturally. It was not an actual proposal, and the
> > fact that you took it as such was *your* mistake.
Carl Banks wrote:
On Jul 30, 4:49 am, Ethan Furman <[EMAIL PROTECTED]> wrote:
Even for those that did realize, and in fact hoped that that is what you
were attempting to accomplish,
I was not attempting to accomplish what you think I was.
I was looking for it, but I didn't want to see it. I
Russ P. wrote:
The reason I wrote that "it would be nice to be able to write"
if x is not empty:
is that it reads naturally. It was not an actual proposal, and the
fact that you took it as such was *your* mistake.
...
Now read carefully: I DID NOT CLAIM THAT THIS IS THE WAY TO DO IT!
On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote:
> On the other hand, iterators provide a clear example of problems with
> "if x": __nonzero__ for iterators (in general) returns True even if they
> are 'empty'.
How do you propose telling whether an iterator is empty?
That's a generic
On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote:
> If you're expecting a list (and only a list)
> then your point makes sense. 'if x' can get you into trouble if you
> _don't_ want its polymorphism.
"if x" is hardly unique in that way. If you're expecting a list, and only
a list, "
On Jul 30, 7:05 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> >> Russ P. wrote:
> >>> Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
> &g
On Jul 30, 1:50 am, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Jul 30, 1:58 am, "Russ P." <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>
> > > On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> > > > Having said that, it would sure be nice
Russ P. wrote:
On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
Russ P. wrote:
Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
__nonzero__ work in Python. It's very basic stuff. You can quit
patronizing me (and Carl too, I'm sure).
You su
On Jul 30, 4:49 am, Ethan Furman <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
> >> I don't have any postable code (it's in a half way state and I haven't
> >> touched it for a while), but I'll see if I can't find the time to b
On Jul 30, 3:56 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > I mean in general. I wouldn't spell it like that. I would prefer if
> > empty(x), with an __empty__ method. (And support __nonzero__ aka
> > __bool__ dropped completely.)
>
> So your argument is purely about
On Jul 30, 11:07 am, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > That's not what I was asking for. I was asking for a use case for "if
> > x" that can't be replaced by a simple explicit test. Your example
> > didn't satisfy that.
>
> But I believe my example of an iterator with
On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
> > __nonzero__ work in Python. It's very basic stuff. You can quit
> > patronizing me (and Carl too, I
Terry Reedy <[EMAIL PROTECTED]> wrote:
>Carl Banks wrote:
>> That's not what I was asking for. I was asking for a use case for "if
>> x" that can't be replaced by a simple explicit test. Your example
>> didn't satisfy that.
> But I believe my example of an iterator with __bool__ but not with
Carl Banks wrote:
On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
I don't have any postable code (it's in a half way state and I haven't
touched it for a while), but I'll see if I can't find the time to bang
something up to give you the gist.
I wouldn't bother at this point.
s. They are instead a very well-defined
language mechanism that isn't perfect for every circumstance, but is
pretty good for the most part. I wanted to do meaningful boolean tests
on various objects, so I used the mechanism that my language gave me.
The natural, obvious way for
a filte
ent" would come
at a much greater price than its worth, and he's absolutely right in that, as
it's an abuse of the "is" operator, but again, that's a somewhat different
point. It changes nothing about the fact that all this discussion centers
around something that is a non-
Carl Banks wrote:
On Jul 30, 1:58 am, "Russ P." <[EMAIL PROTECTED]> wrote:
On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
Having said that, it would sure be nice to be able to write
if myList is not empty:
instead of
if len(
Carl Banks wrote:
That's not what I was asking for. I was asking for a use case for "if
x" that can't be replaced by a simple explicit test. Your example
didn't satisfy that.
But I believe my example of an iterator with __bool__ but not with
__len__ does.
--
http://mail.python.org/mailm
Le Wednesday 30 July 2008 15:31:28 [EMAIL PROTECTED], vous avez écrit :
> > > class Signal:
> > > [...]
> > > def dc_offset(self, amount):
> > > if amount == 0:
> > > return
> > > self.samples = [sample + amount for sample in self.samples]
> >
> > This function i
On Jul 30, 3:53 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> Fair enough. I have no dog in this particular fight. I just think it
> wouldn't hurt to add an "isempty()" or "isnonempty()" method to the
> list type, and let people use it if they wish, or continue using "if
> x" if that's what they prefe
On Jul 30, 5:09 am, Maric Michaud <[EMAIL PROTECTED]> wrote:
> Le Tuesday 29 July 2008 23:48:31 [EMAIL PROTECTED], vous avez écrit :
> > def print_members(iterable):
> > if not iterable:
> > print ''
> > return
> > print ''
> > for item in iterable:
> > print '%s
Le Tuesday 29 July 2008 23:48:31 [EMAIL PROTECTED], vous avez écrit :
> Here's a function, print_members. It's just something that takes some
> iterable and prints its members in XML. It's special-cased so that an
> empty iterable gets an empty tag. (This is a bit of a trivial
> example, I admit
Russ P. wrote:
Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
__nonzero__ work in Python. It's very basic stuff. You can quit
patronizing me (and Carl too, I'm sure).
The point that you seem to be missing, or refuse to acknowledge for
some reason, is that &qu
Russ P. wrote:
Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
__nonzero__ work in Python. It's very basic stuff. You can quit
patronizing me (and Carl too, I'm sure).
You suggested a syntax for testing non-emptiness (`x is not empty`)
which indicated
Carl Banks wrote:
I mean in general. I wouldn't spell it like that. I would prefer if
empty(x), with an __empty__ method. (And support __nonzero__ aka
__bool__ dropped completely.)
So your argument is purely about style, then. You just wish it were
written differently.
--
Erik Max Franc
Russ P. wrote:
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
Russ P. wrote:
Come to think of it, shouldn't the list type have an "isempty" method?
Or does it?
Yes. It's written:
if not aList:
...
As you know, that is not quite exactly the same thing.
On Jul 30, 12:49 am, Heiko Wundram <[EMAIL PROTECTED]> wrote:
> Am Mittwoch, 30. Juli 2008 09:18:48 schrieb Russ P.:
>
> > Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
> > __nonzero__ work in Python. It's very basic stuff. You can quit
>
Am Mittwoch, 30. Juli 2008 09:18:48 schrieb Russ P.:
> Oh, Lordy. I understand perfectly well how boolean tests, __len__, and
> __nonzero__ work in Python. It's very basic stuff. You can quit
> patronizing me (and Carl too, I'm sure).
I'll stop repeating what the curre
ely right in that, as
> it's an abuse of the "is" operator, but again, that's a somewhat different
> point. It changes nothing about the fact that all this discussion centers
> around something that is a non-point, but simply a matter of personal taste.
>
> --
>
Am Mittwoch, 30. Juli 2008 08:30:48 schrieb Russ P.:
> On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> > I'm getting this sneaking suspicion that you guys are all putting us on.
>
> As I said in an earlier post, I realize that this would only work if
> there were only one copy of
On Jul 30, 1:58 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>
> > On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> > > Having said that, it would sure be nice to be able to write
>
> > > if myList is not empty:
>
> > > instead of
>
On Jul 30, 2:06 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Perhaps in the particular use case you're thinking of (numeric types vs.
> container types), there aren't any good examples. But who cares?
You don't have to. I am trying to set the record straight on just how
much polymophism "if
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > Come to think of it, shouldn't the list type have an "isempty" method?
> > Or does it?
>
> Yes. It's written:
>
> if not aList:
> ...
As you know, that is not quite exactly the same thing. An
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
>
> >> I'm getting this sneaking suspicion that you guys are all putting us on.
>
> > As I said in an earlier post, I realize that this would only w
Russ P. wrote:
Come to think of it, shouldn't the list type have an "isempty" method?
Or does it?
Yes. It's written:
if not aList:
...
--
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfranci
Russ P. wrote:
On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
I'm getting this sneaking suspicion that you guys are all putting us on.
As I said in an earlier post, I realize that this would only work if
there were only one copy of "empty" (as there is only one copy of
"Non
On Jul 29, 11:16 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Russ P. wrote:
> > On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> >> On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
>
> >>> Having said that, it would sure be nice to be able to write
> >>> if myList is not e
On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> I'm getting this sneaking suspicion that you guys are all putting us on.
As I said in an earlier post, I realize that this would only work if
there were only one copy of "empty" (as there is only one copy of
"None"). I don't know
Russ P. wrote:
On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
Having said that, it would sure be nice to be able to write
if myList is not empty:
instead of
if len(myList) != 0:
I can agree with this.
But I guess that co
Carl Banks wrote:
On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
All this discussion about "if x" has me wondering. I use it all the
time because a fully explicit test just seems redundant. But maybe it
does have some value in terms of readability and type checking. After
all, it is p
Russ P. wrote:
All this discussion about "if x" has me wondering. I use it all the
time because a fully explicit test just seems redundant. But maybe it
does have some value in terms of readability and type checking. After
all, it is possible to forget whether something is a number or a list.
H
Carl Banks wrote:
Bull. This is a request, that, if satisfied, would prove that "if x"
is more polymorphic than a simple explicit test. I posed the question
precisely to see if anyone could come up with a use case that shows
this benefit of "if x".
Except you're the only one who's not convin
On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> > Having said that, it would sure be nice to be able to write
>
> > if myList is not empty:
>
> > instead of
>
> > if len(myList) != 0:
>
> I can agree with this.
But I guess th
On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> All this discussion about "if x" has me wondering. I use it all the
> time because a fully explicit test just seems redundant. But maybe it
> does have some value in terms of readability and type checking. After
> all, it is possible to for
On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > Much like in Steven D'Aprano's example, still the only actual code
> > snippet I've seen, it seems that this can easily be done with a simple
> > explicit test by having all no-advance filters return None and
On Jul 29, 9:52 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
>
>
> > Carl Banks wrote:
> > >> As I wrote in the second reply email I sent, check out my integer set
> > >> recipe on ASPN (and to save you the search:
> > >> http://code.ac
On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> >> As I wrote in the second reply email I sent, check out my integer set
> >> recipe on ASPN (and to save you the search:
> >> http://code.activestate.com/recipes/466286/).
>
> > Couple points:
>
> > 1. Any containe
On Jul 30, 12:22 am, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > That's not what I was asking for. I was asking for a use case for "if
> > x" that can't be replaced by a simple explicit test. Your example
> > didn't satisfy that.
>
> It's a completely artificial request.
On Jul 29, 7:30 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Tue, 29 Jul 2008 10:30:43 -0700, Carl Banks wrote:
> > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote:
> >> I can't dig up a simple example from code I wrote quickly, but because
> >> of the fact tha
Carl Banks wrote:
That's not what I was asking for. I was asking for a use case for "if
x" that can't be replaced by a simple explicit test. Your example
didn't satisfy that.
It's a completely artificial request. "if x" _is_ a completely simple
test. Simpler, in fact, than the ones you we
On Jul 29, 10:23 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > Bzzt. "if len(x)!=0" is a simple explicit that would work for this
> > class and all built-in containers. (Or should--Steven D'Aprano's
> > objections notwithstanding, any reasonable container type should
> >
Carl Banks wrote:
As I wrote in the second reply email I sent, check out my integer set
recipe on ASPN (and to save you the search:
http://code.activestate.com/recipes/466286/).
Couple points:
1. Any container type that returns a length that isn't exactly the
number of elements in it is b
Carl Banks wrote:
Bzzt. "if len(x)!=0" is a simple explicit that would work for this
class and all built-in containers. (Or should--Steven D'Aprano's
objections notwithstanding, any reasonable container type should
support this invariant. From a language design standpoint, an "empty"
builtin c
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>Anders wrote:
>> "But then you decide to name the method "__nonzero__", instead of some
>> nice descriptive name?"
> That suggests to me that Anders imagined that __nonzero__ is something I
> just made up, instead of a standard Python method. What do
On Tue, 29 Jul 2008 13:53:07 -0700, Carl Banks wrote:
> Bzzt. "if len(x)!=0" is a simple explicit that would work for this
> class and all built-in containers. (Or should--Steven D'Aprano's
> objections notwithstanding, any reasonable container type should support
> this invariant.
What's the le
Matthew Woodcraft wrote:
Ben Finney <[EMAIL PROTECTED]> wrote:
No, he retracted the *insult* and restated the *advice* as a distinct
statement. I think it's quite worthwhile to help people see the
difference.
Ben, it was quite clear from Anders' post that he knows about
__nonzero__ . That's
On Tue, 29 Jul 2008 21:25:44 +0100, Matthew Woodcraft wrote:
> Ben Finney <[EMAIL PROTECTED]> wrote:
>> No, he retracted the *insult* and restated the *advice* as a distinct
>> statement. I think it's quite worthwhile to help people see the
>> difference.
>
> Ben, it was quite clear from Anders'
On Tue, 29 Jul 2008 21:15:12 +0100, Matthew Woodcraft wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>> "if x" is completely type agnostic. You can pass an object of any type
>> to it, and it will work. (Excluding objects with buggy methods,
>> naturally.)
>
> There are many circumstances w
On Tue, 29 Jul 2008 10:42:50 -0700, Carl Banks wrote:
> On Jul 29, 11:12 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
...
>> My use case involves a DAG of filters that pass data (of a variety of
>> types--filters just pass on data types they don't understand) between
>> them. I can also drop
On Tue, 29 Jul 2008 10:30:43 -0700, Carl Banks wrote:
> On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote:
>> I can't dig up a simple example from code I wrote quickly, but because
>> of the fact that explicit comparisons always hamper polymorphism
>
> I'm not going to take your word fo
Carl Banks wrote:
On Jul 29, 11:12 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
Carl Banks wrote:
On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote:
On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTE
1 - 100 of 127 matches
Mail list logo