Skip to main content

a simple basic f-string like behavior in Python 2

Project description

simple-fstring

A simple basic f-string like behavior in Python 2

Installation

$ pip install simple-fstring

Usage

from fstring import f
a = 1
b = 2
c = u"哈哈"
d = "哈哈"
print f("${a + b}")  # 3
print f(u"我是c${c}")  # 我是c哈哈
print f("我是d${d}")  # 我是d哈哈
print f("我是d${c}c")  # 鎴戞槸d哈哈c
print f(u"我是c${d}d")  # 我是c鍝堝搱d
print f("$${}")  # ${}
print f("${{'a':'dict test'\}.get('a')}")  # dict test
print f("${{'a':'dict test'}.get('a')}")  # {'a':'dict test'.get('a')}
# specify expr namespace
print f("${a + b}", globals_ns={"a": 10, "b": 20}, locals_ns={"a": 1})  # 21

License

MIT

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

simple-fstring-0.1.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

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

simple_fstring-0.1-py2-none-any.whl (3.4 kB view details)

Uploaded Python 2

File details

Details for the file simple-fstring-0.1.tar.gz.

File metadata

  • Download URL: simple-fstring-0.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for simple-fstring-0.1.tar.gz
Algorithm Hash digest
SHA256 a2925ed2b3dae1ca25d8fac0c25c04064c7c7e824da37d07e279c7608265d05d
MD5 e0b2cb689484dc65aca40d598ae35ff7
BLAKE2b-256 3328b0efc8fbb0f79387c22c38a53c61675d732c7e260ae25b5245131757bce5

See more details on using hashes here.

File details

Details for the file simple_fstring-0.1-py2-none-any.whl.

File metadata

  • Download URL: simple_fstring-0.1-py2-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for simple_fstring-0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 a04bd904551c9903f0779c61e55ec376539721e1fffbec75392a40dfc62363b3
MD5 84e3e491aeb2f5f6a3d0bf5e45817434
BLAKE2b-256 dc829a34f00a78807941a9f36691d6a26a5778d2ceace2da41736e4514a3b27f

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