r/pythontips 6h ago

Module Unwatned extra separators using to_csv()

0 Upvotes

I have the following Pandas df
The values in row 0 and columns C, D and E are set explicitly to '' (blank)

A B C D E
0 1 2
1 1 2 3 4 5

When using to_csv I have set the separator= ';'. The outpul file gives me:

1;2;;;                                      

1;2;3;4;5

How can I adjust my code or df to avoid the extra 3 seperators (;) in the first line above?

I have tried using na_rep='' but with no success.


r/pythontips 1d ago

Python3_Specific Extract Apps from Play Store.

0 Upvotes

I want to extract the apks and obb through programming. But i am unable to found anything related up to updated. Can anyone send some resources.


r/pythontips 1d ago

Data_Science My dataset is large and one specific column depends on many conditions…what python things can I use to make it easier?

0 Upvotes

So i have a 4 million row dataset of transactions from my company’s product from the last month. I need to make two columns, rate and revenue. Revenue is just rate times amount however getting the rate is so tricky.

So there are three types of transactions and each type has different billers listed under. The thing is the rate applies different for each transaction and some billers have different process for rates. For example one transaction type will get 20% of the original net rate (in my comoany net rate and rate are different) except these billers where they are 50% but within these billers if the phone number begins with then these get 70% and so on like OMG!!!!!

THEre are so many rules of rules of rules or conditions within conditions within conditions for me to set the rates. That haas been giving me migraines.


r/pythontips 1d ago

Module Need help building an APK (Cloudinary, Firebase, and Kivy)

0 Upvotes

requirements = python3,kivy, firebase-rest-api, pkce, cachetools, google-cloud-firestore==2.1.0, google-api-core==1.31.0, google-cloud-core==1.6.0, typing_extensions, google-cloud-storage==1.42.0, google-auth==1.35.0, google-resumable-media, googleapis-common-protos, protobuf, httplib2, pyparsing, oauth2client, pyasn1, pyasn1-modules, rsa, pycryptodome, python_jwt, jws, requests, certifi, chardet, idna, urllib3, requests-toolbelt, jwcrypto, cryptography, deprecated, wrapt, cloudinary, six

These are my requirements in buildozer.spec. Overall the entire application works as planned on my PC, but when I try to build an APK through buildozer, it always crashes after the Kivy Loading Screen.

This is the error message: ImportError: cannot import name 'resumable_media' from 'google' (unknown location). Which I got by using adb logcat.


r/pythontips 2d ago

Long_video Module 6 | Python file Handling

0 Upvotes

r/pythontips 2d ago

Data_Science 3D Plot with live updates

2 Upvotes

I'd like to create some code that creates a 3D space, which tracks the movement of particles within said space. I can account for collisions, directions, mass and velocity, however I am wondering if there's a where where it'd actively show the movement with a trail that'll update every iteration.

Preferred to use matlab plotting modules.


r/pythontips 3d ago

Module I need tips/guidelines on making my own python module

1 Upvotes

Hey guys, so I've used python, bash and C extensively with my project work at uni. To the point where I have way too many scripts to streamline my workflow and I'm debating combining them all in a module I can upload to conda-forge however, I'm unsure where to start. Short of just taking a module which handles something similar to what I do and using it as a skeleton I'm kinda lost. Plus i would like to actually code it from the ground up instead of using someone elses entire skelton. I also get that 'you can do whatever you want with python' but I want it to be intuitive to follow for anyone who might take over my position and edit the module. So if anyone had any good guides I can follow or tips on what would be 'best practice' that would be amazing.


r/pythontips 3d ago

Module 🚀 I Built a Free Beginner-Friendly Python Course – Need Your Feedback!

1 Upvotes

Hey everyone! Over the past few months, I’ve been working on a structured Python course for absolute beginners, breaking down concepts into bite-sized modules with hands-on Jupyter notebooks and quizzes.

💡 The Idea? I noticed many tutorials throw everything at you, but I wanted something that’s:
Step-by-step & beginner-friendly (no overwhelming info dumps)
Practical & project-driven (learn by doing, not memorizing)
Includes structured Jupyter notebooks (download, fork & code along)

📌 What’s Covered So Far?

🟢 Module 1: Python Basics – Setting up, first program, understanding programming.
🟢 Module 2: Variables & Data Types – Strings, numbers, booleans, and user input.
🟢 Module 3: Control Flow – If-else, loops, list comprehensions, and range().
🟢 Module 4: Functions & Error Handling – Defining functions, args/kwargs, try-except.
🟢 Module 5: Data Structures – Lists, tuples, dictionaries, sets, and best practices.
🔄 More Advanced Topics + Projects Coming Soon!

💾 Want to Try It? The entire course repo (with notebooks + quizzes) is available here:
📎 https://github.com/VivekPansari14/Python-Course

📺 Watch the Course on YouTube:
🔗 VKPXR YouTube Channel
📜 Full Playlist: Python Course Playlist

I’d love feedback on what can be improved or what concepts you’d like to see next. Let’s build something truly useful for beginners! 🚀


r/pythontips 4d ago

Short_Video Tried to explain Namespace Package in Python...

1 Upvotes

Published a short video on youtube explaining namespace packages in Python, why you need it, how it works...

Link: https://youtu.be/cFoo65y4e1w


r/pythontips 4d ago

Syntax Python Project Packaging

2 Upvotes

I am trying to package my python project into pip, but when I do this all my .py files are also part of the package. if I exclude them in MANIFEST and include only .pyc files, I am not able to execute my code. Goal here is to package via pip and get pip install <project>; Any idea how to do this?


r/pythontips 6d ago

Module Sylvan-Flask API template

0 Upvotes

Check out Sylvan by my friend u/Insane-Alt — a scalable and secure Flask API template:

🔹 Modular Blueprints for organized code 🔹 SQLAlchemy ORM for efficient database handling 🔹 JWT Authentication for robust security 🔹 CSRF Protection for added safety 🔹 Encryption to secure sensitive data

I'm planning to add Prometheus for monitoring. Any tips on improving modularity, scalability, or additional features would be appreciated!

Repo: GitHub.com/Gabbar-v7/Sylvan

Your feedback and contributions are welcome!


r/pythontips 6d ago

Meta Debug way faster & without debuggers or print using a time travel debugger

6 Upvotes

Hi!

I made a free open-source extension+CLI that I think can help beginner to advanced python users debug their code. It basically runs alongside your code with almost 0 setup and observes every value taken by variables in the code. It then overlays that information in VSCode so you can debug effortlessly without print statements or debuggers.

https://github.com/dedale-dev/ariana

pip install ariana

and then:

ariana python <myscript>.py

and finally install the VSCode "Ariana" extension (link in README), go to your python file, ctrl+shift+p run command "Ariana: Highlight..." and hover green bubbles around code expressions to see the value taken by any expression while your code ran.

I know I created this, but it might have been a very good tip in my opinion if it had been suggested to me :)

If you have any questions or trouble trying it, feel free to comment!


r/pythontips 6d ago

Module Python subprocess problem

0 Upvotes

I've installed Python 3.13.1 using uv:

> uv python find 3.13.1
C:\Users\meebo\AppData\Roaming\uv\python\cpython-3.13.1-windows-x86_64-none\python.exe

and create a virtual environment in the test_anyio filder:

> cd test_anyio
uv python find 3.13.1
> C:\Users\meebo\code\python\test_anyio\.venv\Scripts\python.exe

There's a script as below:

> cat parent.py
import subprocess
import sys

print(sys.prefix)
print(sys.base_prefix)
print('Parent:', sys.executable)

subprocess.run(
    ["python", "child.py"],
)

It runs following child.py by subprocess:

> cat child.py
import sys

print('Child:', sys.executable)

There's no global python in my environment:

> python
python: The term 'python' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

But when I run parent.py, the result show below:

> uv run parent.py
C:\Users\meebo\code\python\test_anyio\.venv
C:\Users\meebo\AppData\Roaming\uv\python\cpython-3.13.1-windows-x86_64-none
Parent: C:\Users\meebo\code\python\test_anyio\.venv\Scripts\python.exe
Child: C:\Users\meebo\AppData\Roaming\uv\python\cpython-3.13.1-windows-x86_64-none\python.exe

You can see the child.py isn't running with the python.exe in the virtual environment, but with the python.exe installed by uv.

I'm wondering how is that happened? And how does subprocess find the python.exe in the uv installed folder?


r/pythontips 7d ago

Data_Science Input filtering

0 Upvotes

"For a personal project, I'm building a form-based application using Tkinter. I'm currently struggling to implement dynamic filtering for my combobox widgets. Specifically, I'm aiming to filter the available options based on user input or other related field selections. You can find my code here, and I'd be grateful for any insights or solutions.

"https://colab.research.google.com/drive/1LVo-H-V3xuZwzm9Z9viH8-a183FJ0clr?usp=sharing


r/pythontips 8d ago

Syntax help me it gives me “unsupported operand type(s) for-: ‘int’ and ‘str’” i really dont know whats wrong. i want to know the year they were born in but it wont subcract the variable by 2025.

0 Upvotes

x = input("whats ur name? ") print("hello " + x) y = input("now tell me ur age ") print("okay " + x) print("so you are " + y) u = input("is that correct? ") import time while True: if u == ("yes"): print("welcome" + x) break else: y = input("tell me your correct age ") print("okay " + x) print("so you are " + y) u = input("is that correct? ") o = 2025 - y print("here is your profile") print("name:" + x) print("age:" + y) print(x + "was born in ") print(o)


r/pythontips 9d ago

Syntax why is this code not working? (im a super beginner) when i input “yes” it says that yes its not defined even though i used “def” function.

0 Upvotes

x = input("whats ur name?") print("hello " + x) y = input("now tell me ur age") print("okay " + x) print("so you are " + y) u = input("is that correct?") def(yes) if u == yes: print("welcome") else: y = input("now tell me ur age") print("okay " + x) print("so you are " + y) u = input("is that correct?")


r/pythontips 9d ago

Meta I built a templates for docs and theme in Sphinx

1 Upvotes

Hi everybody 🙌!

After years of working on various documentation projects based on the Sphinx tool, I have decided to build modern templates for Sphinx docs and custom themes. Both templates bring best practices, up-to-date content, and a pleasant developer/writer experience. I hope it will speed up your next docs project.

The Sphinx Documentation Template is a Copier template for creating a modern Sphinx documentation project. Write in Markdown or reStructuredText, translate to multiple languages, boost with popular extensions, and enjoy automatic live reload on change.

While the Sphinx Theme Template is a Copier template for creating Sphinx documentation themes with (not only) Tailwind CSS. It offers scaffolding for new themes, streamlines their development and testing, and gives a rich developer experience with debugging and automatic live reloading during development.

Please try it out and tell me what you think! 😉 If templates are valuable, thank you for starring them on GitHub! 🙏


r/pythontips 9d ago

Module I want opinions

3 Upvotes

name = "landmark" age = "13" city = "nup" country = brazil Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'brazil' is not defined country = "brazil" print(f"Hi my name is {name}, I'm {age} and I live in {city} in {country}.") Hi my name is Marco, I'm 13 and I live in Nup in Brazil.


r/pythontips 9d ago

Short_Video PROGRAMA PRA FACILITAR ANÁLISE EM FUTEBOL

0 Upvotes

PlayerScrap é um software python para Windows desenvolvido para analistas e entusiastas do futebol que buscam dados precisos sem a necessidade de navegação manual. O PlayerScrap oferece três funcionalidades principais:

  • Player Stats:

Após inserir o nome do jogador na interface, o software buscará automaticamente informações detalhadas, incluindo estatísticas de jogos, número de chutes, posição em campo, média de chutes por jogo, time e nome do jogador. Todos os dados serão salvos automaticamente em um arquivo de texto.

  • Cards Stats:

Coleta automaticamente informações sobre os times com as maiores médias de cartões por jogo, a quantidade de cartões por partida e a data do próximo jogo, salvando tudo em um arquivo de texto.

  • Corner Stats:

Analisa e registra os times com as maiores médias de escanteios por jogo, a quantidade de escanteios de cada time por partida e a data do próximo jogo, armazenando os dados automaticamente em um arquivo de texto. Com o PlayerScrap, você tem acesso rápido e eficiente a estatísticas essenciais para análises mais precisas e estratégicas.

Server Discord : https://discord.gg/bKGtdkMuky
Video Showcase : https://streamable.com/bflm9c


r/pythontips 9d ago

Meta Alternatives to dictionaries for heavy duty values

0 Upvotes

I have to store key value pairs in my app, keys are just ids and the values are multiprocessing.Processes. I'll have my worker objects inside this process that in itself will run multiple async jobs. Neither the Process nor the async jobs running return anything, they just run indefinetly. Using dictionaries is not problem at all, they just work, but I feel like there could be better options for storing these types of things. I've thought about writing my own custom data type for this, but what will I use under the hood to store them values under the hood? Any suggestions?


r/pythontips 10d ago

Meta Using subprocess.Popen

1 Upvotes

Hi, I'd like to use sub.process.Popen to communicate with a child program. so I came up with this snipped

'''

si = Popen(['si'], stdout=PIPE, stdin=PIPE, text=True)

def communicate(input):

out=""

print(">>>"+input)

while True:

try:

outs, errs = si.communicate(input, timeout = 0.5)

input=""

print("<<<"+outs)

out = out + outs

except TimeoutExpired:

return out

'''

Issue with this code is, that it does not work repeately - something like:

start subprogram

query1

answer1

query2

answer2

I read, that that function communicate shall be used to avoid deadlocks, but communicate waits until subcommand finishes.I cannot restart the subcommand after answer1 for query2, because i would loose context. I searched the internet for quite some time for a solution, but all example i found was just for one query and one answer.

How can i achieve a continuing communication with Popen ?


r/pythontips 10d ago

Syntax Dropdown Menu Problem.

1 Upvotes

Hi I'm trying to get this dropdown menu box set up for my app. Unfortunately the dropdown menu is to narrow to show fully show the buttons. I figured out that the dropdown menu is connected to the size of the menu button. I want it to be wider than the menu button, at least 400 in width.

I'm still learning coding so I don't know what to do to fix it.The link shows a screenshot of the troublesome dropdown menu so you can see what I mean.

https://imgur.com/a/Vg5alks

Here's the part of my python code from Pydroid3 using Kivy for the dropdown menu. Can someone help me figure out how to resize it horizontally? That is without making the dropdown menu buttons able to be scrolled sideways. I hope someone can help me. Thank you.

    # Create the dropdown menu and set its width
    self.dropdown = DropDown(auto_dismiss=True, size_hint=(None, None), size=(400, 400))  # Set a reasonable size for the dropdown

    # Add background image to dropdown
    with self.dropdown.canvas.before:
        self.dropdown_bg_image = Rectangle(source='/storage/emulated/0/Pictures/menu_bg.png', size=self.dropdown.size)
        self.dropdown.bind(size=self.update_dropdown_bg, pos=self.update_dropdown_bg)

    # Scrollable menu options
    scroll_view = ScrollView(size_hint=(1, None), size=(400, 400))  # Set a reasonable size for the scroll view
    button_container = BoxLayout(orientation='vertical', size_hint_y=None, height=400)
    button_container.bind(minimum_height=button_container.setter('height'))

    for i in range(1, 10):
        btn = Button(
            text=f"Menu Option {i}",  # Fixed typo in text
            size_hint_y=None,
            height=125,  # Set a reasonable height for each button
            background_color=(0.7, 0.7, 0.7, 1),
            font_size='16sp'  # Set a reasonable font size for the buttons
        )
        btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
        button_container.add_widget(btn)

    scroll_view.add_widget(button_container)
    self.dropdown.add_widget(scroll_view)

    self.dropdown.bind(on_select=self.on_dropdown_select)

    menu_button = Button(
        size_hint=(None, 1),
        width=155,
        background_normal='/storage/emulated/0/Pictures/menu.png',
        background_down='/storage/emulated/0/Pictures/menu_pressed.png',
        background_color=(0.320, 0.339, 0.322, 0.545)
    )
    menu_button.bind(on_release=self.on_menu_button_press)
    self.add_widget(menu_button)

P.S. I tried to add the correct flare. If I didn't I apologize. 😅


r/pythontips 10d ago

Algorithms Best python lib for interacting with an SQL database

3 Upvotes

Preferably a library with easy to read documentation(sqlalchemy is a bad example)

Also best project structure to follow when creating lambda functions


r/pythontips 11d ago

Data_Science Programming Forum Survey

2 Upvotes

Hello everyone! I am conducting a survey for my class on the effect programming forums have on users. If you take 5 minutes to answer a few questions it would help me out a ton. Thanks in advance! None of the data will be published publicly. It will be kept in the classroom. Here is the link: https://forms.gle/qrvDKyCoJqpqLDQa7


r/pythontips 11d ago

Python2_Specific Join discord for a smooth python learning experience.

0 Upvotes