Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 813
LarsVegas Avatar asked Jan 09 '12 14:01

LarsVegas


1 Answers

No, but you could use split:

my_list = "Paul Michael Jessica Megan".split(" ")
like image 163
Daniel Roseman Avatar answered Nov 15 '22 11:11

Daniel Roseman