Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-28 Thread Christopher Subich
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 statement

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread James Stroud
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_excepti

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Steve Holden
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_exc

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Carsten Haese
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

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
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: 

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Micah Elliott
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:

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
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 it

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Simon Brunning
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/ -- http://mail.python.org/

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread W.H.Offenbach
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

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
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 diff

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-26 Thread Fredrik Lundh
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