Skip to content

Commit 1153e81

Browse files
authored
Merge pull request brennerm#76 from chadgh/chadgh-patch-1
Adds object string formatting example.
2 parents 7068b44 + 4ac313e commit 1153e81

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

namedformatting.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@
1616
c = {'email': '[email protected]', 'phone': '919-123-4567'}
1717
print('My name is {0[name]}, my email is {1[email]} and my phone number is {1[phone]}'.format(d, c))
1818

19+
"""object string formatting"""
20+
class Person:
21+
pass
22+
me = Person()
23+
me.name = 'Jeff'
24+
me.email = '[email protected]'
25+
me.phone = '919-123-4567'
26+
print('My name is {me.name}, my email is {me.email} and my phone number is {me.phone}'.format(me=me))

0 commit comments

Comments
 (0)