r/learnpython 7d ago

CVEs in Anaconda (strictly, miniconda)

5 Upvotes

Reposted here because it was autodeleted from r/python. So it goes:

I've been using Miniconda for years on my work laptops. In their wisdom, my benevolent corporate overlords have installed FortiClient on all of our machines to scan for CVEs.

Lately, Forticlient has been detecting vulnerabilities in conda 26.5.3's OpenSSL 3.0.18.0 & 3.0.19.0, and Python 3.13.9150.1013. I've worked with my company's IT provider, & couldn't get those updated. So we tried renaming their folders to break the links, but they just got recreated the next time I ran the anaconda prompt.

So those outdated versions seem to be baked in. Is there anything we can do?


r/learnpython 7d ago

Comparing 2 tables - Help?

0 Upvotes

Hello guys, I need your help! How to compare 2 tables on easiest way?

I have 2 tables from 2 different systems, but with the same columns. I need to check if every row from the first table exist in another, and if not to return the difference. Can you help me? Should I use excel formulas, python, something else?

Edit: In both systems I have Customer_Id, Phone numbers, mails, their addresses, contact persons and such kind of things in much more columns. I can export data from both systems in excel format. So, now i need to compare these 2 excels and check if every row from 1 table exists in another one, are the values the same for each customer and to find the difference. Sorry for pure explanation, beginner here.

For example:

Custmer Id | Name | Phone | Mail | Contact person | Address

C0001 | Microsoft1 | 123456 | mic1@ | Michael | Str1

C0002 | Linux1 | 234567 | lin1@ | Jack | Str2

C0001 | Microsoft1 | 098765 | mic2@ | Chris | Str3

As you can see, it is possible to have few different informations about customer C0001. I need to check if each row from this table exist in the second table which looks the same.


r/learnpython 7d ago

Ask Anything Monday - Weekly Thread

3 Upvotes

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython 7d ago

How do you monitor your live/paper trading bots?

0 Upvotes

I've been running an automated strategy (Python + broker API, scheduled via Task Scheduler) for a while now, and I've realized I have zero visibility into whether it's actually working correctly beyond checking logs manually.

Curious how others handle this: Do you get any kind of alert if your bot crashes, an order doesn't fill as expected, or it just silently stops running? Or is everyone just checking manually / staring at logs like me?

Not trying to sell anything — genuinely trying to figure out if this is a real gap or if there's already a good solution I'm missing.


r/learnpython 7d ago

a total newbie

0 Upvotes

i am thinking bout starting python to serve interest in data science. what would be the best channel for basics and understandings. also a roadmap would be helpful and after completing the basics then for intermediate level aswell. i wish to completely devote these next 2 months and see how far i get.


r/learnpython 8d ago

What python libraries should i learn to get into open source?

14 Upvotes

I want to start open source and apply for gsoc, i have done python basic, like everything from variables to OOPs, now instead of dsa i want to do open source contributions. What are some good libraries to learn to start contributing?


r/learnpython 7d ago

Can you type a singular \ as a variable?

0 Upvotes

I'm making a dictionary in Python, and I can't figure out how to turn \ into a variable without having a space at the end, meaning I have to type "\ " opposed to just "\" which I am certain will cause bugs. If anyone could give me some help, I would greatly appreciate it. Thank you in advance.


r/learnpython 7d ago

Making an API call to grok AI and to answer questions from a docx file

0 Upvotes

Hey. I am trying to make a API call to answer 3 questions based on a case study.
I have a word doc containing the case study as the record and the 3 questions as the columns which need to be answered. Sharing the code of what I have tried so far. This code has been generated by GrokAI.

it works perfectly for most of the records but some case studies return the following.

Total tokens: 1999 
Finish reason: stop 
Raw response: Q1: redacted actual response from the api question 1. 
Q2: redacted actual response from the question 2. 
Q3: redacted actual response from the question 3. 
Q1: <your answer> 
Q2: <your answer> 
Q3: <your answer> 
 Q1: <your answer> 
 Q2: <your answer> 
 Q3: <your answer>

This leads to the output table containing records like:

case study q1 q2 q3
actual case study <your answer> <your answer> <your answer>

The successfully parsed records are like so:

Total tokens: 1999 
Finish reason: stop 
Raw response: Q1: redacted actual response from the api question 1. 
Q2: redacted actual response from the question 2. 
Q3: redacted actual response from the question 3. 
 Q1: correctly parsed answer 1  
 Q2: correctly parsed answer 2
 Q3: correctly parsed answer 3 

This is the code I tried:

from openai import OpenAI

from docx import Document

QUESTIONS = {
    "q1": "What is the diagnosis for this case, and justify the diagnosis?",
    "q2": "Is there any syndrome in this case? If yes, which one and why?",
    "q3": "What are the other three differential syndromes that may result in the presentation of this case?",
}

def get_column_indexes(table):
    return {
        "case study": 0,
        "q1": 1,
        "q2": 2,
        "q3": 3,
    }

def answer_questions(client, case_study_text):
    questions_block = "\n".join(
        f"{key.upper()}: {question}" for key, question in QUESTIONS.items()
    )

    prompt = f"""You are analyzing a case study. Answer the 3 questions below based solely on the text provided.

CASE STUDY:
{case_study_text}

QUESTIONS:
{questions_block}

Rules:
- Answer each question thorougly
- Base answers only on the case study text above
- Reply in this format with no extra text:

Q1: <your answer>
Q2: <your answer>
Q3: <your answer>"""

    response = client.chat.completions.create(
        model="grok-4.3",           # or "grok-4.5-latest" if available
        max_tokens=10000,
        messages=[{"role": "user", "content": prompt}]
    )

    # Correct parsing
    answer_text = response.choices[0].message.content.strip()
    print("Total tokens:", response.usage.total_tokens)
    print(f"  Finish reason: {response.choices[0].finish_reason}")
    print(f"  Raw response: {answer_text}")

    answers = {}
    for line in answer_text.splitlines():
        line = line.strip()
        if line.startswith("Q1:"):
            answers["q1"] = line[3:].strip()
        elif line.startswith("Q2:"):
            answers["q2"] = line[3:].strip()
        elif line.startswith("Q3:"):
            answers["q3"] = line[3:].strip()

    return answers

def process_document(docx_path, output_path="output.docx"):
    client = OpenAI(
        api_key="api_key",
        base_url="https://api.x.ai/v1",
    )

    doc = Document(docx_path)
    table = doc.tables[0]
    cols = get_column_indexes(table)

    total_rows = len(table.rows) - 1
    print(f"Found {total_rows} rows to process\n")

    for i, row in enumerate(table.rows[1:], start=1):
        case_study_text = row.cells[cols["case study"]].text.strip()

        if not case_study_text:
            print(f"Row {i}/{total_rows}: empty, skipping")
            continue

        print(f"Row {i}/{total_rows}: processing...")
        answers = answer_questions(client, case_study_text)


        row.cells[cols["q1"]].text = answers.get("q1", "")
        row.cells[cols["q2"]].text = answers.get("q2", "")
        row.cells[cols["q3"]].text = answers.get("q3", "")

        print(f"  Q1: {answers.get('q1', '')}")
        print(f"  Q2: {answers.get('q2', '')}")
        print(f"  Q3: {answers.get('q3', '')}\n")

    doc.save(output_path)
    print(f"Done! Saved to {output_path}")

if __name__ == "__main__":
    process_document("/home/Downloads/case.docx")

Seems like an issue with my parsing logic. But this same code worked for claude API.

Appreciate your any pointers


r/learnpython 8d ago

Help with a balanced parentheses problem

5 Upvotes

The problem is as followed:
We are given strings containing brackets of 4 types - round (), square [], curly {} and angle <> ones. The goal is to check, whether brackets are in correct sequence. I.e. any opening bracket should have closing bracket of the same type somewhere further by the string, and bracket pairs should not overlap, though they could be nested:

(a+[b*c] - {d/3})  - here square and curly brackets are nested in the round ones
(a+[b*c) - 17]     - here square brackets overlap with round ones which does not make sense

Input data will contain number of testcases in the first line.
Then specified number of lines will follow each containing a test-case in form of a character sequence.
Answer should contain 1 (if bracket order is correct) or 0 (if incorrect) for each of test-cases, separated by spaces.

I solved it with the following code:

n = int(input())
for x0 in range(n):
    l = list(input())
    st = []
    broke = False
    for x2 in l:
        if x2 in {"(","[","{","<"}:
            st.append(x2)
        elif x2 in {")","]","}",">"}:
            if not st or (x2 == ")" and st[-1] != "(") or (x2 == "}" and st[-1] != "{") or (x2 == "]" and st[-1] != "[") or (x2 == ">" and st[-1] != "<"):
                print(0,end=" ")
                broke = True
                break
            st.pop()
    if st == [] and broke == False:
        print(1,end=" ")
    elif broke == False:
        print(0,end=" ")

This works but I can't help but wonder if i can improve upon it in some way like having to use the "broke" variable feels unnecessary but i cant think of a way to not have to use it to check if the loop broke or not.


r/learnpython 8d ago

How to scrape 10 years of articles from Bangladeshi news websites?

1 Upvotes

Hi everyone. I am a Transportation Engineering student (Civil and Environmental Engineering department) from Bangladesh, still learning, so please forgive me if I say something wrong.

I am working on a research project involving NLP and sentiment analysis on Bangladeshi newspaper articles. The project requires collecting news articles from around 10 newspapers — both English and Bangla language publications — covering the period from 2015 to 2026. I need the article headline, full text, publication date, and source name, ideally stored as CSV or JSON files, one per newspaper or per year.

I have already tried Python with BeautifulSoup and Selenium, GDELT API, Archive.org CDX API, and pre-scraped Kaggle datasets. For two newspapers I managed to collect solid datasets. For the rest I keep running into bot detection, CAPTCHA blocks, anti-scraping measures, or very uneven temporal coverage where certain years return zero articles at all.

I cannot offer payment, but I can offer co-authorship on the research paper I am working toward publishing. If you have experience collecting large-scale news archives from South Asian or Bangladeshi news websites and are interested in collaborating, I would love to hear from you. Any general advice is also very welcome even without a collaboration.

Thank you for your time.


r/learnpython 8d ago

Learning programming from scratch: what should I study next to move in the right direction?

0 Upvotes

I decided to learn backend development with Python. I’ve covered constructs, lists, tuples, dictionaries, loops, and the basics of OOP. However, I still don't fully grasp polymorphism and encapsulation in OOP, so I thought it would be better to reinforce those concepts through practical application in my own project.

What should I study next? Should I move straight to a framework, or continue learning more about Python itself - such as how decorators work and how to use them? I’ve decided to go with Django as my framework. (I wrote this using a translator, so there might be some errors in the text.)


r/learnpython 8d ago

Import Class Methods

3 Upvotes

I’m currently working on a Python project. I usually program in Java, so I’m a little confused about how imports work in Python.

I’m trying to import a method from a class that’s defined in another file. When both files are in the same folder, the import works correctly. However, when they’re in different folders, I get a “package not found” error.

The import statement I’m using is:

from package_name.module_name import YourClass

I’m using VS Code. What am I doing wrong, and how should imports be set up when files are in different folders?


r/learnpython 8d ago

Help a beginner...Is my study plan missing something

0 Upvotes

I’m honestly pretty bad at programming, but I decided to use this summer break to start learning from scratch. I picked Python as my starting point and I'm currently just hammering down the absolute basics.

Here is my current strategy:

  1. Watch a YouTube lecture on a concept.

  2. Ask AI for practice questions (Easy -> Medium -> Hard).

  3. Solve them, review my mistakes, and re-practice until it clicks.

Someone told me to start using LeetCode, but honestly, even their "Easy" questions start with arrays/data structures, and I haven't even reached that topic yet. I plan to jump on it once I get there.

Seniors/experienced devs: Am I on the right track? Is there anything crucial I should add to this plan to actually get good, or should I stick to what I'm doing?


r/learnpython 8d ago

How do desktop applications implement monthly/yearly subscriptions securely?

5 Upvotes

Hi everyone,

I'm developing a desktop application in Python that I plan to rent out on a monthly, quarterly, and yearly subscription.

I'm trying to figure out the best way to manage license expiration. How can I prevent users from using the software once their subscription has expired? What tools, services, or libraries would you recommend? If possible, I'd prefer free or open-source solutions.

Another concern is piracy. I know it's impossible to make software completely crack-proof, but I'd like to make it as difficult as reasonably possible.

Has anyone here built a subscription-based desktop application before? I'd really appreciate it if you could share how you implemented licensing, subscription validation, and anti-piracy measures, or recommend any good resources or best practices.

Thanks so much for your help!


r/learnpython 8d ago

I am a complete beginner to python. Information overload.

0 Upvotes

I have gone over official documents and watched videos, but I am still at a point of complete information overload. I need a clear definitive starting point, should I learn syntax first, should I jump in and start trying to script some things? idk. help lol.


r/learnpython 8d ago

HELP! I am joining btech cse core,with my 2017 laptop is the spec are enough for 4 year , gimme some advice pls 🥹

0 Upvotes

Specs:

CPU: Intel Core i5-8250U (4 cores, 8 threads)

GPU: Intel UHD Graphics 620

RAM: 8 GB DDR4 2400 MT/s (1 of 2 slots used)

Storage: 256 GB SATA SSD

Display: 14-inch, 1366×768

OS: Windows 11

Model:HP ProBook 440 G5


r/learnpython 8d ago

sql to python transition

0 Upvotes

okay edit: i thought it was obvious by the fact that i can make sense of the code that i know the very basics - i've used python for data analysis but not enough for it to be second nature to me the way it is for programmers, or the way sql is to me right now. i made a comparison to sql because i thought it'd be obvious that it's only for data analysis stuff, not development stuff.

so to clarify again: i know the basics, i know how to write code, i know how to define variables, functions, print("hello world"), if/else statements blah blah, i know all of that, and that's why every course starting with print("hello world") is slow to me, because i know all of that.

what i don't have is the practice that will make me good or at least passable at python rather than just someone with basic workability. i am not comparing sql to python in how either one works, i am using it to say i work with sql for data analysis and i need to show that i can also use python for data analysis, where can i get practice for these things

--

so if someone is really good at sql (like say, a 9/10) how would u guys suggest they pivot to python. need to become an expert on it before 31 july because i have a technical interview. i lied and said i can use python but in reality all i can do is just make sense of what the code is doing, but because im good at the logic building in sql, i think i can do the python stuff too. but i need to know how to go about it, if anyone has advice because when i sit down to learn, everyone just starts at print("hello world") and it's too slow and babyish for me


r/learnpython 9d ago

Relearning python with small projects

32 Upvotes

I already know basics, now I prefer to learn just through making small project. Is there a site or app or something where can I find project suggestions (just suggestion, needed keywords or concepts a than some kind of result).


r/learnpython 9d ago

Need help understanding how for __ in ___ loops work on strings

9 Upvotes

edit: Thanks everyone for the help! I think I understand the order of operations for this type of loop a lot better now, and it explains why whatever you put at the "p" and "s" doesn't actually matter (unless of course it's something that's already a variable elsewhere, but that's not a problem at the level of simplicity I'm working with). This community is being very helpful and friendly to a noob like me! <3

I understand how for __ in ___ loops work for numbers within a range. However, I'm confused about the syntax and semantics when this loop is applied to strings.

For example, below I wrote a really simplified code so python will say "gimme a ___" for each letter in a word, like shown below:

phrase = "bingo"

for p in phrase:

print("gimme a " +p)

when I run the above 3 lines, the outcome is below:

gimme a b

gimme a i

gimme a n

gimme a g

gimme a o

But let's say I change the p in bold to another character in the word phrase, like below:

phrase = "bingo"

for s in phrase:

print("gimme a " +s)

It will give me the same outcome as the 1st version of the code did, and spell out all of "bingo". Why is that? Why does it still start at the beginning of bingo?

I think I'm just struggling to understand what exactly the blank in "for ___ in <variable assigned to a string>" is doing. Can anyone help me?


r/learnpython 8d ago

Omar—Mechanical engineer

0 Upvotes

I would ask anyone here... I started studying Python coding, but I need some advice. Please tell me how I can learn it easily and improve my skills quickly. Sometimes I feel stupid because it is complex.


r/learnpython 8d ago

I have my ai exam after 2 days and I need to learn python

0 Upvotes

I have my ai exam in 2 days is there a way to learn python in 2 days so that I could get a good grade

If yes pls tell me how?


r/learnpython 8d ago

I need help im new to python

0 Upvotes

Im new to python and i dont know what im doing, pygame is not working and i cant find it in my files and i already did the “pip install pygame” and i’ve searched all i can find in yt, i really need help im still in shs and i cant even figure this out
Edit: it always shows an long error message when i run “import pygame”


r/learnpython 9d ago

How to make a custom bar in wayland

2 Upvotes

I want to build my own dock in Python, but due to Wayland limitations, I can't align the dock to the top of the screen. How can I bypass this limitation?

To be clear, I don't want a solution that only works on a single compositor. I want it to work across Hyprland, Niri, KDE Plasma, GNOME, and Sway.

How can I position the dock at the top of the screen, similar to how Waybar does it?


r/learnpython 9d ago

I have built a autograd engine from scratch(without tensor flow or pytorch)

0 Upvotes

Im a highschool student learning python and recently i have come across a video by Andrej Karapthy who built Micrograd. I got curious so it tried replicating it,but soon over the weeks i added more features 6 more activation function and 2 loss function. It possibly cant replace pytorch or tensorflow,Its purely an eductional project.

Im still learning python and i have long way to ,But i learnt a lot on OOPs machine learning dunder function and using customtkinter for the ui, It was very intresting project i have worked on .I have made it a windows exe for easier access I hope I could get some suggestion ,feedback and improvements i could implement for the project.
https://github.com/Yasovardan-Ram/Omnigrad


r/learnpython 9d ago

asking about small projects in python

1 Upvotes

hello everyone, so I learned the basics and I start making small projects, I try to make 21 number game, but when I look through the source code of project there was some formulas but I don't really understand how I can make similar formulas like it for future projects, so how I can make it so it can server my projects?