python et l'unicode : -U / python 3000 / repr ... [résolu]

python et l'unicode : -U / python 3000 / repr ... [résolu] - Python - Programmation

Marsh Posté le 22-04-2007 à 16:55:43    

Bonjour,
 
j'ai quelques questions sur Python et l'unicode :
 
(1) pour forcer les chaînes à être de type 'unicode' (et non plus 'str') je lance en ligne de commande :
 

python -U


 
... pas de problème, ça fonctionne.
Mais dans un en-tête de fichier, comment faire ? L'exemple suivant ne marche pas (/usr/bin/env: python -U: Aucun fichier ou répertoire de ce type) :
 

Code :
  1. #! /usr/bin/env python -U
  2. # -*- coding: utf-8 -*-


 
(2) Je suis de loin en loin la venue de Python 3000, qui unifiera les types unicode/str en un type unique. Est-ce que vous savez quand la date de sortie est prévue [réponse donnée ici : http://www.artima.com/forums/flat. [...] ead=197203 : juin 2008]? Savez-vous si la fonction __repr__() pourra enfin renvoyer de l'unicode ?


Message édité par suizokukan le 24-04-2007 à 09:37:54

---------------
rule #1 : trust the python
Reply

Marsh Posté le 22-04-2007 à 16:55:43   

Reply

Marsh Posté le 22-04-2007 à 17:10:28    

Pour la question 2, probablement dans la mesure où le type string lui même sera de l'unicode :o


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 22-04-2007 à 17:19:33    

En effet, Masklinn, ça me paraît aussi logique; et pour ma première question, ... ?

Reply

Marsh Posté le 22-04-2007 à 17:23:53    

aucune idée sinon j'y aurais répondu :o


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 22-04-2007 à 17:48:43    

Quelqu'un s'était déjà posé la question : http://mail.python.org/pipermail/p [...] 00698.html,
 mais n'a pas trouvé la réponse.
 
Dans tout ce que je lis, il semble bien qu'il soit impossible de passer un argument à 'env'.

Reply

Marsh Posté le 22-04-2007 à 18:40:53    

Tu peux aliaser sinon, créer un python custom qui lance python -U :o
 
C'est un peu goret, mais ça marche :o


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 22-04-2007 à 18:47:18    

Je suis arrivé à la même conclusion; ça marche bien
 
Juste une note : l'option -U n'est pas officielle et certaines bibliothèques ne l'apprécient pas (ex : xml.sax )
 
Merci à Masklinn de s'être penché sur mon problème !


---------------
rule #1 : trust the python
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed