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
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
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
[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
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:
[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
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:
>
>
> 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):