Nice! Higher order functions make for very expressive code with less clutter.
Did you know that a constructor can be used as well? For conversion between plain str arguments and actualPath for example:
str
Path
paths = map(Path, sys.args) assert all(map(Path.exist, paths))
Caveat, though: map returns a generator, so it can be iterated only once. I often solve this with storing the result in a tuple:
map
paths = tuple(map(Path, sys.args)) assert all(map(Path.exist, paths))
Hi @xtofl ,
I didn't know this yet! Thanks for the examples, written it down to look at I'm sure this can solve certain issues perfectly 😀
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice! Higher order functions make for very expressive code with less clutter.
Did you know that a constructor can be used as well? For conversion between plain
str
arguments and actualPath
for example:Caveat, though:
map
returns a generator, so it can be iterated only once. I often solve this with storing the result in a tuple:Hi @xtofl ,
I didn't know this yet!
Thanks for the examples, written it down to look at I'm sure this can solve certain issues perfectly 😀