2 ms·
Python: The import system. Why can't I easily import a file from any location in the file system? Javascript: Lacks support for 64-bit integers and arbitrary-p
by rpedela 13y ago
Python: The import system. Why can't I easily import a file from any location in the file system?
Javascript: Lacks support for 64-bit integers and arbitrary-precision decimals.
SQL: SQL injection.
- Vaskivo 13y agoI agree with the python one. Some more things I find annoying in Python: - Hardcoded recursion limit + no tail call optimization. I understand Guido's reasons for this but I find myself writing ugly code instead of beatiful code. (But maybe changing this would make Python's internals ugly.) Mainly Python but other languages too. - Length of the collection: len(foo). String representation: str(foo). Why not foo.len() or foo.str(). Or even better: foo.len or foo.str. As a Python user, I'm not a fan of getters. I think we should use the "attribute syntax" to get data about and of the object/type/thing, regardless if it involves any computations or not. (but would probably generate more problems than solve little nitpicks)
- chas 13y agoThis doesn't help in quite the way you would like, but the recursion limit is adjustable through sys.setrecursionlimit [1]. [1]http://docs.python.org/2/library/sys.html#sys.setrecursionlimit http://docs.python.org/2/library/sys.html#sys.setrecursionli...
- Vaskivo 13y agoThe problem is not that there is a hardcoded limit. Python just isn't suited for heavy recursion. As for tail-call optimization, here's Guido's opinion (which I agree): http://neopythonic.blogspot.pt/2009/04/tail-recursion-elimination.html http://neopythonic.blogspot.pt/2009/04/tail-recursion-elimin...
- captainmuon 13y agoI second the Python one. Why the wierd distinction between packages, modules, and things in files? I believe all of these three should give me os.path.isdir: import os import os.path import os.path.isdir os.path.isdir(...) And to get isdir() directly, I would use either: from os.path import isdir import os.path.isdir as isdir This should work if path is either a package (a directory), a module (a file), or an object defined in os.py! Sometimes, for some reason if I only import a module, I can't use submodules. So `import os` wouldn't give `os.path.isdir`. I don't know when that occurs, maybe it was in an ancient version of python. But it leaves me with an uneasy feeling every time I use a submodule. Anyone know when this happens? Last but not least, it should be easier to import stuff from above the script. If my script lives at ./tools/foobar.py, and I want to import ./helper.py, it should just be something like # ./tools/foobar.py from .. import helper $ python ./tools/foobar.py # simple run-a-script syntax and not $ python -m tools/foobar # hideous run-a-module syntax or what I'm using now # ./tools/foobar.py # hideous boilerplate header import sys, os SCRIPTDIR = os.path.relpath(os.path.dirname(__file__) or ".") PARENTDIR = os.path.relpath(os.path.join(SCRIPTDIR, "..")) sys.path.insert(0, PARENTDIR) import helper $ python ./tools/foobar.py # simple run-a-script syntax