ruby %w equivalent

Thorsten Kampe thorsten at thorstenkampe.de
Tue Sep 26 23:56:06 CEST 2006


* Antoine De Groote (Tue, 26 Sep 2006 12:06:38 +0200)
>Thorsten Kampe wrote:
>> * John Machin (24 Sep 2006 15:32:20 -0700)
>>> Antoine De Groote wrote:
>>>> 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.
>> 
>> Something wrong with "list('abc')"? Or is it too simple?!
>> 
>> Thorsten
>
>As far as I can tell this works for single characters only. You're not 
>able to split words, as in "one two three".split().

It does satisfy your example in your first posting nevertheless.

Thorsten



More information about the Python-list mailing list