Re: style question

2006-06-26 Thread Frank Millman
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking indentation

Re: style question

2006-06-26 Thread Frank Millman
Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation character. The opening/closing

Re: style question

2006-06-26 Thread Laurent Rahuel
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking

Re: style question

2006-06-26 Thread Fredrik Lundh
Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation character. The opening/closing

Re: style question

2006-06-26 Thread Frank Millman
Fredrik Lundh wrote: Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation

Re: style question

2006-06-26 Thread Duncan Booth
Hari Sekhon wrote: Since the first method does not follow python's clean and easy looking indentation structure but the second just looks crude and ugly anyway. If you want indented and pretty is important to you: from textwrap import dedent as D message = D(\ This is line1.

Re: style question

2006-06-26 Thread Claudio Grondi
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking

Re: style question

2006-06-26 Thread Scott David Daniels
Claudio Grondi wrote: clever stuff to di indentation When necessary to skip first line _and_ indentation: message = This is line 1 This is line 2 This is line 3 .replace('\n ', '\n')[1:] # adjust here '\n ' to indentation Riffing on this idea: message =

Re: style question

2006-06-26 Thread Claudio Grondi
Scott David Daniels wrote: Claudio Grondi wrote: clever stuff to di indentation When necessary to skip first line _and_ indentation: message = This is line 1 This is line 2 This is line 3 .replace('\n ', '\n')[1:] # adjust here '\n ' to indentation Riffing on this idea:

calling functions style question

2006-06-06 Thread Brian
I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2() or in an if __name__ == __main__

Re: calling functions style question

2006-06-06 Thread Thomas Nelson
that the script runs its main functions when called as a standalone program, but you can also import the code and do something with it without setting off those functions. THN Brian wrote: I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2

Re: calling functions style question

2006-06-06 Thread Kay Schluehr
Brian wrote: I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2

style question: how to delete all elements in a list

2006-03-06 Thread gry
Just curious about people's sense of style: To delete all the elements of a list, should one do: lst[:] = [] or del(lst[:]) I seem to see the first form much more often in code, but the second one seems more clearly *deleting* elements, and less dangerously mistaken for the completely

RE: style question: how to delete all elements in a list

2006-03-06 Thread Delaney, Timothy (Tim)
gry@ll.mit.edu wrote: To delete all the elements of a list, should one do: lst[:] = [] or del(lst[:]) del lst[:] Note that del is not a function - the parentheses are not needed, and in fact obscure the intent. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: style question: anything wrong with super(type(self), self).f() ?

2005-09-19 Thread Tom Anderson
On Mon, 19 Sep 2005, Adam Monsen wrote: Is there anything wrong with using something like super(type(self), self).f() to avoid having to hardcode a type? What happens when that method gets called by an overriding method in a derived class? For example: class A(object): def f(self):

RE: style question: anything wrong with super(type(self), self).f() ?

2005-09-19 Thread Delaney, Timothy (Tim)
As Tom said, using super(type(self), self) will fail when your class gets subclassed. Otherwise we wouldn't have needed that kind of syntax in the first place. You may be interested in my self.super recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 and the considerably

<    1   2   3