Skip to main content

HaoTian's Python Util

Project description

htutil

HaoTian's Python Util

version downloads format implementation pyversions license

Install

pip install htutil

Usage

file

from htutil import file

Refer to C# System.IO.File API, very simple to use.

    s = 'hello'
    write_text('1.txt', s)
    # hello in 1.txt
    append_text('1.txt', 'world')
    # helloworld in 1.txt
    s = read_text('1.txt')
    print(s)  # helloworld

    s = ['hello', 'world']
    write_lines('1.txt', s)
    # hello\nworld in 1.txt
    append_lines('1.txt',['\npython'])
    # hello\nworld\npython in 1.txt
    s = read_lines('1.txt')
    print(s)  # ['hello', 'world', 'python']

cache

cache def result by pickle file.

from htutil import cache
@cache.file_cache
def get_1():
    time.sleep(3)
    return 1

counter

a simple counter based on dict.

    c = Counter()
    c.add('1')
    c.add('1')
    c.add('2')

    print(c.to_dict()) # {'1': 2, '2': 1}

    c.dump() # same as print(c.to_dict())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htutil-3.2.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htutil-3.2.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file htutil-3.2.0.tar.gz.

File metadata

  • Download URL: htutil-3.2.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for htutil-3.2.0.tar.gz
Algorithm Hash digest
SHA256 e56da9d5c8d8b45d60536e8b872246b902873370fd10a3009bfee2f4727c6855
MD5 cd90b740f41e2910334732a22d222f6a
BLAKE2b-256 9f08d7a298cb5b3f2555fc8ec55c7b828abf88bb1d4325f466175252a79f8385

See more details on using hashes here.

File details

Details for the file htutil-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: htutil-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for htutil-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 601306ca12693e366fa6274e0a48329fdde3c329996ead422eb8ecf1d0fbca4d
MD5 9bc1884d26c410d81a163e08c9293ccc
BLAKE2b-256 415b9615adc3021c8f0bf7b602778242160863a1f61b135d2b99041db453aa88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page