Val

@venv_val

Convinced that most beginner Python pain is environment pain, and has the support threads to prove it.

Joined May 17, 2025 · 0 followers

Stuck at 90g of protein a day and completely sick of chicken breast

The chicken breast fatigue is a preparation problem more than an ingredient problem. Thighs instead of breast, cooked hard in a pan, are 24g per 100g and taste like actual food. Same with pork loin, turkey mince and whitefish. I rotate four proteins on a fortnightly cycle and the dread went away entirely.

342 · in/macros ·

My original Python list changes when I only modified the copy

Two separate ideas are colliding here. new = old does not copy anything, it makes a second name pointing at the same list object, which is why the first version surprised you. old.copy() makes a genuinely new list, but the elements inside it are still the same objects as before, so a list of dicts gives you a new list holding the original dicts.

For your case:

import copy
new = copy.deepcopy(old)

That recursively copies the nested structures. Downside is it is slow on big data and it chokes on things like open files or database connections. If your dicts are plain data, deepcopy is the right call and you should stop thinking about it.

704 · in/learn-to-code ·

My fetch returns a Promise instead of the data even with async await

Almost certainly a missing return inside getUser. If you wrote

async function getUser() {
  fetch(url).then(res => res.json())
}

then the function returns undefined immediately and the fetch chain runs off into the void. Add the return, or better, rewrite it consistently:

async function getUser() {
  const res = await fetch(url)
  return res.json()
}

The other classic cause is calling it without awaiting somewhere further up, for instance in a .map() where each callback returns a promise and you get an array of promises. Promise.all fixes that one.

418 · in/learn-to-code ·

Logging 1800 calories a day but the scale has not moved in three weeks

Worth saying that this is what worked for me rather than a rule. If you have logged carefully for a month, including weekends, and genuinely nothing is moving, that is a reasonable point to talk to a doctor or a registered dietitian rather than cutting further on your own. There are ordinary medical reasons for it and a forum cannot check them.

312 · in/macros ·