ruby %w equivalent
Tim Chase
python.list at tim.thechases.com
Sun Sep 24 18:49:30 EDT 2006
>> is there a python equivalent for the ruby %w operator?
>> %w{a b c} creates an array with strings "a", "b", and "c" in ruby...
>>
>
> | >>> "a b c".split()
> | ['a', 'b', 'c']
>
> ... appears to match your single example.
bah, far to easy to understand...add a little line-noise, man,
and it will be closer to ruby/perl.
Maybe something like
>>> from string import split as _
>>> _("a b c")
['a', 'b', 'c']
or perhaps
>>> "a b c".split
>>> _()
['a', 'b', 'c']
to give it that perl/ruby-ish feel of terseness and obscurity.
And people wonder why I like python... :)
-tkc
More information about the Python-list
mailing list