dominicprice / endplay

A suite of tools for generation and analysis of bridge deals. Read the documentation at https://endplay.readthedocs.io
MIT License
22 stars 5 forks source link

Using unicode or characters #28

Closed ThorvaldAagaard closed 7 months ago

ThorvaldAagaard commented 1 year ago

In some situations I would like to print the contract as:

2♠E+1

but in other situations I would like to print it as

2SE+1

In Denom, there is this implementation

image

I think it would be better to have 2 different properties, instead of letting the property use the configuration.

In the current implementation I will have to change the config before and after the call.

dominicprice commented 1 year ago

There is a suppress_unicode context manager:

>>> from endplay.config import suppress_unicode
>>> with suppress_unicode():
...   print(Denom.spades.abbr)
S
>>> print(Denom.spades.abbr)
♠

to make the switching feel a bit less hacky, I don't know if it is really worth adding a abbr_plain property or something like that, but if you have a good use-case which other people might come across then it would be an easy addition to make :)

ThorvaldAagaard commented 1 year ago

I would prefer to have a property, but realizing I always will avoid unicode I have just added

    #Don't use unicode
    config.use_unicode = False 

at the beginning of my application.

The use case would be for applications creating .lin files as unicode is not supported in .lin

So fell free to close this issue if the work around is acceptable.