r/learnpython • • Feb 18 '26

Python modules

Can someone please tell me how they learned python modules and how to know which one to use ?

0 Upvotes

13 comments sorted by

11

u/FriendlyRussian666 Feb 18 '26

Normally you have a problem you're trying to solve, and so you look for already made solutions. You therefore google to see if anything is available, and that's how you know what to use. In terms of learning, you read the documentation to understand what the code provides, how to implement it, etc.

1

u/GodsIWasStrongg Feb 18 '26

Yep, the real skill is learning to read and digest documentation.

7

u/PushPlus9069 Feb 18 '26

Nobody memorizes modules — you learn them by needing them.

Here's how it works in practice: you have a problem ("I need to read a CSV") → you search "python read CSV" → you find the csv module or pandas. Next time you need dates, same thing → datetime. Over time, your mental library grows naturally.

The modules worth knowing early: os and pathlib (files/folders), json (data), datetime (time), collections (Counter, defaultdict), and requests (HTTP calls, pip install). These cover maybe 80%% of beginner needs.

Don't try to study the standard library like a textbook. Build small projects and you'll absorb what you need.

1

u/schoolmonky Feb 18 '26

I would add itertools and functools to that list, if only because you wouldn't know that you need them unless you already have at least a surface level knowledge of what they do.

1

u/Moikle Feb 18 '26

A python module is just a python file.

What do you mean "learn python modules"?

As in how to import? How to make your modules discoverable by other python modules? What are you struggling with specifically?

1

u/Fabulous_Bell6806 Feb 18 '26

Am a beginner in python ,but I know how to import the modules so I just wanted to know like when do you know that you need a particular module

1

u/Moikle Feb 18 '26

Each module has a purpose. Generally you choose the one that is designed to do the thing you are trying to do.

You want a random number? Import the random module, want to send http requests? Import the requests module. Want to make uis? Import tkinter or install and import pyqt/pyside.

Now you might not immediately know which ones do what, but that's what google and the docs are for.

1

u/Fabulous_Bell6806 Feb 19 '26

Ok thanks I'll try that

2

u/etrmx Feb 18 '26

The best way to learn is readings docs, tbh maybe a taboo answer but if you have a particular thing you’re trying to accomplish in my I’ve found asking a couple different LLMs which library they’d recommend and then asking why can be informative

1

u/hantuumt Feb 18 '26

You should design, develop and implement projects. A good place to start is on kaggle to know what are current gaps across various sectors, Project Euler to showcase your logical and maths skills.

Please don't hesitate to contact me.

1

u/stepback269 Feb 18 '26

By "python modules", do you mean rolling your own or simply importing someone elses?

At some point, your code is going to get too long and ungainly. You'll want to stuff some of it away in so-called modules so that the sight of them doesn't interfere with the higher level code you are currently developing. A "module" is simply a dot py file that contains py code like functions for example. The module is an "object" just like pretty much everything in Python is an object (strings are objects, lists are objects, etc.) You call the functions you have in your self-rolled module using dot notation, just like calling string methods. For example:
x = my_module.my_function(input_1, input_2)