Amateur question on class definitions...

Chris Angelico rosuav at gmail.com
Tue Nov 29 10:59:40 EST 2011


On Wed, Nov 30, 2011 at 2:21 AM, J. Marc Edwards <jmarcedwards at gmail.com> wrote:
>     ...a list of "a_workflows", i.e. a composite workflow, should I use this
> syntax?
>     set_of_workflows = list(a_workflow)
>

This would be usual:

set_of_workflows = [a_workflow]

Using the list() constructor directly is for when you have some other
iterable; for instance, a string is iterable over its characters:

>>> list("Hello")
['H', 'e', 'l', 'l', 'o']

When you want to wrap up a single object in a list, square brackets
syntax is what you want.

ChrisA



More information about the Python-list mailing list