| 1 | from __future__ import unicode_literals
|
|---|
| 2 |
|
|---|
| 3 | from future.builtins import *
|
|---|
| 4 | from future import standard_library
|
|---|
| 5 | standard_library.install_aliases()
|
|---|
| 6 |
|
|---|
| 7 | from django.utils.encoding import python_2_unicode_compatible
|
|---|
| 8 |
|
|---|
| 9 | @python_2_unicode_compatible
|
|---|
| 10 | class Foo(object):
|
|---|
| 11 |
|
|---|
| 12 | def __init__(self):
|
|---|
| 13 | self.name = 'foo'
|
|---|
| 14 |
|
|---|
| 15 | def __str__(self):
|
|---|
| 16 | return '{}'.format(self.name)
|
|---|
| 17 |
|
|---|
| 18 | @python_2_unicode_compatible
|
|---|
| 19 | class Bar(Foo):
|
|---|
| 20 |
|
|---|
| 21 | def __init__(self):
|
|---|
| 22 | super().__init__()
|
|---|
| 23 | self.extra = 'bar'
|
|---|
| 24 |
|
|---|
| 25 | def __str__(self):
|
|---|
| 26 | return '{} {}'.format(
|
|---|
| 27 | super().__str__(),
|
|---|
| 28 | self.extra,
|
|---|
| 29 | )
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | if __name__ == '__main__':
|
|---|
| 33 | b = Bar()
|
|---|
| 34 | print(b)
|
|---|