Show More
@@ -1,7 +1,7 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Mimic C structs with lots of extra functionality. |
|
2 | """Mimic C structs with lots of extra functionality. | |
3 |
|
3 | |||
4 |
$Id: ipstruct.py 19 |
|
4 | $Id: ipstruct.py 1950 2006-11-28 19:15:35Z vivainio $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> |
|
7 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> | |
@@ -17,6 +17,7 b' __license__ = Release.license' | |||||
17 | __all__ = ['Struct'] |
|
17 | __all__ = ['Struct'] | |
18 |
|
18 | |||
19 | import types |
|
19 | import types | |
|
20 | import pprint | |||
20 |
|
21 | |||
21 | from IPython.genutils import list2dict2 |
|
22 | from IPython.genutils import list2dict2 | |
22 |
|
23 | |||
@@ -138,13 +139,13 b' class Struct:' | |||||
138 | def __str__(self): |
|
139 | def __str__(self): | |
139 | """Gets called by print.""" |
|
140 | """Gets called by print.""" | |
140 |
|
141 | |||
141 |
return 'Struct('+ |
|
142 | return 'Struct('+ pprint.pformat(self.__dict__)+')' | |
142 |
|
143 | |||
143 | def __repr__(self): |
|
144 | def __repr__(self): | |
144 | """Gets called by repr. |
|
145 | """Gets called by repr. | |
145 |
|
146 | |||
146 | A Struct can be recreated with S_new=eval(repr(S_old)).""" |
|
147 | A Struct can be recreated with S_new=eval(repr(S_old)).""" | |
147 |
return |
|
148 | return self.__str__() | |
148 |
|
149 | |||
149 | def __getitem__(self,key): |
|
150 | def __getitem__(self,key): | |
150 | """Allows struct[key] access.""" |
|
151 | """Allows struct[key] access.""" |
General Comments 0
You need to be logged in to leave comments.
Login now