Re: How can i compare a string which is non null and empty

2007-04-03 Thread Bruno Desthuilliers
Steven Howe a écrit : (nb : original post reinserted) > [EMAIL PROTECTED] a écrit : >> how can i compare a string which is non null and empty? >> (snip) >> In java,I do this: >> if (str != null) && (!str.equals("")) >> >> how can i d

Re: How can i compare a string which is non null and empty

2007-04-02 Thread Steven D'Aprano
On Mon, 02 Apr 2007 13:48:30 -0700, Steven Howe wrote: > how about just testing it's length? > >>> from types import StringType > > def stringTest(x): > ... if type(x) == StringType: > ... if len(x) == 0: > ... print 'Empty String' > ... else: > ..

Re: How can i compare a string which is non null and empty

2007-04-02 Thread Steven Howe
how about just testing it's length? >>> from types import StringType def stringTest(x): ... if type(x) == StringType: ... if len(x) == 0: ... print 'Empty String' ... else: ... print 'Not Empty String' ... else: ...

Re: How can i compare a string which is non null and empty

2007-04-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi, > > how can i compare a string which is non null and empty? Compare with what ?-) > > i look thru the string methods here, but cant find one which does it? > > http://docs.python.org/lib/string-methods.html#string-methods > > I

Re: How can i compare a string which is non null and empty

2007-04-02 Thread Steven D'Aprano
On Mon, 02 Apr 2007 01:35:17 +0200, Georg Brandl wrote: > [EMAIL PROTECTED] schrieb: >> Hi, >> >> how can i compare a string which is non null and empty? >> >> >> i look thru the string methods here, but cant find one which does it? >> >> ht

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Grant Edwards
On 2007-04-02, Shane Geiger <[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("")) >>&g

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Shane Geiger
"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 PROTECT

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Grant Edwards
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

Re: How can i compare a string which is non null and empty

2007-04-01 Thread tac-tics
str != "" returns true if str is NOT the empty string. str is not None returns true if str is null (or None as it's called in python). To check to make sure a string is nonnull and nonempty, do: str is not None and str != "" -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i compare a string which is non null and empty

2007-04-01 Thread eC
On Apr 2, 12:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > how can i compare a string which is non null and empty? > > i look thru the string methods here, but cant find one which does it? > > http://docs.python.org/lib/string-methods.html

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Georg Brandl
[EMAIL PROTECTED] schrieb: > Hi, > > how can i compare a string which is non null and empty? > > > i look thru the string methods here, but cant find one which does it? > > http://docs.python.org/lib/string-methods.html#string-methods > > In java,I do this: >

Re: How can i compare a string which is non null and empty

2007-04-01 Thread hlubenow
[EMAIL PROTECTED] wrote: > > Hi, > > how can i compare a string which is non null and empty? > > > i look thru the string methods here, but cant find one which does it? > > http://docs.python.org/lib/string-methods.html#string-methods > > In

How can i compare a string which is non null and empty

2007-04-01 Thread [EMAIL PROTECTED]
Hi, how can i compare a string which is non null and empty? i look thru the string methods here, but cant find one which does it? http://docs.python.org/lib/string-methods.html#string-methods In java,I do this: if (str != null) && (!str.equals("")) how can i