summaryrefslogtreecommitdiff
path: root/examples/vertical
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 19:53:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 19:53:57 -0400
commit4b614b9b35cd2baddb7ca67c04bee5d70ec6a172 (patch)
tree7483cd269f5823f903f96709eb864fff9b6d9383 /examples/vertical
parent9716a5c45e6185c5871555722d8495880f0e8c7a (diff)
downloadsqlalchemy-4b614b9b35cd2baddb7ca67c04bee5d70ec6a172.tar.gz
- the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
Diffstat (limited to 'examples/vertical')
-rw-r--r--examples/vertical/dictlike-polymorphic.py66
-rw-r--r--examples/vertical/dictlike.py58
2 files changed, 62 insertions, 62 deletions
diff --git a/examples/vertical/dictlike-polymorphic.py b/examples/vertical/dictlike-polymorphic.py
index f800eea73..872a7c52e 100644
--- a/examples/vertical/dictlike-polymorphic.py
+++ b/examples/vertical/dictlike-polymorphic.py
@@ -33,7 +33,7 @@ from sqlalchemy.orm import comparable_property
from sqlalchemy.ext.hybrid import hybrid_property
# Using the VerticalPropertyDictMixin from the base example
-from dictlike import VerticalPropertyDictMixin
+from .dictlike import VerticalPropertyDictMixin
class PolymorphicVerticalProperty(object):
"""A key/value pair with polymorphic value storage.
@@ -150,9 +150,9 @@ if __name__ == '__main__':
class AnimalFact(PolymorphicVerticalProperty):
type_map = {
- int: (u'integer', 'int_value'),
- unicode: (u'char', 'char_value'),
- bool: (u'boolean', 'boolean_value'),
+ int: ('integer', 'int_value'),
+ str: ('char', 'char_value'),
+ bool: ('boolean', 'boolean_value'),
type(None): (None, None),
}
@@ -190,42 +190,42 @@ if __name__ == '__main__':
metadata.create_all(engine)
session = Session(engine)
- stoat = Animal(u'stoat')
- stoat[u'color'] = u'red'
- stoat[u'cuteness'] = 7
- stoat[u'weasel-like'] = True
+ stoat = Animal('stoat')
+ stoat['color'] = 'red'
+ stoat['cuteness'] = 7
+ stoat['weasel-like'] = True
session.add(stoat)
session.commit()
- critter = session.query(Animal).filter(Animal.name == u'stoat').one()
- print critter[u'color']
- print critter[u'cuteness']
+ critter = session.query(Animal).filter(Animal.name == 'stoat').one()
+ print(critter['color'])
+ print(critter['cuteness'])
- print "changing cuteness value and type:"
- critter[u'cuteness'] = u'very cute'
+ print("changing cuteness value and type:")
+ critter['cuteness'] = 'very cute'
session.commit()
- marten = Animal(u'marten')
- marten[u'cuteness'] = 5
- marten[u'weasel-like'] = True
- marten[u'poisonous'] = False
+ marten = Animal('marten')
+ marten['cuteness'] = 5
+ marten['weasel-like'] = True
+ marten['poisonous'] = False
session.add(marten)
- shrew = Animal(u'shrew')
- shrew[u'cuteness'] = 5
- shrew[u'weasel-like'] = False
- shrew[u'poisonous'] = True
+ shrew = Animal('shrew')
+ shrew['cuteness'] = 5
+ shrew['weasel-like'] = False
+ shrew['poisonous'] = True
session.add(shrew)
session.commit()
q = (session.query(Animal).
filter(Animal.facts.any(
- and_(AnimalFact.key == u'weasel-like',
+ and_(AnimalFact.key == 'weasel-like',
AnimalFact.value == True))))
- print 'weasel-like animals', q.all()
+ print('weasel-like animals', q.all())
# Save some typing by wrapping that up in a function:
with_characteristic = lambda key, value: and_(AnimalFact.key == key,
@@ -233,24 +233,24 @@ if __name__ == '__main__':
q = (session.query(Animal).
filter(Animal.facts.any(
- with_characteristic(u'weasel-like', True))))
- print 'weasel-like animals again', q.all()
+ with_characteristic('weasel-like', True))))
+ print('weasel-like animals again', q.all())
q = (session.query(Animal).
- filter(Animal.facts.any(with_characteristic(u'poisonous', False))))
- print 'animals with poisonous=False', q.all()
+ filter(Animal.facts.any(with_characteristic('poisonous', False))))
+ print('animals with poisonous=False', q.all())
q = (session.query(Animal).
filter(or_(Animal.facts.any(
- with_characteristic(u'poisonous', False)),
- not_(Animal.facts.any(AnimalFact.key == u'poisonous')))))
- print 'non-poisonous animals', q.all()
+ with_characteristic('poisonous', False)),
+ not_(Animal.facts.any(AnimalFact.key == 'poisonous')))))
+ print('non-poisonous animals', q.all())
q = (session.query(Animal).
filter(Animal.facts.any(AnimalFact.value == 5)))
- print 'any animal with a .value of 5', q.all()
+ print('any animal with a .value of 5', q.all())
# Facts can be queried as well.
q = (session.query(AnimalFact).
- filter(with_characteristic(u'cuteness', u'very cute')))
- print q.all()
+ filter(with_characteristic('cuteness', 'very cute')))
+ print(q.all())
diff --git a/examples/vertical/dictlike.py b/examples/vertical/dictlike.py
index 71ab77342..f17d1acc8 100644
--- a/examples/vertical/dictlike.py
+++ b/examples/vertical/dictlike.py
@@ -176,49 +176,49 @@ if __name__ == '__main__':
metadata.create_all(engine)
session = Session(bind=engine)
- stoat = Animal(u'stoat')
- stoat[u'color'] = u'reddish'
- stoat[u'cuteness'] = u'somewhat'
+ stoat = Animal('stoat')
+ stoat['color'] = 'reddish'
+ stoat['cuteness'] = 'somewhat'
# dict-like assignment transparently creates entries in the
# stoat.facts collection:
- print stoat.facts[u'color']
+ print(stoat.facts['color'])
session.add(stoat)
session.commit()
- critter = session.query(Animal).filter(Animal.name == u'stoat').one()
- print critter[u'color']
- print critter[u'cuteness']
+ critter = session.query(Animal).filter(Animal.name == 'stoat').one()
+ print(critter['color'])
+ print(critter['cuteness'])
- critter[u'cuteness'] = u'very'
+ critter['cuteness'] = 'very'
- print 'changing cuteness:'
+ print('changing cuteness:')
engine.echo = True
session.commit()
engine.echo = False
- marten = Animal(u'marten')
- marten[u'color'] = u'brown'
- marten[u'cuteness'] = u'somewhat'
+ marten = Animal('marten')
+ marten['color'] = 'brown'
+ marten['cuteness'] = 'somewhat'
session.add(marten)
- shrew = Animal(u'shrew')
- shrew[u'cuteness'] = u'somewhat'
- shrew[u'poisonous-part'] = u'saliva'
+ shrew = Animal('shrew')
+ shrew['cuteness'] = 'somewhat'
+ shrew['poisonous-part'] = 'saliva'
session.add(shrew)
- loris = Animal(u'slow loris')
- loris[u'cuteness'] = u'fairly'
- loris[u'poisonous-part'] = u'elbows'
+ loris = Animal('slow loris')
+ loris['cuteness'] = 'fairly'
+ loris['poisonous-part'] = 'elbows'
session.add(loris)
session.commit()
q = (session.query(Animal).
filter(Animal.facts.any(
- and_(AnimalFact.key == u'color',
- AnimalFact.value == u'reddish'))))
- print 'reddish animals', q.all()
+ and_(AnimalFact.key == 'color',
+ AnimalFact.value == 'reddish'))))
+ print('reddish animals', q.all())
# Save some typing by wrapping that up in a function:
with_characteristic = lambda key, value: and_(AnimalFact.key == key,
@@ -226,21 +226,21 @@ if __name__ == '__main__':
q = (session.query(Animal).
filter(Animal.facts.any(
- with_characteristic(u'color', u'brown'))))
- print 'brown animals', q.all()
+ with_characteristic('color', 'brown'))))
+ print('brown animals', q.all())
q = (session.query(Animal).
filter(not_(Animal.facts.any(
- with_characteristic(u'poisonous-part', u'elbows')))))
- print 'animals without poisonous-part == elbows', q.all()
+ with_characteristic('poisonous-part', 'elbows')))))
+ print('animals without poisonous-part == elbows', q.all())
q = (session.query(Animal).
- filter(Animal.facts.any(AnimalFact.value == u'somewhat')))
- print 'any animal with any .value of "somewhat"', q.all()
+ filter(Animal.facts.any(AnimalFact.value == 'somewhat')))
+ print('any animal with any .value of "somewhat"', q.all())
# Facts can be queried as well.
q = (session.query(AnimalFact).
- filter(with_characteristic(u'cuteness', u'very')))
- print 'just the facts', q.all()
+ filter(with_characteristic('cuteness', 'very')))
+ print('just the facts', q.all())