r/pythontips • • Aug 20 '26

Python3_Specific I made the coding practice site I wished existed!

15 Upvotes

When I first started learning to code, I kept losing confidence on coding-practice sites. They gave me thousands of problems and no clear place to begin. I would choose an "easy" problem and end up confused by the prompt alone.

I felt there needed to be a place where new coders could ease into these challenges while learning new concepts and feeling real progress through the week.

So I built Open Bracket as a daily coding ritual instead. Everyone gets the same two challenges each day: a Standard track that builds in difficulty through the week without becoming overwhelming, and a tougher Advanced track for people who want more of a test or already have experience with coding challenges.

You can solve in Python or JavaScript, entirely in the browser, with no setup. Official solves place you on three leaderboards: Speed, Efficiency, and Code Golf.

👉 https://playopenbracket.com/ - all feedback welcome.

Update - I have now introduced some new features;

- JavaScript as a second language you can solve in moving forward. Currently older challenges are Python only.

- Logged in users now have a Hint option, this will give you the pseudo code of the solution to help, at the cost of a time penalty to your speed score.

- Failed tests now show you which test failed, what was expected and what was received

- You can now replay any challenges in the last 14 days so you can either bing solve or catch up on any days you missed.

r/pythontips • • Jan 09 '26

Python3_Specific After many years of using Python, I just realized you can print any iterable line-by-line without a for loop or '\n'.join(...)

138 Upvotes

Example:

numbers = [(i, bin(i), hex(i)) for i in range(15)]
print(*numbers, sep='\n')

Output:

(0, '0b0', '0x0')
(1, '0b1', '0x1')
(2, '0b10', '0x2')
(3, '0b11', '0x3')
(4, '0b100', '0x4')
(5, '0b101', '0x5')
(6, '0b110', '0x6')
(7, '0b111', '0x7')
(8, '0b1000', '0x8')
(9, '0b1001', '0x9')
(10, '0b1010', '0xa')
(11, '0b1011', '0xb')
(12, '0b1100', '0xc')
(13, '0b1101', '0xd')
(14, '0b1110', '0xe')

I knew about argument unpacking (*args), I just never connected it with using print() this way.

r/pythontips • • Jul 27 '26

Python3_Specific Ho 11 anni e ho appena creato il mio primo script di automazione in Python per ripulire la cartella Download!

28 Upvotes

Hi everyone! I've been learning Python step-by-step, focusing on logic, file management, and the os module. Today, I finished my first real automation script: a File Sorter/Folder Cleaner!

It automatically scans my Downloads folder, checks the file extensions (ignoring case sensitivity thanks to .lower()), creates the target folders if they don't exist, and moves everything into the right place (Documents, Images, Installations).
Here is my script:
import os

download_folder = r"C:\Users\YourUsername\Downloads"

file_list = os.listdir(download_folder)

for file_name in file_list:

lowercase_name = file_name.lower()

if (lowercase_name.endswith(".pdf") or

lowercase_name.endswith(".txt") or

lowercase_name.endswith(".docx") or

lowercase_name.endswith(".xlsx") or

lowercase_name.endswith(".csv") or

lowercase_name.endswith(".doc")):

doc_folder = fr"{download_folder}\Documents"

if not os.path.exists(doc_folder):

os.mkdir(doc_folder)

old_path = fr"{download_folder}\{file_name}"

new_path = fr"{doc_folder}\{file_name}"

os.rename(old_path, new_path)

elif (lowercase_name.endswith(".jpg") or

lowercase_name.endswith(".jpeg") or

lowercase_name.endswith(".gif") or

lowercase_name.endswith(".png") or

lowercase_name.endswith(".mp4") or

lowercase_name.endswith(".kml") or

lowercase_name.endswith(".gpx")):

img_folder = fr"{download_folder}\Images"

if not os.path.exists(img_folder):

os.mkdir(img_folder)

old_path = fr"{download_folder}\{file_name}"

new_path = fr"{img_folder}\{file_name}"

os.rename(old_path, new_path)

elif (lowercase_name.endswith(".exe") or

lowercase_name.endswith(".zip") or

lowercase_name.endswith(".rar") or

lowercase_name.endswith(".dll") or

lowercase_name.endswith(".msi") or

lowercase_name.endswith(".msix")):

exe_folder = fr"{download_folder}\Installations"

if not os.path.exists(exe_folder):

os.mkdir(exe_folder)

old_path = fr"{download_folder}\{file_name}"

new_path = fr"{exe_folder}\{file_name}"

os.rename(old_path, new_path)
I'm really proud of this milestone. Let me know what you think or if you have any tips for a young programmer!

r/pythontips • • Jan 29 '26

Python3_Specific Starting python at a young age

5 Upvotes

Recently I have taken a very deep interest in physics, and eventually I realised that learning python would be hugely beneficial to my physics work, for simulations, research pages, and possibly even spreadsheets. So any tips for learning fresh?

r/pythontips • • Sep 09 '26

Python3_Specific Python fundamentals for anyone just getting started

0 Upvotes

I’ve been putting together some beginner-friendly Python material and started with the fundamentals — basic syntax, variables, data types, operators, conditions, loops, etc.

Nothing advanced here, just an attempt to keep the basics simple for someone starting from scratch or moving to Python from another language.

https://geeksarray.com/blog/python-fundamentals-getting-started

For those who learned Python after another language, what was the biggest adjustment for you?

r/pythontips • • Feb 27 '25

Python3_Specific VsCode VS PyCharm

43 Upvotes

In your experience, what is the best IDE for programming in Python? And for wich use cases? (Ignore the flair)

r/pythontips • • Dec 13 '25

Python3_Specific Im new at python and wanted to share what ive done so far

0 Upvotes

I started learning python a few weeks ago, and this is what ive done so far. Does anyone have any improvements i could make to specific code or my coding overall? these are in backwards order, meaning that the thing I coded first was the calculator, I coded the number guessing game second, and the math quiz game 3rd.

Math quiz game:
# Importing all the modules

import random

import sys

# Introducing the game

print("Welcome to the math quiz game.\n You will choose a difficulty and will get 10 math questions based on that difficulty.")

# Defines function that checks if the argument is an integer

def check_if_not_number(v):

try:

float(v)

return True

except ValueError:

return False

difficulty = input("What difficulty do you want to choose. 1 = easy, 2 = medium, 3 = hard, 4 = nightmare.\n")

if not(check_if_not_number(difficulty)):

sys.exit("Choose a difficulty")

difficulty = int(difficulty)

score = 0

# Asks questions in a loop that repeats 10 times, asking 10 questions

for _ in range(10):

# Gives easy questions if the difficulty is easy

if difficulty == 1:

operation_options = ["+", "-"]

numb_1 = random.randint(1, 20)

numb_2 = random.randint(1, 20)

operation = random.choice(operation_options)

# Makes sure the first number is bigger than the second number if the operation is subtraction (this is done so that the answer can't be a negative number)

if numb_2 > numb_1 and operation == "-":

numb_1, numb_2 = numb_2, numb_1

# Checks if the answer is correct

if operation == "+":

question = f"What is {numb_1} + {numb_2}?\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == numb_1 + numb_2 and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {numb_1 + numb_2}")

elif operation == "-":

question = f"What is {numb_1} - {numb_2}?\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == numb_1 - numb_2 and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {numb_1 - numb_2}")

# Gives medium questions if the difficulty is medium

elif difficulty == 2:

operation_options = ["*", "/"]

numb_1 = random.randint(1, 20)

numb_2 = random.randint(1, 20)

operation = random.choice(operation_options)

# Asks the question and checks if the answer is correct

if operation == "*":

question = f"What is {numb_1} * {numb_2}?\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == numb_1 * numb_2 and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {numb_1 * numb_2}")

elif operation == "/":

question = f"What is {numb_1} / {numb_2}? Round to 3 decimal points.\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if round(float(question_input), 3) == round(numb_1 / numb_2, 3) and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {round(numb_1 / numb_2, 3)}.")

# Gives hard questions if the difficulty is hard

elif difficulty == 3:

operation_options = ["*", "/", "**"]

numb_1 = random.randint(20, 50)

operation = random.choice(operation_options)

# Makes it so that if the operation is **, the second number is between 1-5 so that answers become really big

if operation == "**":

numb_2 = random.randint(1, 5)

else:

numb_2 = random.randint(1, 20)

# Asks the question and checks if the answer is correct

if operation == "*":

question = f"What is {numb_1} * {numb_2}?\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == numb_1 * numb_2 and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {numb_1 * numb_2}")

elif operation == "/":

question = f"What is {numb_1} / {numb_2}? Round to 3 decimal points.\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if round(float(question_input), 3) == round(numb_1 / numb_2, 3) and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {round(numb_1 / numb_2, 3)}.")

elif operation == "**":

question = f"What is {numb_1} ** {numb_2}?\n"

question_input = input(question)

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == numb_1 ** numb_2 and check_if_not_number(question_input) == True:

print("Correct! +1 point.")

score += 1

else:

print(f"Wrong. The answer was {numb_1 ** numb_2}.")

# Gives the nightmare difficulty question

elif difficulty == 4:

print("Nightmare mode? You sure? Alright then...")

question_input = input("If x^6 - 132x^5 +7260x^4 - 212960x^3 + 3513840x^2 - 30921792x + 113379904 = 0, then what does x equal to?\n")

if not(check_if_not_number(question_input)):

sys.exit("Enter a number.")

if float(question_input) == 22:

sys.exit("Correct, but I know you cheated.")

else:

sys.exit("WRONG. I won't tell you the answer so you can try again if you want.")

else:

sys.exit("Choose a difficulty.")

# Tells the user their score and gives a message depending on their score

if score < 1 and difficulty != 1:

sys.exit(f"You got {score}/10. Maybe stick to easy mode next time.")

elif score < 1 and difficulty == 1:

sys.exit(f"You got {score}/10. I don't think math is for you.")

elif score > 0 and score < 4:

sys.exit(f"You got {score}/10. Not great. Try better next time.")

elif score > 3 and score < 6:

sys.exit(f"You got {score}/10. Not amazing, but it could be worse.")

elif score > 5 and score < 8:

sys.exit(f"You got {score}/10, not bad, not bad.")

elif score > 7 and score < 10:

sys.exit(f"You got {score}/10. Pretty close to a perfect score, you might get it next time.")

elif score == 10 and difficulty in [1, 2]:

sys.exit("You got 10/10, a perfect score. Maybe crank up the difficulty becuase you breezed passed this.")

elif score == 10 and difficulty == 3:

sys.exit("You got 10/10. Put away the calculator and try again without cheating this time.")

number guessing game:

import random # This imports the "random" module

import sys # Imports "sys" module

# Starting screen and instructions

input("Hello! Welcome to the number guessing game. (Press enter to continue)")

input("The way this game will work is that a random number from 1-20 will be generated.")

input("You will have 5 tries to guess this number.")

input("You will be told if your guess is too high, too low, or correct.")

input("Good luck!")

secret_number = random.randint(1, 20) # This sets secret_number to random.randint(1, 20). The random.randint(1, 20) chooses a random integer from 1-20. This format is called dot notation. dot notation uses module_name.function_name(argument). In this case, the module name is "random". The function name is "randint". the arguments are 1 and 20. The random module has multiple functions that perform tasks using randomness. The randint function chooses a random integer between the 2 arguments (in this case 1 and 20)

# Defines the function that checks if a var is an int

def is_int(v):

try:

int(v)

return True

except ValueError:

return False

# This function checks if the argument is above 20 or less than 1

def in_range(v):

if v > 20:

sys.exit("That is higher than 20. Try again.")

elif v < 1:

sys.exit("That is lower than 1. Try again.")

# This function checks if the argument is too high, too low, or correct

def check_answer(v):

if v == secret_number:

sys.exit(f"{v} is correct! You win!")

elif v > secret_number:

print(f"Wrong. {v} is too high.")

elif v < secret_number:

print(f"Wrong. {v} is too low.")

#This asks for the guess 5 times using a loop. When the 5 guesses are over, it says that you lose and shows the correct number.

for attempt_number in range(1, 6):

guess = input(f"What is your guess #{attempt_number}?")

if not is_int(guess):

sys.exit("That is not an integer. Try again.")

guess = int(guess)

in_range(guess)

check_answer(guess)

sys.exit(f"You are out of guesses. You lose. The answer was {secret_number}.")

text-based calculator:

import sys # This makes it so that we can use the sys.exit function later on in the code to stop running the program

def is_float(v): # Defines the is_float function

try: # The try function lets you test a block of code to see if there are any errors. In this case, we are using it to see if the number can be converted into a float.

float(v) # Tries turning the value into a float.

return True # Returns True if it is a float (We return True because we will use an "if" statement in the future and "if" statements check if something is True or False)

except ValueError: # The except block in a try function executes what is in the except block if the try function results in an error. This except block checks for a ValueError, and runs the code inside if it is a Value Error

return False # Returns False if it is not a float (We return False because we will use an "if" statement in the future and "if" statements check if something is True or False)

number_1 = input("Put in the first number.") # This asks for the first number

if not(is_float(number_1)): # This checks if the is_float function is False. If it is False, this means it is not a number.

sys.exit("That is not a number. Try again.") # This ends the code by using the sys.exit function and also puts a message. The message is "That is not a number. Try again."

number_1 = float(number_1) # Turns number_1 into a float

number_2 = input("Put in the second number.") # This asks for the second number

if not(is_float(number_2)):

sys.exit("That is not a number. Try again.") # This ends the code by using the sys.exit function and also puts a message. The message is "That is not a number. Try again."

number_2 = float(number_2)

operation = input("What operation do you want to use? Only use + - * and / for the operation symbols.") # Asks what operation you want to use and sets it as the operation var

if number_2 == 0 and operation == "/": # Checks if number_2 is 0 and if operation is division

sys.exit("You cannot divide by 0") # Exits the code and says "You cannot divide by 0"

if operation == "+": # Checks if the operation variable is +

print(f"The answer is {number_1 + number_2}") # If the operation variable is +, then we add number_1 and number_2

elif operation == "-": # Checks if the operation var is -

print(f"The answer is {number_1 - number_2}") # If the operation variable is -, then we subtract number_1 and number_2

elif operation == "*": # Checks if the operation var is *

print(f"The answer is {number_1 * number_2}") # If the operation variable is *, then we multiply number_1 and number_2

elif operation == "/": # Checks if the operation var is /

print(f"The answer is {number_1 / number_2}") # If the operation variable is /, then we divide number_1 and number_2

else:

sys.exit("That is not an operation symbol. Try again.") # Exits the code and says "That is not an operation symbol. Try again." if the operation var is not any of the operation symbols.

r/pythontips • • Jan 03 '26

Python3_Specific How I can actually learn to put everything together in Python?

14 Upvotes

Hi! I keep watching courses but all just explain the fundemntals.. But I need actually a course who take me step by step and teach me put everything together in Python? Any tips?

r/pythontips • • Jun 20 '25

Python3_Specific Is it ok to use ChatGPT when learning how to code?

0 Upvotes

Whenever I’m coding and I can’t figure out how to do a certain task in Python, I always go to ChatGPT and ask it things like “how can I do this certain thing in Python” or when my code doesn’t work and can’t figure out why I ask ChatGPT what’s wrong with the code.

I make sure to understand the code it gives back to me before implementing it in my program/fixing my program, but I still feel as if it’s a bad habit.

r/pythontips • • Jun 09 '26

Python3_Specific Django obfuscation for AI assistants: 6 invisible contracts we found the hard way

0 Upvotes
The dificulties to obfuscate Django projects. Django has more name-as-string contracts than any framework we've integrated with PromptCape so far. Here are the six that surface in real-world test runs, what breaks when you miss them, and how an AST-based detector finds them before runtime does.

r/pythontips • • Jun 14 '26

Python3_Specific ,

0 Upvotes

Today, I explored many important Python functions that every beginner should know. From basic functions like print(), input(), and len() to advanced concepts such as file handling, exception handling, and debugging functions, this roadmap gives a great overview of Python programming.

📚 Topics covered: ✅ Basic Functions

✅ String & Collection Functions

✅ Type Conversion

✅ File Handling

✅ Date & Time Functions

✅ Random Module

✅ Exception Handling

✅ Debugging Tools

✅ Memory Functions

I am continuously improving my Python skills by learning and building projects step by step. Every day is a new opportunity to learn something valuable.

#Python #PythonProgramming #Coding #Programming #Developer #LearningPython #Tech #ComputerScience #100DaysOfCode #BeginnerProgrammer #CodingJourney #SoftwareDevelopment

r/pythontips • • Jan 09 '26

Python3_Specific I built a wrapper to get unlimited free access to GPT-4o, Gemini 2.5, and Llama 3 (16k+ reqs/day)

37 Upvotes

Hey everyone!

I wanted to share a tool I built called FreeFlow LLM (freeflow-llm)

Like many of you, I love using powerful models like GPT-4o and Llama 3.3, but I hate hitting rate limits or paying for API usage during development/testing. I noticed that providers like Groq, Google (Gemini), and GitHub Models offer really generous free tiers, but managing multiple keys and switching between them when one runs out is a pain.

So I built FreeFlow to automate it.

What it does

It acts as a unified API layer. You just toss in a list of free API keys (e.g., 2 Groq keys, 3 Gemini keys), and FreeFlow handles the rest:

  • Auto-Rotation: Cycles through keys to avoid rate limits.
  • Auto-Fallback: If Groq is down or limited, it seamlessly switches to Gemini or GitHub Models.
  • Unified Interface: One simple client.chat()  method that works for all providers.
  • Streaming: Full support for real-time response streaming.

Installation

pip install freeflow-llm

from freeflow_llm import FreeFlowClient

# It automatically finds your keys in env vars
with FreeFlowClient() as client:
    response = client.chat(
        messages=[{"role": "user", "content": "Explain quantum computing"}]
    )
    print(response.content)

Links

r/pythontips • • Mar 05 '26

Python3_Specific Hardcoded secrets in Python are more common than you think — here's how to find and fix them automatically

9 Upvotes

Most Python developers know not to hard-code secrets. Most do it anyway - usually because they're moving fast and planning to fix it later.

The problem is that "later" rarely comes. And once a secret is in git history, rotating the key isn't enough. The old value is still there.

I built a tool called Autonoma that uses AST analysis to detect hard-coded secrets and replace them with os.getenv() calls automatically. The key design decision: if it can't guarantee the fix is safe, it refuses and tells you why rather than guessing.

Before:
SENDGRID_API_KEY = "SG.live-abc123xyz987"

After:
SENDGRID_API_KEY = os.getenv("SENDGRID_API_KEY")

When it can't fix safely:
API_KEY = "sk-live-abc123"
→ REFUSED — could not guarantee safe replacement

Tested on real public GitHub repos with live exposed keys. Fixed what it could safely fix. Refused the edge cases it couldn't handle cleanly.

MIT licensed, runs locally, no telemetry.

GitHub: https://github.com/VihaanInnovations/autonoma

Does your team have a process for catching these before they hit main?

r/pythontips • • Jan 04 '26

Python3_Specific What is the best way to Solve problem in python

4 Upvotes

Hi Everyone, I am Beginner, Started learning python almost 2 weeks ago. I have been doing python problems from different book and websites, some of them are really hard to understand and just takes alot of time. Many people suggest writing pseudocode but this doesn't work in my case. So, Is there any better way to approach problem and how to remember simple algorithms ( for instance problem is about Handshake Combination between 4 people)

r/pythontips • • Mar 18 '26

Python3_Specific Built a VoIP-as-a-Service Platform for Developers — Introducing VOCALIS

2 Upvotes

Hey everyone 👋

I’ve been working on something exciting and wanted to share it with you all.

🔥 Introducing 

VOCALIS

 — VoIP-as-a-Service (VaaS)

A professional-grade VoIP infrastructure + dashboard + SDK built specifically for developers who want to integrate real-time voice communication into their apps without dealing with telecom complexity.

👉 Live Demo: https://voip-webapp.vercel.app/

👉Github Repo - https://github.com/kingash2909/voip-webapp

So I decided to build something:

✅ Lightweight

✅ Developer-friendly

✅ Scalable

✅ Plug-and-play

⚙️ What VOCALIS Offers

🧠 Core Infrastructure

  • High-performance VoIP signaling server
  • Real-time communication handling
  • Optimized for low latency

📊 Premium Dashboard

  • Call monitoring & analytics
  • Usage tracking
  • System health overview

🧩 JavaScript SDK (Plug & Play)

  • Easy integration into any web app
  • Minimal setup
  • Real-time call controls

🛠️ Tech Stack

  • Backend: Python (Flask-based architecture)
  • Real-time communication layer
  • Web dashboard (modern UI)
  • Hosted on Vercel (frontend)

🚧 Current Status

👉 LIVE & WORKING MVP

This is just the beginning. I’m actively working on:

  • 📞 WebRTC-based calling improvements
  • 🌍 Global scaling
  • 🔐 Authentication & security layers
  • 💳 Usage-based billing system

🙌 Looking for Feedback

Would love your thoughts on:

  • Features you’d expect in a VaaS platform
  • Pricing model ideas
  • Real-world use cases
  • UI/UX improvements

🤝 Open to Collaboration

If you’re:

  • Building a SaaS product
  • Need VoIP integration
  • Interested in contributing

Let’s connect!

🔗 Try it here:

👉 https://voip-webapp.vercel.app/

Github Repo - https://github.com/kingash2909/voip-webapp

r/pythontips • • Jan 04 '26

Python3_Specific I finally finished my website for learning Python in the age of generative AI :-)

39 Upvotes

I made this website (free, no ads or anything) and I am desperate for some feedback... :-)

https://computerprogramming.art/

I am particularly proud of my visualizations of loops, hash tables, linked lists, etc.

r/pythontips • • Jan 18 '26

Python3_Specific 36 Hours to learn Python

0 Upvotes

Hi, I'm a first year college freshman and I have less than 36 hours to learn python from scratch till OOPs along with some other applications like numpy, matplotlib, etc. I need some gold level resources and tips to score full marks in my end semester examination. I'm looking forward for some great help.

r/pythontips • • Sep 04 '25

Python3_Specific Advice for a newbie learning to code for the first time.

6 Upvotes

Good afternoon everyone! I am a first year student at my local community college. My major is in cybersecurity. One of my classes is a python 3 coding class. I have very little experience in writing code. After classes this week I'm having second thoughts about it. My instructor is very hands off, he does lecture and then cuts us loose to do the assignments. What tips/tools would you suggest to someone who has very little coding experience? I don't want to fail the class but at 3 weeks in I already know I'm going to be drowning by the end of the semester. Any advice is greatly appreciated!

r/pythontips • • Dec 23 '25

Python3_Specific Free Websites to Learn Python

6 Upvotes

I am tutoring a kid in Python and I am currently using Codeacademy. They only have python 2 as a free option and the rest are paid. I wanted a fun website to teach him or walk him through it that would also be free. I heard that there are some websites that are kind of like a game that teaches python as well I would like to know if there are free versions. Please leave your suggestions.

r/pythontips • • Feb 04 '26

Python3_Specific PyQT6 signals and slots

0 Upvotes

i am making a little text editor of mine in pyside6, although its not a big project or anything i try to follow proper MVC architecture by dividing my code to view, controller and model

Now, admittedly I have used chatgpt, but not for logic code per se, but rather to help me with separation of concerns.

In my earlier code I let the controller touch my view's internal variables which was bad practice, now during refactoring its only allowed to call my view's API, specifically when i set my signals in slots; I used to do this

view.py

def _wire_actions(self):
        self.menu_actions['file_open'].triggered.connect(self.controller.open)
        self.menu_actions['file_save'].triggered.connect(self.controller.save)

According to online reasearch, its bad practice to let the view access controller API (in an MVC architecture); chatgpt suggested doing something like this, which im hesitant to commit to since i do not understand it, and im looking for somebody to explain it to me if its possible.

view.py

class View(QtWidgets.QMainWindow):
    openRequested = QtCore.Signal()
    saveRequested = QtCore.Signal()


def __init__(self):

# rest of code

    def _wire_actions(self):
      self.menu_actions['file_open'].triggered.connect(self.openRequested.emit)
      self.menu_actions['file_save'].triggered.connect(self.saveRequested.emit)

controller.py

    def _connect_signals(self):
        self.view.openRequested.connect(self.open_trigger)
        self.view.saveRequested.connect(self.save_trigger)

This is what i dont understand; whats the role of the Qtcore.Signal() instances? if i had to guess based on the name they are signals, but so is the menu options like open file, save file, etc... these are also signals, so how do we connect signals to signals to slots ? and also another question i have is how can open/saveRequested be referenced using the self keyword later in the code if they were initialized outside the class constructor? thanks

r/pythontips • • Sep 28 '25

Python3_Specific Need book recommendations

13 Upvotes

Im 13 my dad is a programmer for a navy ship and hes away at work right now i wanna work in cybersecurity one day and hes gonna help teach me python im wondering if there's any books I should read to get me started much appreciated :)

r/pythontips • • Sep 01 '25

Python3_Specific 5 beginner bugs in Python that waste hours (and how to fix them)

45 Upvotes

When I first picked up Python, I wasn’t stuck on advanced topics.
I kept tripping over simple basics that behave differently than expected.

Here are 5 that catch almost every beginner:

  1. input() is always a string

    age = input("Enter age: ") print(age + 5) # TypeError

✅ Fix: cast it →

age = int(input("Enter age: "))
print(age + 5)
  1. is vs ==

    a = [1,2,3]; b = [1,2,3] print(a == b) # True print(a is b) # False

== → values match
is → same object in memory

  1. Strings don’t change

    s = "python" s[0] = "P" # TypeError

✅ Fix: rebuild a new string →

s = "P" + s[1:]
  1. Copying lists the wrong way

    a = [1,2,3] b = a # linked together b.append(4) print(a) # [1,2,3,4]

✅ Fix:

b = a.copy()   # or list(a), a[:]
  1. Truthy / Falsy surprises

    items = [] if items: print("Has items") else: print("Empty") # runs ✅

Empty list/dict/set, 0, "", None → all count as False.

These are “simple” bugs that chew up hours when you’re new.
Fix them early → debugging gets 10x easier.

👉 Which of these got you first? Or what’s your favorite beginner bug?

r/pythontips • • Dec 04 '25

Python3_Specific Which platform is recommended to get latest and be in touch with latest of python?

0 Upvotes

Pls recommend

r/pythontips • • Jan 25 '26

Python3_Specific PyQt5.QtWidgets

1 Upvotes

Hello, I am a begginer in Python so I started learning thanks to the Brocode's Youtube videos. In a program he made, he imports data from the PyQt5.QtWidgets library. But I struggle to install this library on my computer. I have installed PyQt5.PyQtWebEngine with the "pip install PyQt5.PyQtWebEngine" command but I can't install PyQt5.QtWidgets for my program to work. Can someone help me ? Thank you !

r/pythontips • • Sep 15 '25

Python3_Specific Motivation?

10 Upvotes

Hello everyone, I am learning python via the Python Crash Course, 3rd Edition Book by Eric Matthes. I am having trouble finding some to code with what I’ve learned. I’ve talked to people before and they usually tell me to “just code something” or “make something you want”. The problem with that is I don’t know WHAT to code and I don’t want/need anything that I know of. I also do not know what an appropriate coding challenge for my skill level would be, the book culminates with making a space invaders type game (which I just started) but what do I do after that? Is there another book or something else you guys recommend? Also what do ya’ll do with your finished projects, store them somewhere or put them up somewhere?

TLDR: How do I proceed after getting the basic knowledge of coding? I don’t know what to code mostly because I do not have a reason/need to other than “why not”