Welcome to Qtils 0.11.0 documentation!¶
Overview¶
Qtils - pronounced as cutieels - is a syntactic sugar library to make sweet Python coding even sweeter.
Dedication¶
This library is dedicated to Pál Hubai, Surfy, my programming Master who spent countless hours answering my questions, providing code examples, and guiding me towards the right approach when I was learning programming as a child.
Features¶
- Convenient collections
qdict
,qlist
andQEnum
- Self-formatting object in
PrettyObject
- Two-way formatter/parser for file sizes, for example ‘5.4 GB’ in
DataSize
- Weak reference property decorator
weakproperty
- Cached property decorator
cachedproperty
- Class logger decorator
logged
- Common string transformations in
qtils.string_utils
Installation¶
$ pip install qtils
Examples¶
>>> from qtils import *
>>> d = qdict()
>>> d.hello = "world"
>>> d.hello
'world'
>>> class MyObject(PrettyObject):
... __pretty_fields__ = [
... 'hello',
... 'answer',
... ]
... def __init__(self, hello, answer):
... self.hello = hello
... self.answer = answer
>>> obj = MyObject('world', 42)
>>> print(obj)
<__main__.MyObject object at ... hello='world', answer=42>
>>> print(DataSize(123000))
123 k
>>> DataSize('1.45 megabytes')
1450000
See more examples and usage in examples and tutorials.
Contribution¶
- Pull requests are always welcome!
- Please have a look at the developer guide to get started.