3 ms·
Oh neat! This is my library. Happy to answer any questions. (Though it's really a pretty tiny library that just does what it says on the tin, not sure how many
by patrickkidger 1y ago
Oh neat! This is my library. Happy to answer any questions.
(Though it's really a pretty tiny library that just does what it says on the tin, not sure how many questions there can be. :D )
- b33j0r 1y agoI have a question. Why do you prefix your package files with an underscore? In fact, you write all of your python like you really have something to hide ;) Like `_Todo`. Where did you get this pattern? (I’m way more curious than accusatory. Are people embracing private modules these days as a convention, and I just missed it?)
- deleted 1y ago[deleted]
- deathanatos 1y agoI think _private has always been a convention in Python, though I'd say most Python is not so rigorous about it. I don't see why it couldn't be applied to modules. I honestly love when I see a package do stuff like this: it's very clear then what is public interface, and I should consider usable (without sin) and what is supposed to be an internal detail. Same with the modules: then it is very clear that the re-export of those names in __init__.py is where they're meant to be consumed, and the other modules are just for organizational purposes, not API purposes. _Todo is then a private type. Very clean.
- Galanwe 1y agoI tend to do the same, some colleagues as well, so I guess this is some common pattern. The way I see it there are two schools: - The whitelist school: You write everything without _ prefix, then you whitelist what you want accessible with __all__. - The explicit school: You forget about all and just use _ for symbols, modules, etc. I find the latter more readable and consistent (can be applied to attributes, free functions, modules...
- patrickkidger 1y agoYup, you(/sibling comments) have it correct, it's to mark it as private. Not sure where I got it from, it just seems clean. I don't think I see this super frequently in the ecosystem at large, although anything I've had a hand in will tend to use this style!
- nurettin 1y agoI just want to say this is brilliant. I've had my share of problems with asyncio and went back to using sync python and deque instead.