Re: Critique of first python code

2008-02-17 Thread George Sakkis
On Feb 17, 10:17 am, Matthew Marshall <[EMAIL PROTECTED]> wrote: > Dan Bishop wrote: > > I will say, however, that hasattr(item, '__iter__') isn't a perfect > > way of checking whether an object is iterable: Objects that just > > define __getitem__ are iterable too (e.g., UserList). > > Speaking of

Re: Critique of first python code

2008-02-17 Thread Matthew Marshall
Dan Bishop wrote: > I will say, however, that hasattr(item, '__iter__') isn't a perfect > way of checking whether an object is iterable: Objects that just > define __getitem__ are iterable too (e.g., UserList). Speaking of which, what *is* the best way to check if an object is iterable? I always

Re: Critique of first python code

2008-02-16 Thread Dan Bishop
On Feb 8, 7:30 pm, Zack <[EMAIL PROTECTED]> wrote: >[snip] > > The generators you show here are interesting, and it prodded me on how > to add tuples but at the moment (I'm a python newbie) the generator > seems less readable to me than the alternative. After some input from > Scott David Daniels I

Re: Critique of first python code

2008-02-16 Thread John Machin
On Feb 17, 4:42 pm, TerryP <[EMAIL PROTECTED]> wrote: > Tomek Paczkowski wrote: > > You can try to put your code through pylint. It will give you some > > automatic critique. > > There is a pylint !? > > That one is defiantly making my workstation later just for fun hehe. > See if you can find an

Re: Critique of first python code

2008-02-16 Thread TerryP
Tomek Paczkowski wrote: > You can try to put your code through pylint. It will give you some > automatic critique. > There is a pylint !? That one is defiantly making my workstation later just for fun hehe. -- There seems no plan because it is all plan. -- C.S. Lewis -- http:/

Re: Critique of first python code

2008-02-08 Thread Zack
On Feb 8, 4:32 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Feb 8, 3:40 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > > > How about: > > > from itertools import count > > from random import randrange > > > def grow(L, depth, counter=count()): > >'''grow L by appending integers and

Re: Critique of first python code

2008-02-08 Thread George Sakkis
On Feb 8, 3:40 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Feb 8, 7:20 pm, "Zack" <[EMAIL PROTECTED]> wrote: > > > > > Hi all. I'm just starting to pick up python. I wanted to play with nested > > lists so first I wrote a little bit of code to create arbitrarily nested > > lists (grow). T

Re: Critique of first python code

2008-02-08 Thread Tomek Paczkowski
Zack wrote: > Hi all. I'm just starting to pick up python. I wanted to play with nested > lists so first I wrote a little bit of code to create arbitrarily nested > lists (grow). Then I wrote a breadth first search. I'm putting this small > snippet up asking for criticism. Was there a more elegan

Re: Critique of first python code

2008-02-08 Thread Arnaud Delobelle
On Feb 8, 7:20 pm, "Zack" <[EMAIL PROTECTED]> wrote: > Hi all. I'm just starting to pick up python. I wanted to play with nested > lists so first I wrote a little bit of code to create arbitrarily nested > lists (grow). Then I wrote a breadth first search.  I'm putting this small > snippet up askin

Critique of first python code

2008-02-08 Thread Zack
Hi all. I'm just starting to pick up python. I wanted to play with nested lists so first I wrote a little bit of code to create arbitrarily nested lists (grow). Then I wrote a breadth first search. I'm putting this small snippet up asking for criticism. Was there a more elegant way to do what I'm