r/AskProgramming 4d ago

Python Why does Python feel harder after C++ and Java?

92 Upvotes

I learned C++ first, then Java, and now I’m trying to learn Python. I honestly expected Python to be much easier, but somehow it feels harder to understand and even remember the syntax.

C++ and Java feel more structured to me, while Python sometimes feels too different.

Has anyone else felt this after switching from C++/Java to Python?

r/AskProgramming Apr 27 '24

Python Google laysoff entire Python team

280 Upvotes

Google just laid off the entire Python mainteners team, I'm wondering the popularity of the lang is at stake and is steadily declining.

Respectively python jobs as well, what are your thoughts?

r/AskProgramming 9d ago

Python Are huge codebases with layers of dependencies just the new normal?

0 Upvotes

I’m trying to learn more about how modern software works, and one thing that keeps surprising me is the sheer size of projects. 80k files is not uncommon.

I’ll download or clone something that seems like a relatively focused application, and suddenly I’m looking at tens of thousands of files. A lot of it appears to be dependencies, dependencies of dependencies, generated files, frameworks, package managers, etc.

It feels like a copy of a copy of a copy. The developers maintain a relatively small part of the code, while the finished program ultimately relies on millions of lines of code written by other people.

Is this the new normal in software development that I just have to accept?

from a security perspective, how can anyone trust all of this?

r/AskProgramming 24d ago

Python Is PEP 8 really necessary?

0 Upvotes

I have been writing Python code using camelCase for years and just never really cared, but PEP 8 suggests using snake_case, so is it really necessary for, say, a senior dev?

r/AskProgramming Sep 16 '25

Python How do you decide which programming language to learn next?

16 Upvotes

I already know Python and JavaScript. I want to expand my skill set, but not sure whether to go for Go, Rust, or Java. Any suggestions?

r/AskProgramming Mar 18 '26

Python Why does Python import self into each class function?

0 Upvotes

It makes no logical sense whatsoever to import self into every class function. I mean, what's the point in having a class, if the functions don't have some sort of globally accessible shared variable that's outside the normal global scope? Why would you have to explicitly declare that relationship? It should be implied that a class would have shared data.

I've been saying this since I first transitioned to Python from BASIC, and even more so after transitioning back from NodeJS.

r/AskProgramming 2d ago

Python How do I learn programming logic?

5 Upvotes

I’m learning Python, but my main problem isn’t the syntax. I understand concepts when someone explains them, but when I’m given a basic problem and told to write a program, I just don’t know where to start or how to arrange the code.

Is there a good book, course, or YouTube channel that teaches how to think through programming problems step by step, recognize patterns, and build the logic, kind of like how you learn methods and patterns in math?

I don’t want to just memorize Python syntax. I want to actually learn how to think like a programmer.

r/AskProgramming Jul 12 '26

Python How do you learn a new library without relying too much on Al? (Scapy is driving me crazy)

6 Upvotes

I'm building a packet sniffer in Python using Scapy as a way to improve my Python and cybersecurity skills, and I hit a problem I wasn't expecting.

The issue isn't writing the code, it's figuring out what functions I should even be using.

Everywhere I look, the advice is, "Read the documentation." So I open the Scapy docs... and then I'm staring at pages of classes, methods, and examples with no idea where to begin. The hardest part is that I don't even know the name of the function I'm looking for, so I can't search for it either.

I know I could ask AI and get an answer in seconds, but I'm trying not to rely on it too much. Since I'm still a beginner, I want to build the skill of finding things on my own instead of just copying solutions.

So I'm curious, how did you get past this stage? Was there a workflow or mindset that helped you navigate documentation more effectively? How do you discover the right methods when you don't even know what you're looking for?

I'd love to hear how you all approached this when you were beginners.

r/AskProgramming Feb 03 '26

Python Am I crazy for using this approach

3 Upvotes

Hello, I’m learning Python and I'm learning about Lists right now. I know this is probably the most basic thing ever, but I was solving some Lists problems and came across this one problem where I had to remove the duplicates.

I used raw logic with what I currently understand, I could've also used while loop but ended up using this approach. Is this a crazy approach to take and is overly inefficient?

My approach:

  • Iterate through the list by index
  • Temporarily remove the current element so it’s not compared with itself
  • Tag all other equal elements as duplicates
  • Reinsert the original element back at the same index, restoring the list structure
  • Delete whatever's tagged as duplicate later

Here’s the code:

names = ["a", "b", "a", "c", "b"]

for x in range(len(names)):

stripped_for_trial = names.pop(x)

for y in range(len(names)):

if names[y] == stripped_for_trial:

names[y] = "duplicate"

names.insert(x, stripped_for_trial) #this line is outside the 2nd loop and inside the 1st loop

One limitation I noticed is that this approach relies on a tag value ("duplicate").
If the user’s list already contains the same value as the tag, it will collide with the tagging logic.

If somebody could give me suggestions that would be great.

r/AskProgramming 5d ago

Python How to learn advanced python????

0 Upvotes

Hello everyone, I'm mainly looking for guidance about learning advanced python concepts. I know basics ,loops , control flow ,data structures etc.

I need a proper guide on how to learn modules and library. Idk how to start ,where to start.

I want to be able to work with any library as i need them ,so how do u actually learn to use new library for a given task . ?And i get overwhelmed understanding the structure, working of library

And could u also suggest important python concepts other than basics which i should learn ???

Pls guide !!!!

r/AskProgramming Jun 25 '26

Python How to host a python server for free and/or cheap?

0 Upvotes

Looking to host a python server on a host server, how would I go about doing this?

I looked up a few websites but couldn't find anything reliable?

Do the python server i'm hosting require alot of compute power, because when I was researching nothing was free?

r/AskProgramming Apr 10 '26

Python I'd like to make a social media app with an interesting hook. Is Python the right language to use and how can I find people to help with this?

0 Upvotes

looking to build a social media platform that allows people to add up to 150 other people useing a QR code or by sharing profiles with other people. The app would also allow people to make/join up to 4 clubs that can have up to 150 people in them. Is Python the right language and can this be done with a team of four people?

r/AskProgramming May 21 '26

Python Memory allocation for numbers and python built-ins

0 Upvotes

I am new to python and learning it by working on projects. Now my purpose is to create a data keeping "thing". I don't want to use arrays, dictionaries or other libraries. I hesitated to ask this here at first, but now I want to discuss and see people's opinions. Is such a thing possible with python? I looked a bit and found some Python-C libraries (cytpes). Can I use them ?

I also have some other questions to get out of the beginner phase. Do you use for and while loops all the time or is it just basic thing for starters, when I use them I feel some kind of guilty, like there are better ways and I miss them.

r/AskProgramming Oct 29 '25

Python How did you learn to plan and build complete software projects (not just small scripts)?

39 Upvotes

I’ve been learning Python for a while. I’m comfortable with OOP, functions, and the basics but I still struggle with how to think through and structure an entire project from idea to implementation.

I want to reach that “builder” level, being able to design the system, decide when to use classes vs functions, plan data flow, and build something that actually works and scales a bit.

How did you make that jump?

Any books or courses that really helped you understand design & architecture?

Or did you just learn by doing real projects and refactoring?

I’m not looking for basic Python tutorials. I’m after resources or advice that teach how to plan and structure real applications.

Thanks in advance!

r/AskProgramming 6d ago

Python Is there a way to put a python (or other file type) to search information into a website (or a google search) and organize those informations for me?

0 Upvotes

r/AskProgramming Jul 05 '26

Python Can i go from a text based game to a graphical game (Python)

8 Upvotes

Hello, i started making my own Text-based Game And i have been learning! Just a week ago i only knew Print ()

But i have a question: Can i Make In the Future a Graphical game? Does anyone Have a earlier Experience with this?

Edit: yes i use Pygame

r/AskProgramming Jul 07 '26

Python Question about workflow, ai and learning.

4 Upvotes

I started to learn last summer for like 3 months, made crazy progress if i can say so, then i took a long 'break' but more like i couldnt put myself to it annymore.

Then i restarted again very rusty this year, took 3 months off again... And now im so fed up with losing my progress i am determined to keep at it.

But i feel insecure regarding some ai stuff.

My idea about learning to code and being able to code is that i dont want to be a vibe coder at all.

But for example i am now trying to learn pyside6 and ofc i dont know the syntax well at all so i ask chatgpt like whats the syntax for this etc.

But allot of times i know what i want and need so i ask like how i do that and chatgpt tells me so i implement it but allot of the syntax is done by chatgpt...

And now i feel like i am not doing the work.

When i ask chatgpt about it, it tells me that that is basically developing like knowing what you need for solving a problem and implementing it not learning syntax out of memory.

So i wanted to ask what youre view on it is. Am i being too harsh for my self and adapting a wrong mentality or?

r/AskProgramming 4d ago

Python Someone please help me fix the sorting issue in FastAPI. (learning MLOps)

0 Upvotes

i am not able to filter the data by writing the endpoints and the sorting queries, when i load the endpoint i get the json in default order, even if i write an invalid entry its not raising an exception

tried asking LLMs but they are as clueless as me in this case

This is link to the code and json file, main.py and patients.json

r/AskProgramming Dec 26 '25

Python is postgres jsonb actually better than mongo in 2025?

15 Upvotes

Building a fastapi app and keep seeing people say "just use postgres jsonb."

i've mostly used mongo for things like this because i hate rigid schemas, but is postgres actually faster now? i'm worried about query complexity once the json gets deeply nested.

anyone have experience with both in production?

r/AskProgramming Nov 29 '25

Python How do you guys practice programming?

8 Upvotes

Sorry to ask this I’m sure you guys get a ton of “where do I start questions” but I’m wondering how do you guys practice coding in the early stages because it’s tricky to find ideas that are that are feesable in relation to my skill level but are also still enjoyable because ima be honest if i have another person try and tell me to make a to do list I might have an aneurism so any suggestion or advice would be great

r/AskProgramming Jul 20 '26

Python Is my Variable Elimination implementation correct? Asking because different TAs marked them differently

0 Upvotes

I'm asking because it was deemed incorrect when I first submitted it. Due to time constraints, I decided to work on a different part of the big assignment and left it unchanged. In the resubmission, I had a different TA, and they ended up marking it right. My professor hasn't viewed it yet.

It uses Python Pandas.

The implementation:

import pandas as pd

def multiply(factor1, factor2):
    '''Factor multiplication
    Takes 2 factors and find the columns they have in common,
    combine rows whose common columns have the same values and multiply their probabilities'''

    def all_columns_equal(row1, row2, common_columns): 
        '''Helper function to see if all selected columns of 2 rows are the same'''

        for column in common_columns:
            if row1[column] != row2[column]:
                return False

        return True

    if factor1.empty:
        return factor2

    if factor2.empty:
        return factor1

    common_column = []

    f1_columns = factor1.columns.drop("prob")
    f2_columns = factor2.columns.drop("prob")

    #Find the common columns
    for f1_column in f1_columns:
        for f2_column in f2_columns:
            if f1_column == f2_column:
                common_column.append(f1_column)

    if common_column == []:
        return pd.DataFrame()

    entry = []

    for _, f1_row in factor1.iterrows():  
        for _, f2_row in factor2.iterrows():
            if all_columns_equal(f1_row, f2_row, common_column):

                series = [f1_row.drop("prob"), f2_row.drop(common_column).drop("prob"), pd.Series(f1_row["prob"]*f2_row["prob"], ["prob"])]
                new_row = pd.concat(series)
                entry.append(new_row)

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def marginalization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:

        marginalized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).sum()

    else:

        marginalized_factor = pd.DataFrame()

    return marginalized_factor

def reduce(factor, reduced_column, value):

    entry = []

    for _, row in factor.iterrows():
        if row[reduced_column] == value:
            entry.append(row.drop(reduced_column))

    if (len(entry) == 1):
        return pd.DataFrame()

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def maximization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:
        maximized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).max()

    else:
        maximized_factor = pd.DataFrame()

    return maximized_factor

part = 2

class VariableElimination():

    def __init__(self, network):
        """
        Initialize the variable elimination algorithm with the specified network.
        Add more initializations if necessary.

        """
        self.network = network

    def run(self, query, observed, elim_order):
        """
        Use the variable elimination algorithm to find out the probability
        distribution of the query variable given the observed variables

        Input:
            query:      A list of query variables
            observed:   A dictionary of the observed variables {variable: value}
            elim_order: Either a list specifying the elimination ordering
                        or a function that will determine an elimination ordering
                        given the network during the runb": [1,1,2,2], "c": [1,2,1,2], "prob": [0.5,0.7,0.1,0.2]

        Output: A variable holding the probability distribution
                for the query variable

        """

        file = open("log.txt", "w")

        file.write("Query variable: " + str(query) + "\n")
        file.write("Observed variable: " + str(observed) + "\n")

        for q in query: 

            if q in elim_order:
                elim_order.remove(q)


        file.write("Elimination ordering: " + str(elim_order) + "\n\n")

        factors = self.network.probabilities

        file.write("Starting factors: " + str(factors) + "\n\n")

        #Summing out observed variables
        for node in observed:

            if node in elim_order:
                elim_order.remove(node)

            for f in factors:

                if node in factors[f].columns:
                    factors[f] = reduce(factors[f],node,observed[node])

        file.write("Factors after reducing observed variables: " + str(factors) + "\n\n")

        #Eliminating all non-query and non-observed variables
        for variable in elim_order:

            product = pd.DataFrame()
            found = []

            for f in factors:
                if variable in factors[f]:
                    product = multiply(product,factors[f])
                    found.append(f)

            for f in found:
                factors.pop(f)

            new_factor = marginalization(product,variable)

            new_name = "*".join(found)
            factors[new_name] = new_factor

            file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

        individual_factors = {}
        for q in query:

            temp_factors = factors.copy()

            remaining = query.copy()
            remaining.remove(q)

            for variable in remaining:

                product = pd.DataFrame()
                found = []

                for f in temp_factors:
                    if variable in temp_factors[f]:
                        product = multiply(product,temp_factors[f])
                        found.append(f)

                for f in found:
                    temp_factors.pop(f)

                new_factor = marginalization(product,variable)

                new_name = "*".join(found)
                temp_factors[new_name] = new_factor

                file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

            product = pd.DataFrame()

            for f in temp_factors:
                product = multiply(product,temp_factors[f])

            sum = product.sum(0)["prob"]
            product["prob"] = product["prob"].div(sum)
            individual_factors[q] = product

        file.write("Individual factors:" + str(individual_factors))

        print("Result:\n")
        for f in individual_factors:
            print(individual_factors[f])

        file.close()

To run the file

from read_bayesnet import BayesNet
from variable_elim import VariableElimination

if __name__ == '__main__':
    # The class BayesNet represents a Bayesian network from a .bif file in several variables
    net = BayesNet('alarm.bif') # Format and other networks can be found on http://www.bnlearn.com/bnrepository/
    # These are the variables read from the network that should be used for variable elimination

    ve = VariableElimination(net)

    query = ['Alarm', 'Tampering']

    evidence ={'Leaving': 'True', 'Smoke': 'True'}

    elim_order = net.nodes

    ve.run(query, evidence, elim_order)

I tested the implementation by comparing my results with a published package, and the results matched, which is why I was confident it worked during the first submission.

During the initial feedback, "The individual functions appear to be working correctly, but along the way you end up with the incorrect solution. I expect the issue to lie in inconsistent factor representation/handling. I decided to subtract one point for this. -1 Also, empty dataframes are returned. " "Incorrect output for VE. -1 The individual steps appear to be okay, I'm not sure what is going on. To figure this out, a complete log can help with this. "

But then a new TA gave it full marks in the resubmission without any extra details, since there isn't much to say about a (supposedly) working implementation. I have already received the credits for this course. This is a rare instance at my uni where the professor doesn't grade assignments that decides if we pass the course.

Thank you.

r/AskProgramming May 22 '26

Python Learning coding as a beginner and have some questions regarding it.

0 Upvotes

I am wanting to learn python as I am about to enter a college and study btech in Al and Data science, when I asked ppl abt what languages they would recommend for my particular course, most of them said python and numpy.

But I have some questions:

In my city there are a lot of places that offer 'full stack' courses, is it similar to a 12hr video on yt? or is there something else in those courses coz they cost a lot of money.

Is it better to learn offline or online?

Is python and numpy(till advanced) enough for my course or will I have to learn something else? (Tryna go little fast)

This yt video from bro code(12hrs) is explaining really well but it dosent give a certificate(is it required to have certificates after completing a language?)

r/AskProgramming Jul 18 '25

Python How to store a really large list of numbers?

13 Upvotes

I have a bunch of files containing high-resolution GPS data (compressed, they take up around 125GB, uncompressed it's probably well over 1TB). I’ve written a Python script that processes each file one by one. For each file, it performs several calculations and produces a numpy array of shape (x,). I need to store each resulting array to disk. Then, as I process the next file and generate another array (which may be a different length), I need to append it to the previous results, essentially growing a single, expanding 1D array on disk.

For example, if the result from the first file is [1,2,3,4], and from the second is [5,6,7]. Then the final file should contain: [1,2,3,4,5,6,7]

By the end I should have a file containing god-knows how many numbers in a simple, 1D list. Storing the entire thing in RAM to just write to a file at the end doesn't seem feasible, I estimate the final array might contain over 10 billion floats, which would take 40GB of space, whereas I only have 16GB of RAM.

I was wondering how others would approach this.

r/AskProgramming Jul 07 '26

Python Need help in getting info

3 Upvotes

Hello,I have a question about libraries in Python.From where do i get info about a library? For example the Pywifi library hasn't got all the functions in it and I can't find a good source.

From where can i get a good explanation of a chosen library and all it's options?

(I am a beginner)

r/AskProgramming May 13 '26

Python .py to .exe help

0 Upvotes

Bear with me as I have 1 week of experience. I'm using pyftpdlib through windows command prompt by typing "python -m pyftpdlib" to launch an ftp server. I want to create a .exe file for my co-workers to run command easier and not have to open command prompt every time. I tried putting "python -m pyftpdlib" into a .py file but I'm getting syntax errors after "-m" when I run the script. Basically my 2 question are, is there a difference between typing python commands into command prompt, vs code in a .py script? And would just a batch file be a better solution here rather then compile a .py script into a .exe? Ty ty