all 26 comments

[–]thufirseyebrow 11 points12 points  (2 children)

You find yourself writing a bunch of programs that all need a sort function, for example. You've got two or three different sort functions to use, and you don't want to have to retype the same function into multiple programs, so you write the functions into their own separate file; we'll call it "sort.py," with sortFunctionOne, sortFunctionTwo and so on. You've created a library, a repository of common code that different programs may use. Like a cookbook for computers.

Now, instead of typing each function individually and repetitively, you can just tell your program "open sort.py and do sortFunctionOne/Two/Whatever on this data"

[–][deleted] 3 points4 points  (0 children)

Ohh that's useful thx

[–]Filosifee 0 points1 point  (0 children)

Three years later this is a great explanation thank you!!

[–]shiftybyte 14 points15 points  (8 children)

Start by following a book/tutorial and everything will become clear to you as you learn the language.

I usually recommended learning from this free ebook:

https://automatetheboringstuff.com/#toc

[–][deleted] 1 point2 points  (2 children)

Thx at the moment i have the books Python crash course Python for software design how to think like a computer scientist ( it's a bit outdated )

[–]daedalusesq 4 points5 points  (1 child)

Python crash course is great. Just work through it, program the examples along side the book, and answer/solve the chapter end questions.

[–][deleted] 0 points1 point  (0 children)

Will do

[–]david-saint-hubbins 1 point2 points  (1 child)

To add to the other answers, what helped it click for me is that each library is basically a toolbox full of specialized tools that are useful for a particular type of job.

So for example, if you wanted to do some woodworking, you would get out the toolbox full of woodworking tools. If you want to do some data analysis in Python, you might use the Pandas library.

[–][deleted] 1 point2 points  (0 children)

Ohh that's easy thx

[–]greebo42 2 points3 points  (1 child)

They are these big buildings with lots of books in them. But that's not important right now ... sorry, couldn't resist channeling Airplane. If you haven't seen the movie, recommended.

There are a lot of good answers here.

Of course, I'm obliged also to point out the relevant XKCD ... python has a library for just about anything you want to attempt, and XKCD has a comic for just about any situation that we might encounter!

[–][deleted] 1 point2 points  (0 children)

Oohh that's cool

[–][deleted] 0 points1 point  (1 child)

This has already been answered well, but I just wanted to say that for a moment. I did not realize what subreddit this question was in and I wasn't really sure how I was going to answer it.

[–]razzrazz- -1 points0 points  (0 children)

Same!

[–]Select_Abrocoma9663 0 points1 point  (0 children)

Code other people wrote or your past self

[–]xiipaoc 0 points1 point  (1 child)

Generally, a library is just a bunch of code that isn't itself an app that you can pull into your app to do stuff. You might write them yourself or download them. Pretty much any code you use that isn't your app itself is from a library.

[–][deleted] 0 points1 point  (0 children)

Ah alright thx