# Python f-string's in Jython

**URL:** <https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541>\
**Category:** Ignition\
**Created:** [July 9, 2020, 1:54pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541 "2020-07-09T13:54:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [July 9, 2020, 1:54pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/1 "2020-07-09T13:54:33Z")

</div>

Is it possible to use f strings in Jython?

I.e.

```auto
name = 'Keith'
print(f"My name is {name}")

```

would print ‘My name is Keith’

But I am assuming something java related is causing this to not run, is there a Jython equivalent?

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [July 9, 2020, 2:03pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/2 "2020-07-09T14:03:03Z")

</div>

Ignition 7.x is using Jython 2.5, Ignition 8.x is using Jython 2.7.

The feature you want was only introduced in Python 3.6, which hasn’t been released as Jython yet, but hopefully some day it will.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [July 9, 2020, 2:30pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/3 "2020-07-09T14:30:22Z")

</div>

Awe bummer, I guess is the “best practice” route to just continue with the following?

```auto
name = 'Keith'
print "My name is " + name

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 9, 2020, 2:43pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/4 "2020-07-09T14:43:32Z")

</div>

```auto
name = 'Keith'
print "My name is %s" % name

```

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [July 9, 2020, 2:44pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/5 "2020-07-09T14:44:28Z")

</div>

You do have regular sting replacements.

```auto
name = 'Keith'
print 'My name is %s' % name

```

and you should also have format strings (though I haven tried them, as I tend to not get into the habit python 2.7 since I also still program a lot on Ignition 7.x)

```auto
name = 'Keith'
print 'My name is {name}'.format(name=name)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 9, 2020, 2:50pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/6 "2020-07-09T14:50:09Z")

</div>

You can do something similar in 2.5 with regular string replacements that I had forgotten about until I read @Sanderd17 reply:

```auto
sal = 'Hello,'
name = 'Keith'
print "%(sal)s my name is %(name)s" % {'sal':sal,'name':name}

```

This outputs

```auto
Hello, my name is Keith

```

You can find out more about the options for 2.5 string formatting here:  
[https://docs.python.org/2.5/lib/typesseq-strings.html](https://docs.python.org/2.5/lib/typesseq-strings.html)

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [July 9, 2020, 3:12pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/7 "2020-07-09T15:12:16Z")

</div>

> [@Sanderd17](#):
>
> name = 'Keith' print 'My name is {name}'.format(name=name)

I think I like this one the best, I appreciate you guys clarifying this!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 9, 2020, 4:33pm UTC](https://forum.inductiveautomation.com/t/python-f-strings-in-jython/36541/8 "2020-07-09T16:33:15Z")

</div>

[https://pyformat.info/](https://pyformat.info/)  
For reference on the “old” (2.5) and “new” (2.7) style formatting and pros/cons of each.
