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
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:
> ..
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:
...
[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
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
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
"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
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
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
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
[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:
>
[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
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
13 matches
Mail list logo