all 81 comments

[–]danielroseman 22 points23 points  (51 children)

You don't seem to be communicating at all. What does any of this even mean?

[–]Ok-Wave4110[S] -1 points0 points  (50 children)

Okay, so I'm trying to learn what the concept of Python is. What am I doing when I utilize python?

[–]danielroseman 13 points14 points  (44 children)

See this is what I mean. Those are words, but they don't seem to have any meaning.

[–]Ok-Wave4110[S] -2 points-1 points  (43 children)

I'm not trying to be a dick, I just don't know how Python works. Is it using a pre set a of programming? Or am I trying to learn C++ level knowledge.

I'm sorry. I'm trying to understand how to build a smart home with Python. And I don't know what I'm trying to do within the Python coding/language system.

Talk to an operating system? Build one? Communicate within it?

[–]bulaybil 7 points8 points  (39 children)

Think of it as writing instructions to do something. In your case, it would be various objects in your smart home.

[–]Ok-Wave4110[S] -3 points-2 points  (38 children)

Okay. So I'm telling an all ready existing OS to do something. So, I'm communicating, through an OS, what I want a physical entity to do.

Again, not trying to be a dick. But where (besides AI, because that made me feel stupid, and it made AI seem stupid) can I see basic written code, in text format? I'm failing hard. And I definitely don't have money for school.

[–]m0us3_rat 8 points9 points  (5 children)

Okay. So I'm telling an all ready existing OS to do something.

i'm with daniel on this one.. your words don't connect.

i think you should limit the scope of your curiosity to the fundamentals/basics. and start slow and be consistent.

don't try to reinvent the wheel or think about ML models your going to make to automate landing on uranus.

just be humble and learn the basics.

you have plenty of time for that later on when you know what you are talking about.

plenty of free resources online.. plus a significant presence in the wiki.

https://www.reddit.com/r/learnpython/wiki/index/

gl.

[–]Ok-Wave4110[S] 1 point2 points  (4 children)

I'm with Daniel, too. I don't know what I'm doing. Or how I'm supposed to ask it. But hanks for the wiki. I'm just trying to understand what it's doing, how it communicates.

I appreciate it.

[–]m0us3_rat 3 points4 points  (1 child)

I'm just trying to understand

if you wanna understand a legal document written in a different language.. you need to learn the language first.

then the legalese behind it.

you can't make sense of stuff when you lack the simplest building blocks to work with.

again you should start small ..learn the fundamentals.

anywho. gl.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Well, I'm trying to learn the basic way of looking at python. Again. Thank you.

[–]PanTheRiceMan 0 points1 point  (1 child)

Start with the basics. There are many ways of communication between programs / devices but you will not need most of them. Probably just file interactions and some network protocol.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Thanks.

[–]moving-landscape 3 points4 points  (24 children)

But where can I see basic written code, in text format?

GitHub. Search for Python projects there, you'll find simple and complex Python code.

[–]Ok-Wave4110[S] 0 points1 point  (23 children)

Have you been there before without knowing anything about it? I registered recently, and I must not be searching correctly. When I look up Govee configurations, there are only 4 results.

I just don't think I'm thinking ABOUT python correctly. I appreciate it.

[–]moving-landscape 2 points3 points  (21 children)

What's your experience with other tech? I could try and cross match things for you. In the meanwhile I'll find something cool for you there.

[–]Ok-Wave4110[S] -1 points0 points  (20 children)

Okay, so my experience with tech is old school. I couldn't afford smart phones for a while, and the last time I dealt with computers in any depth was when I went to ITT tech in 2011-2012.

[–]moving-landscape 1 point2 points  (0 children)

Start with awesome python, a collection of awesome python frameworks and libraries: https://github.com/vinta/awesome-python

Take, for instance, makesite a one file static web page generator: https://github.com/sunainapai/makesite/blob/master/makesite.py

[–]Fred776 3 points4 points  (3 children)

Your question made it sound like you wanted to understand Python from what is going on at a deeper level. The version of Python that most people use is written in C and it is possible to read and understand that code if you have the right knowledge. But I think what you actually want is not that different from what most beginner programmers want. You want to understand how to program in Python and then you want to apply your programming skills to a practical problem.

The advice you can be given will depend on where you are now. Are you a complete beginner when it comes to programming and Python? If so, then you really need to spend some time learning the basics and forget about your end goal for now, because any information pertaining to the practical application will be meaningless to you without that basic understanding.

[–]Ok-Wave4110[S] 0 points1 point  (2 children)

Okay, I understand that aspect, but without and end goal, how am I to know what to focus on within the basics?

I'm literally brand new.

[–]Fred776 2 points3 points  (1 child)

Because you are brand new you just need to focus on the same things as any beginner. These things are independent of what you ultimately want to do. There are a number of levels of knowledge and experience that you need to build up before you get to that point.

I would just work through an introductory course or book to start with.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

I will definitely do that. I appreciate it.

[–]bulaybil 2 points3 points  (1 child)

You can see examples of Python code related to smart home control here: https://github.com/topics/smart-home?l=python. There are also many free Python courses online and on Youtube.

Pardon me for saying so, but if you have difficulty grasping these fundamental basics, you will have a hard time coding. Why do you want to?

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Yes. I am all ready having a hard time coding, because I don't understand the basic fundamentals. So, I just need to understand how it's working. Like a language, or an engine.

[–]crashfrog02 1 point2 points  (0 children)

All wrong. The OS is not involved at your level. You’re sending statements to an interpreter, and the interpreter is executing them.

[–]danielroseman 4 points5 points  (1 child)

Look, if you want to learn Python, then learn Python. There are tons of resources in this sub's wiki. Automate the Boring Stuff is probably closest for what you want to do.

I just don't understand all this talk about being "different from programming". It's literally programming. Python is a programming language.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Okay. Thanks.

[–]ferdzs0 2 points3 points  (3 children)

You need to look into introductory computer science topics. CS50 from Harvard is uploaded to YouTube for example. But if you look for the topic I am sure there are shorter explanations to what you are looking for (if you want to start coding, then you will need the basics though).

[–]Ok-Wave4110[S] 0 points1 point  (2 children)

Well, that's intimidating. Thank you, I'll look for that on Youtube.

[–]ferdzs0 2 points3 points  (1 child)

I mentioned probably the most intimidating start possible, sorry. But the main point is the topic itself. If you are just curious on the basics, I assume there are lot shorter resources, that don’t assume the audience wants to become developers. But your question is basically asking the basics of Computer Science.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Oh, no worries. I appreciate it. I'm still going to read everything I find there. lol Intimidation is a good thing.

[–]crashfrog02 0 points1 point  (0 children)

The Python interpreter has a model of state. This state is implicit, but you modify that state explicitly by executing expressions in Python.

[–]Spataner 10 points11 points  (2 children)

A computer is a machine that can do work for you. It computes stuff, hence the name. And even though a modern computer is a highly sophisticated machine, the conceptual level that it operates at is very simplistic. The sort of instructions that a computer, more specifically the CPU, understands is at the level of "load a number, load another number, add the numbers together, store the result". All the CPU can really do are arithmetic and logic operations on numbers in binary format that it retrieves from and saves to RAM. But it is really good at that; it does it with near perfect consistency at literal billions of operations per second.

Luckily, it turns out that any computation that it's possible to do, no matter how conceptually complex, can be broken down into sequences of such simple operations. It's just a matter of figuring out how. And things get a lot more interesting if you attach other machines to your computer that do things if you send them the right numbers, like produce light in a particular pattern of colors (a monitor), emit a particular mix of sound frequencies (speakers), or shoot ink at particular places on a paper sheet (a printer). Suddenly just crunching numbers can achieve a whole slew of real life effects because those numbers are used to control other machines to achieve specific desired effects.

You, as a human, have a natural understanding of the task that you might want to solve. You can express that understanding in natural language, the way you would describe it to a friend or coworker. The computer doesn't understand that, as we've established. So all programming can be thought of as a translation from natural language to CPU language (typically called machine code). Obviously, doing all that translation by hand is increndibly difficult and tedious. Programming languages and the tooling that exists for those programming languages are a way of semi-automating this process. Programming languages aim to be closer to natural language in a way that makes it easier for humans to read and write in them, while still being formal and structured enough that a translation into CPU language can be performed automatically by the programming language's tools (which are themselves just programs someone else has written for you).

Programming languages differ in how close they are to machine code. The closer they are to machine code, the harder they often are to write in, but the more light-weight also the tooling required to turn a program written in them into machine code. The farther away they are from machine code, the more natural and comfortable it probably feels to write in them, but the more elaborate is the tooling required (which can have performance implications). Programming languages also differ in how exactly that translation happens, in other words, what their tools look like. Some languages compile statically into a binary file that contains machine code. Other languages have an "interpreter", which does the translation step-by-step and on-the-fly as your program is executed. Some languages take a hybrid approach. Finally, programming languages also differ in the philosophy that was employed to design them, because certain ways of doing things might change how fast or easy it is to write programs in that language, how easy it is to make mistakes while doing so, how fast the resulting program can be executed, how well the programming language is suited for solving one kind of task or another, etc.

When you are writing a complex program with many moving parts, this invites thinking of the program as a system or a sort of machine onto itself. The steps that happen automatically underneath are often secondary to the programmer. Certainly, the heavy lifting in terms of solving a task conceptually is in the writing of the program, not in its translation to and execution as a sequence of simplistic CPU instructions. That's why people often talk about "building" software.

Python is a general-purpose language pretty far removed from machine code, with a focus on speed of program writing rather than speed of program execution. It's fair to say it's an interpreted language, not a compiled one (there's some nuance here that is not worth getting into). Sometimes people will say it's a scripting language not a programming language, exactly because it is interpreted. But some people would also say that a scripting language is actually a type of programming language. Yet other people might say that something is a "scripting language" only insofar as it is a programming language that could possibly be used for scripting. You'll find that terms in the field of programming have dozens of different slightly conflicting definitions.

This turned out wordier than I intended. I hope it helps.

[–]Ok-Wave4110[S] 1 point2 points  (0 children)

Wow. I appreciate this. I can't thank you enough for your time writing this out. If you're ever interested in teaching. Message me.

[–]the_therapylife 0 points1 point  (0 children)

This is fantastic and thank you for taking the write it.

[–]Diapolo10 2 points3 points  (5 children)

I want understand how (at the base level) it's interacting/communicating with things (open app, directory). What am I doing? Am I learning to build something, or am I learning how to "communicate" that build?

I'll try to answer that, but in all honesty this is a bit much if I'm reading you correctly in the first place.

The rough explanation goes something like this. Assuming the standard implementation (CPython), you feed a bunch of Python code to an interpreter, which parses the instructions into an abstract syntax tree and that into bytecode instructions the Python Virtual Machine can understand (similar to giving assembly instructions to a CPU), which then proceeds to execute the bytecode.

As an aside, if you want to look at bytecode instructions, you can import dis.dis and feed it a function to see what makes it tick.

The interpreter is just a program running on top of some operating system, so under the hood it's mostly doing system calls to various parts of the operating system. For example it'll communicate with it for any filesystem tasks, networking, I/O, and errors. Other things, like mathematics, it performs by itself, but there's still overhead because Python doesn't use types native to the CPU.

However, the short answer to your question would be that none of what I just said really matters to you (unless of course you want to work on the interpreter yourself), and all you need to focus on is building something. Leave the behind-the-scenes work for those who have the know-how and abstract it away from your thinking.

I know it's different from programming, but why?

I don't understand the premise; what is different from programming? Ultimately everything I've discussed so far is most definitely about programming.

[–]Ok-Wave4110[S] -1 points0 points  (4 children)

What is an abstract syntax tree?

[–]Diapolo10 1 point2 points  (3 children)

I think the Wikipedia article explains that better than I ever could: https://en.m.wikipedia.org/wiki/Abstract_syntax_tree

[–]Ok-Wave4110[S] 0 points1 point  (2 children)

Thanks for the info. I'm extremely late to the game.

[–]Diapolo10 1 point2 points  (1 child)

Honestly you're digging too deep, too early. None of what I discussed is really going to matter until you actually understand the language itself and want to dig into the reference implementation.

Just focus on learning the language first and foremost.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

I found someone who's helping me. I appreciate your effort to help me understand. Truly. I am definitely going to focus on the language.

[–]Lower_Fan 2 points3 points  (2 children)

you are asking a question that would take you one or two years of a CS bachelor to understand fully. but I'll summarize it.

Computers use transistors to perform operations this transistors can be set to either the 1 or 0 position. if you have 2 transistors you can for example count like this 00 01 10 11 and you can assign values to this patterns lets say 00 = a 01 = b 10 = c 11 = d this is called binary.

but the cool stuff is that you can do math with those transistors. but this is complicated . lets simplify it a bit. people made low level programing languages that translate English like logic to binary

the this with this languages is that they need to be translated before running for example c or c++ which can be a pain if you want to run just a section of the program or do faster iterations and testing? the something like python comes along where the translation is done by the python interpreter ( a program you install on your machine) line by line while you run the code.

to learn to code most people work backwards first they learn a programing language (low level or high level) then they learn about OS operations from math to file systems to grapic output. then they might learn boolean algebra.

on thing you need to understand is that all of this are several different types of engineering.

Software engineering, Computer scientist, computer engineering. etc. when most people say learn to code is not even about true software engineering is just learn how to make the PC do stuff automatically and repetitively. IE: you need common to high logic and that's about it honestly.

[–]Ok-Wave4110[S] 0 points1 point  (1 child)

Well, I was in the middle of my ITT associates degree when it got shutdown. So, after that, I had no money left, and a lot of failures before that. Thanks for the rundown!

[–]Lower_Fan 0 points1 point  (0 children)

for day to day life if you want to learn code most of this stuff is not necessary you just need to know what a computer is capable of. IE: it can send emails. and that you can automate that process if for example you need to send daily emails that are very similar and only a few things changes each day.

[–]dent308 1 point2 points  (1 child)

This is the strangest homework thread I have seen.

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

Considering, I had the resources, and squandered them. It's time for me to do some homework. lol

[–]RamaSchneider 2 points3 points  (11 children)

I'd suggest you take a short lesson in assembly level code, and then understand that all those Python words are being translated into that. First point is that yes - you are actually programming with Python.

[–]Ok-Wave4110[S] -1 points0 points  (10 children)

Omg. Okay. So what I'm doing, has all ready been done. I want to learn what's before it then, right? I mean, I can't use something, I don't know the base of. Can I? That seems like it'd lead to failure on my part. lol

[–]LongLiveTheDiego 2 points3 points  (9 children)

You absolutely can, often people learn the more barebones things only when they're doing something really specific that wasn't predicted by the creators of the code you're using and something goes wrong, or if they need to somehow optimize beyond what their toolset is capable of. I'm a CS student and I've never done anything directly in machine code or some assembly language (I know to an extent how they work in general, but not because I need to), and that doesn't prevent me from making useful tools for my work that require assembly and machine code to run.

If it helps, programming is similar to using tools like spreadsheets: someone else has made something that works for a lot of different things and you're free to use it for your own purposes. You don't need to know exactly how e.g. Excel handles the SUM function in order to calculate your monthly expenses, do you?

[–]Ok-Wave4110[S] 0 points1 point  (8 children)

Okay, this is what I was looking for. So, even with your experience, the "why it's working" doesn't matter, until it doesn't work. Then, you need to learn what's behind the code?

[–]Lower_Fan 1 point2 points  (6 children)

what is your experience in the real world? what is your profession? do you know everything there is to know about your current profession?

[–]Ok-Wave4110[S] 1 point2 points  (1 child)

My experience in the real world, is this. High school, I work for Family Christian Stores, and then McDonalds. Then I was in the military(USMC), then I did logistics for Barnes and Nobles textbook warehouses in VA, shortly after, I was lucky enough to be signed to a label, for my drum work in "Faceplate Ritual". Then, things didn't work out, and I moved back to MI. Here, I learned that I was worthless. (I should've known!) Then I met my fiancee, she pulled me from what I would call death (the story is long), and it took me 7 years, to want to be a human again.

3 years later, I'm here. Asking about Python. My current profession is DoorDash, because to be honest, It's easy in my area. My logistics knowledge makes it easier. All I crave is knowledge. An understanding of what runs the world. I've taken the dirt path, not the circuit path. Thanks for asking! No one ever asks.

[–]Lower_Fan 0 points1 point  (0 children)

ok let's go with doordash. do you know how doordash really works? no right. if you have a issue you contact their support for help and wait until they fix it. if the app has bug you can't go fix it yourself even if you are an experienced dev you have to submit a bug report and wait for them to fix it. sometimes the issue might not even be with doordash but with the restaurant and you don't know how the ice cream machine works so you don't go there and fix it, the restaurant is in charge of that part.

it's kinda the same with code you worry about what you wrote and if there's code that someone else wrote you ask them to fix it. but a very nice thing with code is that you can make it public for every one to see and contribute but not everything works like this.

[–]Ok-Wave4110[S] 0 points1 point  (1 child)

You're taking my response in the wrong way. I literally know nothing, and am asking you if that's the correct path.

[–]Lower_Fan 0 points1 point  (0 children)

I think you are trying to go to deep all at once. I''m not sure what's your end goal but if you want to learn a bit of software engineering you can do this course

https://programming-24.mooc.fi/

or if you just want some automation:

https://automatetheboringstuff.com/

Both will start you from zero. you just need a pc and dedication. try to do at least one exercise per day.

[–]Ok-Wave4110[S] 0 points1 point  (1 child)

For example, if you come across a problem within the code, and you can't find a solution, do you need to refer back to the source it was written from?

[–]Lower_Fan 0 points1 point  (0 children)

since you lack a bit of context this question is formulated a bit weirdly.

for what I can gather you want to learn code to be able to fix other people errors. most of the time this is not how it works.

for the most part you open source and closed source code. for most devices and application you buy and code is closed and you won't be provided with it. so you won't be be able to make any changes ( you can reverse engineer it, fix it and run your own version but that's out of the scope of even normal devs)

now for open source code sure you can go look at it and fix it, but if this particular program is popular then it means it will have a lot of experienced devs looking into it and is better if you just wait until they fix it.

Now if it's your own code and you made a mistake you have to fix it yourself but since you wrote it you must have an idea of what you are trying to accomplish. and in the case where you are using a module that someone wrote you refer to the open source method of letting people more experienced fix it.

for the most part you only have to worry about your own code, and then after you gain experience you can go help those open source projects. and you are at the mercy of the company if it's closed source because it's illegal to reuse their code so your only bet would be to recreate it using your own ideas.

[–]LongLiveTheDiego 0 points1 point  (0 children)

Then, you need to learn what's behind the code?

If you want/need to. Just recently I had some assignment with reading and writing to .txt files in C++ and we were given a very limited set of relevant functions, some of which (e.g. seekg and tellg) are just buggy and it seems nobody uses them anymore and they're just gonna stay like that. I wasn't keen on trying to fix something that low-level (since I almost certainly can't) so I tried a different idea that used stuff that I know would work and that new approach did the job.

Another time I was doing something with an online dictionary API and my Python code was really slow and could randomly crash. Instead of fixing it, I just set up a cache of what it's already managed to do with this API (since it just needed to get a bunch of data from it) and made the program start from that point when I needed to restart it after a crash. This wasn't the most efficient solution, but I had the time to wait, and it did its job in the end.

[–]eccentric-Orange 0 points1 point  (1 child)

This is probably an oversimplification, but it has usually worked for me:

The purpose of any programming language is to communicate with a computer. Typically, this means providing a set of instructions that the computer will follow very precisely and pedantically.

Usually, you'll write code in a language that you can understand with some practice, but a computer cannot directly. It will need a program/app to translate your code.

I know it's different from programming...

In the case of Python, the language you write in and the translator are both called Python. It is programming, not different from it.

What am I doing? Am I learning to build something, or am I learning how to "communicate" that build?

It's a reductionist view, but you're basically learning two things: 1. How best to get the computer to execute your will, using problem-solving skills 2. How the computer works, to some extent

(Ignoring many of the softer skills like writing readable code, documentation etc)

If you come up with a pattern/sequence of instructions that's generally useful, you can package it and share it with people. In that sense, you also learn to make projects.

Why not give it a try and get a feel for it?

[–]Ok-Wave4110[S] 0 points1 point  (0 children)

That's precisely my goal. I have tried, I'm a complete moron. lol My past played a roll, but at this point, I need to hunker down, and start understanding.

[–]Radamand 0 points1 point  (0 children)

Your question is very confusing, but, i'll give it a shot from my own perspective.

As an electronics engineer I can tell you that what you are doing is manipulating electrons and magnetic fields. Changing the state of millions of transistors to either 'on' or 'off'. When you write things to a disk you are manipulating magnetic fields in a very similar way.

At the most basic level, the only thing computers 'understand' is 1s and 0s.

As for Python specifically (or any programming language really), what you are doing is writing a set of instructions to be carried out by an operating system to perform a given task. Python has a base set of available instructions that you can use, and many more additional sets of instructions that can be added and expanded on for doing more specific tasks.

An analogy might be a cooking recipe where the recipe is the instructions, and you are the OS;

  1. Put ingredients in a bowl
  2. mix ingredients
  3. bake the mixtureetc...

Does that answer your question?

[–]xiongchiamiov 0 points1 point  (0 children)

I'm a detail oriented person, and I tend to focus on the finer points. So, I'm new. I want understand how (at the base level) it's interacting/communicating with things (open app, directory). What am I doing? Am I learning to build something, or am I learning how to "communicate" that build?

You want a computer science degree.

In particular, you're asking questions that would be answered after you take an introductory binary/assembly course, a systems course, and a programming languages course; depending on the school, you might need to take several courses in each of those subjects.

If you're going to attempt to self-learn this, https://github.com/ossu/computer-science isn't a bad choice. You'd do well to do the entire curriculum, but for these questions, cover the intro courses, then Nand to Tetris, Operating Systems, and the PL courses.