3 ms·
In my opinion, if standard tooling is able to identify the foot-gun, it’s not too terrible of a foot-gun. I don’t think standard python tooling would catch the
by jakear 7y ago
In my opinion, if standard tooling is able to identify the foot-gun, it’s not too terrible of a foot-gun. I don’t think standard python tooling would catch the above issues, but standard JS tooling would identify a missing variable declaration. As for the other things you mention (this, namespaces), I never said JS was perfect! Just that JS got a lot of shit for its scoping, fixed the problem, and now has sane scopes. Py has scoping with a lot of the same problems JS used to have, but for some reason didn’t fix them, and thus to this day is riddled with these foot-guns.
- BiteCode_dev 7y ago> I don’t think standard python tooling would catch the above issues, Of course it does. $ echo " > powers_of_x = [lambda x: x^i for i in range(10)] > [f(2) for f in powers_of_x] > " > test.py $ pylint test.py ... test.py:2:27: W0640: Cell variable i defined in loop (cell-var-from-loop) ... Pylint is the most powerful linter for Python is well integrated in VSCode or PyCharm. When concerns are raised about JS, people are quick to answer you are not supposed to use it without modern tooling (Webpack + babel + typescript + eslint + lowdash...), although many devs still do. Now, I use and teach a lot of JS, and I enjoy many of its modern features. I especially like the object destructuring, it's even better than Python's unpacking. But objectively, you can get a very decent experience in Python without any kind of tooling. And yet, there is a lot of it if you want to up your game: pylint, black, mypy, jedi, pytest, poetry, etc.
- jakear 7y agoThat’s good to hear. As I said, I don’t use python much anymore.
- kortilla 7y agoAre they really foot-guns? The lambda variable reference thing has appeared more in forums comparing languages than I’ve seen it used at all in python and I’ve spent a lot of time working in large open source python projects with thousands of contributors. Even if you got the binding right, your powers of 2 would be shot down for being unpythonic anyway due to lambdas being shunned when there are cleaner ways to write things. powers_of_x makes no sense as a variable name for a list of functions that you have to call in order with the same number to actually get the powers of that number. I get that it’s just a contrived example, but most can be turned into someone more apparent to the reader. def powers_of_x(x, limit=10): for i in range(limit): yield x^i Less memory, no anonymous functions, more flexibility, testable...