Why no string return?
gargonx
gargonx at gmail.com
Wed Mar 12 00:55:20 EDT 2008
On Mar 12, 4:45 am, Adonis Vargas <adonis_var... at -Remove-This-
bellsouth.net> wrote:
> gargonx wrote:
> > Say i have the two methods:
>
> > def ReturnMethod(request, x):
> > if request is True:
> > return x
> > else: print "No String for you...False!"
>
> > def SendMethod(request):
> > xstring = "Some text"
> > ReturnMethod(request, xstring)
>
> > SendMethod(True)
>
> > Why does ReturnMethod not return the string x? I do believe it is
> > returning with a NoneType.
> > Any help would be greatly obliged
>
> > Thanks, Josh
>
> That is because request is bound a string (str) object. You are probably
> testing for null so it should look like:
>
> if request:
> return x
> else:
> print "No String for you...False!"
>
> Hope this helps.
>
> Adonis
Still no return of string. The null testing is not really the deal.
that could be replaced with anything EG:
def ReturnMethod(request, x):
if request is 'random':
return x
else: print "No String for you...False!"
def SendMethod(request):
xstring = "Some text"
ReturnMethod(request, xstring)
SendMethod('random')
More information about the Python-list
mailing list