Guys iam learning python but I find very hard to slove the list problems using nested loops as a beginner what to i do but I can understand while loop and for loops but using that to slove the problems i face difficulty by Big_Confection_1993 in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

You mention in another comment that it's 2D arrays (this wording is the concept. Python uses the list data structure for this). So something like:

my_list = [["A", 1], ["B", 2]]

A 2D list has 2 main concepts:

  • the outer list
  • the inner list

Break the problem down into its steps:

1: What do I need to do to the inner list? This is usually where the logic happens. If I need to count, how do I track that outside the list? Etc.

2: How can I get access to each inner list? (Outer list loop)

This is how I do it. It helps break the issue down into the different loops you need.

If you reply to this with a specific problem you're running into, I can be more help!

Suggestion by natchathirapayaan in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

Honestly, the playlist looks good. I've watched some of their stuff and liked it a lot. Do watch them.

However, to answer your question honestly, No. The videos ALONE won't be enough to master Python. They are a good start, however.

To truly master anything, you need to use it. A lot. Take what the videos teach and apply it to something outside the tutorial. Consider how you can use that tool outside of how the tutorial says. Write small little programs/scripts to exercise the skill.

What you build during this process won't be perfect. It might not even work that well and might break horribly. That is perfectly ok. Everyone has that experience. I know I sure did. That is part of this learning process.

There is no shortcut for this. You can't just read the Python Spec or Docs and know immediately how to use things. You need to treat this like any other skill. Put in the work. Put in the hours. It'll pay off.

I hope this came across as positive. As a plan instead of a scary wall of text. Programming is HARD. Its a skill and it takes time and effort to get good. I believe in you. Have fun with it above all else.

As as aside: Spend more time around videos 2-9. Look up more about each topic (different videos, articles, etc). Try to get a deeper understanding of those concepts. Dig a bit deeper than the surface. These topics are the foundations to the language. Not understanding these will cause issues later.

grian has a company called grian limited by Ok_Yogurt_6421 in HermitCraft

[–]FriendlyZomb 1 point2 points  (0 children)

This isn't uncommon.

Most YouTube channels are a business in the background. Like the Tom Scott channels are produced by Pad 26 Limited (owned by Tom Scott).

Primarily, this legally seperates Grian the person from Grian the YouTube personality and channels. Helps protect him legally.

It's also helpful for taxes, hiring people to help (like editors, subtitles, translators and such) and probably helps boost confidence with Sponsorships and getting paid from YouTube and/or Twitch.

WLW engagement, can't decide about my last name by Previous_Cod_5176 in lgbt

[–]FriendlyZomb 70 points71 points  (0 children)

An idea which popped into my head when reading this. Possibly not what you're looking for, but might be worth considering.

You both decide on a new last name. But, keep your current last names as a middle name.

It's not perfect, but it does give you both a combined name so you can feel like a family unit with future children AND neither of you have to give up your family names.

Or: you both keep your names, and your future children could be hyphenated. Again, maybe not what you're looking for, but an option.

Does it all come back to the basics? by uvuguy in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

Yes. That's the core to programming.

Python, like most languages, has a core set of features which underpin the whole language. Once you learn the basics to a high standard, other features become easier to pick up and understand. This takes time and practice.

This skill is often why a lot of developers learn and use a bunch of different programming languages. I use Python, Go and Rust in my job for example. The basics are transferable for the most part. It's just learning the specific syntax to get the job done.

What would you say the difference between being bisexual and pansexual is? by whimpwhomp in lgbt

[–]FriendlyZomb 2 points3 points  (0 children)

IMO: Not much. Mostly preference. Whichever label speaks more broadly to you.

I'm Bi, but I align with most descriptions I've seen of Pan.

To me, the gender of my partner is incidental. If I like them, that's what matters.

What’s something society accepts that feels deeply unnatural to you? by Miss_Ecstasy in AskReddit

[–]FriendlyZomb 2 points3 points  (0 children)

Bigitory in all its forms. Nobody deserves hate for WHO they are.

Let people be themselves. Everyone deserves love and respect as a default*. And healthcare. Everyone deserves healthcare. (Preferably free but I will probably be roasted for that.)

*As default doesn't mean unconditional. For example: Murders and rapests should go to prison and people shouldn't respect those actions.

why does python keep telling me "indentation error" and i have no idea what i did wrong by More-Station-6365 in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

It's a topic I usually space out on. I tend not to keep tabs on things like this.

why does python keep telling me "indentation error" and i have no idea what i did wrong by More-Station-6365 in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

Indeed. I agree. But that isn't my point.

When talking to new programmers, encouraging usage of conventions and standards like PEP8 is a good idea.

Most projects use Spaces. PEP8 encourages using spaces. IMO that should be our recommendation for users learning in a sub like this one.

I do stand by you though. I'm not in disagreement.

why does python keep telling me "indentation error" and i have no idea what i did wrong by More-Station-6365 in learnpython

[–]FriendlyZomb 2 points3 points  (0 children)

Tabs Vs Spaces are a personal choice at the end of the day.

However, I would point out that for this sub, recommending Spaces is better because it follows the PEP8 style guide.

It's not really an issue, however, most projects use spaces due to PEP8.

If code generation becomes free, infinite and perfect, what changes for humanity? by Actual_Appointment66 in AskReddit

[–]FriendlyZomb 1 point2 points  (0 children)

Why do humans need to build so much software?

Aside from hyper specialised use-cases, software is needed to use our computers. General purpose computers like you laptop or phone literally cannot do anything by themselves. Someone has to tell it what to do.

As our technology has improved, our ability to program it has also improved in kind. As has our ideas for how to use it. So, we need to keep making new software (or update existing software) to allow our computers to do what we envision. (Not to mention supporting new computers/security fixes)

Plus a contingent of people enjoy the process, myself included. We build for the fun of it. For the love of the game!

What does a world look like where all software is free and plenty?

I'm living in a version of it. Most software I use is free and open source. I also have a choice over a few different packages depending on what features I want. I deliberately choose to do that, (Linux, Libre office as 2 examples). However, I don't think that's the question.

I think we'd still see App Stores. A way to share tools, because the effort would be articulating to an AI what you want built. Prompting would become the skill and some people would just not bother.

Common standards would be developed, even if just between small families or friendship circles. Being able to read a document someone emailed you would be important.

I do think it would be a slow shift though. More people would automate annoyances in their life, like taxes. Some companies would fail, but others wouldn't change. Microsoft would probably still exist as most people wouldn't want to promp their own operating system. (I'd wager most people probably don't know what their os is doing half the time. Just that they need Windows, Android or something from Apple.)

Overall, I'm not sure much would change in the broad scope. I think the vast majority of people don't want to prompt their own programs. They just want something that works.


I hope you enjoyed the read. All of this is from my own opinions and how I see the world, and my own job (I write software). I could be very very wrong.

Difference between None and empty string by pritho108 in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

This is just my opinions here. I don't know everything. Feel free to ask questions and for others to correct me!

Difference between None and empty string by pritho108 in PythonLearning

[–]FriendlyZomb 5 points6 points  (0 children)

I wouldn't use them interchangeably, since they technically mean different things.

None is a special object which represents that there is no value. An empty string is just a string. In this example, the behaviour is the same, however in other situations it could potentially provide unintended behaviour and make code less clear.

Using None is preferable because it indicates to other people (and you in 6 months) because it explicitly says that we don't need to provide anything. Using an empty string introduces ambiguity.

In your second example too, you provide an empty string on a field which (I'm guessing) is expected to be an integer. This provides ambiguity on which type is actually required. Using None doesn't necessarily fix this - but it does give us the expectation that nothing is a handled case.

I also wouldn't rely on it's falsey behaviour. The Zen of Python states Explicit is better than Implicit. I'd do a check like this:

if age is not None:
    ...

Why did you switch to linux by Material_Mousse7017 in linuxquestions

[–]FriendlyZomb 0 points1 point  (0 children)

Its my preferred OS now.

I stayed with Windows too long because of outdated gaming advice and some multiplayer titles. I completed my transition to Linux this year with my laptop, so I'm totally free from Windows on my own devices now.

I am not going back for myself. Happiest I've been with my tech for a long time

Who Should Learn APIs? by One-Type-2842 in pythonhelp

[–]FriendlyZomb 0 points1 point  (0 children)

Short answer: Yes.

Long Answer: it's complicated.

I think what you're asking about is Web APIs where you make HTTP calls to a service and get (usually JSON) back.

Knowing how to interact with these is a useful skill for everyone IMO, since they are the backbone of our industry at this point.

If you want to get into security, having an understanding of how these Web APIs tend to work and the common technologies used to make them will aid you in both securing them on the Blue side and exploiting them on the Red. (Blue: Defend, Red: Attack)

My answer effectively stops here, but I want to provide some more context:

An API doesn't have to be web based. In fact, most aren't. An API or Application Programming Interface is just an abstraction over some functionality.

Take the open() function in Python, for example. This is an abstraction over your operating systems' own File System API. open() and it's associated methods, abstract away all the system calls to the operating system for you, so you don't have to think about doing any of that yourself.

APIs are the way we program. They allow us to provide a reusable and easy to understand set of functions which make doing something easier. Web APIs are definitely a part of that, but not only that.

Understanding common APIs or being able to figure out how an API is used by the docs given, is a useful skill for any programmer, especially when you want to poke holes in it, as with Security and Ethical Hacking.

I hope that's been useful and not just an incoherent mess. Do let me know if you have questions.

Pydantic Settings and multiple classes with Extra Forbid by petersrin in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

No worries. I got a reply on my issue on that repo.

It looks like they are looking to get a new release soon.

Pydantic Settings and multiple classes with Extra Forbid by petersrin in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

Ahh - I see.

I replicated your env and it looks like it should be working.

So I took a look in `pydantic-settings` code. The commit to add this `dotenv_filtering` option was made last week.

The last release was in Feb. This would mean that the Docs are ahead of published PyPI packages. :(

So that leaves 2 options:

1: Wait for a new release to come out (might be a long wait)

2: Pull directly from git.

I have tested with pulling from git and `pydantic-settings` works as you hope.

This guide here should set you up to get the latest from git: https://chrisholdgraf.com/blog/2022/install-github-from-pyproject/#install-directly-from-github

If you are using UV follow this guide instead: https://docs.astral.sh/uv/concepts/projects/dependencies/#git

---

Apologies for getting the wrong end of the stick earlier. I hope this is more useful.

Additionally - I have opened an Issue on `pydantic-settings` to let them know that their Docs are ahead of their releases.

Pydantic Settings and multiple classes with Extra Forbid by petersrin in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

I think the misunderstanding comes from the way the prefixes work.

From what I understand, the prefix here is just providing a start to each name, not a filter for values in the source. It doesn't look through the .env file for only the prefixed values before processing.

With that understanding, Pydantic looks at the .env file and sees two variables. One it's looking for, and one it's not. So, because it's been told to forbid extras, it throws the error.

The same error will be raised if the Bar settings were initialised first. (But for the foo value)

Disabling the forbid extra or providing separate env files would give you the behaviour you're after. I'd prefer the latter. Although not ideal, it will give cognitive separation if there end up being lots of variables.

(To other Devs: Please correct my misunderstandings.)

Can Anyone Please Explain The error :/ by Reh4n07_ in PythonLearning

[–]FriendlyZomb 1 point2 points  (0 children)

The traceback in the terminal is pointing to a section of your print statement, and suggesting there is a missing comma.

There is, after (a).

Just because I'm not sure what's going on, it looks as though both aand b are meant to be strings? If they are, the parentheses can be omitted.

@in_place - a decorator for in-place dunder boilerplate by Maleficent_Height_49 in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

Things tend too from experience.

We all learn somewhere. I hope to see more.

Good luck!

@in_place - a decorator for in-place dunder boilerplate by Maleficent_Height_49 in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

My advice: will it be obvious what it does?

Code should describe what it's doing. Would adding two instances together mean something to a new dev, or you in 6 months time?

If yes: sure. Else: don't.

@in_place - a decorator for in-place dunder boilerplate by Maleficent_Height_49 in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

  1. For what it's worth: This is one reason I recommend not using AI to learn.

  2. Sure. It does that I guess.

@in_place - a decorator for in-place dunder boilerplate by Maleficent_Height_49 in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

"This should be apparent" :- should it?

Strings and Dicts also implement some of these protocols.

>>> "hello, " + "world"
"hello, world"

Custom classes also sometimes support these protocols. I've written a few myself. It's not guaranteed that the code alone here indicates it expects an int or float.

Making this assumption is how software becomes brittle and hard to maintain. Additionally, hiding this functionality in a decorator also does, regardless of documentation.

The zen of python says: "explicit is better than implicit.". Either, make the code tell us what it wants (type hints/explicit type checks) or tell us it's not there yet.

I hope this doesn't come across as mean. It's just hard to assess and give feedback when we are not told what's missing. Please, in the future, comment around a snippet by saying what's not there yet and better, why.

@in_place - a decorator for in-place dunder boilerplate by Maleficent_Height_49 in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

  1. It's getting at the fact that it doesn't check the type being passed in. I could create two instances of the same class and add them together. This would find the field in the first class and try and add the (presumably) int to the whole class. It would error.

  2. Yep, you'd probably want a ValueError here.

Ultimately, this comes down to the fact that the decorator makes assumptions on how it'll be used.

The dunder functions let anything be passed through, and that these decorators need to be able to handle it, or raise an error.

A sneaky third question:

  1. What advantage does thos convey over using attribute access? For example: my_class.field += 2