3

Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am making this question a wiki.

itsaboutcode
  • 24,525
  • 45
  • 110
  • 156
  • 3
    Duplicate: http://stackoverflow.com/questions/1453952/most-useful-python-modules-from-the-standard-library. And apparently you haven't made this community wiki either. – ire_and_curses Nov 30 '09 at 16:49

7 Answers7

9

The standard libraries, i.e. the ones considered more or less part of Python. Start with those, there is plenty to learn before starting on 3rd party stuff.

Things like:

unwind
  • 391,730
  • 64
  • 469
  • 606
9

Check out the excellent Python Module of the Week blog series.

Jonathan Feinberg
  • 44,698
  • 7
  • 80
  • 103
  • Those blog are actually just descriptions of modules in python's standard library. Yep, there's plenty of functionality in there. Lots of fun things to do and learn. – Reinout van Rees Dec 01 '09 at 08:53
5

The re module is a must. itertools also often comes handy.

Generally speaking: Take a deep look at Standard library. Then you might think about wxPython for GUI, numPy for computations, Django for web and Amara for XML, and... there's plenty of Python libs and modules out there. Just suit your needs.

u0b34a0f6ae
  • 48,117
  • 14
  • 92
  • 101
Abgan
  • 3,696
  • 22
  • 31
4

Actually, to work problems from a C++ book using Python, you mainly just need to master Python's built-in types, especially the data structures tuple, list, set, and dict; and the built-in functions, like max, min, sorted, and reversed.

These builtins have a lot of features that aren't obvious at first, such as the in keyword, the optional key= argument to list.sort, list slicing, sequence multiplication, the dict(list_of_pairs) constructor, del, tuple unpacking, and so on. It's fun to learn these, and they make Python a real joy to use.

Also see collections.defaultdict. If you need file I/O, read about open and file objects.

Jason Orendorff
  • 42,793
  • 6
  • 62
  • 96
4

math

Seems too fundamental, but when getting started with python (lets face it, I'm still learning it) I missed some functions in the math module that would have been helpful. I ended up writing my own versions which worked but I could have saved time...

Frank V
  • 25,141
  • 34
  • 106
  • 144
2

Since you ask about libraries, not specific modules in them, the standard library that comes with Python is the first and most fundamental answer; the programming challenges from a C++ book are unlikely to require anything beyond that (such as GUI toolkits) -- perhaps numpy/scipy if the book is heavily slanted to scientific programming.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
1

The standard library, especially the built-in functions. They seem trivial but can yield impressive results!

It really pays to know the basics of a default python installation. If you doubt that just follow the Stack Overflow python questions. Some answers are just amazing :)

Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
extraneon
  • 23,575
  • 2
  • 47
  • 51