It is probably worth noting that the example is not executable code: str() is a function.

[EMAIL PROTECTED]:~$ python
Python 2.4.4c0 (#2, Jul 30 2006, 15:43:58)
[GCC 4.1.2 20060715 (prerelease) (Debian 4.1.1-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> if str: print "whoah, str is a function!"
...
whoah, str is a function!
>>>


/me pines for the day when all examples are executable code




Grant Edwards wrote:
On 2007-04-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

how can i compare a string which is non null and empty?
[...]
In java,I do this:
if (str != null) && (!str.equals("")) ....

how can i do that in python?

If you want to litterally do that, it's

  if (str != None) and (str != ""):
<whatever>
However, the standard idiom for doing that in Python is

  if str:
    <whatever>



--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

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

Reply via email to