Skip to main content

strings.py

Print all strings and f-string constants present in a python project.

Ignores docstrings, unused strings, type annotations and single characters.

Installation

pip install strings.py

Usage

python -m strings path/to/project/or/file

Example

Consider this module.py file:

"""My module"""

SOME_CONSTANT = "42"

class C:
    """My Class does this"""

    def __init__(self) -> None:
        self.x = SOME_CONST

c = C()
print(f"The constant: {c.x}")
$ python -m strings module.py
42
The constant:

$ python -m strings -n module.py
/home/john/module.py:3:42
/home/john/module.py:12:The constant:

Local Development / Testing

  • Create and activate a virtual environment
  • Run pip install -r requirements-dev.txt to do an editable install
  • Run pytest to run tests

Type Checking

Run mypy .

Create and upload a package to PyPI

Make sure to bump the version in setup.cfg.

Then run the following commands:

rm -rf build dist
python setup.py sdist bdist_wheel

Then upload it to PyPI using twine:

twine upload dist/*

Metadata

Release files for strings.py 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strings.py 1.0.1
File Size Uploaded
strings_py-1.0.1.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for strings.py 1.0.1
File Interpreter ABI Platform
strings.py-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / strings_py-1.0.1.tar.gz

Download URL strings_py-1.0.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fd62c49663e3430ac0070d9a158877abfd91ee84ffa6334a2afc04b9fa6c0930
BLAKE2b-256 checksum
How to use checksums
68a4f2279eee2ba1dbea59b709dda77989afcd43caf9fce439a86fb06057ea14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / strings.py-1.0.1-py3-none-any.whl

Download URL strings.py-1.0.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4c97a7256efa2e81a7be14d4a69a5c34d2bba23617e1f42c71170c6f4036b0e
BLAKE2b-256 checksum
How to use checksums
407b2d2c32302052f75d3cbbd65d1b95ce5ffd3842cd849d2abab3baeaa1b29a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page