Re: Why no string return?

2008-03-12 Thread Piet van Oostrum
 gargonx [EMAIL PROTECTED] (g) wrote:

g Still no return of string. The null testing is not really the deal.
g that could be replaced with anything EG:

g def ReturnMethod(request, x):
g if request is 'random':

You shouldn't test with `is' but with `=='.

g return x
g else: print No String for you...False!

g def SendMethod(request):
g xstring = Some text
g ReturnMethod(request, xstring)

g SendMethod('random')

-- 
Piet van Oostrum [EMAIL PROTECTED]
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Why no string return?

2008-03-11 Thread gargonx
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why no string return?

2008-03-11 Thread Adonis Vargas
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why no string return?

2008-03-11 Thread gargonx
On Mar 12, 4:45 am, Adonis Vargas [EMAIL PROTECTED]
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')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why no string return?

2008-03-11 Thread Frank Millman


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

ReturnMethod() is executed, but you do nothing with the result.

Try one of the following -

def SendMethod(request):
xstring = Some text
print ReturnMethod(request, xstring)

def SendMethod(request):
xstring = Some text
return ReturnMethod(request, xstring)

HTH

Frank Millman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why no string return?

2008-03-11 Thread gargonx
On Mar 12, 5:10 am, Frank Millman [EMAIL PROTECTED] 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

 ReturnMethod() is executed, but you do nothing with the result.

 Try one of the following -

 def SendMethod(request):
 xstring = Some text
 print ReturnMethod(request, xstring)

 def SendMethod(request):
 xstring = Some text
 return ReturnMethod(request, xstring)

 HTH

 Frank Millman

Thanks Frank the latter worked for my purpose.
-- 
http://mail.python.org/mailman/listinfo/python-list