tldr/pages.fa/common/2to3.md

33 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2to3
> تبدیل خودکار کد پایتون نسخه 2 به 3
> اطلاعات بیشتر: <https://docs.python.org/3/library/2to3.html>.
- نمایش تغییرات که در حال حاضر انجام میشود بدون اجرای آن (dry-run) :
`2to3 {{مسیر/به/فایل.py}}`
- تبدیل فایل پایتون نسخه 2 به 3 :
`2to3 --write {{مسیر/به/فایل.py}}`
- تبدیل قابلیت های خاص پایتون نسخه 2 به 3 :
`2to3 --write {{مسیر/به/فایل.py}} --fix={{raw_input}} --fix={{print}}`
- تبدیل تمامی قابلیت های نسخه 2 به 3 بغیر از ویژگی های معیین شده :
`2to3 --write {{مسیر/به/فایل.py}} --nofix={{has_key}} --nofix={{isinstance}}`
- نمایش لیست قابلیت های زبان پایتون نسخه 2 که قابلیت تبدیل به نسخه 3 را دارند :
`2to3 --list-fixes`
- تبدیل تمامی فایل های پایتون نسخه 2 به 3 در یک مسیر :
`2to3 --output-dir={{مسیر/به/پوشهایتون_3}} --write-unchanged-files --nobackups {{مسیر/به/پوشهایتون_2}}`
- اجرای همزان(چند رشته ای) دستور 2 به 3 :
`2to3 --processes={{4}} --output-dir={{مسیر/به/پوشهایتون_3}} --write --nobackups --no-diff {{مسیر/به/پوشهایتون_2}}`