3 ms·
I really don't understand his critique on python. Being able to do functional programming is still great. He doesn't have a lot to say about python. To be hone
by jokoon 9y ago
I really don't understand his critique on python. Being able to do functional programming is still great. He doesn't have a lot to say about python.
To be honest, python is just the greatest thing ever. It's not penetrating well because there is no money behind it like java or go. Like I said, if there was as much money spent on python that there is on js, it would be just great.
Creating a good enough programming language is very hard because it requires experience in engineering and all the compromises it entails, and it also requires not trivial compsci skills. Creating a maintaining a language is hard.
- ioquatix 9y agoI love your enthusiasm. I agree with the points about functional programming in Python though. Help me fix this line: https://github.com/kurocha/tagged-format/blob/283d9bb1c917684724ad5d7e92f3609e33c155bc/exporters/Blender/io_tagged_format.py#L152 https://github.com/kurocha/tagged-format/blob/283d9bb1c91768... In Ruby it would be output.puts "\t\t#{vertex.join(' ')}"
- qznc 9y agoWhat to fix about it? Looks good to me. You could use f-strings (introduced in Python 3.6) to get rid of the `.format(`. https://www.python.org/dev/peps/pep-0498/ https://www.python.org/dev/peps/pep-0498/ The `[str(value) for value in flatten(vertex)]` part is missing in your Ruby. I assume that happens in some method of the vertex? You could make your vertex iterable as well. Python philosophy prevents you from getting rid of the `str(x) for x in v` because "explicit is better than implicit", so join will not auto-convert stuff into strings.
- throwaway287391 9y agoSince you like map, you could shorten it a bit by doing map(str, flatten(vertex)) instead of the list comprehension.
- cup-of-tea 9y agoOnly suggestion I have is not to build a list explicitly: .join(str(value) for ...)
- chronial 9y agoMy first suggestion would be to add a line break after format( , remove the [ ] and rename the loop variable to a single letter. output.write("\t\t{0}\n".format( " ".join(str(x) for x in flatten(vertex)))) But it looks like your core problem is that try you force another language's idioms onto python. Your flatten function could be a lot simpler (and without quadratic runtime): import itertools def flat(l): return itertools.chain.from_iterable( flat(e) if isinstance(e, (list, tuple)) else [e] for e in l ) But that is still not what you actually want – you only wrote this function because you have it in ruby. What you actually want is: def format_vertex(lst): return " ".join( format_vertex(e) if isinstance(e, (list, tuple)) else str(e) for e in lst ) output.write("\t\t{}\n".format(format_vertex(vertex))
- pjmlp 9y agoPython will be the greatest thing ever when it takes the up the lessons from Smalltalk, Dylan and Lisp, and actually produces fast code, with AOT as an option. Maybe some day PyPy will be it.
- jhbadger 9y agoThe problem is it is clear Guido doesn't like functional programming -- his official statement is that "filter and map should die and be subsumed into list comprehensions". Yes, list comprehensions can do many of the things you can do with map/filter/reduce, but in a way where the functional idiom is obscured and one which is not easily converted to and from other languages.
- icebraining 9y agoGuido may dislike many things, but filter and map are still there, so what's the problem?