Skip to content

Commit e3f60a8

Browse files
authored
Merge pull request pallets-eco#591 from prophile/python3-in-docs
Python 3 tweaks in docs
2 parents ccdb696 + 4620931 commit e3f60a8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

docs/queries.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Retrieve a user by username:
8282
>>> peter.id
8383
2
8484
>>> peter.email
85-
85+
8686

8787
Same as above but for a non existing username gives `None`:
8888

@@ -93,22 +93,22 @@ True
9393
Selecting a bunch of users by a more complex expression:
9494

9595
>>> User.query.filter(User.email.endswith('@example.com')).all()
96-
[<User u'admin'>, <User u'guest'>]
96+
[<User 'admin'>, <User 'guest'>]
9797

9898
Ordering users by something:
9999

100100
>>> User.query.order_by(User.username).all()
101-
[<User u'admin'>, <User u'guest'>, <User u'peter'>]
101+
[<User 'admin'>, <User 'guest'>, <User 'peter'>]
102102

103103
Limiting users:
104104

105105
>>> User.query.limit(1).all()
106-
[<User u'admin'>]
106+
[<User 'admin'>]
107107

108108
Getting user by primary key:
109109

110110
>>> User.query.get(1)
111-
<User u'admin'>
111+
<User 'admin'>
112112

113113

114114
Queries in Views

docs/quickstart.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ But they are not yet in the database, so let's make sure they are::
6060
Accessing the data in database is easy as a pie::
6161

6262
>>> User.query.all()
63-
[<User u'admin'>, <User u'guest'>]
63+
[<User 'admin'>, <User 'guest'>]
6464
>>> User.query.filter_by(username='admin').first()
65-
<User u'admin'>
65+
<User 'admin'>
6666

6767
Note how we never defined a ``__init__`` method on the ``User`` class?
6868
That's because SQLAlchemy adds an implicit constructor to all model
@@ -143,8 +143,8 @@ load all categories and their posts, you could do it like this::
143143
>>> from sqlalchemy.orm import joinedload
144144
>>> query = Category.query.options(joinedload('posts'))
145145
>>> for category in query:
146-
... print category, category.posts
147-
<Category u'Python'> [<Post u'Hello Python!'>, <Post u'Snakes'>]
146+
... print(category, category.posts)
147+
<Category 'Python'> [<Post 'Hello Python!'>, <Post 'Snakes'>]
148148

149149

150150
If you want to get a query object for that relationship, you can do so

0 commit comments

Comments
 (0)