Why these functions don't work in web2py

59 views
Skip to first unread message

Maurice Waka

unread,
Jun 24, 2018, 5:09:43 PM6/24/18
to web2py-users
I have bee using python Idle for some time and with the code below, though not perfected, am able to get an answer(return value as expected). If I import it to web2py, the return value becomes None. I don't know where I have gone wrong. Here is the code:
item = ['time is money']
   
def one():
       
if 'cake' in item[0]:
           
return 'love it too'
   
def two():
       
if 'time' in item[0]:
           
return 'keep time'
   
def three():
       
if 'cook' in item[0]:
           
return 'love cooking too'
   
def four():
       
if 'given' in item[0]:
           
return 'dont give in'
   
def five():
       
if 'admin' in item[0]:
           
return 'administered too'
    fnval
= ['i', 'we', 'cake', 'love', 'time', ]
    fadmin
= ['admin','give',]
    G3
= [one(), two(), three()]
    G4
= [four(), five()]
    l
= []
   
def testing():
       
del l[:]
        b
= False
       
for c in fnval or fadmin:        
            b
= b | (item[0].find(c) != -1)
           
if b:
               
for (func) in G3:
                    l
.append((func))
               
for (func) in G4:
                    l
.append((func))
       
print [x for x in l if x is not None]
       
   
if __name__=='__main__':
        testing
()
I want to get the same return value as one would on python idle, and not a null value.
regards

Junior Phanter

unread,
Jun 25, 2018, 7:33:26 AM6/25/18
to web...@googlegroups.com
your testing function dont have return.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Jun 26, 2018, 5:49:04 PM6/26/18
to web2py-users
Note, Idle is not giving you a return value - the function is simply printing the output, which Idle displays. Of you want a return value, you must return something.

Anthony

Maurice Waka

unread,
Jun 27, 2018, 4:26:04 AM6/27/18
to web...@googlegroups.com
I tested it with return. It's now works but takes to long to respond. Let me work on the code.
Regards 

On Wed, 27 Jun 2018, 00:49 Anthony <abas...@gmail.com> wrote:
Note, Idle is not giving you a return value - the function is simply printing the output, which Idle displays. Of you want a return value, you must return something.

Anthony

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/i1Etezn1YXU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages