Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisioneRevisione precedente
Prossima revisione
Revisione precedente
python:porting_python_2_to_pyton_3 [2020/01/22 17:39] – WIP apressatopython:porting_python_2_to_pyton_3 [2020/01/22 18:01] (versione attuale) – WIP apressato
Linea 1: Linea 1:
 ====== Porting da Python 2 a Python 3  ======  ====== Porting da Python 2 a Python 3  ====== 
  
-<WRAP center round important 60%> 
-***WIP***: Quello seguente è un articolo in divenire 
-</WRAP> 
  
  
Linea 1284: Linea 1281:
   * L'ultima alternativa è il flag ''**--future-unicode**'' che importa gli ''unicode_literals'' dal modulo **<nowiki>__future__</nowiki>** usando il fixer contenuto in ''libmodernize.fixes.fix_unicode_future''.\\ Ciò richiede Python 2.6 e versioni successive e richiederà di contrassegnare le bytestring con b '' e le stringhe native in str('') o qualcosa di simile che sopravviva alla trasformazione.   * L'ultima alternativa è il flag ''**--future-unicode**'' che importa gli ''unicode_literals'' dal modulo **<nowiki>__future__</nowiki>** usando il fixer contenuto in ''libmodernize.fixes.fix_unicode_future''.\\ Ciò richiede Python 2.6 e versioni successive e richiederà di contrassegnare le bytestring con b '' e le stringhe native in str('') o qualcosa di simile che sopravviva alla trasformazione.
  
 +==== Preparazione ====
 +Dal prompt dei comandi lanciare
 +<code bash>
 +pip --install modernize
 +</code>
 +Al termine dell'installazione avrete a disposizione l'eseguibile **python-modernize**
  
 +==== Batch di conversione ====
 +<code batch>
 +set mydatetime=%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%
 +set logpath=.\Logs
 +set logfile=%logpath%\Migrate_%Application%_2to3_%mydatetime%.log
 +set RepoPath=path\to\your \web2py\applications
 +set Application=Your_Folder_App_Name
  
 +IF NOT EXIST %logpath% (
 +  MKDIR %logpath%
 +)
 +
 +(FOR /f "delims=" %%a IN ('DIR %RepoPath%\%Application%\*.pyc /b /s') do (del %%a))
 +(FOR /f "delims=" %%a IN ('DIR %RepoPath%\%Application%\*.py /b /s') do (python-modernize -w %%a >> %LogFile%))
 +(FOR /f "delims=" %%a IN ('DIR %RepoPath%\%Application%\*.bak /b /s') do (del %%a))
 +</code>
  
  
Linea 1295: Linea 1313:
   - [[https://www.geeksforgeeks.org/important-differences-between-python-2-x-and-python-3-x-with-examples/]]   - [[https://www.geeksforgeeks.org/important-differences-between-python-2-x-and-python-3-x-with-examples/]]
   - [[https://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html]]   - [[https://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html]]
 +  - [[https://python-modernize.readthedocs.io/en/latest/]]
  
  
python/porting_python_2_to_pyton_3.1579714751.txt.gz · Ultima modifica: 2020/01/22 17:39 da apressato
Torna su
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0