Python Forum
file extension for python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: file extension for python (/thread-6248.html)



file extension for python - Skaperen - Nov-12-2017

python already uses .py and .pyc and .pyo ... are there any others:  i've started using these:

.pyi - insertable (not necessarily importable) snippets of code that can be useful to inserted while creating a .py file.

.pyd - insertable or importable files that are data being added to a program, such as a list of US states.

.pyt - insertable or importable files that are text being added to a program, such as different licenses.

your thoughts?

*** ducks behind the big blue couch ***


RE: file extension for python - wavic - Nov-12-2017

Hm... I would use some file name prefix or suffix. And I am doing it like that. The programs and the systems depend on file extension when it comes to text files. If the file is executable ( a script ), the shebang line will work regardless of the file extension. But this is valid for Linux/Unix systems. Don't know about Mac OS.


RE: file extension for python - sparkz_alot - Nov-12-2017

You forgot .pyw (though that may apply only to Windows).

Sounds like you're just reinventing the wheel and making life just a little more complicated.


RE: file extension for python - buran - Nov-12-2017

I don't see the point to invent your own extensions. Who else, but you will know what they mean. Not to mention that
pyd - https://docs.python.org/3.6/faq/windows.html#is-a-pyd-file-the-same-as-a-dll
pyt -  http://desktop.arcgis.com/en/arcmap/10.3/analyze/creating-tools/a-quick-tour-of-python-toolboxes.htm


RE: file extension for python - Skaperen - Nov-13-2017

this started for me when i had some files that were snippets of code i could insert into python code.  at first i used the extension .py for everything.  but that was getting them mixed up with python code that was suppose to be a complete command or module.  it first it seemed i needed to read each file to see if it began with #! which was making a lot of my commands big and complex.  at least the ones without #! were short so grep didn't need to read so much.  i started writing a command to detect these (the file command did not ... in some cases it said it was ascii text and in others it said it was python source) then got the idea of an extension (.pyi) as i could get emacs to recognize then that way a lot easier, and recognize them in big one-time commands a lot easier (for example, a one-time command to upload all python-insertable files to a specific location).  so, i started doing it that way.  i have solved similar issues with other things not involving python, before, with general good luck.  then i realized i had some files that were data or text assignments (can import) or quote encodings (inserted after a dangling assignment) and decided .pyi was not enough for these.  too bad Linux did not have meta-attributes for files.


RE: file extension for python - wavic - Nov-13-2017

It sounds like a database is what you need


RE: file extension for python - Skaperen - Nov-13-2017

there would be too much interfacing the database to other things ... i think extensions keeps it simple.