Carl Banks schrieb:
p = myfunction()
if p:
print p
(I recommend doing it this way in C, too.)
This is okay for if-clauses, but sucks for while-loops:
while (fgets(buf, sizeof(buf), f)) {
printf("%s\n", buf);
}
is much shorter than
char *tmp;
tmp = fgets(buf, sizeof(buf), f);
while (tmp) {
printf("%s\n", buf);
tmp = fgets(buf, sizeof(buf), f);
}
For the case where you want to do this in an elif-clause, look for the
recent thread "C-like assignment expression?" which list some
workarounds. Or just Google this newsgroup for "assignment
expression". It's one of few minor irritating things in Python
syntax.
Alright, I will. Thanks.
Regards,
Johannes
--
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electronics <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list