Restore from __pycache__ [duplicate] - python

This question already has answers here:
Is it possible to decompile a compiled .pyc file into a .py file?
(9 answers)
Closed 5 years ago.
I made a huge mistake and included a python file in a large group of files that I removed with -rm. However, I still have the .pyc file stored in __pycache__.
Is there any way to restore a python file from it's cache?

Sorry to hear, try your luck with these Python byte-code de-compilers:
https://github.com/wibiti/uncompyle2
https://pypi.python.org/pypi/uncompyle6
https://sourceforge.net/projects/easypythondecompiler/files/
https://github.com/zrax/pycdc

Related

what is main difference in a .pyi file and .py file? [duplicate]

This question already has answers here:
What is the use of stub files (.pyi ) in python?
(1 answer)
What does "i" represent in Python .pyi extension?
(4 answers)
Closed 1 year ago.
i see that some packages in python use this .pyi files.
Can i use this extension while building a project, and this has any useful application that can't be done with .py files?

How to read files from 7z archive with Python? [duplicate]

This question already has answers here:
How to read contents of 7z file using python
(7 answers)
Closed 3 years ago.
I have a .7z file (archive) and I am trying to find out how to read files from 7z archive? I cannot find any information how to do that. Is there any library for that purpose? I tried zipfile, lzma, however none of them works.
I will be very grateful for any advice.
Best
Look for libarchive or pylzma
https://pypi.org/project/pylzma/
Would help to know which version of Python you are using

What is the difference between "py[cod]" and "pyc" in .gitignore notation? [duplicate]

This question already has answers here:
What do the python file extensions, .pyc .pyd .pyo stand for?
(3 answers)
Closed 9 years ago.
What is the difference (if any) between ".pyc" and ".py[cod]" notation in ignoring files. I am noticing I have both on my git ignore file. Thanks
You are safe to remove the .pyc entry from your .gitignore, since .py[cod] will cover it. The square brackets are for matching any one of the characters, so it matches .pyc, .pyo and .pyd.
Since they are all generated from the .py source, they should not be stored in source control.

Decompile *.pyc file [duplicate]

This question already has answers here:
Is it possible to decompile a compiled .pyc file into a .py file?
(9 answers)
Closed 9 years ago.
I'm a newcomer to programming, and currently taking a course on MIT OCW, using Python 2.6.
The site provides me with a .pyc file, and I wonder if it can be decompiled back to a .py file.
I have researched some ways on the Internet, such as this: Is it possible to decompile a compiled .pyc file into a .py file?
But I just can't understand what they're saying (newcomer).
It would be a great help for newcomers like me if there is a detailed guide on how-to-do this.
Thank you, and sorry for my bad English.
You may check this tools might help you.
http://sourceforge.net/projects/unpyc/

Locking a txt file with python [duplicate]

This question already has answers here:
Locking a file in Python
(15 answers)
Closed 9 years ago.
Is there any way to lock a text file (both Read & Write) with python script? Or is there any module or built in function for that? While running the script, i want the users not to be able to open the text file and change stuffs inside.FYI,I am using windows XP.
I think lockfile should meet your needs

Categories