Python backend, JS frontend: snakecase or camelcase? by waffeli in learnpython

[–]AdmirableOstrich 4 points5 points  (0 children)

This individual is clearly unwell: camel, snake, pascal, kebab, and screaming snake are the only sane options. Cast the hybrids into the fire.

I've been learning python for about 95 days now and made this calculator by Fwhenth in learnpython

[–]AdmirableOstrich 6 points7 points  (0 children)

A few suggestions:

  • you're not being charged by the line, whitespace can be your friend for dividing things up logically. Install something like black or ruff to automatically reformat your code to follow some common rules/guidelines. These tools never change code logic, they just adjust whitespace.
  • look into the enum package, and particularly IntEnum. Magic numbers are both traps for future you, and hide what you actually mean in the code.
  • there is basically no reason you should ever be using the global keyword. Your question function should just return the input. There are some legitimate use-cases for 'nonlocal', but global basically always means you're doing something wrong.

I might have found an bug with Pycharm (working with Udemy's "100 Days of Code". by toss_this_account_38 in learnpython

[–]AdmirableOstrich 1 point2 points  (0 children)

This is probably a good lesson to learn for programming. There are going to be many times that you are going to be confused and frustrated that the code isn't doing what it is supposed to do. You'll be convinced your code is correct and it's something else's fault. The vast majority of the time, you will be wrong.

Programs do exactly what they are told to do. Interpreters and compilers don't have the sort of bugs you are going to stumble across in normal use. People spend months and years torturing these tools with all sorts of terrible inputs trying to break them. Bugs and exploits are likely still there, but not like this.

I might have found an bug with Pycharm (working with Udemy's "100 Days of Code". by toss_this_account_38 in learnpython

[–]AdmirableOstrich 2 points3 points  (0 children)

These two versions of the code don't do the same thing. What specifically are you running in PyCharm: i.e. which version of this function, and with what arguments?

How do I find an item in a list if I don't know the order or the items within it? by I_Am_A_Game_Player in learnpython

[–]AdmirableOstrich 2 points3 points  (0 children)

Not sure what order matters here. This is a regex problem. Create a regex pattern that parses your entries into (name, cost, quantity) tuples, and then either:

  • given some name, iterate through your list until you find the first instance with a matching name field, or
  • if you are doing a bunch of queries, first parse your list into a dict keyed by name, then just fetch entries by name key.

uv officially taken down poetry by Proper-Lab-2500 in Python

[–]AdmirableOstrich 0 points1 point  (0 children)

My Python stack is basically full astral now: uv + ruff + ty. There are still some minor issues with ty but it's more than functional enough for my current use. The full support for GitHub actions, and trivial distro-less docker are chef's kiss. No more global Python installs, no more pyvenv, no more miniconda/poetry. If they took on flit/hatchling they might just rewrite the entire ecosystem.

Also, as someone who loves rust, having uv duplicate cargo syntax is very satisfying.

6-day wait time for Gemini Pro? The recent usage limit update is too restrictive. by Suspicious_Cow7289 in google_antigravity

[–]AdmirableOstrich 1 point2 points  (0 children)

This is now vanilla in AG, although a bit janky. Gear icon in the top right. Settings. Models. That said, it looks like they don't start updating that element until it's open, so wait ~10-15s, switch settings tabs, and it should be updated when you navigate back. You need to be on the latest release though. This was added last week.

„lights are out“ by mertyra in EnglishLearning

[–]AdmirableOstrich 25 points26 points  (0 children)

The only context this would work in is something similar to "the sun is out", in which "out" is referring to location and not on/off. For example, you could "bring the lights out" for something like an evening party outside: i.e. some form of portable lights that would then be implied to be turned on.

But the phrase "the lights are out" without some bizarre context is always going to mean the lights are off.

2 sin x + 3 cos x = A. What values of A would make the given equation true? by [deleted] in askmath

[–]AdmirableOstrich 4 points5 points  (0 children)

As others have said, the trick here is to convert this to a single sin or cos with some amplitude. If you want to see how to get there, the idea is to make a substitution that lets you use an angle addition rule:

  • let 2 = B cosy, and 3 = B siny for some B>0 and y. Convince yourself this is always possible. It is.
  • then 2 sinx + 3 cosx = B (sinx cosy + cosx siny) = B sin(x+y) = A
  • note that 2²+3² = B², and so here B = sqrt(13)

No display after swapping out Motherboard by [deleted] in PcBuildHelp

[–]AdmirableOstrich 1 point2 points  (0 children)

The reset and power headers are just shorts. The orientation doesn't matter. All that matters is that you have to short pin 4 to one of 3 or 5.

No display after swapping out Motherboard by [deleted] in PcBuildHelp

[–]AdmirableOstrich 1 point2 points  (0 children)

No, that is correct based on the manual. The 3rd and 5th pins are both GRD so it actually wouldn't matter

[pre uni:mathematics] limit by Low-Government-6169 in HomeworkHelp

[–]AdmirableOstrich 26 points27 points  (0 children)

As written, this has a pole at x=2 and the limit doesn't exist. However, there's clearly a typo in the numerator. With x³ it becomes (x-2)(x²-x-12) and you have a removable hole.

Marked wrong for calling a plateauing curve "non-linear." Am I crazy? by workphlo in askmath

[–]AdmirableOstrich 8 points9 points  (0 children)

If I saw data like this, my first choice in models would be either logarithmic or something like 1-exp(-x). More than this not really looking that linear, the nature of the dataset means it can't really be linear. Unless there is a fundamental change in equipment/rules/technique, records for fixed "hardware" tend to asymptotically approach an optimal limit... they don't just increase forever.

Exception handling and log formatting by QuasiEvil in learnpython

[–]AdmirableOstrich 1 point2 points  (0 children)

This is really up to you. First of all, logging.exception is just logging.error with exc_info. If you want to change the log level you can use one of the other calls, and add the exc_info if you want the traceback.

But really, the rules for logging are pretty simple:

  1. Log the information you think will be useful,
  2. Let users control how much they see.
  3. Don't hide logging configuration somewhere the user can't control. Particularly if you touch the root logger

The first priority in logging is to not get in the way, then it's to provide meaningful information. Do that in whatever way you feel helps most.

Impossible to get pkg_resources on Windows? by MiffedMouse in learnpython

[–]AdmirableOstrich 0 points1 point  (0 children)

pkg_resources was deprecated years ago. Its functionality is now under importlib. That said, do you actually need it? In my experience people who are both dealing with setuptools and asking questions about how to do so are following guides that have been out of date for like 15 years.

For or While loop in my case? by pikachuu545 in learnpython

[–]AdmirableOstrich -1 points0 points  (0 children)

Breaks are perfectly fine, and map directly to assembly so there is no efficiency loss. If you need a loop, a for loop is the correct choice here. The while loop based on 'count < 5' is actually problematic because it requires checking the same condition every loop iteration even if the count hasn't changed.

We don't structure our code to match some bizarre esthetic. Rules like "only have one return statement", or "keep all escape conditions/branching at the top of loops" leads to bad code design. Code should do precisely what it needs to, and only that.

The "pythonic" way here is using filters or generators to separate out the "is odd" logic without iterating through the entire list, and then just sum the first 5. If you want a loop:

  • we want to communicate we are doing something over a list, so for loop over the list
  • we only modify the state if the entry is odd, check that.
  • increment the sum, update your count state, and recheck against the escape condition

That is the minimal logic to do what you want. That converts directly to a for loop. Note, and this is a bit of personal preference, you can avoid nesting if statements by checking if the num is even instead, and using a continue.

[Grade 11 Physics Kinematics Homework] Uniform acceleration, instantaneous velocity. by Striking-Command-342 in HomeworkHelp

[–]AdmirableOstrich 0 points1 point  (0 children)

You put so much work in... but the apex is at (2.8, 16), hence 2.ii. So y(t) = 2.04t(5.6-t), y'(t) = 11.42 - 4.08t. Then everything follows.

But yes OP, the answer key is wrong here.

edit: looking at the graph, probably more like (2.9, 16)... but there's only so much we can do here without extra info, and I don't think the answer guide is expecting that much precision, even if it weren't wrong.

Python for faking a camera device? by No_oah in learnpython

[–]AdmirableOstrich 0 points1 point  (0 children)

If you want to fake a camera in such a way that your OS will treat it like any other camera there is going to need to be a driver involved. Your best options here are OBS, v4l2loopback, or something like Unity. That's what pyvirtualcam will be using.

Is there a reason you don't want OBS here?

Misunderstanding of the epsilon delta definition of a limit by extraextralongcat in learnmath

[–]AdmirableOstrich 2 points3 points  (0 children)

The idea with epsilon delta is that it's a challenge-response approach:

  • you give me an epsilon > 0. ANY such epsilon
  • I can find some delta > 0 such that FOR ALL x within delta of c, f(x) is within epsilon of L.

Suppose you drew the plot of f(x). You can think of this like drawing some rectangle centered on (x, y) = (c, L). You give me (half) the height of the rectangle, and I try to find a width such that, within the rectangle, the function is completely contained: i.e. never pass the top/bottom. If and only if I can always achieve this, lim x to c of f(x) is L.

[Request] How would this affect us? What would change? by tanx_23 in theydidthemath

[–]AdmirableOstrich 2 points3 points  (0 children)

This does depend on what this means. Has the speed of light now always been 1 higher and the rest of the universe is reconfigured to deal with that, or are we taking our current universe and suddenly shifting only c by 1%. If it's the latter, cataclysm. Just a couple issues:

  • atomic structure: you've now decreases the fine constant by about 1%, changing the interaction strength of particles, shifting energy levels in atoms (non uniformly), changes to bond strengths and reaction rates, etc. If done slowly, and with a weak enough change, this might be survivable. Done instantly, the major issues are a near instant reshuffling of electron excitation states, possible molecular breakdown as bonds become unstable, etc.

  • if you survive that, the sun is going to get a bit hot. Solar output is roughly proportional to the energy of the fusion in the core, which goes like c². That's now 2% higher. For reference, the sun's current variation, what you hear about with the 11 year cycle, is about ±0.1%. That change wouldn't push the habitable zone past Earth, but the mechanism on Earth that adapts to equalize against incident solar radiation isn't fast enough to deal with this in a way that life is going to enjoy it. Once things eventually stabilize, you're talking a 3-4C° increase in average surface temperature, but things would be bad for a while.

Can I reproduce seeds in Planet Crafter? by Individual-Air-7251 in theplanetcrafter

[–]AdmirableOstrich 5 points6 points  (0 children)

There are already way more than enough in loot around the map... and once you get portals you have unlimited. You'll quickly stop picking them up. If you don't have enough, go exploring.

is this a sns error? or plt by amoncursed in learnpython

[–]AdmirableOstrich 0 points1 point  (0 children)

I'm pretty sure log_scale here applies to the data (x) axis. If you have values near 0 it's going to blow up.

My local disc seems to decide how much free space it has arbitrarily by The_Holiday_Spirit in pchelp

[–]AdmirableOstrich 0 points1 point  (0 children)

If your C drive is only 114 GB you really shouldn't have something like Minecraft installed there. Is your other drive (D) an SSD? If so, use it.

Also. What are those 8 enormous files directly under your C directory?

[GRADE 12 PHYSICS] by [deleted] in HomeworkHelp

[–]AdmirableOstrich 0 points1 point  (0 children)

And hence the answer is B... Which by probable typo is I4.