(May-10-2018, 06:09 PM)ThiefOfTime Wrote: since strings always has to be inside of quotes i don't think that this is possible in python. Though, what comes close to that what you want to do is when you have a string some_string = "a b c d e f g h i j k l m n o p q r s t u v w x y z" and you then use the split operator
some_string = "a b c ... z" list = some_string.strip()then list == ["a", "b", ..., "z"]
But maybe someone else nows a different way :)
Please, never - even in examples - shadow builtin "list" with a custom variable
(May-10-2018, 05:44 PM)Antipaladin Wrote: When creating an explicit list, list = [ 'a', 'b', 'c', ... 'z' ], is there a way to "self quote" like @list = qw( a b c ... z) in Perl?
There are str and repr functions in python - for a "flat" list of scalars, their output is similar
Output:In [1]: l = list('abcde')
In [2]: l
Out[2]: ['a', 'b', 'c', 'd', 'e']
In [3]: str(l)
Out[3]: "['a', 'b', 'c', 'd', 'e']"
In [4]: repr(l)
Out[4]: "['a', 'b', 'c', 'd', 'e']"
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.