Pytudes
github.com
github.com
Never really had a reason to use one, but it seems like people are big fans.
No one is using Python like that in the professional world. The most complex you'll see are simple comprehensions.
Python is supposed to be a readable language for newbies, like Golang.
I see quite a lot of higher-order functions in "real" Python anyway. I'm not sure what other FP concepts there are in Pytudes.
That's part of why much of the software industry is incredibly boring work. And also this isn't work, it's supposed to be fun, do whatever you want.
It is possible that blub-Python and "let's code it in Java-flavoured Python" rules your particular slice of the profession, but in my world of getting shit done I see more FP and using simple built-in data structures in a >1 KLoc line script/module than I do of traditional OO and GoF styles. Most objects I deal with in Python are from libraries I call and not from our own code. Different strokes I guess, but I think you underestimate the breadth of Python usage and how much of it is semi-complicated scripting that picks from FP-style and OO-style depending on what is easiest to accomplish the task.
Worse, sometimes I will have to dig down into accessors of accessors to find the actual logic for a library (which is why I often implement my own, shorter and easier to debug ones).
I write Python in a mix of FP style (with the occasional class for handling specific contexts or tasks) that aims to be as concise and readable as possible, and yes, I will use global variables in a module if it saves me the trouble of herding some constants or common state around and making function invocations unnecessarily long.
Some parts of the code feel like what I would expect from a junior dev who started learning the language a couple weeks ago.
[1]: https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a7...
[2]: https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a7...
The things I mentioned do matter in any situation. If you don’t take good habits when you exercise your brain, you won’t take them when you code "for real". In addition to that, this repository is not just to exercise the brain of the author, but to serve as example code for others to read it; it has a README and most functions have a docstring.
I'm always surprised what I find when I move into a codebase. A lot of it is just what was fashionable when the application started. 90s and 00's everything is over objectified complete with lots of factories and tons of getters and setters. 10's you started seeing a lot more FP style usage, and now I'm seeing a lot more async code.
> Python is supposed to be a readable language for newbies, like Golang.
Python is supposed to be readable because most developers spend more time reading code than writing it.
Agreed, a complex application riddled with global variables is not elegant.
In a fifty line self-contained script, global variables are often the simplest way to go. Turning the code into a reusable class with member variables, which will never be reused, is not simpler. YAGNI.
This and the fact Python is often used in the context of writing simple utilities, where globals (even without the defense above) are perfectly fine (because it's not a huge codebase with namespace collisions etc.).
Using absolute axioms like "globals are always bad" and religiously applying them is a toxic attitude in my opinion.