6.12. Named Parameters
Python allows you to add the names of parameters to function and method calls. This naming can help make the code easier to read, especially when there are lots of parameters.
CD-ROM reference=6045.txt class Account: ... def __repr__(self): """ Return executable form """ return 'Account (balance=%d,name="%s")' % (self.Balance,self.Name) >>> from accounts import Account >>> a = Account (100,"Sean") >>> print a Account Object: Balance is '100'. Account Name is 'Sean' >>> s = repr(a) >>> print s Account (balance=100,name="Sean") >>> b = eval (s) >>> print b Account Object: Balance is '100'. Account Name is 'Sean'
Get XML Processing with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.