~crunch.io/ubuntu/precise/pymongo/unstable

« back to all changes in this revision

Viewing changes to doc/python3.rst

  • Committer: Joseph Tate
  • Date: 2013-01-31 08:00:57 UTC
  • mfrom: (1.1.12)
  • Revision ID: jtate@dragonstrider.com-20130131080057-y7lv17xi6x8c1j5x
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
  [GCC 4.5.3] on linux2
31
31
  Type "help", "copyright", "credits" or "license" for more information.
32
32
  >>> import pymongo
33
 
  >>> c = pymongo.Connection()
 
33
  >>> c = pymongo.MongoClient()
34
34
  >>> c.test.bintest.insert({'binary': b'this is a byte string'})
35
35
  ObjectId('4f9086b1fba5222021000000')
36
36
  >>> c.test.bintest.find_one()
43
43
  [GCC 4.5.3] on linux2
44
44
  Type "help", "copyright", "credits" or "license" for more information.
45
45
  >>> import pymongo
46
 
  >>> c = pymongo.Connection()
 
46
  >>> c = pymongo.MongoClient()
47
47
  >>> c.test.bintest.find_one()
48
48
  {u'binary': Binary('this is a byte string', 0), u'_id': ObjectId('4f9086b1fba5222021000000')}
49
49
 
151
151
will be the first thing in your path. Importing pymongo will result in an
152
152
exception similar to::
153
153
 
154
 
  Python 3.1.4 (default, Mar 21 2012, 14:34:01)
155
 
  [GCC 4.5.3] on linux2
 
154
  Python 3.1.5 (default, Jun  2 2012, 12:24:49)
 
155
  [GCC 4.6.3] on linux2
156
156
  Type "help", "copyright", "credits" or "license" for more information.
157
157
  >>> import pymongo
158
158
  Traceback (most recent call last):
159
159
    File "<stdin>", line 1, in <module>
160
 
    File "pymongo/__init__.py", line 104, in <module>
161
 
      from pymongo.connection import Connection
162
 
    File "pymongo/connection.py", line 573
163
 
      except Exception, why:
164
 
                      ^
165
 
  SyntaxError: invalid syntax
 
160
    File "pymongo/__init__.py", line 58, in <module>
 
161
      version = get_version_string()
 
162
    File "pymongo/__init__.py", line 54, in get_version_string
 
163
      if isinstance(version_tuple[-1], basestring):
 
164
  NameError: global name 'basestring' is not defined
166
165
 
167
166
Note the path in the traceback (``pymongo/__init__.py``). Changing out of the
168
167
source directory takes the untranslated modules out of your path::
169
168
 
170
169
  $ cd ..
171
170
  $ python
172
 
  Python 3.1.4 (default, Mar 21 2012, 14:34:01) 
173
 
  [GCC 4.5.3] on linux2
 
171
  Python 3.1.5 (default, Jun  2 2012, 12:24:49)
 
172
  [GCC 4.6.3] on linux2
174
173
  Type "help", "copyright", "credits" or "license" for more information.
175
174
  >>> import pymongo
176
175
  >>> pymongo.__file__