معرفی شرکت ها


autoinit-1.1.1


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Python decorator for automatic initialization instance attributes
ویژگی مقدار
سیستم عامل -
نام فایل autoinit-1.1.1
نام autoinit
نسخه کتابخانه 1.1.1
نگهدارنده []
ایمیل نگهدارنده []
نویسنده -
ایمیل نویسنده Constantine Kosmachevski <oversider.kosma@gmail.com>
آدرس صفحه اصلی -
آدرس اینترنتی https://pypi.org/project/autoinit/
مجوز The MIT License (MIT) ===================== Copyright (c) 2020-2023, Constantine Kosmachevski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
![Tests Pypy](https://github.com/oversider-kosma/autoinit/actions/workflows/pylint.yml/badge.svg?branch=master) ![Tests CPython](https://github.com/oversider-kosma/autoinit/actions/workflows/test_cpython.yml/badge.svg?branch=master) ![Tests Pypy](https://github.com/oversider-kosma/autoinit/actions/workflows/test_pypy.yml/badge.svg?branch=master) # autoinit > Python decorator for automatic initialization instance attributes ### What ```python3 import autoinit # same as `from autoinit import autoinit` @autoinit class X: def __init__(self, a, b, c, d:int, e=99.99, f='some_default_value'): print("__init__ do some another things") x = X(42, 100, 500, None) # Output: "__init__ do some another things" print(x.__dict__) # Output: {'a': 42, 'b': 100, 'c': 500, 'd': None, 'e': 99.99, 'f': 'some_default_value'} ``` ### How $ ```pip install autoinit``` ### Where Tested in: * CPython: 2.7, 3.5-3.11 * Pypy: 2.7, 3.5-3.9 * Jython: 2.7 ...but with a high probability will work with other implementations as well. ### Why A lot of elementary assignments inside `__init__` are a fairly frequent and rather dull case. ```python3 class FiveDimensionRecord: def __init__(self, x:int, y:int, z:int, u:int, v:int, dt:typing.Optional[datetime]=None, description:str=''): self.x = x self.y = y self.z = z self.u = u self.v = v self.dt = dt or datetime.now() self.description = description ``` Dataclasses do not make it much more fun, mainly because you still cannot declare attributes in one line ```python3 @dataclass class FiveDimensionRecord: x: int y: int z: int u: int v: int dt: 'typing.Any' = None description: str = '' def __post_init__(self): self.dt = self.dt or datetime.now() ``` With `autoinit` it looks much more compact and minimalistic ```python3 class FiveDimensionRecord: @autoinit def __init__(self, x:int, y:int, z:int, u:int, v:int, dt=None, description:str=''): self.dt = self.dt or datetime.now() ``` ### Options * `@autoinit(exclude='attr')` or `@autoinit(exclude=['attr1', 'attr2]')`: skip specified attributes. Default: `[]` * `@autoinit(no_warn=True)`: do not throw warning if decorator applied to non-`__init__` method. Default: `False`. * `@autoinit(reverse=True)`: invert the order of actions - first call the wrapped method (which is usually `__init__`), and then do assignment. Default: `False`. The decorator itself can be equally applied to both the `__init__` method and the entire class.


زبان مورد نیاز

مقدار نام
>=2.7 Python


نحوه نصب


نصب پکیج whl autoinit-1.1.1:

    pip install autoinit-1.1.1.whl


نصب پکیج tar.gz autoinit-1.1.1:

    pip install autoinit-1.1.1.tar.gz