~ubuntu-branches/ubuntu/karmic/python3.0/karmic

« back to all changes in this revision

Viewing changes to Doc/howto/doanddont.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-16 17:18:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090216171823-1d5cm5qnnjvmnzzm
Tags: 3.0.1-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
************************************
2
 
  Idioms and Anti-Idioms in Python  
 
2
  Idioms and Anti-Idioms in Python
3
3
************************************
4
4
 
5
5
:Author: Moshe Zadka
94
94
   # bar.py
95
95
   from foo import a
96
96
   if something():
97
 
       a = 2 # danger: foo.a != a 
 
97
       a = 2 # danger: foo.a != a
98
98
 
99
99
Good example::
100
100
 
271
271
 
272
272
This version is bulletproof::
273
273
 
274
 
   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9] 
 
274
   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9]
275
275
           + calculate_number(10, 20)*forbulate(500, 360))
276
276