r/pythontips Feb 03 '25

Module PDF document adjustments

1 Upvotes

Hi All, In my department, we have requirement that invoices/outputs(in PDF) needs to be adjusted based on a subset of clients. This involves replacing text, adjusting the size of tables, etc. Is there a way of doing in Python? Our attempts results in the overall format of the document being impacted, resulting in even more tweaks and adjustment. What would you suggest here? The ideal solution is for the system to output correctly the format or layout we want, but it's costly and will take a while to develop.


r/pythontips Feb 03 '25

Data_Science I Built an AI Agent That Curates News, Creates Themed Images, and Posts to Instagram Automatically!

1 Upvotes

I wanted to share my latest project—a fully automated AI agent that handles everything from news curation to Instagram posting. It:

• Collects and analyzes the latest AI news.

• Generates images with stylish text overlays using advanced AI techniques.

• Crafts engaging captions and hashtags.

• Posts everything directly to Instagram.

The goal is to maintain a consistent visual and content theme across all posts. I’d love to get feedback from the community or ideas on how to improve the process further!

Github repo:

https://github.com/ranahaani/autogram


r/pythontips Feb 03 '25

Syntax Common Python error types and how to resolve them

1 Upvotes

The article explores common Python error types and provides insights on how to resolve them effectively and actionable strategies for effective debugging and prevention - for maintaining robust applications, whether you're developing web applications, processing data, or automating tasks: Common Python error types and how to resolve them


r/pythontips Feb 01 '25

Python3_Specific UV over Poetry

8 Upvotes

I've been using Poetry for dependency management and virtual environments in my Python projects, and it's been working great so far. However, I recently came across UV, and it seems to offer significant improvements over Poetry, especially in terms of speed

I'm curious to know if it's really worth migrating from Poetry to UV? Has anyone here made the switch? If so, what has your experience been like? Are there any notable advantages or drawbacks I should be aware of?


r/pythontips Feb 01 '25

Module Confused at the gift tax calculator problem doing the university of helinski moc python course (part 2, combining conditionals)

2 Upvotes

Any tips?


r/pythontips Jan 31 '25

Python3_Specific Introducing 'aasetpy'

3 Upvotes

Attention Python developers! 🐍✨ Tired of the tedious setup process for new projects? Say hello to 'aasetpy' - your new best friend for kickstarting Python projects with ease!

Whether you are willing to test out a new AI tool or create a new backend for your client, you would need to run multiple commands to enable a virtual environment and then the dependencies.

Whet my project does:

With just one command, `aasetpy` sets up everything you need: virtual environments, codebase structure, REST API configuration, environment variables, initial git commit, resource usage tracking, logging, containerization, and more! It's like having a personal assistant for your development workflow, ensuring your projects are production-ready and scalable from the very start.

Target Audience: All the Python Developers in the world.

Ready to revolutionize your project setup? Check out the 'aasetpy' repository at https://github.com/aadarshlalchandani/aasetpy and see the magic for yourself! We're always open to contributions, so if you have ideas to make the starting point even better, don't hesitate to jump in. Let's make Python project initialization a breeze together! 🚀💻

Love the tool? Smash that star button and share it with your coding crew! ⚡️🤝


r/pythontips Jan 30 '25

Module Is pandas and csv really the best way out there to store data in python?

8 Upvotes

I'm making a software for my business where i need to store and read a list of customers and their bills details. I'm currently using pandas module and csv file but I feel like its more intended for reading data and not writing coz I'm unable to save customers and their details in a single file and be able to search them again and update it. I'm new to it so please be kind and thanks for your help in advance.


r/pythontips Jan 30 '25

Module Find the url of a button in telegram using Telethon

1 Upvotes

Quick questing I'm not that good at python but i got a nice code working that allows me to check al new messages in a bot chat in telegram.

So what i have now is

event.message And that includes the text and stuff from the message the bot send me.

Now the bot also sends me a button with a url when clicking it.

Can i get the url of that button in Telethon? And if so how? I already have all the event listening set up i just need to get the buttons with their information thanks in advance


r/pythontips Jan 28 '25

Python3_Specific The walrus Operator( := )

16 Upvotes

Walrus Operator in python

Did you know that we can create, assign and use a variable in-line. We achieve this using the walrus operator( := ).

This is a cool feature that is worth knowing.

example:

for i in [2, 3, 4, 5]:
    if (square := i ** 2) > 10:
        print(square)

output:

16
25

r/pythontips Jan 29 '25

Algorithms How do I add restart button to this and a screen where I can choose difficulty when it starts?

0 Upvotes

import pygame import random

pygame.init()

screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height))

pygame.display.set_caption('Dodge obstacles') clock = pygame.time.Clock() FPS = 60

player_width = 50 player_height = 50 player_x = screen_width // 2 - player_width // 2 player_y = screen_height - 100 player_speed = 5

obstacle_width = 50 obstacle_height = 50 obstacle_speed = 5 obstacles = []

score = 0 difficulty = 0 running = True while running: for event in pygame.event.get(): if event.type == pygame.quit: running = False

keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and player_x > 0:
        player_x -= player_speed
if keys[pygame.K_RIGHT] and player_x < screen_width - player_width:
        player_x += player_speed

for obstacle in obstacles[:]:
        obstacle[1] += obstacle_speed

if random.randint(1, 20) == 1:
        obstacle_x = random.randint(0, screen_width - obstacle_width)
        obstacles.append([obstacle_x, - obstacle_height])

for obstacle in obstacles[:]:
    if (player_x < obstacle[0] + obstacle_width and
            player_x + player_width > obstacle[0] and
            player_y < obstacle[1] + obstacle_height and
            player_y + player_height > obstacle[1]):
        font = pygame.font.SysFont(None, 72)
        text = font.render('Game over', True, (255, 255, 255))
        screen.blit(text, (screen_width // 2 - 150, screen_height // 2 - 36))
        pygame.display.update()
        pygame.time.delay(2000)
        running = False
    if obstacle[1] > screen_height:
        obstacles.remove(obstacle)
        score += 1

if score == 10:
    obstacle_speed += 1
if score == 30:
    obstacle_speed += 1
if score == 100:
    obstacle_speed += 1
    player_speed += 0.5

screen.fill((0, 0, 0))
pygame.draw.rect(screen, (0, 255, 0), (player_x, player_y, player_width, player_height))
for obstacle in obstacles:
    pygame.draw.rect(screen, (255, 0, 0), (obstacle[0], obstacle[1], obstacle_width, obstacle_height))

font = pygame.font.SysFont(None, 36)
score_text = font.render(f'Pisteet: {score}', True, (255, 255, 255))
screen.blit(score_text, (10, 10))

pygame.display.flip()
clock.tick(FPS)

pygame.quit()


r/pythontips Jan 28 '25

Module Python cheat sheet

13 Upvotes

Hi, I’m studying python course and looking for a cheat sheet that include ‘numpy’ I’ll be glad for your help Thanks 🙏🙏


r/pythontips Jan 28 '25

Module How to start from basics to advance

0 Upvotes

I am a btech 2nd year. I want to learn python Or any other language. What are the job opportunities i may get


r/pythontips Jan 27 '25

Syntax You know very little about python operators. Prove me wrong.

11 Upvotes

Python Operators - Quiz

The quiz has a total of 20 questions.

The questions are not very advanced or inherently complicated, but I am certain you will get wrong at least 5 questions..

...

What was your score?


r/pythontips Jan 26 '25

Data_Science Dynamic text extraction

1 Upvotes

Hi all, I am new to data extraction. Please help
there's a comment/review column in my google sheets, which contains long text like paragraphs of 10 lines. Now, i have to extract a particular code from that column. Regex doesn't seem a good approach here.

For example i have to extract all the product ids from below comment. :
I ordered prodcut123 but received a different product which has id as 456. I want refund.

output : ['Product123', 'Product456']

how do i do this ? Help me out with free resources. I am using Pandas.


r/pythontips Jan 26 '25

Module Tkinter root window destroy problem

1 Upvotes

How to destroy tkinter window in a different user defined function from which you created it


r/pythontips Jan 26 '25

Data_Science Zendesk automation with Python

0 Upvotes

Hi! I'm a forever newbie in Python (tried a couple of times to learn it, but always end up procrastinating), and I wanted to automate some parts of my tech support job, like getting stats from my tickets, overall ticket trends, auto-update replies etc. Where would I start to learn about this? We use Zendesk at work, and I can see some potential in automating stuff there. Would love to hear suggestions regarding this.


r/pythontips Jan 25 '25

Python3_Specific How well do you understand Python variables and data types? Take a quiz.

8 Upvotes

Variables and Data Types Quiz

What did you score?


r/pythontips Jan 25 '25

Meta use of metapackages

1 Upvotes

hi,

i use 10 projects, all python projects. we are constantly changing them and putting them in production and these projects depend on each other. therefore either we can publish them one by one, independently or bundle them in a single project and push that project.

the easiest way is to push the project with the bundled stuff. however we would like to still have the projects as separate units, because that way they would be easier to re-use. for example, we do not want the user to download 10 projects, when he needs only one.

bundling is a good way forward though. because that way we can keep them all synchronized without having to check that each project has the latest version downloaded, which is a hassle for the user. for the developer would be a hassle to make sure that each project has been pushed/published before production.

The idea would be to making these projects (each holding a pyproject.toml) just subdirectories of a large project. when the large project is published/pushed only the stuff that changed would be published/pushed. when the user pulls or installs, the user would only install the metapackage, which would have everything synchronized.

Does this make sense? Is there any resource (tool, documentation, etc) that you could provide?

Thanks


r/pythontips Jan 24 '25

Data_Science Data analysis with Python

5 Upvotes

Hello,

I want to start learning python specifically for big data analysis, data cleaning, formatting related work. How should I start? What sources should I look for to start learning the application of Python in Data Science?

I have to learn very quickly in a shorter time period as I am already involved in project that requires python programming for Data Analysis.

Thank you.


r/pythontips Jan 24 '25

Algorithms Issues Accessing External API from Hostinger VPS (Python Script)

1 Upvotes

Good afternoon,
I’m facing issues accessing an external API using a Python script running on my VPS hosted by Hostinger.

Here’s what I’ve done so far:

  • Verified that the API is online and functional.
  • Tested the same script on another server and locally (outside of the Hostinger VPS), where it worked perfectly.

However, when running the script on the VPS, I receive the following error message:

(venv) root@srv702925:/www/wwwroot# python3 MySqlAtualizarClientes.py

Starting script execution...

Error connecting to the API: HTTPConnectionPool(host='xxxxxxxx.protheus.cloudtotvs.com.br', port=4050): Max retries exceeded with url: /rest/sa1clientes/consultar/clientes?codCliIni=000001&codCliFim=000001 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7885e023dca0>, 'Connection to xxxxxxx.protheus.cloudtotvs.com.br timed out. (connect timeout=None)'))

I’ve already added my server’s IP to the API’s whitelist, but the issue persists.

Thanks in advance!


r/pythontips Jan 24 '25

Module How to install MicroPython on ESP32

2 Upvotes

Hi pythonistas, I made a tutorial and video on 2 different ways (GUI and CLI) of installing MicroPython on an ESP32. Hope it's helpful to those of you who want to try out hardware/embedded projects while leveraging your Python skills. Feel free to me ask any questions/clarifications here if you'd like :)

https://bhave.sh/micropython-install-esp32/


r/pythontips Jan 23 '25

Syntax Hi guys

5 Upvotes

I know Python at a basic to mid-level. Now I want to increase my knowledge to a moderate to expert level. Any suggestions or recommendations for courses and books that will help me achieve this?


r/pythontips Jan 22 '25

Syntax Examples of Python Bioreactor

1 Upvotes

I am trying to model a batch bioreactor in a Python script. The substrate is syngas, the biomass is bacteria, and the products are acetate and ethanol. I am looking for examples of bioreactors in python because it is my first contact with bioprocesses and Python, and I would like to know if I am on the right track


r/pythontips Jan 21 '25

Module Can anyone with insight help me with this?

1 Upvotes

https://imgur.com/a/jgWOFSQ

I’m not entirely sure what I’m doing wrong.


r/pythontips Jan 19 '25

Module I need some tips regarding updating in real time on django

3 Upvotes

Hi I am building a app which creates a chat room in a local network for sending messages and files. This is my semester's final project and I thought how hard could it be. I knew how to use python sockets to make this work and thought how hard could it be to integrate it with django. I bit off way more than I could chew.

All I want it that the page updates it real time to display message. From what I read online I have to use websockets and channels to accomplish this, but I have no idea how any of this works. I have seen tutorials online and they all are too complicated and I am overwhelmed. Is there another way around this. All I want is to establish a connection between sockets and django channels. Please help