Steve Holden wrote:
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote:
Not quite because if something(3) fails, I still want something(4) to
run.
Then the obvious extension:
for i in range(20):
...
but I get the idea that Gregory was thinking of different statements
rather than
So much for writing my whole program on one line :-(
j/k
-GregOn 10/26/05, Fredrik Lundh [EMAIL PROTECTED] wrote:
Gregory Piñero wrote: Any idea why I can't say: if 1:print 'a';else:print 'b' all in one line like that?because ; can only be used to separate simple statements, not
the different
Gregory Piñero wrote:
So much for writing my whole program on one line :-(
Why bother with one liners?
The number of meaningful lines and pages a writer produces is a
measure for his writer-ship
-- my old Literature professor
--
http://mail.python.org/mailman/listinfo/python-list
On 27/10/05, Gregory Piñero [EMAIL PROTECTED] wrote:
So much for writing my whole program on one line :-(
http://www.unixuser.org/~euske/pyone/
But you didn't hear it from me, OK? ;-)
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
That's interesting, Simon. However, my goal really was to do:
try:something(1);except:pass
try:something(2);except:pass
try:something(3);except:pass
...
for about 20 lines.
I figured this would be more readable because if I reader sees 20 lines
of nearly identical text he'll understand that
On Oct 27, Gregory Piñero wrote:
my goal really was to do:
try:something(1);except:pass
try:something(2);except:pass
try:something(3);except:pass
...
for about 20 lines.
If you just want to ignore the exceptions while saving space/typing,
you could equivalently do::
Not quite because if something(3) fails, I still want something(4) to run.
On 10/27/05, Micah Elliott [EMAIL PROTECTED] wrote:
If you just want to ignore the exceptions while saving space/typing,you could equivalently do::try:something(1)something(2)# ...except:pass
or::try:something(1);
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote:
Not quite because if something(3) fails, I still want something(4) to
run.
def something_ignore_exceptions(x):
try: something(x)
except: pass
something_ignore_exceptions(1)
something_ignore_exceptions(2)
# etc...
HTH,
Carsten Haese
Carsten Haese wrote:
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote:
Not quite because if something(3) fails, I still want something(4) to
run.
def something_ignore_exceptions(x):
try: something(x)
except: pass
something_ignore_exceptions(1)
something_ignore_exceptions(2)
#
On Thursday 27 October 2005 11:16, Carsten Haese wrote:
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote:
Not quite because if something(3) fails, I still want something(4) to
run.
def something_ignore_exceptions(x):
try: something(x)
except: pass
something_ignore_exceptions(1)
Any idea why I can't say:
if 1:print 'a';else:print 'b'
all in one line like that?
It's just a random question I ran across a few days ago. -- Gregory PiñeroChief Innovation OfficerBlended Technologies(www.blendedtechnologies.com
)
--
http://mail.python.org/mailman/listinfo/python-list
Gregory Piñero wrote:
Any idea why I can't say:
if 1:print 'a';else:print 'b'
all in one line like that?
because ; can only be used to separate simple statements, not
the different parts in a compound statement.
see the grammar for details:
http://docs.python.org/ref/grammar.txt
12 matches
Mail list logo