Skip to main content

Python f-strings for before Python3.6

Project description

tests flake8 Upload Python Package

fstringlt36 Regex Edition

Installation: pip install fstringlt36

About:

Python f-strings for before Python 3.6. using Regex
This package should try to emulate all f-string features
by using a class that inherits from str.
You can also use it to get newer f-string features in earlier versions of Python.
such as: h = 'hello'; f'{h = }'. the ; is just to denonote the end of a line.
This package requires the re (regular expressions, regex) module.
To my knowledge most versions of Python have re, if not you can use the non regex version
So it should be able to install on any Python version.
Although it's not been tested if thats true because it's not working yet.
Once I implement all the features I will test it across multiple python version and platforms.

Features currently working:

basic variable replacement

>>> from fstringlt36 import f
>>> h = "Hello,"
>>> f("{h} world")
hello world

using the equal operator (I don't know a better name for this and I'm to lazy to look at the document)

>>> from fstringlt36 import f
>>> h = "Hello,"
>>> # instead of doing print(f("h = {h}"))
>>> # you can do print(f("{h = }"))
>>> print(f("{h = }"))
h = 'Hello,'

note:

please note to not call f().f_string_parse() directly but use the f() class.
if you try to f_string_parse() to use directly it will ruin your output and fall back to:

>>> value = 'error: variable ' + string + ' not found'

where value is the replacement string to whatever you put in {}.

>>> from fstringlt36 import f
>>> var = 'foo'
>>> s = f("{var}")
>>> print(s)
foo
>>> t = s.f_string_parse()
>>> print(t)
error: variable value not found
>>> print(s)
error: variable value not found
# besides for messing up t it will also mess up s because it's a reference to the same object.

Version:

Version Number: 0.0.3
Version Stage: alpha

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fstringlt36-0.0.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fstringlt36-0.0.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file fstringlt36-0.0.3.tar.gz.

File metadata

  • Download URL: fstringlt36-0.0.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for fstringlt36-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c7dfede9bf3968f2bdb7d9714e2199517cfcfb31bb0541d6a5e4624e10dfbc15
MD5 42be4502b76d313e502ac05cae1368f8
BLAKE2b-256 adf23316c219f7a2af41a99a2365b8b407c190ac5ddb7be2c52e5d65d553a8d2

See more details on using hashes here.

File details

Details for the file fstringlt36-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fstringlt36-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for fstringlt36-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b141b51f0e0e85f331019abfb3a6088e5c60748015cf0d54618c06c11687d73
MD5 7a81361f04b59882a2451ff8cc7433d0
BLAKE2b-256 45b9764f590b1e50013ce206483342abfed36e9ff6a36daa822d22406034913b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page