~ubuntu-branches/ubuntu/natty/python3.2/natty-security

« back to all changes in this revision

Viewing changes to Doc/tutorial/stdlib.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-12-06 12:19:09 UTC
  • mfrom: (1.1.3 upstream) (7.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20101206121909-c40vnqniur1fq5lx
Tags: 3.2~b1-1
* Python 3.2 beta1 release.
* Configure with --enable-loadable-sqlite-extensions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
operating system::
15
15
 
16
16
   >>> import os
17
 
   >>> os.system('time 0:02')
18
 
   0
19
17
   >>> os.getcwd()      # Return the current working directory
20
18
   'C:\\Python31'
21
 
   >>> os.chdir('/server/accesslogs')
 
19
   >>> os.chdir('/server/accesslogs')   # Change current working directory
 
20
   >>> os.system('mkdir today')   # Run the command mkdir in the system shell
 
21
   0
22
22
 
23
23
Be sure to use the ``import os`` style instead of ``from os import *``.  This
24
24
will keep :func:`os.open` from shadowing the built-in :func:`open` function which
207
207
:mod:`tarfile`. ::
208
208
 
209
209
   >>> import zlib
210
 
   >>> s = 'witch which has which witches wrist watch'
 
210
   >>> s = b'witch which has which witches wrist watch'
211
211
   >>> len(s)
212
212
   41
213
213
   >>> t = zlib.compress(s)
214
214
   >>> len(t)
215
215
   37
216
216
   >>> zlib.decompress(t)
217
 
   'witch which has which witches wrist watch'
 
217
   b'witch which has which witches wrist watch'
218
218
   >>> zlib.crc32(s)
219
219
   226805979
220
220