{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "f-strings...sorta\r\n=================\r\n\r\nHome-page: https://github.com/danbradham/fstrings\r\nAuthor: Dan Bradham\r\nAuthor-email: danielbradham@gmail.com\r\nLicense: MIT\r\nDescription: =================\r\n f-strings...sorta\r\n =================\r\n .. image:: https://travis-ci.org/danbradham/fstrings.svg?branch=master\r\n :target: https://travis-ci.org/danbradham/fstrings\r\n \r\n Python 3.6 f-strings are pretty awesome. It's too bad you can't use them in 2.7 or 3.5. With **fstrings** you can...sorta. The **fstrings** module provides a function *f* that acts similar to f-strings. Pass a string with str.format tokens and *f* will return a string formatted using the available globals and locals. Like this::\r\n \r\n >>> from fstrings import f\r\n >>> x = 'Hello, World...'\r\n >>> f('{x}')\r\n 'Hello, World...'\r\n \r\n You can't evaluate arbitrary python code within the format tokens like you can in Python 3.6, but, some of that lost functionality is gained by allowing you to pass *args* and *kwargs* to *f*. For example, you can still use positional arguments with *f*::\r\n \r\n >>> x = 'World...'\r\n >>> f('{} {x}', 'Hello,')\r\n 'Hello, World...'\r\n \r\n Or you could override globals and locals by passing keyword arguments::\r\n \r\n >>> x = 'Hello'\r\n >>> y = 'World...'\r\n >>> f('{x}, {y}', x='Goodbye')\r\n 'Goodbye, World...'\r\n \r\n Or do both, it's your life. In addition to *f*, fstrings also provides some other nifty stuff.\r\n \r\n \r\n fdocstring Decorator\r\n ====================\r\n ::\r\n \r\n >>> from fstrings import fdocstring\r\n >>> x = 'Hello from ya docs'\r\n >>> @fdocstring()\r\n ... def func():\r\n ... '''{x}'''\r\n ...\r\n >>> func.__doc__\r\n 'Hello from ya docs'\r\n \r\n Right now you might be thinking, \"Cool, *fdocstring* provides the same funcality as *f*, but, for doc strings.\" You would be correct. You can even use *fdocstring* to format class doc strings:\r\n \r\n ::\r\n \r\n >>> x = 'BOOM!'\r\n >>> @fdocstring()\r\n ... class Obj(object):\r\n ... '''{x}'''\r\n ... def method(self):\r\n ... '''{x}'''\r\n ...\r\n >>> Obj.__doc__\r\n 'BOOM!'\r\n >>> Obj.method.__doc__\r\n 'BOOM!'\r\n \r\n \"Boom boom\" is right. Methods are auto formatted too.\r\n \r\n \r\n printf?\r\n =======\r\n After implementing *f*, *printf* was too obvious not to implement.\r\n \r\n ::\r\n \r\n >>> from fstrings import printf\r\n >>> x = 'PRINTFED'\r\n >>> printf('{x}')\r\n PRINTFED\r\n \r\n *printf* and *fdocstring* accept *args* and *kwargs* for overriding globals and locals just like *f*.\r\n \r\n Features and Differences\r\n ========================\r\n \r\n - Uses str.format instead of evaluating python code in {}\r\n - Allows overriding globals and locals by passing in \\*args and \\*\\*kwargs\r\n - Supports python 2.7 to python 3.6\r\n \r\n Tests\r\n =====\r\n **fstrings** comes with a robust set of tests. *pip install nose* and run them if you like.\r\n \r\n ::\r\n \r\n > nosetests -v --with-coverage --with-doctest --doctest-extension rst\r\n \r\n Similar Projects\r\n ================\r\n If you're looking for an implementation truer to Python 3.6 f-strings check out `fmt `_.\r\n \r\nPlatform: UNKNOWN\r\nClassifier: Development Status :: 4 - Beta\r\nClassifier: Intended Audience :: Developers\r\nClassifier: License :: OSI Approved :: MIT License\r\nClassifier: Operating System :: OS Independent\r\nClassifier: Programming Language :: Python\r\nClassifier: Programming Language :: Python :: 2.7\r\nClassifier: Programming Language :: Python :: 3.2\r\nClassifier: Programming Language :: Python :: 3.3\r\nClassifier: Programming Language :: Python :: 3.4\r\nClassifier: Programming Language :: Python :: 3.5\r\nClassifier: Programming Language :: Python :: 3.6\r\nClassifier: Topic :: Software Development :: Libraries :: Python Modules\r\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "fstrings", "package_url": "https://pypi.org/project/fstrings/", "platform": "", "project_url": "https://pypi.org/project/fstrings/", "project_urls": null, "release_url": "https://pypi.org/project/fstrings/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "0.1.0" }, "last_serial": 2702221, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "75993ce83fb6ca137d7b49ffec0253c3", "sha256": "053c27bc2fbfa586582f0866b5cbc037bd81305f0fe10eeceac342391efe7faa" }, "downloads": -1, "filename": "fstrings-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "75993ce83fb6ca137d7b49ffec0253c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5635, "upload_time": "2017-03-13T11:53:43", "url": "https://files.pythonhosted.org/packages/56/70/01cbc51a2541cb97917037b41e5102e21c9c4d792a77bcd87f0304c11946/fstrings-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7f88a027d162893e4673ea135e36e270", "sha256": "ee7f7d552ec6f83c74a0d6d93459d906cb470f2f57539bf4186c7c6534789198" }, "downloads": -1, "filename": "fstrings-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7f88a027d162893e4673ea135e36e270", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3419, "upload_time": "2017-03-13T11:53:44", "url": "https://files.pythonhosted.org/packages/c9/a6/69aa2dc8ca7c379145bbb0abe1d5e1fe1fc06ea23d33c29946524bf9fcfd/fstrings-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "75993ce83fb6ca137d7b49ffec0253c3", "sha256": "053c27bc2fbfa586582f0866b5cbc037bd81305f0fe10eeceac342391efe7faa" }, "downloads": -1, "filename": "fstrings-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "75993ce83fb6ca137d7b49ffec0253c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5635, "upload_time": "2017-03-13T11:53:43", "url": "https://files.pythonhosted.org/packages/56/70/01cbc51a2541cb97917037b41e5102e21c9c4d792a77bcd87f0304c11946/fstrings-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7f88a027d162893e4673ea135e36e270", "sha256": "ee7f7d552ec6f83c74a0d6d93459d906cb470f2f57539bf4186c7c6534789198" }, "downloads": -1, "filename": "fstrings-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7f88a027d162893e4673ea135e36e270", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3419, "upload_time": "2017-03-13T11:53:44", "url": "https://files.pythonhosted.org/packages/c9/a6/69aa2dc8ca7c379145bbb0abe1d5e1fe1fc06ea23d33c29946524bf9fcfd/fstrings-0.1.0.tar.gz" } ] }