[PATCH] change semantics of "delete" LFUNs again (was: Re: Assertion from command-sequence)

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Dec 4 21:14:58 UTC 2022


Le 04/12/2022 à 22:13, José Matos a écrit :
> On Sun, 2022-12-04 at 21:12 +0100, Jean-Marc Lasgouttes wrote:
>> I finally managed to convinced python to like me, and pushed the
>> result.
>>
>> JMarc
> 
> Nice, I intended to look into this issue this weekend.

Let's say I believe you ;)

> On the other hand I was concerned with encoding a text message in
> integer number that in Python is infinite precision:

You lost me here.

JMarc

> def encode(message):
>      val = 0
>      for c in message:
>          val = val*64 + ord(c.replace(' ', '_')) - ord('A')
>      return val
> 
> I am replacing the space (code 32) with the underscore (code 95) for
> obvious reasons.
> 
> In [2]: encode("Hello fellow LyX developers")
> Out[2]: 691762051676284770344776816411513612200769899634
> 
> def decode(data):
>      message = []
>      while data:
>          c = data % 64
>          message.append(chr(c+ord('A')))
>          data //= 64
>      return "".join(message[::-1]).replace('_', ' ')
> 
> In [4]: decode(encode("Hello fellow LyX developers"))
> Out[4]: 'Hello fellow LyX developers'
> 
> This allows to encode and decode a message into a number.
> 
> Best regards,



More information about the lyx-devel mailing list