[Discuss] A question for the Python gurus
Adam Parkin
pzelnip at telus.net
Mon Jul 31 09:59:24 PDT 2006
Brian Quinlan wrote:
> Adam Parkin wrote:
>> Which was the original version I was complaining about. =8-p
>
> Nope, your version had extra parens.
Actually the parenthesis wasn't my complaint about the original version.
My complaint was the movement of loop control information (in the form
of the if/break) inside the body of the while loop.
> Do you write a lot of C code that looks like this:
>
> if (((((((condition))))))) {...
Well, actually my original version had one extra set of parenthesis
(enclosing the conditional expression), which I think isn't a bad thing
as it helps to more clearly identify what part of the line is the
expression and what part is not. To answer your question, I do tend to
use more parenthesis than necessary but only to avoid ambiguity. For
example:
if (a && b || c && d)
I would probably write as:
if ((a && b) || (c && d))
Because it's clearer and explicity states what I had in mind.
> That is because of caching. Are you really doing interactive input or
> just testing that way?
Interactive (ie - I ran the script, it prompted me for something, I
typed some text, hit enter, still nothing on screen, entered some more,
hit enter, nothing on screen, hit EOF and got the two lines I entered at
once).
>> 2) for some reason I had to hit EOF twice to get the loop to terminate
>
> Yeah, that's interesting and only true on Windows. The same seems to be
> true of cygwin's "cat".
Hmm, that's odd. But actually Cygwin's cat command works exactly the
same as on any *nix machine I've used (no need for 2 EOF's). And the
cat from unxutils.zip (collection of common unix commands for Windows)
works the same way as well (no 2nd EOF needed). So I'm not entirely
sure why you think that this is a Windows-problem.
>> Now imagine if you say, want to capitalize every word in the line,
>> then the memory/time requirements would explode, would they not? If
>> there were n words in the sentance, then you'd have to create n copies
>> of the string (or so it would seem to me -- correct me if I'm wrong).
>
> "Explode"? The memory required will be triple the length of the line
> (plus overhead) i.e. who cares?
Yikes. I think triple the memory costs is pretty substantial.
--
--
Adam Parkin
E-mail: pzelnip at telus.net
----------------------
Never assume. It makes an "ass" out of "u" and "me".
More information about the Discuss
mailing list