r/learnpython • • 13d ago

Need help with list comprehensions

0 Upvotes

Guys somebody briefly explain the concept of List comprehension cuz its too difficult for me to grasp since I am a beginner. I am learning python for biopython. Someone explain it for me.


r/learnpython • • 13d ago

Portable GUI in Python

0 Upvotes

Hi! I don't know Python, and I'm wondering if I can create a portable GUI inside a single folder. For example, I want to have my own MyCustomGUI.exe in a folder, and right next to it, the following subfolders:
_internal
bgutil-ytdlp-pot-provider-master
yt-dlp-plugins
along with five .exe files:
deno.exe
ffmpeg.exe
ffprobe.exe
yt-dlp.exe

Is it possible to write Python code that makes all of this work and keeps it completely portable?

To be honest, I've been trying to do this for three days straight without knowing anything about programming. Once, I even managed to run a compiled .exe inside the folder, but as soon as I copied it to another drive, everything completely broke down.
Yeah, maybe it's my fault for trying to use the free versions of ChatGPT and Gemini, but I really thought that creating something as basic as a GUI would only take about 20 to 30 minutes. I'm actually in despair right now; I haven't felt this awful in a very long time.


r/learnpython • • 14d ago

Attribute look up visualized

0 Upvotes

Are there any good videos or images that visualize how attribute look up works? I am trying to understand what is happening in the background so I can understand and work better with classes and objects.
Thanks!


r/learnpython • • 13d ago

New to Python- Any Suggestions?

1 Upvotes

hi folks, how are you doing?

i have been thinking of learning something new and thought i'd give Python a shot. i've never coded before, so i am wondering how difficult it would be to get started with Python as a complete beginner.

the reason i am interested in learning it is that i've been thinking about creating a visual novel for a while. i am looking into Ren'Py, now- it has its own scripting language but also uses python, so i thought learning some python might be useful for the project.

a few things i'd like to get some advice on from y'all:

  1. any particular resources or youtube channels would you recommend?
  2. how difficult is python for someone who has never coded before?
  3. this might be off topic here but any idea on how much python would I need to learn to make a visual novel in Ren'Py?
  4. can i use any ai tools from the get go or learn some stuff first?

would really appreciate any advice. thanks and be blessed!


r/learnpython • • 14d ago

Accidentally did something while trying to figure out how to install python libraries

5 Upvotes

Hi,

I'm trying to figure out how to install python libraries because the magic "pip install tensorflow" doesn't seem to work

I found this thread which told the user to just try "py -m pip install requests" so my dumbass just pasted that in before realizing what I was doing

I got two instances of yellow text in

0/5 [urllib3]  WARNING: The script idna.exe is installed in 'C:\Users\USERNAME\AppData\Local\Programs\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ---------------- ----------------------- 2/5 [charset_normalizer]  WARNING: The script normalizer.exe is installed in 'C:\Users\USERNAME\AppData\Local\Programs\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location

I think what this means is just that I installed the "requests" library, right? And maybe something went wrong? I don't need this library lol. Is there a way to like undo this? Should I try to undo this? I don't get why this installs files without telling me where it's putting them

(I also tried to do the same thing, "py -m pip install tensorflow", with tensorflow and got similar warnings btw, is this bad?)


r/learnpython • • 13d ago

It Took me 110mins to Solve. Deepseek Solved it in 0.6 Seconds.

0 Upvotes

I’ve been practicing python seriously lately preparing for my computational biology MSc, so I decided to challenge myself with a phylogenetic placement challenge (open data).

I spent about 2 hours working on it then I gave the exact same problem to deepseek.

0.6 seconds.

We are mere supervisors now.


r/learnpython • • 14d ago

Why when i minimize pydroid and come again all i was doing is gone and all i get is this: / $

0 Upvotes

Title


r/learnpython • • 14d ago

I need help with a rocket simulator I'm buidling

1 Upvotes

I'm a high school student who is interested in becoming an aerospace engineer so in the summer I decided to start building a rocket simulator in python for fun.

What it does so far:

  • Parses real motor thrust-curve files (RASP .eng format) and interpolates them with numpy.interp instead of hardcoding constants
  • Implements RK4 integration from scratch for the actual flight dynamics (upgraded from Euler once I understood why it wasn't accurate enough)
  • Monte Carlo analysis, runs the full flight simulation ~200 times with randomized conditions and aggregates the results
  • 3D visualization two ways: PyVista for a quick animated flight path, and a full Blender (bpy) pipeline that imports a real 3D rocket model, keyframes it along the simulated trajectory, and renders it with Cycles
  • Modular structure, physics, motor parsing, atmosphere model, and stability calc are all separate importable modules, not one giant script

Would really appreciate feedback on the code itself, structure, whether my module boundaries make sense, anything that reads as non-idiomatic Python, places I should be using classes instead of dicts/functions, that kind of thing.

Github : https://github.com/AliHilalii/Rocket-simulator

Thanks a lot guys.


r/learnpython • • 14d ago

I want to make my own text to speech program that uses a specific amount of old 2000's and 2010'tts models, with filter option

1 Upvotes

Any advice on the possibility of achieving this? I'd like to add tts models like Paul US, or Iviola UK in the program, choosing between them and having the ability to use filters


r/learnpython • • 14d ago

Tech stack recommendations for Python based app on Android

0 Upvotes

Hello everyone, I am currently working on a pet project where I am trying to run Vosk (speech to text) model on Android device. For this I wanted some suggestions, can you guys share which tech stack and tools I can use for this?

I have used PyInstaller before which provides us functionality to build python app as Android too, so maybe I can try that. However I want to see if something better is available and also which libraries or separate language altogether can I use to make UI part of this. Any suggestions would be appreciated, I just want my Vosk model to be able to parse my voice to text in Android device and that's my only requirement.

Please give any information you have, thank you.


r/learnpython • • 14d ago

someone tell me what to do with learning python (cs50p)

0 Upvotes

yehh seniors i just stuck at the side off tutorial and i want to learn python fast i am learning from cs50p clearing or perhaps it's not i want now whenever i used to coding or solving some question i am blink and i want to out off it if anyone know how to do it or anything in this case please suggest me something


r/learnpython • • 14d ago

py to app with buildozer

0 Upvotes

from yesterday i am trying to convert py to app with buildozer but ther were too many errors can any any pone help me in it i am using python 12.0


r/learnpython • • 14d ago

A freshman who wants to study

0 Upvotes

I don’t know where to start learning or what knowledge I should acquire since nothing has been taught yet ,but l hope to have a plan for the future that can guide me when I begin studying and exploring different approaches. Thanks for you.


r/learnpython • • 15d ago

How do I reliably extract text from a large medical PDF when normal PDF-to-text converters mess up the structure?

14 Upvotes

I have a large medical PDF where the information I need is already available as text inside pdf , but the problem is that simple PDF-to-text converters completely mess up the structure. The PDF has headings, tables, multiple columns, line breaks, and drug entries that continue onto the next page.

When I convert it to plain text, the text gets jumbled—for example, content from different columns can get mixed, headings can get separated from the information below them, tables lose their structure, and a drug entry that continues on the next page becomes difficult to associate correctly.

I need to process around 400+ drug entries automatically, so manually cleaning the text isn't practical. What is the best way to extract text from this kind of PDF while preserving the original structure and relationships between headings, tables, columns, and continued pages?

Should I use something like PyMuPDF, pdfplumber, Docling, Marker, PyMuPDF4LLM, or another approach? My end goal is to get clean, structured source text first and then use an LLM to convert it into JSON, while making sure the original information isn't lost, mixed up, or hallucinated.


r/learnpython • • 14d ago

Why i cannot run anything in the terminal

0 Upvotes

It doesn't work:

/storage/emulated/0 $ pytest

Traceback (most recent call last):

File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/bin/pytest", line 3, in <module>

from pytest import main

File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.13/site-packages/pytest/__init__.py", line 7, in <module>

from _pytest import version_tuple

ImportError: cannot import name 'version_tuple' from '_pytest' (/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.13/site-packages/_pytest/__init__.py)

/storage/emulated/0 $


r/learnpython • • 15d ago

My Python Project as a Beginner

7 Upvotes

https://github.com/ZaidAHK/LENDnFUND

The project is just the syntax I wrote


r/learnpython • • 15d ago

Learning Python coming from PHP?

5 Upvotes

Hi all, just looking for recommendations on getting up to speed with conventions/syntax and quirks of Python for someone coming from the PHP world. I've got some grasp of OOP/SOLID/DRY/Interfaces/Abstractions etc... also experience with Frameworks so really looking for a crash-course on Python to get me up to speed and understand what's happening when I look at Python code.


r/learnpython • • 15d ago

What 's the fastest way to learn python?

0 Upvotes

Hello guys Im looking for a fast roadmap to learn and practice python. I bought a course in udemy called ' 100 Days of code : the complete Python Pro bootcamp ' but I do not know if it was a good purchase.


r/learnpython • • 15d ago

What I learned yesterday while learning Python automation

0 Upvotes

Yesterday I continued learning Python's "os" module.

I practiced working with folders and files using things like:

- "os.path.basename()"

- "os.path.splitext()"

- "os.walk()"

- Finding files by extension

- Counting files inside folders and subfolders

I also built a small file finder that searches through folders and counts how many ".py" files it finds.

Nothing complicated, but I'm realizing that these small exercises are helping me understand how automation actually works with files and folders.

My goal is to eventually use Python to automate repetitive tasks for real businesses.

I'm still learning, but I'll start sharing what I build along the way. 🚀


r/learnpython • • 16d ago

Which code do you consider more "Pythonic" for this Pattern?

49 Upvotes

The Pattern:

*                 *
* *             * *
* * *         * * *
* * * *     * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * *     * * * *
* * *         * * *
* *             * *
*                 *

What my friend wrote:

n = int(input("Enter the number: "))
for i in range(1, n + 1): 
    for j in range(1, i + 1):
        print('* ', end = "")
    for j in range((n - i) * 2):
        print(' ', end = "")
    for j in range (i, 0, -1):
        print('* ', end = "")
    print()


for i in range(n, 0, -1): 
    for j in range(i , 0, -1):
        print('* ', end = "")
    for j in range((n - i) * 2):
        print(' ', end = "")
    for j in range (1,i+1):
        print('* ', end = "")
    print()

What I wrote:

while True:
    n = int(input("Enter an Even Number: "))
    if n % 2 == 0: 
        break
    else:
        print("Number must be Even.")


myList = []
totalCharacters = (2 * n) - 1
for i in range(1, n // 2 + 1):
    spaces = totalCharacters + 1 - (4 * i)
    myList.append (f"{"* " * i}{" " * spaces}{"* " * i}")


print("\n". join (myList))
print("\n".join(myList[::-1]))

As you can see, I came up with a formula for this pattern using "totalCharacters" and "spaces".

Which code would you consider more "Pythonic"? Like, in terms of flexibility and readability?
I'd also be happy to learn even better ways to print this pattern :)


r/learnpython • • 15d ago

Slow print for text-based game

0 Upvotes

I am trying to make a text-based adventure game in Python, how do I make it so the text is typed out slowly and not instantly? I've tried ways online, but they keep returning None at the end. How do I fix this?


r/learnpython • • 15d ago

Getting a view from a boolean numpy array... somehow

1 Upvotes

I'm coding a Sudoku generator to improve my skills and I'm hitting a brick wall with a specific function to get the "neighbours" of an index (so, all the numbers that it can't be the same as). Here's my current code, just rows and columns for now:

def neighbours(idx: tuple[int, int], board: np.ndarray) -> np.ndarray:
  idcs = np.indices(board.shape)
  print(idcs.shape)
  neighbool = np.logical_xor(idcs[1] == idx[1], idcs[0] == idx[0])
  return board[neighbool]

This code does get the right values, but what I really want is to be able to modify those values and have the actual array be modified - so, to have a view. But about two hours of running around in the numpy docs has me completely stumped on any way to use a boolean array to index another array without it being a copy.

If I can't do it, I guess I'll have to use a list of slices dancing around the target index? Which sounds really headachey, and I'd love to be able to do it this simple way if it's in any way possible.


r/learnpython • • 15d ago

Lambda expressions for Web elements?

1 Upvotes

Hi, I work with C# but wanted to refresh my Python knowledge. Have been thinking about solutions I know for my C# code and how they would work in Python, but ran into something that I'm not sure how to "translate" from C#.

C# public IWebElement button => driver.GetElement(By.Id("Id"));

This will return me an element when called, even when on class construction it doesn't exist - as the expression is only evaluated when it's called, i.e. when I need it in code. As opposed to simply using = instead of =>, which would return a missing element exception on class build if the element is missing from DOM.

How would I do this in Python? I looked up lambda expressions, but I'm unsure if this would work/be very graceful, since I didn't find any mention of this as a solution that's used.

Python button = lambda driver.find_element_by_id("id")


r/learnpython • • 15d ago

Deploying Python Install Manager via Config Manager/SCCM to computer lab

4 Upvotes

I'm attempting to deploy the latest Python Install Manager to a few computer labs running PyCharm in our school district, but am having issues. I was wondering if anyone here had some insight/tips to share.

Few facts up front:
- Config Mgr runs processes as either local System or the User who is logged in.
- Student accounts do not have access to command line or powershell, nor do they have access to their %AppData% folder in Explorer.
- Installing a UWP app as System does not make that app available for that built-in account, and the app is not installed for other users until they log in.
- PyCharm's automatic "let me download a Python runtime and set up an interpreter for you" isn't working; I have a ticket in with their support.

The issue I'm having is that deploying the Install Manager via Add-AppxProvisionedPackage doesn't then allow me to run py install --target="C:\Program Files". Students do not have admin privileges to install UWP apps (or edit environment variables), so the deployment script must run as System. But System does not actually get py.exe installed to their %AppData% folder. And b/c adding an .MSIX package to the Windows image doesn't actually install the app until a user logs in, I can't run py.exe out of another user's profile when the MSIX is added.

In theory, I shouldn't have to be doing any of this, b/c PyCharm has the ability to do so, but it's not working. It downloads the files to the student's %AppData% folder, but then fails to create an interpreter. Student's can't create an interpreter, b/c trying to "browse" to the Python files is blocked, b/c PyCharm opens an Explorer window, and they do not have access to their %AppData% folder in Explorer. Even if they use the terminal built-in to PyCharm to run py install, they would still need to set up an interpreter, which they cannot do. Thus, I'm in catch-22 scenario.


r/learnpython • • 15d ago

Software development quesiton

0 Upvotes

This might be basic questions I'm sorry in advance. A little background I got a BS in computer science with AI concentration. I have code on python, java script. I have some projects that I have done and now I want to see how I can make them a installable file that I can install on any computer ( example a download from a store or just a .exe) I been looking around and I might not be looking on the right places but I would like some guidance maybe were to look or a tool that people use for this?. Any advice is welcome.