Skip to main content

k3fmt

Action-CI Documentation Status Package

It provides with several string operation functions.

k3fmt is a component of pykit3 project: a python3 toolkit set.

Name

k3fmt

It provides with several string operation functions.

Status

This library is considered production ready.

Install

pip install k3fmt

Synopsis

import k3fmt

lines = [
    "hello",
    "world",
]

# add left padding to each line in a string
k3fmt.line_pad("\n".join(lines), " " * 4)
# "    hello"
# "    world"


# format a multi-row line
items = [
    "name:",
    ["John", "j is my nick"],
    "age:",
    26,
    "experience:",
    ["2000 THU", "2006 sina", "2010 other"],
]

k3fmt.format_line(items, sep=" | ", aligns="llllll")
# outputs:
#    name: | John         | age: | 26 | experience: | 2000 THU
#          | j is my nick |      |    |             | 2006 sina
#          |              |      |    |             | 2010 other


# ['ab']
print(k3fmt.tokenize("ab"))
# ['a', 'b']
print(k3fmt.tokenize("a b"))
# ['a', 'b']
print(k3fmt.tokenize(" a  b "))
# ['a', 'b']
print(k3fmt.tokenize(" a\t b\n c\r "))
# ['a b', 'c d']
print(k3fmt.tokenize("a bxyc d", sep="xy"))
# ['a', 'x x', 'b']
print(k3fmt.tokenize('a "x x" b'))
# ['a', 'x x', 'b']
print(k3fmt.tokenize("a 'x x' b 'x"))  # the last `'x` has no pair, discard
# ['a', 'a b', 'c d']
print(k3fmt.tokenize(" a  xa bx yc dy ", quote="xy"))
# ['a', 'xa bx', 'yc dy']
print(k3fmt.tokenize("a xa bx yc dy", quote="xy", preserve=True))
# ['', 'a', 'xa bx', 'yc dy', '']
print(k3fmt.tokenize(" a xa bx yc dy ", sep=" ", quote="xy", preserve=True))

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Metadata

Release files for k3fmt 0.1.8

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

Source distribution (sdist)

Source distribution for k3fmt 0.1.8
File Size Uploaded Provenance Actions
k3fmt-0.1.8.tar.gz 12.4 kB Without provenance Details for k3fmt-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for k3fmt 0.1.8
File Interpreter ABI Platform Actions
k3fmt-0.1.8-py3-none-any.whl Python 3 none any Details for k3fmt-0.1.8-py3-none-any.whl

Total release size: 21.6 kB

Release files / k3fmt-0.1.8.tar.gz

Download URL k3fmt-0.1.8.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
86124bd7ce60163f98090fbf400cb1f2c88255529ac71bc48723939fbf0c91a3
BLAKE2b-256 checksum
How to use checksums
1623cdbd17a07ee1525b90b6aebf3e62c2d488e7ae1d4cf07151500240bd8bf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / k3fmt-0.1.8-py3-none-any.whl

Download URL k3fmt-0.1.8-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
218283c6fff79303f6f46a79c75c827dce7871b358ef1e585df974c661385a09
BLAKE2b-256 checksum
How to use checksums
2ba3be05ba62566ead1f2e1963f59733affb9317e2de84f67c9546aa949b7934
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for k3fmt 0.1.8

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.

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