Skip to content

Instantly share code, notes, and snippets.

@maio
Created February 19, 2009 20:32
Show Gist options
  • Save maio/67108 to your computer and use it in GitHub Desktop.
Save maio/67108 to your computer and use it in GitHub Desktop.
class User:
name = None
class Book:
title = None
owner = None
client = None
user1 = User()
user1.name = 'maio'
user2 = User()
user2.name = 'Idaho'
book1 = Book()
book1.title = 'Flotila'
book1.owner = user2
book1.purchaser = user1
[maio@maio-vs ~(master)] $ python
Python 2.5.2 (r252:60911, Mar 9 2008, 03:52:30)
[GCC 4.3.0 20080301 (prerelease) [gcc-4_3-branch revision 132801]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class User:
... name = None
...
>>>
>>> class Book:
... title = None
... owner = None
... client = None
...
>>>
>>> user1 = User()
>>> user1.name = 'maio'
>>>
>>> user2 = User()
>>> user2.name = 'Idaho'
>>>
>>> book1 = Book()
>>> book1.title = 'Flotila'
>>> book1.owner = user2
>>> book1.purchaser = user1
>>>
>>>
>>> book1.title
'Flotila'
>>> book1.title = 'XXX'
>>> book1.title
'XXX'
>>> book1.owner
<__main__.User instance at 0x40219dac>
>>> book1.owner.name
'Idaho'
>>> book1.purchaser.name
'maio'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment