Skip to main content

sortpythonmethods

Rearrange methods alphabetically in a Python source file. - Python3

sortorder

  1. docstring

  2. future imports

  3. imports first on alphabet then on length (apo, alpha-pipe-organ)

  4. from, modules on apo, imports on alpa

  5. classes sorted on baseclassname then on classname alpha (internals of class unchanged)

  6. methods sorted on methodname alpha

example

Source file before sort

"""
Docstring is required
"""
import sys
import http
import email
import concurrent.futures
import os

class Zorro(object):
    pass

class actie(object):
    pass

def applemethod():
    pass

def foobar():
    pass

class Alpha1(object):
    pass


def helloworld():
    pass

class ZZ(object):
    pass


class Alpha2(ZZ):
    pass

Run command

sortpythonmethods -f myfile.py

Sorted source file

#!/usr/bin/env python3
# coding=utf-8
"""
Docstring is required
"""

import email
import http
import os
import sys
import concurrent.futures

class ZZ(object):
    pass


class Alpha1(object):
    pass


class Alpha2(ZZ):
    pass


class Zorro(object):
    pass


class actie(object):
    pass


def applemethod():
    pass


def foobar():
    pass


def helloworld():
    pass

Metadata

Release files for sortpythonmethods 9

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

Source distribution (sdist)

Source distribution for sortpythonmethods 9
File Size Uploaded Provenance Actions
sortpythonmethods-9.tar.gz 4.3 kB Without provenance Details for sortpythonmethods-9.tar.gz

Release files / sortpythonmethods-9.tar.gz

Download URL sortpythonmethods-9.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cf249d17c7ede517e6107b2277a21bfd814778456508fda90c3b374195e7b9cc
BLAKE2b-256 checksum
How to use checksums
749d0713c0039f8607ccc818ac1c701cade6424053d2bfcf3e10f12ac6b3ced3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for sortpythonmethods 9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

9 This release

1 release file No provenance

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