On Oct 17, 8:00 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote:
> > 'if x' doesn't test if x exists, it tests if x when cast to a bool is
> > True.
>
> To be pedantic:
>
> Python doesn't have type casts. bool(x) doesn't cast
Ben Finney wrote:
> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>
>> stef mientki schrieb:
>> > What should I do to the same simple test for existance ?
>>
>> Use isinstance(obj, type).
>
> No, that's *far* more specific than "does it exist", and will give
> false negatives.
I've misread th
En Thu, 18 Oct 2007 00:07:34 -0300, Steven D'Aprano
<[EMAIL PROTECTED]> escribió:
> On Thu, 18 Oct 2007 03:00:56 +, Steven D'Aprano wrote:
>
>> On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote:
>>
>>> 'if x' doesn't test if x exists, it tests if x when cast to a bool is
>>> True.
>>
>>
On Thu, 18 Oct 2007 03:00:56 +, Steven D'Aprano wrote:
> On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote:
>
>> 'if x' doesn't test if x exists, it tests if x when cast to a bool is
>> True.
>
> To be pedantic:
>
> Python doesn't have type casts. bool(x) doesn't cast x as a bool, it
>
On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote:
> 'if x' doesn't test if x exists, it tests if x when cast to a bool is
> True.
To be pedantic:
Python doesn't have type casts. bool(x) doesn't cast x as a bool, it
creates a brand new Boolean object from x.
Also, the "if x" test looks at
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> stef mientki schrieb:
> > What should I do to the same simple test for existance ?
>
> Use isinstance(obj, type).
No, that's *far* more specific than "does it exist", and will give
false negatives.
Much better is::
foo = None
foo = do_so
stef mientki schrieb:
> hello,
>
> I've written a convenience wrapper around ConfigObj (which is a imporved
> ConfigParser).
>
> Now if I use an instance of the base class, I can easily test is the
> instance exists by " if ini:",
> like in this example
>
>ini = None
>if ini:
>
On Oct 17, 11:39 pm, stef mientki <[EMAIL PROTECTED]> wrote:
> the test if an instance exists, always returns false.
> ini = inifile (filename)
> if ini:
> print 'ok',type(ini)
> else:
> print 'wrong',type(ini)
>
> Why is that ?
> What should I do to the same simple test