Portable Object f-string SyntaxError

What I’m trying to do: calling server function from client-side to create a portable object. I’ve done this many times before, but I’m now getting an error I haven’t seen before: SyntaxError: invalid syntax (<fstring>, line 1) at <fstring>:1.

What I’ve tried and what’s not working: I’ve checked my functions for any actual f-string errors. I can not find any. I’ve experimented and made very simple classes and functions to test inside of this app (see below), and I still get same error.

Is it possible an f-string else somewhere in my app is causing this error when I call this function? Does anyone know where I should look to correct this? Thanks!!!

Code Sample:

# Client-side module
class Cat:
def __init__ (self, sound):
self.sound = sound

# Server-side
@anvil.server.callable
def cat():
  cat = Portable_Classes_Module.Cat('meow')
  return cat

#Client-side
cat = anvil.server.call('cat')

SyntaxError: invalid syntax (<fstring>, line 1)
at <fstring>:1 ``` 

Clone link:
share a copy of your app

Perhaps it would be worth checking this:

IIRC, Python 2 does not support f-strings.

Thanks for response. I’ve checked and I’m using Python 3 on client code and full python 3 on server code.

I just found the error. In my code I found an f-string that had error: print(f’{variable=}’). In Pycharm IDE that works just fine. On Anvil it causes an f-string error. Lesson learned.

1 Like

The trailing = is a Python 3.8 feature:

Anvil is currently 3.7:

You’re not the first to want 3.8 features in Anvil!

2 Likes

I have one virtual environment with Python 3.7 called Anvil that I use as interpreter with all the cloned Anvil apps. It doesn’t allow me to use 3.8+ features on uplink modules, but it helps with this type of problems.

2 Likes