{ "info": { "author": "koher", "author_email": "koher@koherent.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Utilities" ], "description": "Swifpy\n======\n\n*Swifpy* makes Python Swifty. It provides some types which have similar\nAPIs with Swift's.\n\n.. code:: python\n\n from swifpy import Array, Dictionary, Int, Optional, Some, String\n\n array: Array[Int] = Array([2, 3, 5])\n squared: Array[Int] = array.map(lambda x: x * x) # [4, 9, 25]\n count: Int = array.count # 3\n\n dictionary: Dictionary[String, Int] = Dictionary({'a': 2, 'b': 3, 'c': 5})\n a: Optional[Int] = dictionary['a'] # Optional(2)\n b: Optional[Int] = dictionary['b'] # Optional(3)\n\n sum: Optional[Int] = a.flat_map(lambda x: b.map(lambda y: x + y)) # Optional(5)\n\nUsage\n-----\n\nBool, Float, Int, String\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThey are just type aliases of ``bool``, ``float``, ``int`` and ``str``\nrespectivly.\n\nArray\n~~~~~\n\n.. code:: python\n\n from swifpy import Array, Int, Optional, Some\n\n numbers: Array[Int] = Array([2, 3, 5])\n\n second: Int = numbers[1] # 3\n count: Int = numbers.count # 3\n\n squared: Array[Int] = numbers.map(lambda x: x * x) # [4, 9, 25]\n odd: Array[Int] = numbers.filter(lambda x: x % 2 != 0) # [3, 5]\n sum: Array[Int] = numbers.reduce(0, lambda r, x: r + x) # 10\n twice: Array[Int] = numbers.flat_map(lambda x: Array([x, x])) # [2, 2, 3, 3, 5, 5]\n\n first: Optional[Int] = numbers.first # Optional(2)\n third: Optional[Int] = numbers.last # Optional(5)\n\n for number in numbers:\n print(number)\n\nDictionary\n~~~~~~~~~~\n\n.. code:: python\n\n from swifpy import Dictionary, Int, Optional, Some, String\n\n dictionary: Dictionary[String, Int] = Dictionary({'a': 2, 'b': 3, 'c': 5})\n\n a: Optional[Int] = dictionary['a'] # Optional(2)\n dictionary['d'] = 7\n count: Int = dictionary.count # 4\n\n for key, value in dictionary:\n print(\"%s -> %d\" % (key, value))\n\nOptional\n~~~~~~~~\n\n.. code:: python\n\n from swifpy import Int, Nil, Optional, Some, NilError\n\n a: Optional[Int] = Some(2)\n b: Optional[Int] = Some(3)\n n: Optional[Int] = Nil\n\n if a:\n print('Reaches here.')\n\n if not n:\n print('Reaches here.')\n\n squared1: Optional[Int] = a.map(lambda x: x * x) # Optional(4)\n squared2: Optional[Int] = n.map(lambda x: x * x) # Nil\n sum1: Optional[Int] = a.flat_map(lambda x: b.map(lambda y: x + y)) # Optional(5)\n sum2: Optional[Int] = a.flat_map(lambda x: n.map(lambda y: x + y)) # Nil\n\n unwrapped: Int = a.x # `!` in Swift: `x` of e*x*clamation marks\n _ = n.x # NilError\n\n # `??` in Swift: `q` of *q*uestion marks\n coalesced1: Int = a.qq(0) ## 2\n coalesced2: Int = n.qq(0) ## 0\n\nLicense\n-------\n\n`The MIT License `__\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/koher/swifpy", "keywords": "swift swifty", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "swifpy", "package_url": "https://pypi.org/project/swifpy/", "platform": "", "project_url": "https://pypi.org/project/swifpy/", "project_urls": { "Homepage": "https://github.com/koher/swifpy" }, "release_url": "https://pypi.org/project/swifpy/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Makes Python Swifty", "version": "0.0.1" }, "last_serial": 2649714, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "107c8d1e9d96a31cb58ea9847fdc05c1", "sha256": "4cb60f5e081539b5b2dab2464d9117c77a2a5e0b5351cf60c48f9f2351689e31" }, "downloads": -1, "filename": "swifpy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "107c8d1e9d96a31cb58ea9847fdc05c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5219, "upload_time": "2017-02-17T14:53:57", "url": "https://files.pythonhosted.org/packages/9b/2f/89b0c8a177fd9a7052c7520957cee45be03a4114b843e2494a4a67fcc5f2/swifpy-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "107c8d1e9d96a31cb58ea9847fdc05c1", "sha256": "4cb60f5e081539b5b2dab2464d9117c77a2a5e0b5351cf60c48f9f2351689e31" }, "downloads": -1, "filename": "swifpy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "107c8d1e9d96a31cb58ea9847fdc05c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5219, "upload_time": "2017-02-17T14:53:57", "url": "https://files.pythonhosted.org/packages/9b/2f/89b0c8a177fd9a7052c7520957cee45be03a4114b843e2494a4a67fcc5f2/swifpy-0.0.1.tar.gz" } ] }