Search code examples
pythonlistoperatorsquotes

Perl qw-operator in Python?


I'm a native perl but are using python a lot lately. I was wondering if there is something similar to the perl qw// operator which is a shortcut to get around typing multiple quotes and commas when creating a list of several strings that do not include spaces.

Example: @list = qw(Paul Michael Jessica Megan); (from wikibooks

I can't really find anything but the operator's name might be very different... Cheers, Lars


Solution

  • No, but you could use split:

    my_list = "Paul Michael Jessica Megan".split(" ")