Re: try/except KeyError vs "if name in ..."

2012-10-06 Thread Manuel Pégourié-Gonnard
risk, why not use > the try...except version and avoid it completely? > Ok. Thanks for your explanations. -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list

Re: try/except KeyError vs "if name in ..."

2012-10-06 Thread Manuel Pégourié-Gonnard
Günther Dietrich scripsit : > Somewhere I read a text regarding 'try:' versus 'if'. If you take the > probabitility into consideration, how many times the test will fail or > succeed, there are two possibilities: [...] Ok, thanks for the details! -- M

try/except KeyError vs "if name in ..."

2012-10-05 Thread Manuel Pégourié-Gonnard
ering EAFP over LBYL here? Thanks in advance for your comments. -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I hide my stack frames in a TestCase subclass?

2012-10-05 Thread Manuel Pégourié-Gonnard
Peter Otten scripsit : > Manuel Pégourié-Gonnard wrote: > >> Peter Otten scripsit : >> >>> __unittest = True >>> >> Hum, is it documented somewhere? I can't find it in the doc. Also, I'm >> curious to know what kind of magic it's usi

Re: How can I hide my stack frames in a TestCase subclass?

2012-10-04 Thread Manuel Pégourié-Gonnard
his >> frame-hiding behaviour to my own method? > > Move MyTestCase in a separate module and define a global variable > > __unittest = True > Hum, is it documented somewhere? I can't find it in the doc. Also, I'm curious to know what kind of magic it's using.

Re: Combinations of lists

2012-10-03 Thread Manuel Pégourié-Gonnard
soon as i != j, if r is the resulting list of lists. (As opposed to having r[i][j] != r[i][k] for all i and j != k.) -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Should one always add super().__init__() to the __init__?

2012-09-30 Thread Manuel Pégourié-Gonnard
f __init__(self): print("C init, calling C's parent init?") super().__init__() # sic class NotParentOfC: def __init__(self): print("NotParentOfC init") class Sub(C, NotParentOfC): pass spam = Sub() When Sub is instantiated, the line marked "sic" calls NotParentOfC.__init, not object.__init__ (as if would if C was instantiated). -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list