Velocity Reviews > Tuples !?!?

Tuples !?!?

aaragao@gmail.com
Guest
Posts: n/a

 12-11-2007
Hi,

Is the tuple comparison brooked in python ?!?!?

Thanks.

Try this and you will see funny things:

# -*- coding: cp1252 -*-
import random
import csv
import struct
import array

def gera_string(res):

# acampo3
acampo3=((0,5,'muito reduzidos'),(6,20,'reduzidos'),
(21,32,'satisfatórios'),(33,40,'bons'),(41,45,'exc elentes'))
# acampo4
# acampo5
# acampo6
# acampo7
acampo7=((0,2,'pouco'),(3,4,'bastante'),(5,5,'quas e sempre'))
# acampo8
acampo8=((0,4,'mal'),(5,9,'satisfatoriamente'),(10 ,10,'de forma
exemplar'))
# acampo9
acampo9=((0,2,'muito reduzidos'),(3,4,'reduzidos'),
# acampo10
acampo10=((0,2,'pouco'),(3,4,'bastante'),(5,5,'mui to'))
# acampo11
acampo11=((0,2,'muito pouco'),(3,4,'pouco'),(5,8,'bastante'),
(9,10,'grande'))

campo1=res[0]
campo2=res[1]
campo3=res[2]
campo4=res[3]
campo5=res[4]
campo6=res[5]
campo7=res[6]
campo8=res[7]
campo9=res[8]
campo10=res[9]
campo11=res[10]

for a in acampo3:
x=a[0]
y=res[2]
z=a[1]
print x
print y
print z
print x < y
print y < z
print z < y
if a[0] <= res[2] <= a[1]:
campo3=a[2]

for a in acampo4:
if (res[3]>=a[0] and res[3]<=a[1]):
campo4=a[2]

for a in acampo5:
if (res[4]>=a[0] and res[4]<=a[1]):
campo5=a[2]

for a in acampo6:
if (res[5]>=a[0] and res[5]<=a[1]):
campo6=a[2]

for a in acampo7:
if (res[6]>=a[0] and res[6]<=a[1]):
campo7=a[2]

for a in acampo8:
if (res[7]>=a[0] and res[7]<=a[1]):
campo8=a[2]

for a in acampo9:
if (res[8]>=a[0] and res[8]<=a[1]):
campo9=a[2]

for a in acampo10:
if (res[9]>=a[0] and res[9]<=a[1]):
campo10=a[2]

for a in acampo11:
if (res[10]>=a[0] and res[10]<=a[1]):
campo11=a[10]

...

return frase

# processar

f=open('leituras.csv','rb')
csv.register_dialect('dialecto', delimiter=';',
quoting=csv.QUOTE_NONE)

for res in leitor:
print res
print gera_string(res)

f.close()

quit()

Grant Edwards
Guest
Posts: n/a

 12-11-2007
On 2007-12-11, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> Hi,
>
> Is the tuple comparison brooked in python ?!?!?

No.

> Thanks.

You're welcome.

> Try this and you will see funny things:

No thanks.

Maybe you could to post a smaller, easier to read example of
what you think is broken?

--
Grant Edwards grante Yow! I demand IMPUNITY!
at
visi.com

Bruno Desthuilliers
Guest
Posts: n/a

 12-11-2007
(E-Mail Removed) a écrit :
> Hi,
>
> Is the tuple comparison brooked in python ?!?!?

Given the size and average level of the user base, I think this would
have been noticed.

>
> Try this

If you hope anyone to try anything, please post the *minimal* working
code showing the problem. And while your at it, also explain the
expected result.

> and you will see funny things:

Sorry but the only thing I see so far is that your code needs refactoring.

Berco Beute
Guest
Posts: n/a

 12-11-2007
> > Is the tuple comparison brooked in python ?!?!?
>
> No.
>
> > Thanks.

>
> You're welcome.

HHH! That just made my day. Too funny.

2B

aaragao@gmail.com
Guest
Posts: n/a

 12-11-2007
Ok. This is small code.

The problem is '2' != 2 there is a way of converting 'some number' in
number ?

Thanks.

# -*- coding: cp1252 -*-
import random
import csv
import struct
import array

# resultados para colocar nos campos
def gera_string(res):

# acampo3
acampo1=((0,5,'muito reduzidos'),(6,20,'reduzidos'),
(21,32,'satisfatórios'),(33,40,'bons'),(41,45,'exc elentes'))
campo1=''

for a in acampo1:
print res[1]
if (res[1]>=a[0] and res[1]<=a[1]):
campo1=a[2]

return campo1

# processar

res=['a','2']

print gera_string(res)

quit()

On 11 Dez, 20:40, Bruno Desthuilliers
<(E-Mail Removed)> wrote:
> (E-Mail Removed) a écrit :
>

> > Hi,

>
> > Is the tuple comparison brooked in python ?!?!?

>
> Given the size and average level of the user base, I think this would
> have been noticed.
>
>
>
> > Try this

>
> If you hope anyone to try anything, please post the *minimal* working
> code showing the problem. And while your at it, also explain the
> expected result.
>
> > and you will see funny things:

>
> Sorry but the only thing I see so far is that your code needs refactoring.

aaragao@gmail.com
Guest
Posts: n/a

 12-11-2007
On 11 Dez, 22:02, (E-Mail Removed) wrote:
> Ok. This is small code.
>
> The problem is '2' != 2 there is a way of converting 'some number' in
> number ?
>
> Thanks.
>
> # -*- coding: cp1252 -*-
> import random
> import csv
> import struct
> import array
>
> # resultados para colocar nos campos
> def gera_string(res):
>
> # acampo3
> acampo1=((0,5,'muito reduzidos'),(6,20,'reduzidos'),
> (21,32,'satisfatórios'),(33,40,'bons'),(41,45,'exc elentes'))
> campo1=''
>
> for a in acampo1:
> print res[1]
> if (res[1]>=a[0] and res[1]<=a[1]):
> campo1=a[2]
>
> return campo1
>
> # processar
>
> res=['a','2']
>
> print gera_string(res)
>
> quit()
>
> On 11 Dez, 20:40, Bruno Desthuilliers
>
> <(E-Mail Removed)> wrote:
> > (E-Mail Removed) a écrit :

>
> > > Hi,

Thanks. I have found that there is int() function on python. The print
function always show me a number when was 'number'. Ok thanks.

> > > Is the tuple comparison brooked in python ?!?!?

>
> > Given the size and average level of the user base, I think this would
> > have been noticed.

>
> > > Try this

>
> > If you hope anyone to try anything, please post the *minimal* working
> > code showing the problem. And while your at it, also explain the
> > expected result.

>
> > > and you will see funny things:

>
> > Sorry but the only thing I see so far is that your code needs refactoring.

NethanO@SPdogdiniAM.com
Guest
Posts: n/a

 12-11-2007
On 12/11/2007 5:08 PM, (E-Mail Removed) wrote:

> On 11 Dez, 22:02, (E-Mail Removed) wrote:
>> Ok. This is small code.
>>
>> The problem is '2' != 2 there is a way of converting 'some number' in
>> number ?
>>

<snip>

>>> ord('2')

50
>>> chr(50) == '2'

True
>>> int('2')

2
>>> int('2') == 2

True
>>>

Bruno Desthuilliers
Guest
Posts: n/a

 12-12-2007
(E-Mail Removed) a écrit :
> Ok. This is small code.
>
> The problem is '2' != 2

It would indeed be a problem if this expression eval'd to True. That's
the case in some, hem, 'languages', and believe me it's *not* the
RightThing.

> there is a way of converting 'some number' in
> number ?

assert(2 == int(2))

Bjoern Schliessmann
Guest
Posts: n/a

 12-12-2007
Bruno Desthuilliers wrote:
> (E-Mail Removed) a écrit :

>> The problem is '2' != 2

>
> It would indeed be a problem if this expression eval'd to True.
> That's the case in some, hem, 'languages', and believe me it's
> *not* the RightThing.

What kind of "hem" language is this?

>>> '2' != 2

True
>>>

Regards,

Björn

--
BOFH excuse #430:

Mouse has out-of-cheese-error

Bruno Desthuilliers
Guest
Posts: n/a

 12-12-2007
Bjoern Schliessmann a écrit :
> Bruno Desthuilliers wrote:
>
>>(E-Mail Removed) a écrit :

>
>
>>>The problem is '2' != 2

>>
>>It would indeed be a problem if this expression eval'd to True.
>>That's the case in some, hem, 'languages', and believe me it's
>>*not* the RightThing.

>
>
> What kind of "hem" language is this?

>
>>>>'2' != 2

>
> True

hem... Sorry, I of course meant that it would be a problem if '2' == 2
eval'd to true - or '2' != 2 eval'd to false. My bad...

Thanks for the correction anyway.

Ah, and, yes, the 'hem' language I was thinking about has a three
letters recursive acronym for name and is widely (and mostly) used for
web applications. Should I spell the name, or did you guess ?-)