r/learnpython • • 4h ago

How do you keep a small open-source package maintained over time?

5 Upvotes

I recently published my first package on PyPI. It works and has tests and CI, but I've never maintained anything long term. For those of you with packages people actually use:

  • How to determine which features should be in a patch and which in a small release. And when to upgrade to 1.0?
  • How to ensure that your dependencies and GitHub actions are up-to-date without it becoming tedious. For example, is Dependabot or Renovate (or another tool) used?
  • Should dependencies be version locked or not?
  • How much time do you allocate to this? And how do you manage it if you are particularly busy?

All good practice and common errors are really appreciated!


r/learnpython • • 6h ago

Append key and value list to another value list of a different dict...

2 Upvotes

I have a problem that I need to solve, and I've been working on this for too long to care about doing it another way.

I have a dict with keys that I need to split into different sections. For example: I need keys 1-3, 4-6, 7-9 to go into section 1, 2, 3 etc, which have their own keys in another dictionary (Code below)

sectioned = {'1': {}, '2': {}, '3': {}}
unsectioned = {'key1': [value1, value2, value3], 'key2': [value1, value2, value3], 'key3': [value1, value2, value3], 'key4': [value1, value2, value3], 'key5': [value1, value2, value3], 'key6': [value1, value2, value3], 'key7': [value1, value2, value3], 'key8': [value1, value2, value3], 'key9': [value1, value2, value3]}

I want to move these to make:

sectioned = {'1': {'key1': [value1, value2, value3], 'key2': [value1, value2, value3], 'key3': [value1, value2, value3]}, '2': {'key4': [value1, value2, value3], 'key5': [value1, value2, value3], 'key6': [value1, value2, value3]}, '3': {'key7': [value1, value2, value3], 'key8': [value1, value2, value3], 'key9': [value1, value2, value3]}}

How would I do this? I've tried a few things using 'for' statements, but I can't get it quite right...


r/learnpython • • 14h ago

6 weeks into learning python and a friend keeps telling me to switch to go for backend

2 Upvotes

6 weeks in, about an hour most nights. function, loops, dicts, just started classes. i want to end up doing backend work and was about to pay for a structured python course but a friend who writes go at work keeps saying python is a detour and i should switch now before i get too deep. i don't want to restart every time someone has an opinion but i also don't want to burn months on the wrong things. so do i stay or switch??


r/learnpython • • 15h ago

What exactly i've should learn to automation and script building?

2 Upvotes

Hey guys, my english is very bad but i think you can understand!

I have a good knowledge in java development and linux fundamentals, but lately i have searching ways to be more efficient in my personal projects, and python always appears in very different cases.

To be more specifically, i love build my own programs and create some terminal apps.

So, how can i learn python without watching insane playlists with 40 minutes / video, just using previous knowledge!


r/learnpython • • 15h ago

Hot write "Not A, unless B" in Boolean Algebra?

2 Upvotes

I have a rather complex row selection mission at hand.

To select the rows I want, I have to use two lists of keywords. One contains words that I want (kw_Y), and the other contains words I don't want (kw_N). I originally used this simply to collect the rows that have the wanted information, but now I need to do some comparison analysis with rest of the data.

I need to select rows "that don't have the kw_Y terms, unless they have kw_N terms". Or as Google put it: "No A unless B" (meaning A is false except when B is true) translates to ¬A unless B, or ¬A ∨ B (logically equivalent to B → A, "if B then A").

Boolean logic has never been my strongest point. What would this be in Python?

Codes:

good_stuff = dataframe[kw_Y & ~kw_N] #Yes these masks, not just lists. Algebra is the focus.

bad_stuff = dataframe[kw_N & ~kw_Y] #didn't select enough rows

bad_stuff2 = dataframe[~kw_Y] #I realized this removes rows that contain stuff I now want. 

all_bad_stuff = dataframe[???]

r/learnpython • • 51m ago

Does anyone play high level sudoku?

1 Upvotes

Hi,

I'm trying to make a very advanced sudoku player in python.

However, it generates sudokus far too slowly. Can someone help me? (I'll only share source code once someone says yes)


r/learnpython • • 19h ago

At what point did Python finally click for you as a beginner?

1 Upvotes

I've recently started learning Python and have covered variables, loops, functions, lists and dictionaries. I also started building a simple banking system to put what I've learned into practice.

I can understand most of the code when reading it, but writing everything from scratch is a different challenge.

For those who started with absolutely no programming background, at what point did you become confident enough to build something independently?

Did you finish a course first or just keep building small projects until things started clicking?

Would love to hear about your experiences and anything you wish you had done differently as a beginner.


r/learnpython • • 19h ago

How to not clobber a class when inheriting

0 Upvotes

I wrote a visitor to extract some datas via the ast

class VariableFinder(ast.NodeTransformer):
    """ Visitor pattern impl."""
    def __init__(self, find_object:str, find_method:str):
        """ 
        filter for only method calls that match find_object.find_method 
        store the line number and store the value or args passed to the call
        """
        self.find_method = find_method
        self.find_object = find_object
        self.found = []
...

And it struck me this is not C++, so how do we stop ourselves accidentally blatting/clobbering over ast.NoteTransformer attributes? I'm missing something and my searches are all indicating that the visitor pattern is frowned upon. Is there an alternative way to do these safely?