• [^] # Re: Tout les bugs ? vraiment ?

    Posté par (site web personnel) . En réponse à la dépêche Sortie de Python 3.0 version finale. Évalué à 3.

    Apparemment tu n'as pas trop pris le temps de chercher.

    Il suffit d'utiliser le module fileinput [http://docs.python.org/3.0/library/fileinput.html] que l'on trouve dans la documentation de sys.argv [http://docs.python.org/3.0/library/sys.html?highlight=filein(...)].
    La méthode fileinput.input [http://docs.python.org/3.0/library/fileinput.html#fileinput.(...)] permet d'ouvrir un flux (par défault le flux d'arguments) suivant un mode spécifié.
    With mode you can specify which file mode will be passed to open(). It must be one of 'r', 'rU', 'U' and 'rb'.

    La documentation de open [http://docs.python.org/3.0/library/functions.html#open] nous indique alors comment l'on configure l'ouverture d'un flux :

    ========= ===============================================================
    Character Meaning
    --------- ---------------------------------------------------------------
    ``'r'`` open for reading (default)
    ``'w'`` open for writing, truncating the file first
    ``'a'`` open for writing, appending to the end of the file if it exists
    ``'b'`` binary mode
    ``'t'`` text mode (default)
    ``'+'`` open a disk file for updating (reading and writing)
    ``'U'`` universal newline mode (for backwards compatibility; unneeded
    for new code)
    ========= ===============================================================


    Tu doit pouvoir alors convertir un flux de donné suivant un encodage spécifié (en l'occurrence celui du système).

    PS: je n'ai pas fait de python depuis 1 ans
    PS2: la documentation de python 3 est vraiment superbe