Re: Fwd: A typing question

2022-10-29 Thread dn
On 30/10/2022 11.59, Paulo da Silva wrote: Solution (below) will not work if the mention of Foos in GLOBALS is a forward-reference. Either move GLOBALS to suit, or surround "Foos" with quotes. This is the problem for me. So far, without typing, I used to have some config and globals classes, mo

Re: A typing question

2022-10-29 Thread Thomas Passin
On 10/29/2022 1:45 PM, Paulo da Silva wrote: Hi! Consider this simple script ... ___ from typing import List, Optional class GLOBALS:     foos=None class Foo:     def __init__(self):     pass class Foos:     Foos: List[Foo]=[]     # SOME GLOBALS ARE USED HERE in a r

Re: Fwd: A typing question

2022-10-29 Thread Paulo da Silva
Às 22:34 de 29/10/22, dn escreveu: Out of interest, tested snippet in PyCharm, cf native-mypy. It flags the original:     GLOBALS.foos: Optional[Foos]=Foos() but not the fall-back:     GLOBALS.foos=Foos() Must admit, the first query coming to mind was: why is the typing taking place at i

Re: str.replace() when str contains \

2022-10-29 Thread MRAB
On 2022-10-29 19:21, Bernard LEDRU wrote: Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurr

Re: str.replace() when str contains \

2022-10-29 Thread Dan Stromberg
I believe you would do well to print a, before trying to transform it into something else. '\2' is chr(2). '\a' is the bell character, and is unprintable. '\_' is two characters though. On Sat, Oct 29, 2022 at 2:12 PM Bernard LEDRU wrote: > Hello, > > https://docs.python.org/3/library/stdtypes.

Re: str.replace() when str contains \

2022-10-29 Thread Thomas Passin
Better to use raw strings whenever backslashes are involved. On 10/29/2022 2:21 PM, Bernard LEDRU wrote: Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If

Re: Fwd: A typing question

2022-10-29 Thread dn
Out of interest, tested snippet in PyCharm, cf native-mypy. It flags the original: GLOBALS.foos: Optional[Foos]=Foos() but not the fall-back: GLOBALS.foos=Foos() Must admit, the first query coming to mind was: why is the typing taking place at initialisation-time, rather than within

Re: str.replace() when str contains \

2022-10-29 Thread Barry
> On 29 Oct 2022, at 22:14, Bernard LEDRU wrote: > > Hello, > > https://docs.python.org/3/library/stdtypes.html#string-methods > > str.replace(old, new[, count])¶ > Return a copy of the string with all occurrences of substring old replaced by > new. If the optional argument count is given,

Fwd: A typing question

2022-10-29 Thread Sam Ezeh
Do you want the following? ``` from typing import List, Optional class GLOBALS: foos: Optional[Foos] = None class Foo: def __init__(self): pass class Foos: Foos: List[Foo] = [] def __init__(self): pass GLOBALS.foos = Foos() ``` Kind regards, Sam Ezeh On S

A typing question

2022-10-29 Thread Paulo da Silva
Hi! Consider this simple script ... ___ from typing import List, Optional class GLOBALS: foos=None class Foo: def __init__(self): pass class Foos: Foos: List[Foo]=[] # SOME GLOBALS ARE USED HERE in a real script def __init__(self): pass G

str.replace() when str contains \

2022-10-29 Thread Bernard LEDRU
Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced. Attention when the

Re: Any PyQt developers here?

2022-10-29 Thread Michael Torrie
On 10/28/22 21:31, DFS wrote: > I found one person that said they did it but their syntax didn't work. > But it doesn't throw an error either. > > model.setData(model.index(tblRow, col), font, Qt.FontRole) I wouldn't expect that to work but it's understandable why it didn't throw an error. setD