Now that Python 2.6 is out, what modules currently in the language should every programmer know about?

A lot of useful features in Python are somewhat "hidden" inside modules. Named tuples (new in Python 2.6), for instance, are found in the collections module.

The Library Documentation page will give you all the modules in the language, but newcomers to Python are likely to find themselves saying "Oh, I didn't know I could have done it this way using Python!" unless the important features in the language are pointed out by the experienced developers.

I'm not specifically looking for new modules in Python 2.6, but modules that can be found in this latest release.


Asked by: Rafael339 | Posted: 28-01-2022






Answer 1

The most impressive new module is probably the multiprocessing module. First because it lets you execute functions in new processes just as easily and with roughly the same API as you would with the threading module. But more importantly because it introduces a lot of great classes for communicating between processes, such as a Queue class and a Lock class which are each used just like those objects would be in multithreaded code, as well as some other classes for sharing memory between processes.

You can find the documentation at http://docs.python.org/library/multiprocessing.html

Answered by: Kelvin743 | Posted: 01-03-2022



Answer 2

The new json module is a real boon to web programmers!! (It was known as simplejson before being merged into the standard library.)

It's ridiculously easy to use: json.dumps(obj) encodes a built-in-type Python object to a JSON string, while json.loads(string) decodes a JSON string into a Python object.

Really really handy.

Answered by: Edgar837 | Posted: 01-03-2022



Answer 3

May be PEP 0631 and What's new in 2.6 can provide elements of answer. This last article explains the new features in Python 2.6, released on October 1 2008.

Answered by: John316 | Posted: 01-03-2022



Answer 4

Essential Libraries

The main challenge for an experienced programmer coming from another language to Python is figuring out how one language maps to another. Here are a few essential libraries and how they relate to Java equivalents.

os, os.path 

Has functionality like in java.io.File, java.lang.Process, and others. But cleaner and more sophisticated, with a Unix flavor. Use os.path instead of os for higher-level functionality.

sys 

Manipulate the sys.path (which is like the classpath), register exit handlers (like in java Runtime object), and access the standard I/O streams, as in java.lang.System.

unittest 

Very similar (and based on) jUnit, with test fixtures and runnable harnesses.

logging 

Functionality almost identical to log4j with loglevels and loggers. ( logging is also in the standard java.util.Logging library)

datetime  

Allows parsing and formatting dates and times, like in java.text.DateFormat, java.util.Date and related.

ConfigParser  

Allows persistant configuration as in a java Properties file (but also allows nesting). Use this when you don't want the complexity of XML or a database backend.

socket, urllib 

Similar functionality to what is in java.net, for working with either sockets, or retrieving content via URLs/URIs.

Also, keep in mind that a lot of basic functionality, such as reading files, and working with collections, is in the core python language, whereas in Java it lives in packages.

Answered by: Owen765 | Posted: 01-03-2022



Similar questions

vba - Resources for Python Programmer


Advice for C# programmer writing Python


C++ or Python for C# programmer?

Closed. This question is opinion-based. It is not c...


Python for C++ or Java Programmer

I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its "Main Function" or from where the program start executing. So is there any tutorial/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python. OK i think i did not put the que...


java - asm / C / Python / Perl / Lisp / Scheme Programmer looking for something new to learn

Closed. This question does not meet Stack Overflow guid...


Python for a Perl programmer

I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others). I might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like to ask SO overmind for good references on how to best learn Python for someone w...


Perl for a Python programmer

I know Python (and a bunch of other languages) and I think it might be nice to learn Perl, even if it seems that most of the people is doing it the other way around. My main concern is not about the language itself (I think that part is always easy), but about learning the Perlish (as contrasted with Pythonic) w...


Newbie Python programmer tangling with Lists

Here's what I've got so far: # A. match_ends # Given a list of strings, return the count of the number of # strings where the string length is 2 or more and the first # and last chars of the string are the same. # Note: python does not have a ++ operator, but += works. def match_ends(words): counter = 0 for word in words: if len(word) >= 2 and word[0] == word[-1]: counter += counter retur...


php - Old desktop programmer wants to create S+S project

I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage...


Proper way to do session handling in Python + Pylons for a php programmer

I'm a php programmer who's just getting started with Python. I'm trying to get Python to handle login/logout via database-stored sessions. Things work, but seem inconsistent. For example, sometimes a user isn't logged out. Sometimes users "switch" logins. I'm guessing this has something to do with thread-safety, but I'm just not sure where to begin on how to fix this. Any help would be appreciated. Here's what I hav...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top