Re: Interesting list Validity (True/False)



On May 12, 8:10?pm, Carsten Haese <cars...@xxxxxxxxxxx> wrote:
On Sat, 2007-05-12 at 17:55 -0700, mensana...@xxxxxxx wrote:
On May 12, 12:56?pm, Carsten Haese <cars...@xxxxxxxxxxx> wrote:
On Fri, 2007-05-11 at 14:26 -0700, mensana...@xxxxxxx wrote:
if arg==True:

tests the type property (whether a list is a boolean).

That sounds nonsensical and incorrect. Please explain what you mean.

<quote>
Sec 2.2.3:
Objects of different types, except different numeric types and
different string types, never compare equal;
</quote>

That doesn't explain what you mean. How does "if arg==True" test whether
"a list is a boolean"?

type(sys.argv)
<type 'list'>
type(True)
<type 'bool'>


Actually, it's this statement that's non-sensical.

<quote>
"if arg==True" tests whether the object known as arg is equal to the
object known as True.
</quote>

None of these four examples are "equal" to any other.

a = 1
b = (1,)
c = [1]
d = gmpy.mpz(1)

type(a)
<type 'int'>
type(b)
<type 'tuple'>
type(c)
<type 'list'>
type(d)
<type 'mpz'>
a==b
False
b==c
False
a==d
True

And yet a==d returns True. So why doesn't b==c
also return True, they both have a 1 at index position 0?

x = [1]
y = [1]
x==y
True



--
Carsten Haesehttp://informixdb.sourceforge.net


.



Relevant Pages

  • Re: Logical fields in MySQL, field mapping from VFP to MySQL
    ... VFP does accept 1/0 instead of T/F in a number of object properties, ... > we currently use numeric types exclusively instead of logical .. ... > only FoxPro has a native boolean type ... > the new cursoradapter is also of no help in this context .. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Interesting list Validity (True/False)
    ... different string types, never compare equal; ... there is no explicit type test. ... of shoes is not the same as a box of shoes, even if they are the same ... numeric types, so the earlier rule applies: ...
    (comp.lang.python)
  • Re: Differences between VB6 and VB.Net causing problem
    ... Converts them both to the same type (Boolean) and does the compare. ... I was pointign you to Larry his assumption that the Byte was beign converted to a Booelan in the expression If bln = CByteThen was clearly wrong. ... CSngis a perfectly valid conversion, albeit a highly unlikely one, and it will indeed return -1, but it certainly doesn't return all bitwise 1's when examined at the bit level. ... It is only in the bittable numeric types where bitwise operations can be used, and in those types the conversion of a Boolean is either 0 or bitwise Not 0. ...
    (microsoft.public.vb.general.discussion)
  • Re: Interesting list Validity (True/False)
    ... numeric types and different string types, ... the equivalency of numeric types and do the type conversion, ... the print statement isn't so smart. ...
    (comp.lang.python)
  • Re: Logical fields in MySQL, field mapping from VFP to MySQL
    ... we currently use numeric types exclusively instead of logical .. ... only FoxPro has a native boolean type ... DEFINE CLASS oSomeAdapter AS CursorAdapter .. ...
    (microsoft.public.fox.programmer.exchange)