Michael Hoffman <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>
>> Making None a constant broke existing code (and I just saw old code
>> that assigned to None). Are True and False that much more common as
>> variable names than None?
>
> Yes. In fact, I count at least 4 different modules in the
Michael Hoffman <[EMAIL PROTECTED]> wrote:
> I count at least 4 different modules in the Python 2.4 standard
> library that assign to True or False, mainly as a compatibility
> measure for the days before they were built-ins.
Hopefully, none of them as creative as
http://thedailywtf.com/forums/36
Antoon Pardon wrote:
> Op 2005-06-22, Michael Hoffman schreef <[EMAIL PROTECTED]>:
>
>>Remi Villatel wrote:
>>
>>>Fredrik Lundh wrote:
>>>
checking if a logical expression is true by comparing it to True is bad
style, and comparing values using "is" is also bad style.
>>>
>>>I wrote it thi
Mike Meyer wrote:
> Making None a constant broke existing code (and I just saw old code
> that assigned to None). Are True and False that much more common as
> variable names than None?
Yes. In fact, I count at least 4 different modules in the Python 2.4
standard library that assign to True or F
Mike Meyer wrote:
> Making None a constant broke existing code (and I just saw old code
> that assigned to None). Are True and False that much more common as
> variable names than None?
I would think so. I know that my pre-booleans-in-Python code routinely
did something like "from booleans impor
Stelios Xanthakis <[EMAIL PROTECTED]> writes:
> Michael Hoffman wrote:
>> Stelios Xanthakis wrote:
>>
>>> Magnus Lycka wrote:
>> >
>>
Right. Silly me. Maybe in some future Python version, True and False
will be constants, like None is since Python 2.4.
>>>
>>>
>>> Actually, there is sup
Michael Hoffman wrote:
> Stelios Xanthakis wrote:
>
>> Magnus Lycka wrote:
>
> >
>
>>> Right. Silly me. Maybe in some future Python version, True and False
>>> will be constants, like None is since Python 2.4.
>>
>>
>> Actually, there is support in marshal to write True and False objects so
>>
Op 2005-06-22, Michael Hoffman schreef <[EMAIL PROTECTED]>:
> Remi Villatel wrote:
>> Fredrik Lundh wrote:
>>> checking if a logical expression is true by comparing it to True is bad
>>> style, and comparing values using "is" is also bad style.
>>
>> I wrote it this way because, first, it's perfec
Stelios Xanthakis wrote:
> Magnus Lycka wrote:
>
>> Right. Silly me. Maybe in some future Python version, True and False
>> will be constants, like None is since Python 2.4.
>
> Actually, there is support in marshal to write True and False objects so
> I don't understand why this isn't in 2.4
Be
Magnus Lycka wrote:
> In some cases, "==" and "is" happens to give the same result.
> >>> a = 1
> >>> b = 1
> >>> a == b
> 1
> >>> a is b
> 1
>
> But often not.
>
> >>> c = 123456789
> >>> d = 123456789
> >>> c == d
> 1
> >>> c is d
> 0
>
...
> First of all, a lot of Python values except
def until(pred):
yield None
while True:
if pred(): break
yield None
def example():
i = 0
for _ in until(lambda: x==0):
x = 10 - i
i += 1
print x, i
example()
pgpeP7iW6mcQm.pgp
Description: PGP signature
--
http://mail.python.org/mailman/l
Remi Villatel wrote:
> Fredrik Lundh wrote:
>> checking if a logical expression is true by comparing it to True is bad
>> style, and comparing values using "is" is also bad style.
>
> I wrote it this way because, first, it's perfectly valid Python code and,
> second and most important, it's also
Remi Villatel wrote:
> Erm... You totally missed the point. I wrote it this way because, first,
> it's perfectly valid Python code and, second and most important, it's
> also a valid english sentence.
Remi, I think you have failed to understand what Fredrik was
telling you. I can understand that
- Original Message -
From: "Greg Lindstrom" <[EMAIL PROTECTED]>
> A bit off topic, but what does the expression "Don't try to teach your
> grandfather how to suck eggs." mean? I've never heard it before and am
> curious to the story behind it.
A relatively well know phrase, however as
A bit off topic, but what does the expression "Don't try to teach your
grandfather how to suck eggs." mean? I've never heard it before and am
curious to the story behind it.
Thanks,
--greg
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 22 Jun 2005 09:54:44 +0200, Fredrik Lundh wrote:
>> [CENSORED] I keep for myself how stupid I found your post.
>
> so let's see if everyone who understands how embarrassingly stupid
> your post is will keep that to themselves...
Damn, did I fail some test?
--
Steven.
--
http://ma
> "Stelios" == Stelios Xanthakis <[EMAIL PROTECTED]> writes:
Stelios> Anyway, if you can't wait for 2.5 either use 'while 1:',
Stelios> or pyc[1]
... and I can't see why people don't want to use 'while 1:' in the
first place, given that everyone can identify the idiom
immediately. It'
Remi Villatel wrote:
> >>while True:
> >> some(code)
> >> if final_condition is True:
> >> break
> >> #
> >>#
>
> > checking if a logical expression is true by comparing it to True is bad
> > style, and comparing values using "is" is also bad style.
>
> Erm... You totally missed the point. I wrote
Remi Villatel wrote:
> Hi there,
>
> There is always a "nice" way to do things in Python but this time I can't
> find one.
>
> What I'm trying to achieve is a conditionnal loop of which the condition
> test would be done at the end so the loop is executed at least once. It's
> some way the opp
On Wed, 22 Jun 2005 02:01:14 +0200, Remi Villatel wrote:
> Fredrik Lundh wrote:
>
>>>while True:
>>> some(code)
>>> if final_condition is True:
>>> break
>>> #
>>>#
>
>> checking if a logical expression is true by comparing it to True is bad
>> style, and comparing values
Fredrik Lundh wrote:
>>while True:
>> some(code)
>> if final_condition is True:
>> break
>> #
>>#
> checking if a logical expression is true by comparing it to True is bad
> style, and comparing values using "is" is also bad style.
Erm... You totally missed the point.
Magnus Lycka wrote:
> Konstantin Veretennicov wrote:
>
>> On 6/21/05, Magnus Lycka <[EMAIL PROTECTED]> wrote:
>>
>>> I don't know anything about the Python compiler internals,
>>> but it doesn't seem very hard to identify simple literals following
>>> while and if, and to skip the runtime test. (P
Konstantin Veretennicov wrote:
> On 6/21/05, Magnus Lycka <[EMAIL PROTECTED]> wrote:
>
>>I don't know anything about the Python compiler internals,
>>but it doesn't seem very hard to identify simple literals following
>>while and if, and to skip the runtime test. (Perhaps it's done
>>already?)
>
On 6/21/05, Magnus Lycka <[EMAIL PROTECTED]> wrote:
> I don't know anything about the Python compiler internals,
> but it doesn't seem very hard to identify simple literals following
> while and if, and to skip the runtime test. (Perhaps it's done
> already?)
True doesn't seem to be a literal, it
Benji York wrote:
> If by "economy" you mean "optimization", then I would suggest that the
> difference would be unnoticeable.
If there is a measurable performance gain in skipping the runtime
test in "while True", then this is a compiler issue, not a language
issue. I don't know anything about t
Remi Villatel wrote:
> There is always a "nice" way to do things in Python but this time I can't
> find one.
>
> What I'm trying to achieve is a conditionnal loop of which the condition
> test would be done at the end so the loop is executed at least once. It's
> some way the opposite of "while".
On Tue, 21 Jun 2005 12:05:25 +0200, Magnus Lycka <[EMAIL PROTECTED]> wrote:
> Remi Villatel wrote:
>> while True:
>> some(code)
>> if final_condition is True:
>> break
>> #
>> #
>>
>> What I don't find so "nice" is to have to build an infinite loop only to
>> break it.
>
> Th
Cyril BAZIN wrote:
> Another question could be: why is there not a statement "whileTrue" or
> "loop"?
I don't think the saving of a single space to transform "while True:"
into "WhileTrue:" is really worth it. The same goes for "loop", the
added complexity to the language (as little as it is)
Another question could be: why is there not a statement "whileTrue" or "loop"?
For exemple:
whileTrue:
statement 1
if condition:
break
statement 2
It could be an economy of one unuseful test by loop.On 6/21/05, Magnus Lycka <[EMAIL PROTECTED]> wrote:
Remi Villate
Remi Villatel wrote:
> while True:
> some(code)
> if final_condition is True:
> break
> #
> #
>
> What I don't find so "nice" is to have to build an infinite loop only to
> break it.
This is a common Python idiom. I think you will get used to it.
> Is there a better recipe?
Joseph Garvin wrote:
> Peter Otten wrote:
>
>> I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of
>> "for
>> (" in the Python 2.4 source, so using these rough estimates do-while
>> still
>> qualifies as "rarely used".
>>
>> Peter
>>
>>
>>
> That's 136 times you'd have to use
See Pep 315, which is still open, and targeted at 2.5.
It survived the recent spate of PEP closings and rejections.
http://www.python.org/peps/pep-0315.html
John Roth
"Remi Villatel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi there,
>
> There is always a "nice" way to do t
Joseph Garvin wrote:
> Peter Otten wrote:
>
>> I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of
>> "for
>> (" in the Python 2.4 source, so using these rough estimates do-while
>> still
>> qualifies as "rarely used".
>>
>> Peter
>>
>>
>>
> That's 136 times you'd have to use
Peter Otten wrote:
>I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of "for
>(" in the Python 2.4 source, so using these rough estimates do-while still
>qualifies as "rarely used".
>
>Peter
>
>
>
That's 136 times you'd have to use an ugly hack instead. I definitely
wouldn't m
In article <[EMAIL PROTECTED]>,
Andrea Griffini <[EMAIL PROTECTED]> wrote:
> On Sat, 18 Jun 2005 13:35:16 -, Grant Edwards <[EMAIL PROTECTED]>
> wrote:
>
> >AFAICT, the main use for do/while in C is when you want to
> >define a block of code with local variables as a macro:
>
> When my job
On Sat, 18 Jun 2005 13:35:16 -, Grant Edwards <[EMAIL PROTECTED]>
wrote:
>AFAICT, the main use for do/while in C is when you want to
>define a block of code with local variables as a macro:
When my job was squeezing most out of the CPU (videogame
industry) I remember that the asm code generat
Quoth Peter Otten <[EMAIL PROTECTED]>:
...
| 'until' in C is actually
|
| do
| statement
| while (expression);
Oops. Well, QED - I sure don't need it often.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
- Original Message -
From: "Remi Villatel" <[EMAIL PROTECTED]>
> There is always a "nice" way to do things in Python but this time I can't
> find one.
> So far, all I got is:
>
> while True:
> some(code)
> if final_condition is True:
> break
> #
> #
>
> What I don't find so "nice" is t
On 2005-06-18, Peter Otten <[EMAIL PROTECTED]> wrote:
>> If you look at C code, at least in my experience the
>> "until" loop is quite rarely used. (I don't see it once in the source
>> to Python 2.4, for example.)
>
> Long time no C?
>
> 'until' in C is actually
>
> do
> statement
> while
Donn Cave wrote:
> If you look at C code, at least in my experience the
> "until" loop is quite rarely used. (I don't see it once in the source
> to Python 2.4, for example.)
Long time no C?
'until' in C is actually
do
statement
while (expression);
I found 136 occurrences of "do {" ver
Quoth Remi Villatel <[EMAIL PROTECTED]>:
| What I'm trying to achieve is a conditionnal loop of which the condition
| test would be done at the end so the loop is executed at least once. It's
| some way the opposite of "while".
|
| So far, all I got is:
|
| while True:
| some(code)
|
Hi there,
There is always a "nice" way to do things in Python but this time I can't
find one.
What I'm trying to achieve is a conditionnal loop of which the condition
test would be done at the end so the loop is executed at least once. It's
some way the opposite of "while".
So far, all I got
42 matches
Mail list logo