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.5

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.5
File Size Uploaded
k3fmt-0.1.5.tar.gz 11.9 kB Details

Built distribution (wheel)

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

Total release size: 20.9 kB

Release files / k3fmt-0.1.5.tar.gz

Download URL k3fmt-0.1.5.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
37898504b55927e9b5ff1b2add5262ce5bd25263b5de5a4749c7352d40613cff
BLAKE2b-256 checksum
How to use checksums
3f404aa4ffac1dd228e0372e22225c8f4daccbb5224c8a20f8fe747cf5850b87
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.5-py3-none-any.whl

Download URL k3fmt-0.1.5-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b469ac4326f8e27c4858f679b74f65fdef52a114289733032a5cc80980414c3f
BLAKE2b-256 checksum
How to use checksums
420249d564be986ea207db6abc9ff39965c1a147ff11c0d48976d64a41813671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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