Message1555
| Author | nobody |
|---|---|
| Recipients | |
| Date | 2000-09-22.19:36:01 |
| SpamBayes Score | |
| Marked as misclassified | |
| Message-id | |
| In-reply-to |
| Content | |
|---|---|
The built-in function eval() takes a string argument and a dictionary. The second argument should allow any instance which defines __getitem__ as opposed to just dictionaries.
The following example creates a type error:
eval, argument 2: expected dictionary, instance found
class SpreadSheet:
_cells = {}
def __setitem__( self, key, formula ):
self._cells[key] = formula
def __getitem__( self, key ):
return eval( self._cells[key], self )
ss = SpreadSheet()
ss['a1'] = '5'
ss['a2'] = 'a1*5'
ss['a2']
|
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2007-08-23 13:50:45 | admin | link | issue215126 messages |
| 2007-08-23 13:50:45 | admin | create | |