~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/howto/doanddont.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
   f.read()
53
53
 
54
54
does not work. Of course, it works just fine (assuming you have a file called
55
 
"www".) But it does not work if somewhere in the module, the statement ``from os
56
 
import *`` is present. The :mod:`os` module has a function called :func:`open`
57
 
which returns an integer. While it is very useful, shadowing builtins is one of
58
 
its least useful properties.
 
55
"www".) But it does not work if somewhere in the module, the statement ``from
 
56
os import *`` is present. The :mod:`os` module has a function called
 
57
:func:`open` which returns an integer. While it is very useful, shadowing a
 
58
builtin is one of its least useful properties.
59
59
 
60
60
Remember, you can never know for sure what names a module exports, so either
61
61
take what you need --- ``from module import name1, name2``, or keep them in the
261
261
More useful functions in :mod:`os.path`: :func:`basename`,  :func:`dirname` and
262
262
:func:`splitext`.
263
263
 
264
 
There are also many useful builtin functions people seem not to be aware of for
 
264
There are also many useful built-in functions people seem not to be aware of for
265
265
some reason: :func:`min` and :func:`max` can find the minimum/maximum of any
266
266
sequence with comparable semantics, for example, yet many people write their own
267
267
:func:`max`/:func:`min`. Another highly useful function is :func:`reduce`. A