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

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

Built distribution (wheel)

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

Total release size: 21.0 kB

Release files / k3fmt-0.1.6.tar.gz

Download URL k3fmt-0.1.6.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1aad632793a4365362dd6668b02d219e7f25dcf03a2e30eb22ad19629d1eeda9
BLAKE2b-256 checksum
How to use checksums
764aa665e1f964940f8911f76476894661d660f4f6b949140ba18fd12dbbba79
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.6-py3-none-any.whl

Download URL k3fmt-0.1.6-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ac801a6a8a0426f3d041e70842b52cb05d9469f5798e431d2cccbd558d92369
BLAKE2b-256 checksum
How to use checksums
e44f44be92026337853d26130c9032a3d5715544b8232d87495d67781246b8d0
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

This release

0.1.6 This release

2 release files

0.1.5

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