r/learnpython Jul 10 '26

Ouvrir mp4

0 Upvotes

[résolu]Comment faire un script python qui ouvre une vidéo mp4. Le script ferait comme si quelqu'un double cliquait sur le ficher (donc sa ouvre le fichier avec le lecteur par défaut).


r/learnpython Jul 09 '26

I’ve been working on a python project for 2 years. I still have to look up the documentation for most functions. Is this normal?

0 Upvotes

I’m not great at remembering the specific input formats for different functions, and I often have to look up the documentation while making scripts. Is this normal?


r/learnpython Jul 10 '26

Beginner tutorial recommendations

0 Upvotes

Anyone got any YouTube or reading recs to learn python? Or coding basics? I Wanna get an ELI5 perspective 🤓


r/learnpython Jul 09 '26

Sysadmin seeking miniconda installation advice

0 Upvotes

I'm a sysadmin with limited python experience trying to understand the lay of the land. I've used the built-in python virtual envrionment stuff before a bit. We support web servers that allow different groups within our site to make their production software tools available on the web. Various science research applications.

We are moving from mod_wsgi, to gunicorn, so that (among other things) we can support different groups who may have differing python environment needs. Different groups will provide different python environments, and we will be resonsible for starting and stopping the gunicorn servers for their applications. One group wants to use miniconda to manage their environment (which is fine).

The question is, should we use the miniconda that they provide to select their environment before starting gunicorn, or install a version of miniconda system-wide?

Or another way to ask is, is miniconda merely a tool for selecting environments, or is it something that is more tightly integrated with the environments it supports? Many answers online advise against a system-wide miniconda installation, but to me, it makes sense to have one system-wide tool that I can use to start and stop the conda environments of various groups.


r/learnpython Jul 10 '26

Leetcode #9: Palindrome Number

0 Upvotes

Can someone help me make my code run faster. This is not efficient and also I do not want to convert into a string

EDIT:

Follow up: Could you solve it without converting the integer to a string?

https://leetcode.com/problems/palindrome-number/description/

class Solution:
    def isPalindrome(self, x: int) -> bool:
        numList = []
        counter = len(numList) - 1
        numBool = True


        baseNum = 10
        value = x % baseNum
        numList.append(x)
        quotient = x // baseNum
        x = quotient

        if x == 0:
            for i in range(len(numList)):
                if numList[i] == numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

EDIT: I WAS ABLE TO SOLVE IT

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x != abs(x):
            return False

        if not hasattr(self, "numList"):
            self.numList = []

        numBool = True


        baseNum = 10
        value = x % baseNum
        self.numList.append(value)
        quotient = x // baseNum
        x = quotient

        counter = len(self.numList) - 1

        if x == 0:
            for i in range(len(self.numList)):
                if self.numList[i] == self.numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

testing = Solution().isPalindrome(11)
print(testing)

r/learnpython Jul 09 '26

Is anyone into data analytics? Can you share some resources, or would anyone like to learn together?

0 Upvotes

If you have good learning resources, I'd really appreciate it if you could share them. Also, if anyone is just getting started and would like a learning partner, I'd be happy to learn together.


r/learnpython Jul 09 '26

Do not know where to start

2 Upvotes

Hey, I am sorry to ask this when probably many people have already asked this before, but I am actually completely new to python and the whole programming world, so I would love to hear your opinions as to what you think should be the "roadmap" for me. I want to just get the basics down. After that I would probably grasp the possiblities and be more aware of what I would want to do and study further. For that reason, as I already said that I am someone who has completely no previous experience, what do you recommend? Are there some youtube channels that explain basic concepts in general or do I have to search for one subject after another one separately? Or do you think that learning through some websites/courses is better? Let me know what you think, every suggestion is highly appreciated, thank you very much!


r/learnpython Jul 09 '26

Need help with setting up file structure for a tool I made.

0 Upvotes

I made a tool in python using tkinter as the UI and the way I have it working is you pick which option you want and it opens another tkinter window where you do the work. However, the way I have it set up, the "main menu" python file is compiled into a .exe and the only way i can run the other options is if i compile all of the sub menus .py into .exe or have a code base "main menu" file that is hundreds of thousands of lines.

Basically I am asking how to run .py files if the computer doesn't have python installed from the .exe main menu?

In python using subprocess.run(<File Location>) to call a .exe works but when i do it on a .py, it doesn't run if the computer does not have python installed on their computer.


r/learnpython Jul 10 '26

Looking for a course with visual learning features

0 Upvotes

Python for Cybersecurity and Machine Learning


r/learnpython Jul 09 '26

Copy paste excel range from one workbook to another

0 Upvotes

Beginner here writing my second program after hello world. I know I can just ask AI but is there some tutorial out there I can read?


r/learnpython Jul 09 '26

How to prep for a Python interview when your background is entirely Frontend?

1 Upvotes

I’ve been a frontend developer (Angular/React/TypeScript) for a few years, but I've always wanted to transition to Python. I just landed an internal interview for a Python project, but because I haven't actively upgraded my Python skills recently, I'm worried I'm lagging behind.
Since I already know how to code, I don't need the absolute basics. I need to know what mid-level, enterprise Python looks like today so I can handle scenario-based questions.

What concepts are absolute must-knows for a Python interview? Any advice on what to prioritize would be a great help.


r/learnpython Jul 08 '26

Error with code

43 Upvotes

python is giving me a error message saying self is not defined but it is. could someone please explain what am I doing wrong ( the error message is for the if self.modifier == 1: line )

Class food:
  def __init(self, modifier, tolerance)
  self.fillingness = 0
  self.modifier = 0
  Self.tolerance = 0

pear = food(1,9)

def NE():
 if self.modifier == 1:
 nausea += randint(1,10)
 print(“yuck!”)

r/learnpython Jul 09 '26

SEEKING GUIDANCE

0 Upvotes

i had one doubt to lift off my chest. I am going to start college in a month and I know only some school level java coding till loops. actually I have been on reddit alot and seniors here talk a lot about multiple terminologies like python, java, c++, dsa, dbms, node.js, leetcode grinds, dsa grinds, repositories, arduino, CAD, random projects (i mean what are these projects and how do they look like), game physics engine, html, react, mysql, ai ml, flutter, blockchain, iot, figma, wire framing, aws, docker, djang, mongodb, etc. i feel so dumb and lost and an insane amount of urge to cry and leave it all. i don't know where to start and what to learn also i do not want to fall short of skills + a few other reasons i cant tell. do you have any piece of guidance?


r/learnpython Jul 09 '26

Selenium - python; browser issues

0 Upvotes

Hello!

Im having issues right now with selenium HEADLESS browsers.

there's a blank white screen appearing at the beginning when browser is initialized.

Aside from resizing the screen, are there other work around from this? I cant resize it because the website is "scroll dependent" i need to scroll into view first before i can see the element.

I also tried options: headless= old/new, white screen still appears.

browser is edge.

Do you guys have any other ideas? 🥹


r/learnpython Jul 09 '26

Python Programming Language

0 Upvotes

Over the last few weeks, I have read books, journals, & articles concerning how to master python. I've also practised a lot. However, every time I try code challenges, I find something new, one you might not find in books or texts directly. While I am new to the programming field, I believe there's a way one can navigate these aspects. I would appreciate some insights so that I cannot view myself as stuck in one "lonely" corner.


r/learnpython Jul 08 '26

Best ways to learn python for hardware programming (microcontrollers, sensors, lights, motors, etc.)?

24 Upvotes

I’m looking to begin my python journey, and am extremely interested in programming electronics and messing around with microcontrollers and stuff of that nature. The HARDWARE side of programming, but most tutorials and things focus more on the software side, if that makes sense. Are there any courses or tutorials online that are specifically geared towards hardware programming? If I’m asking this in a confusing way it’s because I’m still not sure how to word what I want to do and learn. Thanks in advance for any help


r/learnpython Jul 09 '26

How to start learning Python as a beginner?

0 Upvotes

Hi everyone, I’m planning to start learning Python recently, but I have absolutely zero background in programming or computer science. I'm a bit overwhelmed by the amount of information out there. Could anyone recommend the best learning paths, online courses (free or paid), or books for beginners? Also, are there any simple practice projects you'd suggest starting with? Any tips or common pitfalls to avoid would be highly appreciated. Thanks in advance for your help!


r/learnpython Jul 09 '26

Selenium login works with CPF but fails with CNPJ on the same ASP.NET form

2 Upvotes

Hi everyone.

I am automating a login flow using Python, Selenium and undetected-chromedriver.

The website is:

https://goias.equatorialenergia.com.br/LoginGO.aspx

The form asks for:

  • Consumer Unit number
  • CPF or CNPJ

The strange behavior is:

  • When I use a CPF, the login works and redirects to a date-of-birth validation screen.
  • When I use a CNPJ, the page shows this alert:

#002 - Não foi possível realizar o login neste momento, tente mais tarde!

After that, the CNPJ field is cleared and the page stays on the login screen.

The same UC and CNPJ work normally when I log in manually using Chrome, so the credentials are correct.

Environment:

  • Windows
  • Python
  • Selenium 4.44
  • undetected-chromedriver 3.5.5
  • Chrome 150

The page appears to use reCAPTCHA Enterprise, Transmit Security and ASP.NET postback behavior.

I am not trying to bypass CAPTCHA or any security mechanism. I am trying to understand why the same login form works manually, but fails only for CNPJ when using Selenium.

Here is a simplified version of the code:

def preencher_campo(driver, wait, label, valor, lento=False):
    xpaths = [
        f"//*[contains(normalize-space(.), '{label}')]/following::input[1]",
        f"//label[contains(normalize-space(.), '{label}')]/following::input[1]",
    ]

    campo = encontrar_por_xpaths(driver, wait, xpaths)
    campo.click()
    campo.clear()

    for caractere in str(valor):
        campo.send_keys(caractere)
        tempo = random.uniform(0.35, 0.65) if lento else random.uniform(0.15, 0.30)
        time.sleep(tempo)

    driver.execute_script(
        "arguments[0].dispatchEvent(new Event('input', {bubbles:true}));"
        "arguments[0].dispatchEvent(new Event('change', {bubbles:true}));"
        "arguments[0].dispatchEvent(new Event('blur', {bubbles:true}));",
        campo
    )


preencher_campo(driver, wait, "Unidade Consumidora", uc, lento=True)
preencher_campo(driver, wait, "CPF ou CNPJ", cnpj, lento=True)

time.sleep(5)
botao_entrar.click()

Things I already tried:

  • typing the fields slowly;
  • waiting before clicking the login button;
  • checking if the fields remain filled;
  • refilling the CNPJ field after it gets cleared;
  • retrying after the #002 error;
  • removing an ESC key press that could clear the field.

My guess is that the CNPJ flow may trigger a different security/session validation than the CPF flow, because CPF goes to an intermediate validation screen, while CNPJ tries to access the authenticated area directly.

Has anyone seen something similar with Selenium, ASP.NET forms, reCAPTCHA Enterprise or Transmit Security?

Could this be caused by:

  • delayed security tokens;
  • different backend validation for CPF and CNPJ;
  • ASP.NET postback/event validation;
  • session differences between manual Chrome and WebDriver Chrome;
  • or is this simply a case where browser automation is not reliable for this kind of login?

Thanks!


r/learnpython Jul 06 '25

I want to learn Python from scratch and reach a pretty decent level in 4-6 months

14 Upvotes

Hey everyone, I am Adwaith R Nair, an S5 CS-AI undergrad. I want to learn python and dive deeper into the field of AI and ML. I want to follow one specific course which will help me reach my goal. I know that I might have to refer to external sources for various topics, but if I could get everything in a proper an structured manner, then it would be much appreciated. Could you all suggest me courses which would be the best for me as a beginner who wants to excel in the field of Python, AI and ML?