Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

93 rindas
2.9 KiB

  1. Metadata-Version: 2.1
  2. Name: dataclasses
  3. Version: 0.6
  4. Summary: A backport of the dataclasses module for Python 3.6
  5. Home-page: https://github.com/ericvsmith/dataclasses
  6. Author: Eric V. Smith
  7. Author-email: eric@python.org
  8. License: Apache
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  13. Classifier: License :: OSI Approved :: Apache Software License
  14. Classifier: Programming Language :: Python :: 3.6
  15. .. image:: https://img.shields.io/pypi/v/dataclasses.svg
  16. This is an implementation of PEP 557, Data Classes. It is a backport
  17. for Python 3.6. Because dataclasses will be included in Python 3.7,
  18. any discussion of dataclass features should occur on the python-dev
  19. mailing list at https://mail.python.org/mailman/listinfo/python-dev.
  20. At this point this repo should only be used for historical purposes
  21. (it's where the original dataclasses discussions took place) and for
  22. discussion of the actual backport to Python 3.6.
  23. See https://www.python.org/dev/peps/pep-0557/ for the details of how
  24. Data Classes work.
  25. A test file can be found at
  26. https://github.com/ericvsmith/dataclasses/blob/master/test_dataclasses.py,
  27. or in the sdist file.
  28. Installation
  29. -------------
  30. .. code-block::
  31. pip install dataclasses
  32. Example Usage
  33. -------------
  34. .. code-block:: python
  35. from dataclasses import dataclass
  36. @dataclass
  37. class InventoryItem:
  38. name: str
  39. unit_price: float
  40. quantity_on_hand: int = 0
  41. def total_cost(self) -> float:
  42. return self.unit_price * self.quantity_on_hand
  43. item = InventoryItem('hammers', 10.49, 12)
  44. print(item.total_cost())
  45. Some additional tools can be found in dataclass_tools.py, included in
  46. the sdist.
  47. Compatibility
  48. -------------
  49. This backport assumes that dict objects retain their sort order. This
  50. is true in the language spec for Python 3.7 and greater. Since this
  51. is a backport to Python 3.6, it raises an interesting question: does
  52. that guarantee apply to 3.6? For CPython 3.6 it does. As of the time
  53. of this writing, it's also true for all other Python implementations
  54. that claim to be 3.6 compatible, of which there are none. Any new
  55. 3.6 implementations are expected to have ordered dicts. See the
  56. analysis at the end of this email:
  57. https://mail.python.org/pipermail/python-dev/2017-December/151325.html
  58. As of version 0.4, this code no longer works with Python 3.7. For 3.7,
  59. use the built-in dataclasses module.
  60. Release History
  61. ---------------
  62. +---------+------------+-------------------------------------+
  63. | Version | Date | Description |
  64. +=========+============+=====================================+
  65. | 0.6 | 2018-05-17 | Equivalent to Python 3.7.0rc1 |
  66. +---------+------------+-------------------------------------+
  67. | 0.5 | 2018-03-28 | Equivalent to Python 3.7.0b3 |
  68. +---------+------------+-------------------------------------+