Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

💻 computer-languages

File extensions for computer languages.

It's just a JSON file, so you can use it in any environment. Sourced from GitHub's Linguist project (defines all 700+ languages known to GitHub). Data is updated via script and released via new package version.

Installation

pip install computer-languages

Usage

import computer_languages

py_lang_data = computer_languages['Python']

print(py_lang_data['type']) # => programming
print(py_lang_data['extensions']) # => ['.cgi', '.fcgi', '.gyp', ...]

Note: Most type checkers will falsely warn computer_languages is not subscriptable because they are incapable of analyzing runtime behavior (where the module is replaced w/ a dictionary for cleaner, direct access). You can safely suppress such warnings using # type: ignore.


Examples

List all extensions for a language:

js_exts = computer_languages['JavaScript']['extensions']

print(js_exts) # => ['._js', '.bones', '.cjs', '.es', ...]

Get language from an extension:

def get_lang(file_ext):
    for lang, data in computer_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang('.rs')) # => Rust

Filter by language type:

markup_langs = [
    lang for lang, data in computer_languages.items()
        if data['type'] == 'markup'
]

print(markup_langs) # => ['Antlers', 'API Blueprint', 'Astro', 'BibTeX', ...]
print(f'{len(markup_langs)} markup languages') # -> 69 markup languages

MIT License

Copyright © 2026 Adam Lui


Related

</> markup-languages - File extensions for markup languages.
## prose-languages - File extensions for prose languages.
{ } data-languages - File extensions for data languages.
#! programming-languages - File extensions for programming languages.

More Python utilities / Discuss / Report bug / Report vulnerability / Back to top ↑