Odd list behavior
Emile van Sebille
emile at fenx.com
Thu May 14 00:24:27 CEST 2009
On 5/13/2009 2:51 PM Evan Kroske said...
> I'm working on a simple file processing utility, and I encountered a
> weird error. If I try to get the first element of a list I'm splitting
> from a string,
What value of string gives these results?
> I get an error:
> key = string.split()
> However, I can slice the list like normal, but that gives me a
> one-element-long list:
> key = string.split()[:1]
> Finally, the operation works perfectly if I initialize the list beforehand:
> list = string.split()
> key = list
> Why does this happen?
> -- |
> Evan Kroske
> Welcome2Obscurity.Blogspot.com <http://welcome2obscurity.blogspot.com>
> Glory is fleeting, but obscurity is forever. — some French guy |
More information about the Python-list