INFO: Geany 0.14, GTK+ 2.14.4, GLib 2.18.2 under ubuntu 8.10
(also under window XP)
the following trouble refers to ubuntu environment:
*consider this code:*
tast = u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' iera = u'\u00e0\u00e8\u00e9\u00ec\u00f2\u00f9'.encode('utf-8') car=''
while car != '!!':
car = raw_input('digita un carattere--->: ')
if car in iera:
print 'ok iera', car
elif car in tast:
print 'ok tast', car
elif len(car) > 1:
print 'solo 1 carattere. ne hai messi', len(car)
when usin Geany if I type 1 or more normal characters (e.g. 'ab' or 'cdf') or a single character with accent (e.g. 'è' or 'à') the program works well. if I type a group (more than 1) of characters containing an accented character (e.g. 'ghètè' or simply 'ùù'), the program stop working with the error 'in <string>' requires string as left operand
the following, intead, lines refer to the Python shell:
tast = u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' iera = u'\u00e0\u00e8\u00e9\u00ec\u00f2\u00f9'.encode('utf-8') car='' while True:
car = raw_input('digita un carattere--->: ') car = car[0] if car in iera: print 'ok iera' elif car in tast: print 'ok tast'
digita un carattere--->: sd ok tast digita un carattere--->: d ok tast digita un carattere--->: fdg ok tast digita un carattere--->: f ok tast digita un carattere--->: r ok tast digita un carattere--->: y ok tast digita un carattere--->: h ok tast digita un carattere--->: èpioè ok iera digita un carattere--->: è ok iera
Note that the instruction *car = car[0] *under Geany issues another error: prints a strange character with a question mark inside and moves the following line right. the question is: HAS GEANY PROBLEMS WITH THOSE PARTICULAR CONVERSTIONS? thanks Virgilio semprini
On Mon, 17 Nov 2008 21:17:05 +0100, "virgilio semprini" virgilio.semprini@gmail.com wrote:
Hi,
first, I don't know Python very well but it seems like an error with your code.
Note that the instruction *car = car[0] *under Geany issues another error: prints a strange character with a question mark inside and
No, it works fine here and if I add this line at the appropriate place in your code, it magically starts to work as expected with your provided example strings. But I think 'car[0]' gives you only the first byte of the string 'car' but you actually want to get the first character. And in UTF-8 bytes are not always equal to UTF-8. This is probably one of your problems. Feel free to correct me if I'm wrong, it's late and I'm not a Python guy.
moves the following line right. the question is: HAS GEANY PROBLEMS WITH THOSE PARTICULAR CONVERSTIONS?
No, Geany is a text editor, it doesn't know anything about the semantics of your code...
Regards, Enrico