|
QuarkJets posted:If a User can belong to multiple Groups then the only type annotation that you need is probably `list` anyway - User doesn't need to see any Group code at all what? you'd still want it as list[Group].
|
# ¿ Apr 15, 2023 19:42 |
|
|
# ¿ May 15, 2024 05:52 |
|
huhu posted:I want to import project into demos. However, when I cd into the demos directory and try and run any variation of import statements, I get various errors. I've Googled a bunch and I cannot figure out what's wrong with my import. Or is there a better way to make a demos directory for a package I'm building? One of the stack overflow answers says You'll probably want to follow a guide like this. This will allow you to install the project path permanently to the python path. In short: 1. Create a 'src' subfolder in the root folder and move the project folder there 2. Create a pyproject.toml file in the root folder and add the appropriate contents 3. In the root folder, run 'pip install --editable .' Then 'python demos/demo1.py' should work as expected. (The --editable part means you don't have to reinstall everything everytime you modify the code)
|
# ¿ Sep 25, 2023 19:49 |
|
Falcon2001 posted:So the question: What's the correct (or at least painless) way to store (and ideally visualize) a 2d cartesian grid where each coordinate can be an arbitrary data type? I'm not looking for code golf style solutions, as I'm using these problems as ways to explore concepts/etc, and so it's more useful to have something that I can dig through and visualize/debug/interact with than a perfect impenetrable one-line solution. a dict or defaultdict with a tuple of ints as the key type would be my first try eta: not great for visualization though
|
# ¿ Oct 19, 2023 15:23 |
|
Falcon2001 posted:Yep, exactly. I'd love to be able to visualize these setups quickly like they do in the explanations (which I've sort of got working with my PIL solution) here's what one of their example explainers looks like: the ascii grid isn't too bad: code:
|
# ¿ Oct 19, 2023 22:00 |
|
I believe stopping time in this context simply means the number of steps taken. obnoxious itertools solution:Python code:
Zoracle Zed fucked around with this message at 19:42 on Nov 11, 2023 |
# ¿ Nov 11, 2023 19:39 |
|
are you responsible for anonymizing PII? stay the hell away imo
|
# ¿ Nov 14, 2023 18:48 |
|
Maybe check out the 'sliding_window' iterator from the itertools recipes, which continues to drive me insane for not being importable but instead requires copy-pasting.
|
# ¿ Dec 12, 2023 23:11 |
|
have you read the building a git clone documentation? I've that used that approach a lot, where the base command has the @pass_context decorator and stashes a custom dataclass in ctx.obj, and then the subcommands have the @pass_obj decorator to recieve the dataclass object directly.
|
# ¿ Dec 13, 2023 02:38 |
|
Falcon2001 posted:I'll take another look. I thought this method involved having group options which necessitated breaking your cli args up in a weird way ex: (command group --opt-one subcommand --opt-two) but I might have misread it. yeah you end up with an api like code:
Zoracle Zed fucked around with this message at 03:47 on Dec 13, 2023 |
# ¿ Dec 13, 2023 03:44 |
|
Anyone got opinions about API docs generation? I kinda hate sphinx for being insanely over-configurable and writing rst feels like unnecessary friction. Sphinx with numpydoc is managable but I still feel like there's got to be something better.
|
# ¿ Mar 11, 2024 03:28 |
|
Oysters Autobio posted:FastAPI swagger page generation is pretty cool but it's not like a drop-in or anything to my knowledge (ie you have to build the API with it from the beginning). Thanks for this by the way! I've been playing around with it and like it a lot. Markdown instead of rst is wayyy more ergonomic for me and `mkdocstrings` is the plugin does the automatic API docs generation exactly like I'd want it to, including out of the box support for parsing type annotations from function signatures
|
# ¿ Mar 20, 2024 23:31 |
|
|
# ¿ May 15, 2024 05:52 |
|
Oysters Autobio posted:Is there a particular 'style' of python that leans towards tables and similar relational data rather than slinging everything around in key:value pairs, lists etc. I've been finding it hard to get imperative styles to click in my head when I'm so used to how "connected" All the data is within a SQL statement for example. Like is there a way to manage data in python script basically create dimensional tables of data that you need and join em as needed. Slinging around pandas/polars DataFrames I guess? The polars example here is pretty neat. I think static typing this kind of stuff is still going to be an uphill battle, but I'm not up to date.
|
# ¿ Mar 23, 2024 13:23 |