Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > strange TypeError exception in function compiled from a string

Reply
Thread Tools

strange TypeError exception in function compiled from a string

 
 
nelson
Guest
Posts: n/a
 
      12-01-2010
Hi all,
I have this function, defined in a string and ecetuted through ad
exec call

def cell1(d):

x=d.get('x')
print x

import y
return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x ))


d is a dict of this kind {'x':2}

I receive the following exception, that i find very strange...

File "<string>", line 7, in cell1
TypeError: 'dict' object is not callable

I have tested all the function al line 7, and none of them raise any
exception.
Have anyone some suggestion on how to solve this?

thanks!
 
Reply With Quote
 
 
 
 
bruno.desthuilliers@gmail.com
Guest
Posts: n/a
 
      12-01-2010
On 1 déc, 14:48, nelson <(E-Mail Removed)> wrote:
> Hi all,
> * I have this function, defined in a string and ecetuted through ad
> exec call
>
> def cell1(d):
>
> * * x=d.get('x')
> * * print x
>
> * * import y
> * * return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x ))
>
> d is a dict of this kind {'x':2}
>
> I receive the following exception, that i find very strange...
>
> * File "<string>", line 7, in cell1
> TypeError: 'dict' object is not callable
>
> I have tested all the function al line 7, and none of them raise any
> exception.
> Have anyone some suggestion on how to solve this?
>


Not without the minimal executable code reproducing your error.
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      12-01-2010
On 01/12/2010 13:48, nelson wrote:
> Hi all,
> I have this function, defined in a string and ecetuted through ad
> exec call
>
> def cell1(d):
>
> x=d.get('x')
> print x
>
> import y
> return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x ))
>
>
> d is a dict of this kind {'x':2}
>
> I receive the following exception, that i find very strange...
>
> File "<string>", line 7, in cell1
> TypeError: 'dict' object is not callable
>
> I have tested all the function al line 7, and none of them raise any
> exception.
> Have anyone some suggestion on how to solve this?
>

A call looks like foo(), so probably either y.add or self.adf0 is a
dict. Print both of them to check.
 
Reply With Quote
 
Piet van Oostrum
Guest
Posts: n/a
 
      12-02-2010
nelson <(E-Mail Removed)> writes:


> Hi all,
> I have this function, defined in a string and ecetuted through ad
> exec call
>
> def cell1(d):
>
> x=d.get('x')
> print x
>
> import y
> return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x ))
>

What is self in line 7?
--
Piet van Oostrum <(E-Mail Removed)>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Nu Fair Trade woonartikelen op http://www.zylja.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TypeError: 'in <string>' requires string as left operand, not Element Victor Hooi Python 4 12-10-2012 02:42 AM
Metaclass conflict TypeError exception: problem demonstration script Barak, Ron Python 0 02-23-2009 09:32 AM
Default __nonzero__ impl doesn't throw a TypeError exception Sergey Kishchenko Python 6 01-09-2009 08:58 PM
If I create a page, then it's compiled upon first request, where cani find the compiled code?? lander ASP .Net 5 03-05-2008 04:34 PM
g++ compiled C++ code called from gcc compiled C code Klaus Schneider C++ 1 12-02-2004 01:44 PM



Advertisments