7 ms·
Alice in Python projectland
- deleted 9y ago[deleted]
- PleaseHelpMe 9y agoVery good writing indeed. However, the metaphor here gives me the feeling of "enough internet today"... Btw, the anchor link to #project-structure don't work. Hope you (if you are the author) fix that soon.
- ainiriand 9y agoVery good article. It is really astounding the amount of work that needs to be done in the python ecosystem!
- monkmartinez 9y agoWhat do you mean by; "astounding the amount of work that needs to be done in the python ecosystem!"? Can you provide examples of different ecosystems that would compare favorably in your opinion?
- danharaj 9y agoI write both python and haskell for my day job. I think the latter has much better project management when it's paired with Nix. Even without Nix, stackage and even just dealing with Cabal is much easier than the mess in the Python ecosystem.
- marcosdumay 9y agoThe stability of the Haskell ecosystem is something I just can not understand. It's not enforced by policies, the tooling isn't much more helpful than in any other language, and it is not more mature than any widely used ecosystem. It feels like Haskell libraries just need less changes.
- jdormit 9y ago(I've never seriously used Haskell) I wonder if the strong static typing has something to do with that. That eliminates many if the common bugs found in Python programs.
- xapata 9y agoIn my experience, type errors in Python get discovered during testing. So, I doubt that's the reason. Perhaps the nature of Haskell discourages changes, making the community more stable.
- yen223 9y ago> In my experience, type errors in Python get discovered during testing That would be the optimistic view. In reality, `NoneType has no attribute Foo` errors happen in production all the time.
- xapata 9y agoPerhaps because someone got into the (bad) habit of returning Nones instead of raising errors. Errors should never pass silently, etc. The older Python APIs have that C habit of sentinel values, but more modern style is to raise an error on failure.
- yen223 9y agoFunctions implicitly returns None if you forget to provide a return value on any of the branches. This is an error that can easily slip past eyeball reviews, since this is caused by the absence of something.
- xapata 9y agoShouldn't unit tests be exploring all the code paths? I know that's tough to enforce, but it's ideal. Regardless of whether you use a static analyzer. And Python does have static analyzers, including for typing.
- ainiriand 9y agoCome on, you only have to take a look at the javascript ecosystem to know what I´m talking about. Tenths of bundlers, a cuple of good dependency resolvers, a myriad of test frameworks, etc... In python you are lucky if you have one of each.
- pmoriarty 9y agoPython's package management makes a mockery of the famous Zen of Python: "There should be one--and preferably only one--obvious way to do it." https://en.wikipedia.org/wiki/Zen_of_Python https://en.wikipedia.org/wiki/Zen_of_Python
- hobofan 9y agoAs someone who mainly works with other programming languages, I feel like the "obvious way to do it" was always the way Pipenv and its Pipfiles handle things, and it finally arrived. It's not the first time I say this, but I think it's crazy how long some package ecosystems live without a "sane" package manager, and how recently those even appeared.
- sametmax 9y agoYou mean the tool that has a 2/3 flag option, but no way to choose precisely which from 3.4, 3.5 or 3.6 you want ?
- asddddd 9y agopipenv --python python34
- sametmax 9y agopipenv --python python34 Error: no such option: --python Is that recent ?
- asddddd 9y agoMaybe, the project as a whole seems to be under a year old and is under very active development. Probably 7.0.0 or 3.2.9, where current version is 8.2.6: https://github.com/kennethreitz/pipenv/blob/master/HISTORY.txt#L288 https://github.com/kennethreitz/pipenv/blob/master/HISTORY.t... Also, I guess --python 3.4 would be the preferred way to do it, seems to work with either versions or executables.
- flavor8 9y agoThe "python hides the hurt" example isn't great. First, he's missing the imports on the python side (which can be just as verbose as java imports). Second, he's talking 10 lines of code in java (plus closing braces) vs 6 in python, but with a little bit of tweaking you could easily drop 2 of those lines in Java. Third, if you were to import guava or some other library that makes handling files more streamlined, you could get to an equivalent number of lines in the Java example.
- jpeanuts 9y ago1. The Python in that example requires no imports. 2. I think the author (Vicki) is a she.
- notamy 9y ago> Third, if you were to import guava or some other library that makes handling files more streamlined, you could get to an equivalent number of lines in the Java example. You don't even need that. The Files[1] class - which has been in the standard library since at least Java 7 - makes this really easy to do. [1] https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html https://docs.oracle.com/javase/8/docs/api/java/nio/file/File...
- depressedpanda 9y agoWhy are you optimizing the LOC only for Java? With a little bit of tweaking, Python can do the whole thing in 2 lines -- no imports, libraries or closing braces needed: with open('alice.txt') as inp, open('new_alice.txt', 'w') as out: out.write('\n'.join([line.rstrip().replace('Alice', 'Dora the Explorer') for line in inp])) The author's point is that Java is verbose and requires a lot of boilerplate, which has benefits and drawbacks. I think her example does a decent job of illustrating that.
- kd5bjo 9y agoIn the refactoring section, it says: Note that if you don’t have if __name__ == '__main__', the code won’t run anything since the function is initialized but not executed Isn't this backwards? That test isn't required to make the code run, it prevents the code from running if the file is imported as a module.
- cup-of-tea 9y agoYeah, it's written slightly badly, but it means if you don't include that block then nothing will run. The way it's written makes it seem like using the ifmain construct isn't optional, which isn't a terrible thing to teach.
- el3ctron 9y agoi learn about good practices testing some python cookiecutters where you can find a lot of practical project clues :)
- thinkling 9y agoFunny to see the name Alice in the context of Python. Alice [1][2] is a Python-based environment for creating animated, interactive 3D scenes, created by Randy Pausch and his students. They picked python intentionally for its simplicity at a time when it wasn't yet well known. [1] http://www.alice.org http://www.alice.org [2] https://en.m.wikipedia.org/wiki/Alice_(software) https://en.m.wikipedia.org/wiki/Alice_(software)
- neuronexmachina 9y agoYep, playing around with Alice in the early 2000s was actually the first time I ever encountered Python.
- tibbon 9y agoThis was really helpful for me, someone who does Ruby most of the time. The programming parts of Python aren't hard, but I'm simply unfamiliar with the layout of things.