* vze...@ve... <vze...@ve...> [2002-11-20 20:18 -0600]:
> Thanks for the python tips. I guess it shows that I am new to the language
> :-)
>
> Unfortunately, I still can't seem to get this right. I tried this:
>
> if retval: print "YES" else: print "NO"
>
> When executed, this prints out "YES" when the statement "print retval" prints
> either
>
> [<PgBoolean instance at 0x401c890c: Value: True>]
>
> - or -
>
> [<PgBoolean instance at 0x401c8900: Value: False>]
>
> What am I doing wrong?
I don't know. It works just fine here:
gerhard@gargamel:/tmp$ python
Python 2.2.2 (#1, Oct 18 2002, 03:24:30)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyPgSQL import PgSQL
>>> db = PgSQL.connect(); cursor = db.cursor()
>>> cursor.execute("select b from test where b is true")
>>> res = cursor.fetchone()
>>> res.b
t
>>> repr(res.b)
'<PgBoolean instance at 0x2826202c: Value: True>'
>>> res.b == 1
1
>>> res.b == 0
0
>>> if res.b:
... print "true"
... else:
... print "false"
...
true
>>> cursor.execute("select b from test where b is false")
>>> res = cursor.fetchone()
>>> res.b
f
>>> repr(res.b)
'<PgBoolean instance at 0x28262020: Value: False>'
>>> if res.b:
... print "true"
... else:
... print "false"
...
false
>>>
If you still can't get it to work, could you please post a complete code
section that shows the problem?
-- Gerhard
|