Alan Gauld freenet.co.uk> writes:
> > With other words I'd like to tell Python: Convert into a float if
> > possible, otherwise append anyway.
>
> [ (type(x) == type(5) and float(x) or x) for x in mylist ]
Almost fell for it too, but the original list contains numbers
stored as strings :).
Christian Meesters wrote on Mon, 4 Apr 2005 14:49:28 +0200:
> Could it be that a C-like solution with
> '?' and ':' is more straightforward than a solution with Python or am I
> just too blind to see a real pythonic solution here?
Pierre did the Python equivalent of the ternary operator in his
Christian Meesters wrote:
Hi
Yesterday night I was thinking about the following problem: I do have
a list like l = ['1','2','3','abc','','4'] - for instance like a list
one could get from a file import with the csv module (which is where
my 'problem' comes from). Now I would like to generate the fo