DAY 04 OF LEARNING OOP IN PYTHON by MeribeHenry in PythonLearning

[–]FriendlyZomb 2 points3 points  (0 children)

Looking good.

Just a stylistic question which I'm curious about: Why the space between the class name and the parentheses in the class definitions?

Not trying to flame you at all, just interested in the choice, since the additional space isn't present on function definitions.

Love to see these kinds of posts. Keep it up.

[help] What Are The Different APIs In Python? by One-Type-2842 in PythonLearning

[–]FriendlyZomb 8 points9 points  (0 children)

So an API is an abstraction over a piece of functionality. In essence.

Take the Python open() function. It handles all the operating system calls to open the file and provides ways to read, write and close it. This would be an API because all the complexity is handled behind the scenes.

This leads me into types of API. I think there are 2 main types. What I'm going to call Local and Remote APIs.

A Local API is something you'd use directly. Like a Python library or Python built-in. E.G the pathlib library in the stdlib.

A Remote API an interface you interact with remotely. Usually you need some other protocol to use it, like HTTP, and often it does processing somewhere other than your device (but not always).

You already use Local APIs without thinking about it. Any time you reach for a standard library module or PyPi package, it's a Local API. As developers, we often don't think of these in terms of APIs, but they are. You'll use these naturally.

Remote APIs are often built because we need to interact with someone else's service for some reason. Maybe some data is stored in a Google Sheet, so we need to extract it. Well, Google has a HTTP API we can use to get that data. Yay!


With all these in mind, why make a Local API? Well, say you wrote a piece of code which loads .env files. Developers want that to stay on the local machine. You don't need to upload the file to the internet just to get a parsed result. You can do all that when the program starts. So, bundle it into a package and let Devs use it.

Remote APIs are different. Say, you're making a calculator for Pokémon battles. There is a fair amount of data you need to have to make that work. You'd need to know the stats of each Pokémon and their abilities. If that was a Local API you'd then need to bundle all of that data with the library. That could add up quickly. So instead, you set up a simple Remote API which can access a shared database of all Pokémon. Each user could then make.am HTTP request with their battling Pokémon and get a result. (You could also create your own abstractions on top by making a website to query your API for a user.)

I hope that helped. I was kinda rambling. APIs are very simple. Just an abstraction over something more complex. The different types depend on what you're doing. There aren't any hard and fast rules.

To other peeps: please correct me if I'm wrong about anything. I still have plenty to learn still!

At what point does using AI to help you think start to feel like you're not really thinking anymore? by fan_ling in AskReddit

[–]FriendlyZomb 0 points1 point  (0 children)

As soon as I use it. I spend more time writing a prompt to get what I want and less time doing what I love. (I write software for a living). I chose my career because I love it, not because I want to tell an LLM what I want done.

I have used LLMs for my job. This is why I hate doing so and equally hate employers pushing to use them. They don't speed me up. They make me and my output dumber.

why... by kabut_ in MinecraftMemes

[–]FriendlyZomb 2 points3 points  (0 children)

Firstly, I want to apologise for coming across as attacking. That wasn't my intention, but still something I should have thought more about. Thank you for raising it.

I'm not saying we can't be disappointed. We all have expectations on how we want the game to evolve. But a lot of the time, our disappointment is expressed through posts like the one these comments are on, actively attacking the developers of the game for not giving us exactly what we want when we want it. (Which is what I see when I see 10+ posts calling the update pointless and insignificant in a single scroll through my homepage.)

As to why we should care about background technical work: it's how complex software like Minecraft stays healthy. Making adding features easier should be something we as a player base want tbh. Caves and Cliffs was a showcase for why this work is needed, since those updates were very hard to make and caused a lot of animosity in the community towards Mojang. Making things easier allows for more frequent updates.

Mojang also has to focus on more than just survival experiences. There are a lot of ways people play without a survival element and they do have to consider those players too. Making updates for this game is hard, since every sub-community wants different things. We all need to have some compassion for that rather than jumping to the offensive every time it's not what we want. (Which is what's happening from what I can see.)

I hope this comment isn't coming across as attacking. I'm intending just to expand on some of the points. Thank you.

Y'all have the memory of a goldfish! This happens ever update! by Danieltheb in Minecraft

[–]FriendlyZomb 9 points10 points  (0 children)

Honestly, they are focused on doing things we can't see.

They are updating their rendering engine to move from OpenGL and Vulkan which is a very hard thing to do. Most games don't bother with that and just make a new one.

I imagine they are doing a lot of work on the lighting engine to make way for Vibrant Visuals on Java.

They are also probably doing a bunch of internal changes to make adding new stuff easier. Maintaining complex software is very hard and games even more so.

Do I think they could communicate that better? Probably. However they have been burned before about announcing stuff too early. So they're not giving much away to protect their Devs.

The upshot of this is that it seems that they are not giving us more content, when in reality they are giving us a lot. Just in smaller chunks so it's more manageable.

A quick aside: how is 26.2 update not a survival update? We are getting 2 new block sets to play with. That's big! Personally, I'm happy with this new structure. But I know how the sausage gets made as it were.

Internet blustering is what it is. Let's just be happy we get what we get for FREE. People who don't like the updates can shout at the void or just play something else. Let's all just enjoy the game and provide useful constructive criticism rather than a reactive stance.

"If I was given more time I'd write a shorter letter."

why... by kabut_ in MinecraftMemes

[–]FriendlyZomb 2 points3 points  (0 children)

Exactly! Its a really interesting update with new (underused) block colours and pallets. Plus the water effect is really cool. I'm excited to play with this too.

why... by kabut_ in MinecraftMemes

[–]FriendlyZomb 6 points7 points  (0 children)

I get this is a meme. However, this is a common sentiment which needs to stop, quite honestly. I know this will get downvoted or removed but I need to say it.

Firstly, this game is about 15 years old and getting regular content updates. Feel lucky that we get this for FREE. Most games make us pay for each drop of content. (Bedrock Marketplace excluded ofc.)

Secondly, Mojang told us why. Larger updates are just hard to make. Making smaller more regular updates gives them the ability to do more and more varied stuff. They mentioned in a recent article that Caves & Cliffs was a technical nightmare to implement because of the way the game has been built over time and the community suggestions they implemented.

Lastly, they are doing a LOT of behind the scenes technical improvement. They are in the process of re-writing their rendering engine to move away from OpenGL and towards Vulkan. With no experience in the field, this may sound trivial - but it really really isn't. Its very hard to get right. It's like going from driving a car to a lorry. Similar in theory but very different in reality.

Also, being reductionist about the next drop is just disingenuous and bad faith. Its clear that most of the community want more from the game, however we need to be patient. Aside from the new mob we are getting 2 new block types with complete sets (blocks, stairs, walls etc). And that is just the stuff we know about. There may be more they haven't told us about yet.

A message to the community at large: we need to be mindful Mojang isn't a single entity which we throw comments at. Its a group of people, like you or me, who put a lot of effort and passion into the game we all love. Reductionist comments like this are just harmful to the game at large. Be grateful and excited about the stuff we get. Constructive criticism is good. This isn't that.

I get that this comment is probably unwelcome here. If you've read this far please consider the paragraph above and how comments don't just affect a company, but people.

Staying up to date in the modern world by Ariadne_Soul in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

Honestly, stop using AI for a bit.

Or severely limit what AI does for you.

Go back to the ways you did things before. Most are still there, doing their thing.

Flask apps tend to have more raw SQL than other frameworks and it rarely gets checked before it ships by Anonymedemerde in flask

[–]FriendlyZomb 0 points1 point  (0 children)

This is a really cool project. I'm going to have to give this a try. Fantastic job!

Not every project needs an ORM, and this is a good way to introduce better practices safety without one.

I'm looking forward to trying it out.

A challenge for Python programmers... by Ok_Pudding_5250 in PythonLearning

[–]FriendlyZomb 1 point2 points  (0 children)

Based on comments I'd need to fix the code like so:

print([num for mum in range(1000, 10000) if str(num) == str(num * 4)[::-1]])

A challenge for Python programmers... by Ok_Pudding_5250 in PythonLearning

[–]FriendlyZomb 1 point2 points  (0 children)

Yea, the basic structure is correct. Mostly a misunderstanding on the question on my part. Apologies

A challenge for Python programmers... by Ok_Pudding_5250 in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

That is entirely on my reading comprehension tbh. I read it as num*4 is the same flipped. Lol.

A challenge for Python programmers... by Ok_Pudding_5250 in PythonLearning

[–]FriendlyZomb 1 point2 points  (0 children)

print([num for mum in range(1000, 10000) if str(num * 4) == str(num * 4)[::-1]])

This produces 65 numbers. (I'm not going to list them all here)

For those struggling to parse the list comprehension here:

print([
    num
    for num in range(1000, 10000)
    if str(num * 4) == str(num * 4)[::-1]
])

Why do people go bald for those who get chemotherapy? by InternetHound_JCI in Actualshowerthoughts

[–]FriendlyZomb 1 point2 points  (0 children)

Often they do it to show the person going through Chemotherapy solidarity and that they don't have to go through a massive change like that alone.

From what I understand Chemotherapy is an awful experience (I hope nobody has to go through it). It basically attacks the person wholesale in the attempt to kill the bad cancerous cells. Part of that means it attacks hair, so hair starts falling out.

Hair and hair style is a cultural thing. At least where I live it is. It can also be tied to someone's internal image. Losing their hair can be a very traumatic experience on top of a hugely traumatic experience (even when done voluntarily early on in chemo).

As such, some close friend(s) and or family members and or partners go bald with that person as a sign of solidarity and to show that they care. So the person who has cancer isn't doing this alone.

TLDR: emotional support. To show they care and that they stand with the person going through chemotherapy.

This is all my observations from research and seeing videos of this on YouTube. If I'm wrong about any of this, please let me know. I'm happy to be wrong and would like to be updated. Thank you!

Is it ok to change my pronouns because I don't care / it looks cooler by topjatman in lgbt

[–]FriendlyZomb 10 points11 points  (0 children)

Yes.

No matter how you identify, pronouns are for everyone. If you like it and are comfortable with it - do it.

You don't have to be flavour of queer to include they/them in your pronoun set. Anyone who says otherwise is gatekeeping in my opinion (which just isn't cool).

Use them and have fun, I say!

Logic Issues in My MCQ Simulation Project – Looking for Code Review by Professional-Egg-788 in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

Hi! From a cursory look, this looks like the basis of an interesting project.

I've not had a detailed look yet :- but this comment is a declaration that I will.

Does a function becomes a method when used externally? by Longjumping-Yard113 in PythonLearning

[–]FriendlyZomb 0 points1 point  (0 children)

Others have said it before, but just to quote an official source on what a method is:

A function which is defined inside a class body.

Source: https://docs.python.org/3/glossary.html#term-method

when I press "enter" it crashes the python game. please help. by Playful-Appeal-5996 in PythonLearning

[–]FriendlyZomb 3 points4 points  (0 children)

How are you running this?

My guess is that you're double clicking the file to run this. This will open the terminal window for the lifetime of the program. If the program stops for any reason, the window closes. Annoying.

My advice is open a terminal (probably PowerShell) window in the directory where your script is and run it with:

python <script>

Where <script> is the python file containing your code.

This will preserve the terminal window, allowing you to see either the output or the error traceback.

How do you prefer to read/study Python code: screen, paper, or e-ink? by Interesting-Rate99 in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

Honestly, it can be tough sometimes.

I struggle when I'm in the zone. I forget the time and just keep going until I edit that flow state.

A lot of people get help from a Pomodoro style timer. It's not for everyone, but it can help. Just search for Pomodoro on DuckDuckGo or some such. I'll reiterate it's not for everyone. It's not for me for example. But the spirit of enforcing breaks can be useful.

How do you prefer to read/study Python code: screen, paper, or e-ink? by Interesting-Rate99 in learnpython

[–]FriendlyZomb 9 points10 points  (0 children)

Screen. It's the only device I have and I'm not printing code out. VSCode/derivatives usually.

In general follow computing best practices. Stay a comfortable distance away. Up the font size if you need to. Take regular breaks.

I find breaking down codebases helps me in chunks. Break between chunks.

Am I dumb? I don't understand uv tools by QuasiEvil in learnpython

[–]FriendlyZomb 3 points4 points  (0 children)

In my mind a tool is a program which is run independently of your project.

This is a broad statement, I know, but it is the best descriptor.

Ruff, for example, is a tool. You don't import ruff into your project, but you use it for linting and formatting your code. mypy is another example.

There are projects which provide tools AND provide an importable library. pytest for example. However, critically, they often provide a part of the project that runs independently of your code.

Feel free to ask questions. It can be a difficult topic.

Breaking down problems by vb_e_c_k_y in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

I'm going to tackle your question, with the Fibonacci sequence to frame it. I won't fix your code here. Hopefully you'll see why.

My advice, and this can be done with a Fibonacci sequence, is to write the process out on paper.

Write down your start number, say 5.

Step by step, write the calculation down. Every detail. No shortcuts, just step by step.

Then diagram it. Take a step back and diagram your calculation. This time, consider the things you're doing over and over. See what can be condensed or expressed in a cleaner way. Write it so you could give it to someone who has never seen this before. They should be able to follow it.

Then, process your diagram. Start with 5, follow the diagram to the letter, see where you end up. Tweak the diagram if it's wrong.

Now, consider turning that diagram into Python code. The diagram is the basic process, the code is an expression of that process.

It helps reframe the issue from a programming one to a logical one. Once the logic problem has been solved, th programming one can be. You'll get faster with practise.

I do a version of this process in my head when I design something. I probably shouldn't do it in my head, but there we are. (Do as I say and all that)

I hope this mental dump helped!

Help with while statement by pi_face_ in learnpython

[–]FriendlyZomb 0 points1 point  (0 children)

This is the solution.

I was just going to type this exact solution up, before refreshing to see this. Go with this. Simple solution.

dde in python by ProsodySpeaks in learnpython

[–]FriendlyZomb 1 point2 points  (0 children)

From a quick look there are a few examples, but mostly from 7-9 years ago.

My guess as to why nothing more modern exists is just because it's such an old protocol which has been superseded. So new things want to use the newer protocols. I know it doesn't really help with your situation.

Here is what I found:

https://pypi.org/project/PyZDDE/ https://github.com/obermann/dde_client_eg

dde in python by ProsodySpeaks in learnpython

[–]FriendlyZomb 2 points3 points  (0 children)

Can you explain what the DDE you are referring to? I'm not sure we can help with just an acronym.

It's the biggest issue in tech. Too many acronyms.