1

It seems that python allow to combine r'string and b'string together. But not f'string and b'string !

classic usage:

>>> name='john'
>>> print(f'hello {name}')
hello john

with bytes and f'string:

Try 1:

>>> name=b'john'
>>> print(fb'hello {name}')
  File "<stdin>", line 1
    print(fb'hello {name}')
                     ^
SyntaxError: invalid syntax

Try 2:

>>> print(f'hello {name}')
hello b'john'

So it seems that I need to perform 2 extra computation per lines

  1. bin -> ascii
  2. f'string
  3. ascii -> bin

Is there a better approach ? Is it possible to combine f'string with bytes'string ?

Thanks best regards

bioinfornatics
  • 1,749
  • 3
  • 17
  • 36

0 Answers0