Hi Folks
I have the following code in one of my classes along with checks when the code does not eval:

filterParam="self.recipientMSISDN==tmpBPSS.split('_')[3].split('#')[0] and self.recipientIMSI==tmpBPSS.split('_')[3].split('#')[1]" 
if eval(filterParam):
   print "Evalled"
else:
   print "Not Evalled\nfilterParam\n'%s'\ntmpBPSS\n'%s'\nself.recipientMSISDN\n'%s'\nself.recipientIMSI\n'%s'" % (filterParam, tmpBPSS, self.recipientMSISDN, self.recipientIMSI)

I am not getting anything to 'eval'. Here are the results:

Not Evalled
filterParam
'self.recipientMSISDN==tmpBPSS.split('_')[3].split('#')[0] and self.recipientIMSI==tmpBPSS.split('_')[3].split('#')[1]'
tmpBPSS
'bprm_DAILY_MO_919844000039#892000000'
self.recipientMSISDN
'919844000039'
self.recipientIMSI
'892000000'

So I used the outputs from the above to check the code in a python shell and as you can see the code evalled correctly:

>>> filterParam="recipientMSISDN==tmpBPSS.split('_')[3].split('#')[0] and recipientIMSI==tmpBPSS.split('_')[3].split('#')[1]"
>>> tmpBPSS='bprm_DAILY_MO_919844000039#892000000'
>>> recipientMSISDN='919844000039'
>>> recipientIMSI='892000000'
>>> if eval(filterParam):
...    print "Evalled"
... else:
...    print "Not Evalled"
...
Evalled
>>>

Am I off my rocker or what am I missing?

A

The code is not equal first has 5 lines and the other code has 8.

The code is not equal first has 5 lines and the other code has 8.

you're joking right? The first is obviously from a class. The output tells you what self.recipientIMSI, self.recipientMSISDN and tmpBPSS was in this particular method call. In order to debug this I have to set these variables. I got this answered in another forum anyway. The problem was that a string and an int were getting compared. When I set the comparison to check both as ints it worked.

I only set the second code to run as script and it got same result as command line.

It is difficult to test object code without context. I have not enough experience to only read and debug from that, expesially as the variable values were not the most reader friendly.

Nice to hear you got your problem solved!

Happy hacking!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.