Skip to content

Instantly share code, notes, and snippets.

@xyj404
Created February 28, 2017 06:06
Show Gist options
  • Save xyj404/a2dc980e3b7803c4740cc0633a4b9907 to your computer and use it in GitHub Desktop.
Save xyj404/a2dc980e3b7803c4740cc0633a4b9907 to your computer and use it in GitHub Desktop.
from collections import namedtuple
P=namedtuple('Point',['x','y'])
pp=namedtuple('pp',['x','y'])
print P.__doc__
p=P(111,222)
print p
print p.x+p.y
print p[0]+p[1]
m,n=p
print m,n
d=p._asdict()
print d,d['x'],d['y']
x=pp(**d)
print x
@xyj404
Copy link
Author

xyj404 commented Feb 28, 2017

This is a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment