Today I was trying to process some very long string. The string actually was a list of pair of values to be translated to a dictionary.
a = """...
...
...""".split("\n")
a = [x.split("\t") for x in a]
You see, Python has cool features but I think while list comprehensions are readable, they’re annoying to be written. And maps generate iterators
and I always lose it, when I need to write the function before the actual sequence to be mapped. I wish I could do a simple .map(_.split("\n"))
in the spirit of Scala…
This is why I’ve written a simple module for Python. It is available on PyPI under syntax
(I was surprised no-one ever took that name). The core
feature is the “it” construct, which makes lambdas smaller:
cb = it.split("\t")
a = """...""".split("\n") |- cb
The module is not feature complete, but is a good start for my needs. Since recently I work primarily on Jupyter, such tool would be convenient,
Also, there is another project with similar premise. Well, I though I won’t be the first ;)