Syntax across languages
Fredrik Lundh
fredrik at pythonware.com
Sun Oct 23 05:22:22 EDT 2005
bearophileHUGS at lycos.com wrote:
> >if you can define the semantics, it's a few lines of code. if you're not
> sure about the semantics, a built-in won't help you...<
>
> I think the language needs a fast built-in version of it. If something
> is both inside Mathematica and Ruby, then probably it can be useful in
> Python too :-)
numpy already has one:
http://numeric.scipy.org/numpydoc/numpy-9.html#pgfId-36512
(it's probably there in scipy too, but the scipy docs don't appear to be
freely available. hmm...)
PIL also has one:
http://www.effbot.org/imagingbook/image.htm#image-getdata-method
there's also one in Tkinter:
>>> import Tkinter
>>> Tkinter._flatten(["abc", 1, 2, (3, 4, 5), None, [6, 7, 8, (9,)]])
('abc', 1, 2, 3, 4, 5, 6, 7, 8, 9)
to create a generic version, you have to decide which sequences to
treat like sequences, and which sequences you don't want to treat
like sequences...
</F>
More information about the Python-list
mailing list