paparazzi / pprzlink

Message and communication library for the Paparazzi UAV system
Other
24 stars 55 forks source link

Fixed python string formating to avoid error #139

Closed jburns11 closed 3 years ago

jburns11 commented 3 years ago

Hello All,

I was working on a python program to automate testing, and I was attempting to use pprzlink to connect to the vehicle during this process. When I included the required files (i.e., from pprzlink.ivy import IvyMessagesInterface) i got an syntax error on line that I replaced. I simply changed the statement ... f'{pid}_{sequencenumber}' ... to the line ... '%%'.format(pid, sequence_number)

I replaced this line in V1.0 and V2.0

Here is the error message....

Traceback (most recent call last): File "automate.py", line 14, in from pprzlink.ivy import IvyMessagesInterface File "/home/jb/paparazzi/var/lib/python/pprzlink/ivy.py", line 12, in from pprzlink.request_uid import RequestUIDFactory File "/home/jb/paparazzi/var/lib/python/pprzlink/requestuid.py", line 12 yield f'{pid}{sequence_number}' ^ SyntaxError: invalid syntax

Fabien-B commented 3 years ago

Hello, The syntax used is indeed new in python 3.6, it's good to replace it with a more available syntax. But are you sure your syntax is good ? If I test it:

>>> '%d_%d'.format(10,42)
'%d_%d'

You can replace it with this syntax instead:

>>> '{}_{}'.format(10,42)
'10_42'
jburns11 commented 3 years ago

Thank you for the suggestions!! I made the fix and re-committed!