Change the display style of the text on the STACKLINE.
Roland Mueller
roland.em0001 at googlemail.com
Thu Sep 9 08:57:02 EDT 2021
Hello
to 9. syysk. 2021 klo 6.53 hongy... at gmail.com (hongyi.zhao at gmail.com)
kirjoitti:
> I'm using the following code in my forked project [1]:
>
> percol.view.STACKLINE = 'Fold:F1,F2,F3 Push:C-p Pop:M-p Script:M-s Dir:M-d
> Dircmd:M-b'
>
> I would like to change the display style of the text mentioned above, for
> example, to underline some characters in it, as shown below:
>
> _D_ir:M-d
>
>
You can use e.g. str.replace() or re.sub()
>>> percol.view.STACKLINE = percol.view.STACKLINE.replace('D', '_D_')
Result: 'Fold:F1,F2,F3 Push:C-p Pop:M-p Script:M-s _D_ir:M-d _D_ircmd:M-b'
>>> import re
Replace D with _D_
>>> percol.view.STACKLINE = re.sub(r'([D])',
r'_\1_', percol.view.STACKLINE)
Result: 'Fold:F1,F2,F3 Push:C-p Pop:M-p Script:M-s _D_ir:M-d _D_ircmd:M-b'
Replace D and M with _D_, _M_
>>> percol.view.STACKLINE = re.sub(r'([DM])', r'_\1_',
percol.view.STACKLINE)
'Fold:F1,F2,F3 Push:C-p Pop:_M_-p Script:_M_-s _D_ir:_M_-d _D_ircmd:_M_-b'
Regards,
Roland
> How to achieve this purpose?
>
> [1]
> https://github.com/hongyi-zhao/ariadne/blob/838179bb4275ac85f5342d9e7d086d6ade3be1de/rc.py#L55
>
> Regards,
> HY
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list