Skip to main content

This is A foundamental package containing some basic self-designed functions and types for Project PyCTLib.

Project description

pyctlib

Introduction

Package pyctlib is the fundamental package for project PyCTLib, a powerful toolkit for python development. This package provides basic functions for fast python v3.6+ programming. It provides easy communication with the inputs and outputs for the operating systems. It provides quick try-catch function touch, useful types like vector, timing tools like timethis and scope as long as manipulation of file path, reading & writing of text/binary files and command line tools.

Installation

This package can be installed by pip install pyctlib or moving the source code to the directory of python libraries (the source code can be downloaded on github or PyPI).

pip install pyctlib

Basic Types

vector

vector is an improved implement of list for python. In addition to original function for list, it has the following advanced usage:

In [1]: from pyctlib.basictype import vector                                         

In [2]: a = vector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])                                  

In [3]: a.map(lambda x: x * 2)                                                       
Out[3]: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

In [4]: a.filter(lambda x: x % 2 == 0)                                               
Out[4]: [2, 4, 6, 8, 10]

In [5]: a.all(lambda x: x > 1)                                                       
Out[5]: False

In [6]: a.any(lambda x: x == 2)                                                      
Out[6]: True

In [7]: a[a > 7] = 7                                                                 

In [8]: a                                                                            
Out[8]: [1, 2, 3, 4, 5, 6, 7, 7, 7, 7]

In [9]: a.reduce(lambda x, y: x + y)                                                 
Out[9]: 49

In [10]: a.index(lambda x: x % 4 == 0)                                               
Out[10]: 3

File Management

Timing Tools

scope

>>> from pyctlib import scope, jump
>>> with scope("name1"):
...     print("timed1")
...
timed1
[name1 takes 0.000048s]
>>> with scope("name2"), jump:
...     print("timed2")
...
>>>

timethis

>>> from pyctlib import timethis
>>> @timethis
... def func(): print('timed')
... 
>>> func()
timed
[func takes 0.000050s]

Touch function

>>> from pyctlib import touch
>>> touch(lambda: 1/0, 'error')
'error'
>>> touch('a')
>>> a = 4
>>> touch('a')
4

Acknowledgment

@Yiteng Zhang, Yuncheng Zhou: Developers

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tpdataset-0.0.25-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file tpdataset-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: tpdataset-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tpdataset-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 39e32f2ac59f367ead33bb6372a52e8579da64cff9423df9c60235e99c1271a4
MD5 7e1cd8a652b3b8e4ac15c2aaae2304e7
BLAKE2b-256 e2fca2314987eef834aacd803a1dc3ee026b1d9680021e0310b3f6a488ded524

See more details on using hashes here.

Provenance

Supported by

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