Re: EAFP gone wrong

2010-02-09 Thread Malte Helmert
Ben Finney wrote: > def latex(val): > def make_result_in_the_absence_of_a_latex_method(): > result = transmogrify(val) > return result > > try: > typeset_func = val.latex > except AttributeError: > typeset_func = make_result_in_the_absence_of_a_latex_met

Re: EAFP gone wrong

2010-02-09 Thread Malte Helmert
Arnaud Delobelle wrote: > This means that EAFP made me hide a typo which would have been obviously > detected had I LBYLed, i.e. instead of > > try: > return val.latex() > except AttributeError: > ... > > do > > if hasattr(val, 'latex'): > return val.latex()

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-24 Thread Malte Helmert
Paul Miller wrote: > On Mon, 23 Nov 2009 19:57:05 -0800, Richard Thomas wrote: > >> Not sure exactly how you're representing graphs, this seems like the >> simplest way of listing the edges. >> >> def complete_partite(*sizes): >> total = sum(sizes) >> nodes, edges = range(total), [] >>

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-16 Thread Malte Helmert
[EMAIL PROTECTED] wrote: > If you're an Emacs user who has used both python-mode.el (the python mode > code distributed with Python and XEmacs) and python.el (the python mode code > distributed with GNU Emacs), I'd like to get your impressions on how they > compare and where you feel the bugs lie.