Implicit conversion to boolean in if and while statements
Rick Johnson
rantingrickjohnson at gmail.com
Fri Feb 8 19:49:02 EST 2013
On Friday, February 8, 2013 6:05:54 PM UTC-6, Chris Angelico wrote:
> The sum builtin works happily on any sequence of objects
> that can be added together. It works as an excellent
> flatten() method:
>
> >>> nested_list = [["q"], ["w","e"], ["r","t","u"], ["i","o","p"]]
> >>> sum(nested_list,[])
> ['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p']
> >>> nested_list
> [['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']]
What the hell? Oh yeah, you must be using pike again. No, if it were pike the list would look like this:
({({"q"}), ({"w","e"}), ({"r","t","u"}), ({"i","o","p"})})
Of course you'd have to declare it first using an /expanded/ Java syntax:
nested_list = array(array(string))
Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if want a few laughs.
http://pike.lysator.liu.se/docs/tutorial/data_types/container_types.xml
> I'm not sure what your definition of a numeric type is, but I suspect
> that list(str) isn't part of it.
Of course not.
More information about the Python-list
mailing list