Re: Request a short code review

2008-04-20 Thread Gabriel Genellina
En Fri, 18 Apr 2008 15:10:09 -0300, <[EMAIL PROTECTED]> escribió: > lessons = self.lesson_data["lessons"] > if lesson_type: > lessons = [x for x in lessons if x["type"] == lesson_type] > > Changes: > - generator expression instead of filter The above is not a generator expression

Re: Request a short code review

2008-04-18 Thread james
Thank you all for posting insightful and useful comments. Here is what I have based on your input: def output_random_lesson_of_type(self, lesson_type=None): """Output a lesson of a specific type. If no type is passed in then output all types.""" lessons = self.lesson_data["lessons

Re: Request a short code review

2008-04-18 Thread Sam
Hello, I would personally avoid using "type" as variable name, or key, because built-in class type already exists. As I understand your code, it was not your intention to override it. ++ Sam -- http://mail.python.org/mailman/listinfo/python-list

Re: Request a short code review

2008-04-17 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Here is a method I came across that I would like to clean up: > > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type - if no type is passed in > then output any type.""" > if type: > filtered_lessons = filter(lam

Re: Request a short code review

2008-04-17 Thread Ivan Illarionov
On Thu, 17 Apr 2008 15:11:40 -0700, james wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something to >> improve then I am happy to learn. > > To give an example of what I mean I have already altered the code:

Re: Request a short code review

2008-04-17 Thread John Machin
[EMAIL PROTECTED] wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something >> to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_le

Re: Request a short code review

2008-04-17 Thread André
On Apr 17, 7:11 pm, [EMAIL PROTECTED] wrote: > > I am not necessarily looking to make the code shorter or more > > functional or anything in particular. However if you spot something > > to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > >

Re: Request a short code review

2008-04-17 Thread james
> I am not necessarily looking to make the code shorter or more > functional or anything in particular. However if you spot something > to improve then I am happy to learn. To give an example of what I mean I have already altered the code: def output_random_lesson_of_type(self, type=None):