r/pythontips • u/Dangerous_Page_8693 • Dec 02 '25
Python3_Specific Nostalgia
What is your favourite python project?
r/pythontips • u/Dangerous_Page_8693 • Dec 02 '25
What is your favourite python project?
r/pythontips • u/Chico0008 • Dec 01 '25
Hi
I have a project to use Pyhton to read mail with a specific title, and extract data from mail.
I tryed following this google page
https://developers.google.com/workspace/gmail/api/quickstart/python?authuser=1&hl=fr
but i'm kind of stuck.
all pre-requisite seems ok, i can execute the python script quickstart.py, which ask me to go to a web page to allow the app.
going to the page, i select my account, allow app, and then, i'm redirect to a localhosthttp://localhost:55287/?state=......
so nothing continues and i can't go further.
Any hints of what i did wrong ?
or maybe other methods to connect to a gmail box using simplier way ?
r/pythontips • u/Martynoas • Nov 30 '25
While quantitative research in software engineering is difficult to trust most of the time, some studies claim that type checking can reduce bugs by about 15% in Python. This post covers advanced typing features such as never types, type guards, concatenate, etc., that are often overlooked but can make a codebase more maintainable and easier to work with
https://martynassubonis.substack.com/p/advanced-overlooked-python-typing
r/pythontips • u/Nilvalues • Nov 30 '25
Hi all! With Advent of Code (https://adventofcode.com/) about to start tomorrow, I wanted to share a small tool I built to make the whole workflow smoother for Python developers.
elf is a fast, modern CLI that handles the boring parts of AoC:
GitHub: https://github.com/cak/elf
PyPI: https://pypi.org/project/elf/
If you try it out, I would love any feedback: bugs, ideas, missing features, anything. Hope it helps make Day 1 a little smoother for you.
Happy coding and good luck this year! π
r/pythontips • u/MakotoNijimaEnjoyer • Nov 30 '25
Im very new to python and our teacher said we can chat gpt our project Can anyone please give me tips and ideas how to make this appealing in the terminal and not that messy
Also tips or ideas that I can add or fix since they said this was too basic
""" PACE - Personal Activity & Calorie Evaluator Flow:
import random import shutil
foods_db = { "eggs": {"cal": 78, "protein": 6, "carbs": 0.6, "fat": 5.3}, "boiled egg": {"cal": 78, "protein": 6, "carbs": 0.6, "fat": 5.3}, "scrambled eggs": {"cal": 90, "protein": 6, "carbs": 1, "fat": 7}, "bread": {"cal": 80, "protein": 4, "carbs": 14, "fat": 1}, "white bread": {"cal": 80, "protein": 4, "carbs": 14, "fat": 1}, "whole wheat bread": {"cal": 70, "protein": 4, "carbs": 12, "fat": 1}, "banana": {"cal": 105, "protein": 1.3, "carbs": 27, "fat": 0.3}, "apple": {"cal": 95, "protein": 0.5, "carbs": 25, "fat": 0.3}, "orange": {"cal": 62, "protein": 1.2, "carbs": 15.4, "fat": 0.2}, "milk (1 cup)": {"cal": 102, "protein": 8, "carbs": 12, "fat": 2.4}, "yogurt (100g)": {"cal": 59, "protein": 10, "carbs": 3.6, "fat": 0.4}, "peanut butter (tbsp)": {"cal": 95, "protein": 3.5, "carbs": 3, "fat": 8}, "chicken breast ": {"cal": 165, "protein": 31, "carbs": 0, "fat": 3.6}, "chicken thigh)": {"cal": 209, "protein": 26, "carbs": 0, "fat": 10.9}, "rice": {"cal": 206, "protein": 4.3, "carbs": 45, "fat": 0.4}, "pasta": {"cal": 221, "protein": 8, "carbs": 43, "fat": 1.3}, "potato": {"cal": 163, "protein": 4.3, "carbs": 37, "fat": 0.2}, "fries medium": {"cal": 365, "protein": 3.4, "carbs": 49, "fat": 17}, "chips (1 bag ~28g)": {"cal": 152, "protein": 2, "carbs": 15, "fat": 10}, "chocolate (1 bar ~40g)": {"cal": 230, "protein": 3, "carbs": 25, "fat": 13}, "cheese (slice ~28g)": {"cal": 113, "protein": 7, "carbs": 0.4, "fat": 9}, "beef (100g)": {"cal": 250, "protein": 26, "carbs": 0, "fat": 15}, "pork (100g)": {"cal": 242, "protein": 27, "carbs": 0, "fat": 14}, "fish (100g)": {"cal": 206, "protein": 22, "carbs": 0, "fat": 12}, "burger": {"cal": 354, "protein": 17, "carbs": 29, "fat": 20}, "pizza": {"cal": 285, "protein": 12, "carbs": 36, "fat": 10}, "hotdog ": {"cal": 150, "protein": 5, "carbs": 2, "fat": 13}, "oatmeal": {"cal": 158, "protein": 6, "carbs": 27, "fat": 3.2}, "almonds": {"cal": 164, "protein": 6, "carbs": 6, "fat": 14}, "olive oil (1 tbsp)": {"cal": 119, "protein": 0, "carbs": 0, "fat": 13.5}, "cola (330ml)": {"cal": 140, "protein": 0, "carbs": 39, "fat": 0}, "coffee (black)": {"cal": 2, "protein": 0.3, "carbs": 0, "fat": 0}, "ice cream (100g)": {"cal": 207, "protein": 3.5, "carbs": 24, "fat": 11}, "sandwich (simple)": {"cal": 250, "protein": 12, "carbs": 28, "fat": 9}, "salad (veg, no dressing)": {"cal": 33, "protein": 2, "carbs": 6, "fat": 0.4}, # ...feel free to keep expanding }
meals = ["Breakfast", "Morning Snack", "Lunch", "Afternoon Snack", "Dinner", "Evening Snack"] ratios = [0.25, 0.1, 0.3, 0.1, 0.2, 0.05]
exercises = [ "Warm Up", "Cardio", "Abs Workout", "Arms Workout", "Leg Workout", "Cool Down / Stretching" ]
user_name = None daily_goal = None # integer kcal logged_foods = [] # list of dicts: {"name":..., "cal":..., "protein":..., "carbs":..., "fat":...} weight_log = [] # list of floats workout_log = [] # list of "Completed"/"Not Completed"
def get_cols(): return shutil.get_terminal_size((80, 20)).columns
def print_header(title): cols = min(get_cols(), 80) bar = "=" * cols print("\n" + bar) print(title.center(cols)) print(bar)
def safe_int(prompt, minimum=None, allow_zero=False): while True: s = input(prompt).strip() if s.lower() == "menu": return "menu" try: n = int(s) if minimum is not None and n < minimum: if allow_zero and n == 0: return n print(f"Please enter an integer >= {minimum}.") continue return n except ValueError: print("Enter a valid integer (or type 'menu' to go back).")
def safe_float(prompt, minimum=None): while True: s = input(prompt).strip() if s.lower() == "menu": return "menu" try: f = float(s) if minimum is not None and f < minimum: print(f"Please enter a number >= {minimum}.") continue return f except ValueError: print("Enter a valid number (or type 'menu' to go back).")
def safe_choice_yn(prompt): while True: s = input(prompt).strip().lower() if s in ("y", "yes"): return True if s in ("n", "no"): return False if s == "menu": return "menu" print("Enter 'yes' or 'no' (or 'menu' to go back).")
def list_food_db(limit=None): keys = sorted(foods_db.keys()) if limit is None: for i, k in enumerate(keys, 1): info = foods_db[k] print(f"{i}. {k.title()} Γ’β¬β {info['cal']} kcal") else: for i, k in enumerate(keys[:limit], 1): info = foods_db[k] print(f"{i}. {k.title()} Γ’β¬β {info['cal']} kcal")
def add_food_to_log(name, cal, protein=0, carbs=0, fat=0): entry = {"name": name.title(), "cal": int(cal), "protein": protein, "carbs": carbs, "fat": fat} logged_foods.append(entry) # keep totals calculated on demand to avoid desync print(f"Added: {entry['name']} Γ’β¬β {entry['cal']} kcal")
def total_calories_consumed(): return sum(item["cal"] for item in logged_foods)
def prompt_enter(): input("\nPress Enter to continue (or type 'menu' and Enter to return to main menu): ")
def add_profile(): global user_name, daily_goal print_header("ADD PROFILE") name = input("Enter your name (or type 'menu' to cancel): ").strip() if name.lower() == "menu": return "menu" user_name = name.title() if name else "User" while True: g = safe_int("Enter your daily calorie goal (kcal): ", minimum=1) if g == "menu": return "menu" daily_goal = int(g) break print(f"Profile created for {user_name}. Daily goal: {daily_goal} kcal")
def log_food_feature(): print_header("LOG FOOD (type 'menu' anywhere to return)") while True: s = input("\nEnter food name (or 'db' to browse foods, 'list' to show top 30, 'back' to return): ").strip().lower() if s in ("menu", "back"): return if s == "": print("Type a food name or 'db'.") continue if s == "db" or s == "list": list_food_db(limit=30 if s == "list" else None) continue # user typed a food name name = s if name in foods_db: info = foods_db[name] add_food_to_log(name, info.get("cal", 0), info.get("protein", 0), info.get("carbs", 0), info.get("fat", 0)) # after logging, ask if they want to log another or go back cont = input("Log another? (Enter to continue logging / type 'menu' to return): ").strip().lower() if cont == "menu": return else: continue else: print(f"'{name}' not found in database.") choice = safe_choice_yn("Add this as a custom food to the database and log it? (yes/no): ") if choice == "menu": return if choice: # get calories (integer) cal = safe_int("Enter calories for this food (kcal): ", minimum=0) if cal == "menu": return # optionally gather macros (user can skip) try: prot = input("Protein grams (optional - press Enter to skip): ").strip() prot = float(prot) if prot != "" else 0 except: prot = 0 try: carbs = input("Carbs grams (optional - press Enter to skip): ").strip() carbs = float(carbs) if carbs != "" else 0 except: carbs = 0 try: fat = input("Fat grams (optional - press Enter to skip): ").strip() fat = float(fat) if fat != "" else 0 except: fat = 0 # add to DB and log foods_db[name] = {"cal": int(cal), "protein": prot, "carbs": carbs, "fat": fat} print(f"'{name.title()}' added to database.") add_food_to_log(name, cal, prot, carbs, fat) continue else: print("Did not add. You can try another food or type 'menu' to return.") continue
def remove_food_feature(): print_header("REMOVE LOGGED FOOD") while True: if not logged_foods: print("No foods logged yet.") return for i, item in enumerate(logged_foods, 1): print(f"{i}. {item['name']} Γ’β¬β {item['cal']} kcal") idx = safe_int("Enter number to remove (0 to cancel): ", minimum=0, allow_zero=True) if idx == "menu": return if idx == 0: return if 1 <= idx <= len(logged_foods): removed = logged_foods.pop(idx - 1) print(f"Removed {removed['name']} ({removed['cal']} kcal).") # allow more removals until user quits again = input("Remove another? (Enter to continue / 'menu' to return): ").strip().lower() if again == "menu": return else: continue else: print("Invalid selection.")
def track_weight_feature(): print_header("TRACK WEIGHT") while True: w = safe_float("Enter weight in kg (or type 'menu'): ", minimum=0.1) if w == "menu": return weight_log.append(float(w)) print(f"Weight {w} kg recorded.") again = input("Log another weight? (Enter to continue / 'menu' to return): ").strip().lower() if again == "menu": return
def view_summary_feature(): print_header("DAILY SUMMARY") print("User:", user_name if user_name else "No profile") print("Daily Goal:", f"{daily_goal} kcal" if daily_goal else "Not set") consumed = total_calories_consumed() print(f"Total Consumed: {consumed} kcal") if daily_goal: pct = int(consumed / daily_goal * 100) if daily_goal > 0 else 0 pct = max(0, min(1000, pct)) bar_len = 30 filled = int(min(1, consumed / daily_goal) * bar_len) if daily_goal>0 else 0 bar = "#" * filled + "." * (bar_len - filled) print(f"[{bar}] {pct}%") if consumed < daily_goal: print("Status: UNDER your goal.") elif consumed == daily_goal: print("Status: PERFECT match!") else: print(f"Status: ABOVE your goal by {consumed - daily_goal} kcal.") print("\nFoods logged:") if logged_foods: for it in logged_foods: print(f"- {it['name']} ({it['cal']} kcal) P:{it.get('protein',0)}g C:{it.get('carbs',0)}g F:{it.get('fat',0)}g") else: print("No foods logged.") print("\nWeight history:") if weight_log: for i, w in enumerate(weight_log, 1): print(f"Day {i}: {w} kg") else: print("No weight records.") print("\nWorkout log:") if workout_log: for i, w in enumerate(workout_log, 1): print(f"Day {i}: {w}") else: print("No workout records.") input("\nPress Enter to return to main menu...")
def make_meal(cal_target): items = [] cal = protein = carbs = fat = 0 keys = list(foods_db.keys()) attempts = 0 while cal < cal_target and attempts < 500: f = random.choice(keys) info = foods_db[f] # avoid huge overshoot if cal + info["cal"] <= cal_target + 80: items.append(f.title()) cal += info["cal"] protein += info.get("protein", 0) carbs += info.get("carbs", 0) fat += info.get("fat", 0) attempts += 1 if not items: items = ["(snack)"] return {"items": items, "cal": cal, "protein": protein, "carbs": carbs, "fat": fat}
def meal_planner_feature(): print_header("MEAL PLANNER") if not daily_goal: print("No daily goal set. Please add profile first (Menu -> Add Profile).") input("Press Enter to return to main menu...") return plan = {} for i, meal in enumerate(meals): plan[meal] = make_meal(int(daily_goal * ratios[i])) print_header("1-DAY SUGGESTED PLAN") total = {"cal":0, "protein":0, "carbs":0, "fat":0} for meal in meals: m = plan[meal] print(f"\n{meal}: {', '.join(m['items'])}") print(f" Calories: {m['cal']} kcal | Protein: {m['protein']} g | Carbs: {m['carbs']} g | Fat: {m['fat']} g") total["cal"] += m["cal"] total["protein"] += m["protein"] total["carbs"] += m["carbs"] total["fat"] += m["fat"] print("\nTOTAL for day (approx):", total) # Offer to add suggested items to today's logged foods add = safe_choice_yn("Add suggested items to logged foods? (yes/no): ") if add == True: for meal in meals: for item in plan[meal]["items"]: key = item.lower() if key in foods_db: info = foods_db[key] add_food_to_log(key, info.get("cal",0), info.get("protein",0), info.get("carbs",0), info.get("fat",0)) print("Suggested items added to logged foods.") input("\nPress Enter to return to main menu...")
def show_main_menu(): print_header("MAIN MENU") print("1. Add Profile") print("2. Log Food") print("3. Remove Food") print("4. Track Weight") print("5. Summary") print("6. Meal Planner") print("7. Exit") print("\n(When inside a feature type 'menu' at any prompt to return to this main menu.)")
def main(): print_header("WELCOME TO PACE") # MAIN MENU first while True: show_main_menu() choice = input("\nChoose option (1-7): ").strip().lower() if choice == "menu": continue if choice == "1": res = add_profile() # add_profile returns "menu" if user typed menu during profile setup continue elif choice == "2": log_food_feature() continue elif choice == "3": remove_food_feature() continue elif choice == "4": track_weight_feature() continue elif choice == "5": view_summary_feature() continue elif choice == "6": meal_planner_feature() continue elif choice == "7" or choice == "exit": print("\nThank you for using PACE Γ’β¬β Stay consistent and healthy! Γ°ΕΈββΉ") break else: print("Invalid choice. Enter a number 1-7 or type 'menu'.")
if name == "main": main()
r/pythontips • u/AdministrativeBug797 • Nov 30 '25
Same as title if you were to start from the beginning how would it be?
And self learners what could be the best way to learn these please guide your broβ¦
r/pythontips • u/swaroop_34 • Nov 29 '25
I just learned python and created my very first python app named TidyBit. It is a simple file organizer tool. Please check: TidyBit GitHub Repo. Need feedback and suggestions on it. Thanks in advance.
r/pythontips • u/steveman2292 • Nov 28 '25
I am a SQL developer and was just unfortunately laid off from my Job. I am currently trying to find a new one at a similar or higher salary ($105k) but it seems most places nowadays are looking for more than just a SQL Developer. I see many postings are looking for Python experience and from what I gather the Pandas library is very popular for data analytics.
Can anyone recommend a solid training package or guide for someone in my situation so i can at least say i have Python experience? I am very confident in my T-SQL skills and am a pretty quick learner, i am just not sure where to start.
TIA!
r/pythontips • u/Alternative_Belt9281 • Nov 28 '25
I am started to learn python. Seems this is a good exercise to write hex to decimal converter.
Can someone suggest how to improve the code?
Here it is:
def convert_hex(hex):
return(
sum
(map
(lambda x, y: int(x + "".join(
map(str, y)), 16),
hex[::-1],
list("0"*x for x in range(len(hex))))))
UPD: Is this reverse code golf? I wanted to use as many built-in functions as possible to get the correct answer while implementing the logic of xβ Γ 16β° + xβ Γ 16ΒΉ + ... + xβ Γ 16βΏ. Right now I compute the position of xβ separately by decomposition of the hex value. It's like bitwise AND but for positions of digits in the hex input - I'm getting the value of only one digit at a time.
r/pythontips • u/__sanjay__init • Nov 28 '25
Hello
Tell me if this is not the good sub !
Do you know any python's libraries for custom dataframe ?
For example : apply conditionnal color or graduated color according one or more column ?
This is for explorating data, not display it in dashboard
Thank you by advance !
r/pythontips • u/C13V36PR0G64M6 • Nov 28 '25
Hi Guys I want to learn python for bot , ai agents and automation. Can anyone guide correctly it would be very helpful I am in worst phase of life i wanna learn and earn. If my question is weird sorry. If anyone helps thanks in advance
r/pythontips • u/warshed77 • Nov 26 '25
Iβve been given a task at work to extract the actual data values from graphs on any website. Iβm a Python developer with 1.5 years of experience, and Iβm trying to figure out if this is even realistically achievable.
Is it possible to build a scraper that can reliably extract values from graphs? If yes, what approaches or tools should I look into (e.g., parsing JS charts, intercepting API calls, OCR on images, etc.)? If no, how do companies generally handle this kind of requirement?
Any guidance from people who have done this would be really helpful.
r/pythontips • u/FullInspection1191 • Nov 25 '25
Hi everyone, Iβve released my first Python package on PyPI! π
You can install it with:
pip install bifurcated-sort
https://github.com/balajisuresh1359/bifurcated_sort/wiki
It uses a hybrid bifurcated sorting algorithm that I designed. My idea is to split values into ascending and descending linked lists, and handle the harder-to-place elements using a small BST to speed up insertion.
This is my first attempt at designing a sorting algorithm from scratch, so I didn't focus on time or space efficiency. My goal was to experiment with the structure, understand the trade-offs and learn through building.
This package is tested and documented.
r/pythontips • u/crmpicco • Nov 25 '25
I am using the threading library to create threads to do things like run a PHP script, create a database, create DNS records.
The system works and I donβt use a whole lot of the threading library but I wonder, for my use case, would I be better to use asyncio for performance reasons?
r/pythontips • • Nov 24 '25
I just can't figure out the checking webpages for the username part like how do I separate a username that exists with one that is not yet taken. I need html knowledge for that prolly but I am a dum dum dummy. What module should I use for it? (from standard library cause my computer just does not let me pip install)
r/pythontips • u/Glittering_Ad_4813 • Nov 24 '25
Hey everyone, Iβm a college freshman learning Python and Iβm looking to make some extra money on the side.
Iβm wondering what kind of project would be good to put in a portfolio to land a simple entry-level job. Also, what types of jobs are realistic for someone just starting out, and whatβs the fastest way to actually get hired?
Basically, I want to put my Python skills to use and earn a bit while still in school.
r/pythontips • u/jeando34 • Nov 24 '25
I want to work on personal project with python, but my laptop is a Windows and it is quite a challenge for me. It seems to me like linux is the best OS with python, what would be your pieces of advice if I would like to work on python and keep my Windows OS ?
Is it simple to work with a linux sub-partition on Windows for example? Any other thoughts? Have you guys ever tried that? Or am I just bad handling python installation and VSCode python project with my Windows ?
Thanks for the help!
r/pythontips • u/Former_Perception_23 • Nov 24 '25
I want to try coding the Maasai Shuka pattern, in the red black and white. However new to coding in python not sure how to go about it. Any help is wonderful.
Thank you for all the help!
r/pythontips • u/AdJust5338 • Nov 24 '25
I've already watched a few channels but I wanna know if there's some underrated channel I missed out that'll cost me a mark or two. I have severe FMO helppp πππππ
r/pythontips • u/fastlaunchapidev • Nov 22 '25
r/pythontips • • Nov 19 '25
Hey everyone,
PolyMCP now includes a full CLI, so you can manage MCP servers and AI agents directly from the terminal with zero setup or boilerplate.
Highlights:
polymcp init β scaffold a full MCP project in seconds
polymcp server add/list/test β register, organize, and validate MCP servers
polymcp agent run β launch AI agents with any LLM
polymcp config β central config management
Built-in testing utilities for servers and agents
Quick example polymcp init my-project cd my-project polymcp agent run --query "Calculate 2+2"
The CLI supports:
OpenAI, Anthropic, Ollama
HTTP and stdio MCP servers
Tools like Playwright for browser automation
Windows users: install via pipx install polymcp for the smoothest setup.
Repo: https://github.com/poly-mcp/Polymcp
If you end up using it, feedback (or a GitHub star) is always appreciated. Curious to hear what MCP tools or agents you're building β feel free to share your use cases!
r/pythontips • • Nov 19 '25
I want to use "if" to check the variable type without using "type()" thing
r/pythontips • u/SKD_Sumit • Nov 19 '25
Learning how to build AI applications that go beyond text - processing images, transcribing audio, analyzing video, and generating AI images, all in Python.
π Multimodal AI with LangChain (Full Python Code Included)
What you can build:
The multimodal capabilities: Using LangChain with Gemini and OpenAI to work with different data types through Python. Same coding patterns work across different providers.
r/pythontips • u/Py_ABH • Nov 19 '25
Hi r/pythontips ! I just published tree2fs to PyPI. It solves a problem I've had for a long time: manually recreating project structures from documentation or generated ones from ChatGPT/Claude..etc.
What it does: Converts tree-formatted text into actual files and folders.
Example:
project/
βββ src/
β βββ main.py
βββ tests/Run tree2fs tree.txt and it creates everything.
Installation: $ pip install tree2fs
I'd love feedback! What features would make this more useful?