Skip to main content

File extensions for programming languages.

Project description

> programming-languages

File extensions for programming languages.

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

Installation

pip install programming-languages

Usage

import programming_languages

py_lang_data = programming_languages['Python']

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

Note: Most type checkers will falsely warn programming_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

Get language from an extension:

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

print(get_lang('.al')) # => 'AL'

Get language from a file path:

def get_lang_from_path(filepath):
    from pathlib import Path
    file_ext = Path(filepath).suffix
    for lang, data in programming_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang_from_path('main.rs')) # => 'Rust'
print(get_lang_from_path('script.kt')) # => 'Kotlin'
print(get_lang_from_path('data.avsc')) # => None (use data-languages pkg)

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.

More Python utilities / Back to top ↑

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

programming_languages-2.0.2.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

programming_languages-2.0.2-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file programming_languages-2.0.2.tar.gz.

File metadata

  • Download URL: programming_languages-2.0.2.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for programming_languages-2.0.2.tar.gz
Algorithm Hash digest
SHA256 c9b0735c55b814c64196b5dd021a3dd10f579014f1d1ebdbbb047c738f9ecbfe
MD5 d57ecb12e4dd539d739519ecddc4b4ed
BLAKE2b-256 828e9559fadf1c02e93b39d622b28c2e19f16a3168f0e2a2bbe8658f9e7d7bea

See more details on using hashes here.

File details

Details for the file programming_languages-2.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for programming_languages-2.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 82fa57bc6e4a56ab1429b597f697df92bfacfad8a228cad5709905ea1bc3b7ed
MD5 f76c3ece8edea1f6f908c5c3b4689db1
BLAKE2b-256 337ca72c1c41f6becdaf83ad227b3c1509ab8fc74cab3553dbcea70bd64959ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page