r/learningpython • • Aug 13 '20

Empty classes

3 Upvotes

I recently stumbled upon empty classes in python but I still couldn't understand the benefit of such a feature. Can someone explain what is the purpose of an empty class ?


r/learningpython • • Aug 10 '20

Data not producing in when training image classifier

3 Upvotes

Hi there,I've gone through multiple structural edits of this code. Ive been referencing others code but for some reason past students in this project have been able to produce multiple epochs with quantative data yet mine is returning flat.Can anyone see what im doing wrong?I know the libary im referring to is properlly linked as ive manage to make data graphs higher up in the notebook.


r/learningpython • • Aug 03 '20

My first python project. Please give feedback.

3 Upvotes

Github page. i have been learning python for the past 1 year, this is my first project that i want to share. Its a program to sort all files in a directory into appropriate sub-directories it creates. Please give me feedback and all kinds of criticism based on my code.


r/learningpython • • May 08 '20

A Noob Question...

3 Upvotes

Hi everyone.

I’m new to programming having tried to learn it as a skill for years and am dabbling with building GUI programs in python.

Things are getting interesting.

Now my question is this:

Is there a way to see what I’m building in real time? I’m ask because I’m dyslexic and I think and learn visually and it takes extra time to go through the code and try to imagine what things look like or what code is effecting what when I type it.

Obviously once I run the code I can see it but it’s very abstract trying to imagine a shape and a object when I read lines of code.

Is this at all possible or is this just the nature of the beast so to speak?

Thanks.


r/learningpython • • May 07 '20

Should I use Jupyter or pycharm

3 Upvotes

...I am learning python and idk which ide to use


r/learningpython • • May 07 '20

Try/except error with non-integer (as provided via PY4E)

3 Upvotes

Edit: Problem solved, see bottom.

Hello! New here, apologies if formatting needs work. I did my best to search for this issue, but I don't see any posts/previous questions about this issue.

Learning via PY4E and I keep trying the example provided in Chapter 3 Part 2. The following is provided in video (12 minute mark, but when I try to apply the script in Python, it actually does not run as intended when a non-integer is submitted.

From what I understand, input() returns a string-type variable. But shouldn't that mean the try/except logic applies when the string fails to be converted to an integer with int()?

Any and all help would be appreciated as I'm banging my head against the wall trying to figure it out myself.

rawstr = input('Enter a number:')
try:
    ival = int(rawstr)
except:
    ival = -1

if ival > 0:
    print('Nice work')
else:
    print('Not a number')

Error

Traceback (most recent call last):

File "3_Lesson_Notes.py", line 1, in <module>

rawstr = input('Enter a number:')

File "<string>", line 1, in <module>

NameError: name 'Three' is not defined

Solution (?)

So, after a bit more digging I found that by executing the script in the terminal just as "python", it doesn't like the non-integer input unless I put it in quotes. So the problem that I'm still not 100% understanding but I suppose I have a workaround for is:

A) Executing the script via python in the terminal requires using "" for any non-integer input.

B) Run the script but ensure that I'm clearly executing via python3 as opposed to just typing in python "file name".py


r/learningpython • • Apr 14 '20

Python tipps

3 Upvotes

I have chosen Python and start learning the language today. Since it is my first programming language, I have no idea about it and wanted to ask if there are some tips for beginners :)

Something that might help me in the future or what you would have liked to know when you started.

Thank you in advance! Stay healthy.


r/learningpython • • Apr 02 '20

Dev needs me to write a script that will be deployed to a cron job - I've only ever run scripts locally. Can you deploy to a cron job a script that can read something from a folder?

3 Upvotes

So the script I'm deploying makes use of the docx-mailmerge library. It has one line in it where a file's name and path need to be passed in - how I usually do it locally is I simply pass in the path to the file, but I'm not sure how this would be replicated if it were running in a cron job.

I figure there has to be a solution to something like this, a way to store the files necessary in some kind of temporary folder, right?

I'm hoping to be able to:

  1. Download the file from S3,

  2. Dump it into a folder that my script will create,

  3. simply reference it from the folder where I just dumped it.

Wondering if that's something that would be possible.


r/learningpython • • Mar 29 '20

Best IDE to code with?

3 Upvotes

Im new to programming and Im trying to find the most user friendly IDE for using python. Something with multiple to windows to display, also would like having a terminal and a place to write code(whatever that’s called) Im probably getting VScode to use java on. Does VScode also work with python?


r/learningpython • • Jan 11 '20

Can anyone tell me how to get my sum to 7

Post image
3 Upvotes

r/learningpython • • Dec 05 '19

Can python be learned through audio

3 Upvotes

Hello I recently joined a job that I had at first thought was gonna need some. Background in programming.

Turns out the job was more clerical in nature and very limited in terms of me being able to apply my basic knowledge in python there.

Is there a way to learn python via audio like podcasts and audio books? I understand that it's better to see and do thing when learning to code, but my schedule is very tight and the job pays too well for the kind of work I do for me to just give it up immediately.

At the very least if I found a way to learn python via audio while I do my clerical work. I'll still be learning


r/learningpython • • Oct 07 '19

Super() and attribute question?

3 Upvotes

This might be a simple question and maybe the answer is right there but here is a simple code to try to explain my confusion.

class Person:
	def __init__(self,name,age):
		self.name=name
		self.age=age
	def get_name(self):
		print(self.name)
		
class Girl(Person):
    def _init__(self,name,age):
        super().__init__(name,age)
        self.gender="Female"		

class Boy(Person):
    def __init__(self,name, age):
        super().__init__(name,age)
        self.gender ="Male"

Jack=Boy("Jack",21)
Jill=Girl("Jill", 21)

hasattr(Jack,"gender")
//Gives me False

hasattr(Jill,"gender")
//Also gives me False

So my question how come the Boy object and the Girl object don`t get the gender attribute. I know they inherit the Person objects attribute of age and name.

class Person:
	def __init__(self,name,age):
		self.name=name
		self.age=age
	def get_name(self):
		print(self.name)
		
class Girl(Person):
    self.gender="Female"
    def _init__(self,name,age):
        super().__init__(name,age)
        		

class Boy(Person):
    self.gender="Male"
    def __init__(self,name, age):
        super().__init__(name,age)
        

Jack=Boy("Jack",21)
Jill=Girl("Jill", 21)

hasattr(Jack,"gender")
//Gives me True

hasattr(Jill,"gender")
//Also gives me True

This varietion seems to work. I know why this works, but aren't the two codes kind of the same?


r/learningpython • • Apr 23 '19

Create a Python Simple Weather App

Thumbnail
natebruneau.com
3 Upvotes

r/learningpython • • Apr 17 '19

31 yo stuck in dead end job. Considering making a career switch and learning a new skill with Python

3 Upvotes

I recently moved to a new country. No distinguished skill set. I work in a dead end sales job that I’m not very good at. I’ve worked in several industries but was never very successful in the sales role. Perhaps I don’t have the sales personality.

I’ve been toying with the idea of learning programming as I feel this is a skill that can be learned with sufficient practice regardless of previous qualifications. I have always had an inclination to learn but never followed through. Joined a C class when I was 16 for a couple of months and also took JavaScript for a few months last year.

I’ve toyed with JavaScript and C and have a fair idea of the basics - loops, if statements, conditions, functions etc.

I was wondering if it’s a good idea to start off with Python as it feels like the perfect language to start with - highly in demand, not complicated syntax, lot of resources to learn online.

I’m currently reading automate the easy stuff.

I wanted to know if this is a good idea to start learning now (at 31). Im willing to dedicate all my free time to this. Do you think it’s possible for someone to learn it to a level where you can eventually be employed in a year or should I just keep it as hobby? Also, any helpful resources would also be appreciated where I can learn with a low budget. (<1000 $).

Thank you!


r/learningpython • • Aug 20 '26

I framed all my photos with python and I accept comment or suggestion

2 Upvotes

I need to frame a lot of my photos adding in the frame the config of the camera, camera model and camera lens and I am a lazy man so I code it with Python. If you have suggestion or comment I LOVE to read them

https://fundor333.com/post/2026/framing-photos-with-python/


r/learningpython • • Aug 10 '26

How to prevent dict from being a valid input (Pydantic BaseModel)

2 Upvotes

So I have a Pydantic BaseModel called Latitude. It is the following:

class Latitude(BaseModel):
  latitude: Decimal

I then have another BaseModel called SetReferencePoint that includes Latitude in its attributes. I've tried testing the SetReferencePoint BaseModel with Hypothesis using:

st.from_type(type)

I then get a ValidationError as follows with a couple tests (minus the url portion):

{'type': missing, 'loc': ('lat', 'Lat'), 'msg': 'Field required', 'input': {}}

The rest of the tests throw a 'model_type' error as expected.

I want to prevent an empty dict from being accepted as an input which would prevent the 'missing' error from showing up in the first place. How can I do this? Should I use 'field_validator'? If so how best to set it up and test it?


r/learningpython • • Feb 04 '26

AI can write Python...but can it teach you Python?

2 Upvotes

What rules do you give beginners about using AI to learn Python?

I’m helping r/neuromatch run a free Python for Computational Science Week using their open-source tutorials. We realized our materials don’t currently include any guidance on how or when learners should use AI while learning to code. We’re planning to update that and would love broader input.

We’re generally excited about AI as a coding tool but we’re also aware that it can short-circuit learning, especially in the first days or weeks. One idea we’re leaning toward is something like:

  • Try to write the code yourself first

  • Use AI to debug, explain errors, or suggest improvements

  • Don’t copy/paste code you don’t fully understand

  • Be more cautious using AI in your very first week of learning Python

For those who teach Python or learned with AI in the mix:

  • What advice did you get that you found helpful?

  • When does AI genuinely help learning?

  • When does it get in the way?

Curious to hear how others approach this or if there are citations you can point me to! Thanks!


r/learningpython • • Feb 01 '26

Some Data Should Be Code

Thumbnail
borretti.me
2 Upvotes

r/learningpython • • Jan 18 '26

Confused about why code A doesn't work

2 Upvotes

This is in a while loop called is_bidding

Code A:

resume = input("Is there another bidder? Type 'yes' or 'no': \n").lower()
    print(resume)
    if resume != 'no' or 'yes:
        print('We will take that as a no')
        is_bidding = False        
    elif resume == 'yes':
        print("Let us resume.")
    else:
        print("Very well let's see whose won...")
        is_bidding = False

intentions: I wanted the if statement to check if the user did NOT enter 'yes' or 'no'

results: When typing 'yes', the first condition runs, and I am not sure why

Edit: Thanks for the feedback, I understand what I did wrong.


r/learningpython • • Jan 09 '26

AI Leetcode Tutor Platform Looking For Beta Users

2 Upvotes

Hey guys,

I had been grinding Leetcode for the past two months and I had been using an AI workflow to help me understand the questions better.

It utilizes MC quizzes and open-ended probing questions to test your understanding while allowing you to ask clarifying questions.

I later built a scaffolding app around this core workflow and I am now giving out a free lifetime usage for the first 20 users.

codeboss.codes

Thanks

Vincent


r/learningpython • • Jan 04 '26

I built a FastAPI template after learning Python — sharing what helped me most

2 Upvotes

Hey

I wanted to share a side project I built while getting deeper into Python: FastLaunchAPI.dev.

It’s a production-ready FastAPI template, but I’m posting here mainly to share what I learned while learning Python and moving from scripts to real-world apps.

What helped me most when learning Python

If you’re aiming to build real products with Python, these things made the biggest difference for me:

- Building something real early, even if it was messy

- Learning async and how async/await actually works

- Reading other people’s code, especially FastAPI projects

- Focusing on one framework instead of jumping between many

- Treating errors and stack traces as learning tools, not blockers

Why I built this

After a while, I noticed I was rebuilding the same things in every project:

auth, configs, database setup, payments, deployment prep.

So I decided to turn that repetition into a reusable FastAPI template that reflects how I now approach Python projects.

If you’re learning Python and want to build APIs

FastAPI was a big unlock for me because:

- It forces you to understand typing

- It encourages clean structure

- You get instant feedback via docs and validation

You don’t need to build something like this to learn, but building real APIs helped everything click for me.

If this is useful

Site: https://fastlaunchapi.dev

Happy to answer questions about learning Python, FastAPI, or turning side projects into real products.


r/learningpython • • Oct 11 '25

Why does the .bat file that runs my programs need to be in the same folder?

2 Upvotes

When I run a .bat file that isn't in the same folder as the .py file I'm running, the code gives me a "FileNotFoundError: [WinError 3] The system cannot find the path specified:" error. But when the .bat file is in the same folder, it runs with no issue. Can someone explain why? the error occurs on a call using os to list all the files in a folder. I even have the full paths listed for the python.exe and the python code in the batch file.

Full error:

 "File "C:\Users\<username>\Desktop\CBB Model\CBB_Test_2024-2025\3_track_stats.py", line 600, in <module>
file_list = os.listdir(halve_start_loc)
 FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\<username>\\Desktop\\CBB Model\\Schedule\\All Halves Adjusted\\Adjusted Halves\\'

Python Code here:

 import pandas as pd
 import numpy as np
 import re
 import os
 import pathlib
 from os import listdir
 import datetime as dt
 from datetime import timedelta
 pd.set_option("display.max_rows", None)
 pd.set_option('display.max_columns', None)
 pd.set_option('display.width', None)
 pd.options.mode.chained_assignment = None


 main_folder_loc = pathlib.Path().resolve()
 main_folder_loc = str(main_folder_loc)+ "\\"
 halve_start_loc = main_folder_loc + "Schedule\\All Halves Adjusted\\Adjusted Halves\\"

 halve_end_loc = main_folder_loc + "Schedule\\All Halves Adjusted\\Adjusted Halves with stats track\\"

 600 lines of functions and main

if __name__ == "__main__":
     file_list = os.listdir(halve_start_loc)  ##error occurs here
     main(file_list)

Batch Code Here:

  @echo off
  "C:\Users\<username>\AppData\Local\Programs\Python\Python314\python.exe" "C:\Users\<username>\Desktop\CBB Model\CBB_Test_2024-2025\3_track_stats.py"

r/learningpython • • Sep 13 '25

Want to learn Python, try out EasyDev: Learn to Code!

Post image
2 Upvotes

Link to the App Store page: https://apps.apple.com/app/6749594445

Hello everyone, I wanted to share my new Learn to Code app, EasyDev. I built this app using Swift UI in around 4 months, and it is actually my first ever Swift project. I am coming here to gain some eyes on my app, and give me suggestions on what I can do to make my app better and grow as a developer.

The app itself was made exclusively by me, including all the programming, UI, assets, logos, etc. The actual learning content was also handcrafted by using structures similar to popular websites such as Edube and Learncpp, and there is a lot of interactive and descriptive content that takes inspiration from these websites, which are very popular for their effectiveness in teaching people how to code.

If you are interested in learning programming or just want to check the app out, please consider downloading the app using the link above. Also, if you experience any bugs or errors of any kind, please go to the Discord (in the app store page or directly in the app (Settings -> Join the Discord)) and let me know. Thanks in advance!


r/learningpython • • Jun 21 '25

is it even possible to create this

2 Upvotes

i’m looking to build (or at this point even pay) a mini video editing software that can find black screen intervals from my video then automatically overlays random meme images on those black parts, and exports the edited video.


r/learningpython • • May 31 '25

Slowly learning Python - working on the Caesar Cipher exercise.

2 Upvotes

I'm working on the decryption portion of the exercise. It was recommended to use the modulo function to perform the alphabet letter shift.
While I am slowly understanding the modulo shift for encrypting (moving forward in the alphabet) - I'm not understanding how the modulo shift works for decrypting (moving backward in the alphabet):

My specific issue:

Let's say that you're working with the "c" character (index position 2), with the idea of decrypting it, by shifting backwards 5 spaces. you get the "x" character as the decoded letter (index position 23).
How does one divide -3 by 25 to get mod 23?

If someone could explain that, I'd be really grateful.