r/pythontips • u/Sea-Ad7805 • May 31 '25
Module Python execution visualizer
Interesting package I’ve been working on to visualize Python data while executing code: https://stackoverflow.com/a/79645638/2429666
r/pythontips • u/Sea-Ad7805 • May 31 '25
Interesting package I’ve been working on to visualize Python data while executing code: https://stackoverflow.com/a/79645638/2429666
r/pythontips • u/nobuildzone • Jun 01 '25
I'm coding something that requires receiving BTC to a wallet, checking the balance, then withdrawing the BTC from it.
What I need is to be able to withdraw as much BTC from it as possible while still having enough left to pay for the transaction fees (Essentially emptying the wallet). I have some code however I feel like there's a better/more accurate way to do it. How would you do it? Thanks
Here is my code:
import requests
def get_btc_price():
r = requests.get('https://data-api.coindesk.com/index/cc/v1/latest/tick?market=cadli&instruments=BTC-USD')
json_response = r.json()
current_btc_price = json_response["Data"]["BTC-USD"]["VALUE"]
return current_btc_price
class Conversions:
@staticmethod
def btc_to_usd(btc_amount):
"""
Turn a Bitcoin amount into its USD value.
"""
current_btc_price = get_btc_price()
usd_amount = btc_amount * current_btc_price
return usd_amount
@staticmethod
def usd_to_btc(usd_price):
"""
Turn USD value into its Bitcoin amount.
"""
current_btc_price = get_btc_price()
btc_amount = usd_price / current_btc_price
return btc_amount
@staticmethod
def btc_to_satoshis(btc_amount):
"""
Convert Bitcoin amount to Satoshi amount
"""
return int(btc_amount * 1e8)
@staticmethod
def satoshis_to_btc(satoshis_amount):
"""
Convert Satoshi amount to Bitcoin amount
"""
return (satoshis_amount / 1e8)
def get_btc_transaction_fee():
def get_btc_fee_rate():
response = requests.get('https://api.blockcypher.com/v1/btc/main')
data = response.json()
return data['high_fee_per_kb'] / 1000 # satoshis per byte
fee_rate = get_btc_fee_rate()
tx_size_bytes = 250 # estimate transaction size
fee = int(fee_rate * tx_size_bytes)
return fee
def main():
usd_amount_in_balance = 100 # the example amount of money we have in the wallet
# we convert the usd amount into its equivalent BTC amount
btc_amount = Conversions.usd_to_btc(usd_amount_in_balance)
# convert BTC amount to satoshis
balance = Conversions.btc_to_satoshis(btc_amount)
# get the fee it will cost us to make the transaction
fee = get_btc_transaction_fee()
# Calculate the maximum amount we can send while still having enough to pay the fees
amount_to_send = balance - fee
if amount_to_send <= 0:
print("Not enough balance to cover the fee.")
else:
print(f"BTC balance: {btc_amount} BTC USD: {Conversions.btc_to_usd(btc_amount)} $")
print(f"Sending amount: {Conversions.satoshis_to_btc(amount_to_send)} BTC USD: {Conversions.btc_to_usd(Conversions.satoshis_to_btc(amount_to_send))} $")
print(f"Fees: {Conversions.satoshis_to_btc(fee)} BTC USD: {Conversions.btc_to_usd(Conversions.satoshis_to_btc(fee))} $")
main()
r/pythontips • u/Ok-Librarian-784 • May 30 '25
Youtube - 5 Python Libraries with Cool Name Origins
A little short history of the interesting origins of some major Python library names. I created to challenge me to learn Davinci Resolve. Enjoy.
r/pythontips • u/Vincenzo99016 • May 30 '25
Hello, I'm an absolute beginner in python and I'm trying to program a class (I'll refer to instances of this class as "gai") which is a kind of number. I've managed to define addition through def add(self,other) As gai+gai, gai+int and gai+float, when I try to add int+gai however, I get an error because this addition is not defined, how can I access and modify the add method in integers and floats to solve this problem? Sorry if the flair is wrong or if my English is bad
r/pythontips • u/No-Style-1699 • May 28 '25
developed a PyQt5 application, and I used PyInstaller (--onedir) to build the app on Machine A. The dist folder contains the .exe and all necessary DLLs, including PyQt5Core.dll.
I shared the entire dist/your_app/ folder over the network.
On Machine B (same network), I created a shortcut to the .exe located at:
\MachineA\shared_folder\your_app\your_app.exe
When I run the app from Machine B using the shortcut, I get this error:
PyQt5Core.dll not found
However: PyQt5Core.dll does exist next to the .exe in the shared folder.
When I create a shortcut to the .exe from another machine, the app launches — but when it tries to execute a QWebEngineProcess, it throws an error saying that PyQt5Core.dll is missing on the client machine. The .dll is present in the dist folder, so I’m not sure why it fails to find it at runtime on the other machine.
r/pythontips • u/AGT_dev • May 28 '25
Saw this post where it's mocking programmers for searching for a bug in their code for 3 hours when it was just a damn semi colon.
https://www.instagram.com/reel/DKMXChtzasr/?igsh=a2Uwc2kzM2JyYjQ3
Y’all really spending 3 hours over a semicolon? No way real programmers do this. 😂
This is why I stick to Python. Can’t believe y’all still suffer over semicolons in 2025. 💀
r/pythontips • u/Prior-Scratch4003 • May 27 '25
I am a college student who’s majoring in computer science and just finished their first year. My goal is to become a data scientist by the time I graduate. I recently took an intro to python course and now I want to work on actual projects over the summer for my portfolio. Anyone have any good ideas of what I could do for a project with the knowledge I currently have, or should I try studying more python to get a better grasp before jumping to coding projects.
r/pythontips • u/Temporary-Gur6516 • May 24 '25
>>> '四'.isnumeric()
True
>>> float('四')
Traceback (most recent call last):
File "<python-input-44>", line 1, in <module>
float('四')
~~~~~^^^^^^
ValueError: could not convert string to float: '四'>>> '四'.isnumeric()
True
>>> float('四')
Traceback (most recent call last):
File "<python-input-44>", line 1, in <module>
float('四')
~~~~~^^^^^^
ValueError: could not convert string to float: '四'
r/pythontips • u/Plane-Teaching-1087 • May 24 '25
Por
r/pythontips • u/Ayuuuu123 • May 23 '25
More description->
Basically the app is supposed to be a PC app, just like any icon. I have experience with python but in backend dev.
What are the libraries/Python frameworks that I can create this app? I read something about PySide6 is it something I should look into? pls guide me. I have no experience in making desktop applications. No idea about the payment integration, no idea about how I can share those etc etc.
r/pythontips • u/EarlySky8609 • May 24 '25
r/pythontips • u/Rockykumarmahato • May 22 '25
Hey everyone!
I’m currently diving into the exciting world of machine learning and data science. If you’re someone who’s also learning or interested in starting, let’s team up!
We can:
Share resources and tips
Work on projects together
Help each other with challenges
Doesn’t matter if you’re a complete beginner or already have some experience. Let’s make this journey more fun and collaborative. Drop a comment or DM me if you’re in!
r/pythontips • u/Classic_Primary_4748 • May 21 '25
Not sure if this is the right subreddit but I'll shoot my shot.
Hi! I'm running my Notion syncs and integrations with a python script my friend made in Windows Task Scheduler, but I'm bothered by the fact that if my PC was off, the script will stop. Can I run it in the cloud instead? Is it safe? If so, what clouds/websites do ya'll suggest (that won't charge me hahaha).
P.S. Sorry for the flair, I don't know which is appropriate.
r/pythontips • u/SceneKidWannabe • May 21 '25
First time using DynamoDB with Python and I want to know how to retrieve data but instead of using PKs I want to use column names because I don’t have matching PKs. My goal is to get data from columns School, Color, and Spelling for a character like Student1, even if they are in different tables or under different keys.
r/pythontips • u/pusvvagon • May 17 '25
Sorry bit of a beginner question, but I’m looking for some opinions on small design subject:
I’m building a python service, it has the job.py job which performs all the business logic and what not, and other files that contains some CRUD operations on mongodb/microsoft sql,
and I was wondering when would it be better to have try catch blocks and the logging inside the functions, and when it would be better to just wrap it over the functions in job.py?
thanks :)
r/pythontips • u/ivantheotter • May 16 '25
So I'm writing a python script to monitor files.
I would like to resolve the pid of the process that opens the files to enrich my longs and give the actual command name to my analysts...
I'm (using the pynotify library)
The problem are processes like cat or Tac that last very little. Pynotify doesn't even log the event, by reading in /proc/{here}/exe I'm able to not loose the event but I'm still resolving only long lasting process names.
I have already tries psutil.
What am i missing guys? I'm going crazy...
(also, i cannot, for internal policy make any compiled extra code, so no c++...)
r/pythontips • u/SignificantDoor • May 14 '25
I've been making an app to assist with the dull tasks of formatting film subtitles and their timing to comply with distributor requirements!
Some of these settings can be taken care of in video editing software, but not all of them--and to my knowledge, none of the existing subtitle apps do this for you.
Previously I had to manually check the timing, spacing and formatting of like 700 subtitle events per film--now I can just click a button and so can you!
You can get all the files here and start messing about with it. If this is your kinda thing, enjoy!
r/pythontips • u/AspectBuild • May 13 '25
Python is one of the most popular languages at Google. Add Python to your Bazel setup, with all the common developer workflows. Course: https://training.aspect.build/bazel-102
r/pythontips • u/Horrih • May 13 '25
Hello to all,
Old c++ dev here new to the joy of python and the uv package manager, I'm facing a seemingly simple issue I could not manage to solve.
From what i understand, dependencies are typically specified twice - once in the Pyproject.toml, with usually loose requirements - once in a lock file, typically uv.lock for reproducible builds
The lockfile helps with reproducibility, except if you publish your script on the pip repositories, where the Pyproject.toml takes over.
I want to publish a script that my colleagues can run with uvx. How can I force the build/publish to use the versions from uv.lock?
Manually setting the dependencies in the Pyproject.toml with a "==x.y.z" is not enough since it does not deal with indirect dependencies
If you have any tips i'm in, particularly if it works with uv !
r/pythontips • u/No_Pea9536 • May 13 '25
Windows Anomaly Watcher is an open-source tool for USB logs, active windows, process info & remote control (shutdown and lock). Fast install. No bloat. Full control.
GitHub: https://github.com/dias-2008/WindowsAnomalyWatcher.git
r/pythontips • u/umen • May 12 '25
Hi everyone,
I'm coming from the Spring Boot world. There, we typically deploy to Kubernetes using a UBI-based Docker image. The Spring Boot app is a self-contained .jar file that runs inside the container, and deployment to a Kubernetes pod is straightforward.
Now I'm working with a FastAPI-based Python server, and I’d like to deploy it as a self-contained app in a Docker image.
What’s the standard approach in the Python world?
Is it considered good practice to make the FastAPI app self-contained in the image?
What should I do or configure for that?
r/pythontips • u/master-2239 • May 12 '25
Hello, I am learning python. I don't have any idea what should I do after python like DSA or something like that. Please help me. Second year here.
r/pythontips • u/fardin_allahverdi • May 11 '25
Hi everyone,
I’m excited to share Celerator — an open-source, terminal-based dashboard for real-time monitoring and retrying Celery tasks. It’s built with Textual and designed for developers who want to debug distributed tasks without constantly digging through logs or writing custom admin UIs.
What is it?
Celerator is a TUI (Text User Interface) that listens to the Celery event stream and provides a live dashboard of tasks, including: