Re: Problem with sets and Unicode strings

2006-06-29 Thread Fredrik Lundh
Dennis Benzinger wrote: >>> shadows the error of not setting sys.defaultencoding()? >> >> You can't set the default encoding. If you could, then scripts that run >> on your machine wouldn't run on mine. >> [...] > > As Serge Orlov wrote in one of his posts you _can_ set the default > encoding

Re: Problem with sets and Unicode strings

2006-06-29 Thread Jean-Paul Calderone
On Thu, 29 Jun 2006 21:19:30 +0200, Dennis Benzinger <[EMAIL PROTECTED]> wrote: >Robert Kern wrote: >> Dennis Benzinger wrote: >>> Ok, I understand. >>> But isn't it a (minor) problem that using a set like this: >>> >>> # -*- coding: UTF-8 -*- >>> >>> FIELDS_SET = set(("Fächer", )) >>> >>> print u"

Re: Problem with sets and Unicode strings

2006-06-29 Thread Robert Kern
Dennis Benzinger wrote: > Robert Kern wrote: >> Dennis Benzinger wrote: >>> Ok, I understand. >>> But isn't it a (minor) problem that using a set like this: >>> >>> # -*- coding: UTF-8 -*- >>> >>> FIELDS_SET = set(("Fächer", )) >>> >>> print u"Fächer" in FIELDS_SET >>> print u"Fächer" == "Fächer" >

Re: Problem with sets and Unicode strings

2006-06-29 Thread Dennis Benzinger
Robert Kern wrote: > Dennis Benzinger wrote: >> Ok, I understand. >> But isn't it a (minor) problem that using a set like this: >> >> # -*- coding: UTF-8 -*- >> >> FIELDS_SET = set(("Fächer", )) >> >> print u"Fächer" in FIELDS_SET >> print u"Fächer" == "Fächer" >> >> shadows the error of not settin

Re: Problem with sets and Unicode strings

2006-06-29 Thread Robert Kern
Dennis Benzinger wrote: > Ok, I understand. > But isn't it a (minor) problem that using a set like this: > > # -*- coding: UTF-8 -*- > > FIELDS_SET = set(("Fächer", )) > > print u"Fächer" in FIELDS_SET > print u"Fächer" == "Fächer" > > shadows the error of not setting sys.defaultencoding()? Yo

Re: Problem with sets and Unicode strings

2006-06-29 Thread Dennis Benzinger
Diez B. Roggisch wrote: >> But I'd say that it's not intuitive that for sets x in y can be false >> (without raising an exception!) while the doing the same with a tuple >> raises an exception. Where is this difference documented? > > 2.3.7 Set Types -- set, frozenset > > ... > > Set elements ar

Re: Problem with sets and Unicode strings

2006-06-28 Thread Diez B. Roggisch
> But I'd say that it's not intuitive that for sets x in y can be false > (without raising an exception!) while the doing the same with a tuple > raises an exception. Where is this difference documented? 2.3.7 Set Types -- set, frozenset ... Set elements are like dictionary keys; they need to de

Re: Problem with sets and Unicode strings

2006-06-28 Thread Diez B. Roggisch
> But says: > > Strings are compared lexicographically using the numeric equivalents > (the result of the built-in function ord()) of their characters. Unicode > and 8-bit strings are fully interoperable in this behavior. > > Doesn't this mean that Un

Re: Problem with sets and Unicode strings

2006-06-28 Thread Dennis Benzinger
Robert Kern wrote: > Dennis Benzinger wrote: >> Serge Orlov wrote: >>> On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: Hi! The following program in an UTF-8 encoded file: # -*- coding: UTF-8 -*- FIELDS = ("Fächer", ) FROZEN_FIELDS = frozenset(FIE

Re: Problem with sets and Unicode strings

2006-06-28 Thread Dennis Benzinger
Serge Orlov wrote: > On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: >> Serge Orlov wrote: >> > On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: >> >> Hi! >> >> >> >> The following program in an UTF-8 encoded file: >> >> >> >> >> >> # -*- coding: UTF-8 -*- >> >> >> >> FIELDS = ("Fäch

Re: Problem with sets and Unicode strings

2006-06-28 Thread Laurent Pointal
Dennis Benzinger a écrit : > No, byte strings contain characters which are at least 8-bit wide > . But I don't understand what > Python is trying to decode and why the exception says something about > the ASCII codec, because my file is encoded with UTF-8. [a

Re: Problem with sets and Unicode strings

2006-06-27 Thread Robert Kern
Dennis Benzinger wrote: > Serge Orlov wrote: >> On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: >>> Hi! >>> >>> The following program in an UTF-8 encoded file: >>> >>> >>> # -*- coding: UTF-8 -*- >>> >>> FIELDS = ("Fächer", ) >>> FROZEN_FIELDS = frozenset(FIELDS) >>> FIELDS_SET = set(FIELDS

Re: Problem with sets and Unicode strings

2006-06-27 Thread Serge Orlov
On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: > Serge Orlov wrote: > > On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: > >> Hi! > >> > >> The following program in an UTF-8 encoded file: > >> > >> > >> # -*- coding: UTF-8 -*- > >> > >> FIELDS = ("Fächer", ) > >> FROZEN_FIELDS = fro

Re: Problem with sets and Unicode strings

2006-06-27 Thread Dennis Benzinger
Serge Orlov wrote: > On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: >> Hi! >> >> The following program in an UTF-8 encoded file: >> >> >> # -*- coding: UTF-8 -*- >> >> FIELDS = ("Fächer", ) >> FROZEN_FIELDS = frozenset(FIELDS) >> FIELDS_SET = set(FIELDS) >> >> print u"Fächer" in FROZEN_FIE

Re: Problem with sets and Unicode strings

2006-06-27 Thread Serge Orlov
On 6/27/06, Dennis Benzinger <[EMAIL PROTECTED]> wrote: > Hi! > > The following program in an UTF-8 encoded file: > > > # -*- coding: UTF-8 -*- > > FIELDS = ("Fächer", ) > FROZEN_FIELDS = frozenset(FIELDS) > FIELDS_SET = set(FIELDS) > > print u"Fächer" in FROZEN_FIELDS > print u"Fächer" in FIELDS_S

Problem with sets and Unicode strings

2006-06-27 Thread Dennis Benzinger
Hi! The following program in an UTF-8 encoded file: # -*- coding: UTF-8 -*- FIELDS = ("Fächer", ) FROZEN_FIELDS = frozenset(FIELDS) FIELDS_SET = set(FIELDS) print u"Fächer" in FROZEN_FIELDS print u"Fächer" in FIELDS_SET print u"Fächer" in FIELDS gives this output False False Traceback (mos