04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 10 ■ BATTERIES INCLUDED 253<br />

• sets, heapq, deque: Three modules giving you three useful data structures. Sets are also<br />

available in the form of the built-in type set.<br />

• time: A module for getting the current time, and for manipulating and formatting<br />

times and dates.<br />

• random: A module with functions for generating random numbers, choosing random<br />

elements from a sequence, or shuffling the elements of a list.<br />

• shelve: A module for creating a persistent mapping, which stores its contents in a<br />

database with a given file name.<br />

• re: A module with support for regular expressions.<br />

If you are curious to find out more, I again urge you to browse the Python Library Reference<br />

(http://python.org/doc/lib). It’s really interesting reading.<br />

New Functions in This Chapter<br />

Function<br />

dir(obj)<br />

help([obj])<br />

reload(module)<br />

Description<br />

Returns an alphabetized list of attribute names<br />

Provides interactive help or help about a specific object<br />

Returns a reloaded version of a module that has already been imported<br />

What Now?<br />

If you have grasped at least a few of the concepts in this chapter, your Python prowess has<br />

probably taken a great leap forward. With the standard libraries at your fingertips, Python<br />

changes from powerful to extremely powerful. With what you have learned so far, you can write<br />

programs to tackle a wide range of problems. In the next chapter, you learn more about using<br />

Python to interact with the outside world of files and networks, and thereby tackle problems of<br />

greater scope.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!