I've been following along various issues in mypy regarding challenges with
getting the ABCs in numbers
(https://docs.python.org/3/library/numbers.html) working. Currently,
there's a lot of clever logic in the functions int, float, and complex.
Currently, inheriting from Real doesn't give you __
Inheriting from `numbers.Real` _does_ give you `__complex__`, though:
https://github.com/python/cpython/blob/314b8787e0c50985ba708034b84ff5b37a1d47de/Lib/numbers.py#L245-L248
Is it instead `float.__complex__` you're asking for?
___
Python-ideas mailing
Yes, I believe the ask is for `int.__complex__`, `float.__complex__` and
`complex.__complex__` (
https://github.com/python/mypy/issues/3186#issuecomment-762121456)
On Mon, 18 Jan 2021 at 09:47, Mark Dickinson
wrote:
> Inheriting from `numbers.Real` _does_ give you `__complex__`, though:
> https:
On Wed, Jan 13, 2021, at 08:31, Antonio Cavallo wrote:
> Hi,
> I've found myself typing too many time this:
> pathlib.Path("some-dir-name").mkdir(parent=True, exist_ok=True)
>
> Wouldn't be better to have a pathlib.Path.makedirs with parent/exist_ok
> set to True by default?
Worth mentioning, th
On Tue, Jan 5, 2021, at 17:17, lasizoillo wrote:
> Sorry, but if I'm understanting the point is to make one-liners. For
> example, if I want to do something like:
>
> $ env | grep "^XDG"
>
> In one python one liner like
>
> $ python -c 'import os;print("\n".join([f"{key}:{value}" for key, value
Thanks for the correction Mark, I didn't realize that!
Shantanu is right about what my ask was meant to be. I guess I'm nowhere
near the first to propose things like this and there's a lot of discussion
in various threads about it that I wasn't aware of.
Best,
Neil
On Monday, January 18, 202
On Fri, Jan 8, 2021, at 15:47, Joseph Martinot-Lagarde wrote:
> One remark about this : .tar.gz files are the exception rather than the
> rule, and AFAIK maybe the only one ? It's pretty common to have dots in
> filenames instead of blanks for example, and stem does the right thing
> here : '/da
On 18Jan2021 16:49, Random832 wrote:
>On Wed, Jan 13, 2021, at 08:31, Antonio Cavallo wrote:
>> I've found myself typing too many time this:
>> pathlib.Path("some-dir-name").mkdir(parent=True, exist_ok=True)
>>
>> Wouldn't be better to have a pathlib.Path.makedirs with parent/exist_ok
>> set to Tr
On Tue, Jan 19, 2021 at 8:58 AM Random832 wrote:
>
> On Tue, Jan 5, 2021, at 17:17, lasizoillo wrote:
> > Sorry, but if I'm understanting the point is to make one-liners. For
> > example, if I want to do something like:
> >
> > $ env | grep "^XDG"
> >
> > In one python one liner like
> >
> > $ pyt
Hi, all.
I want to write type hints without worrying about runtime overhead.
Current best practice is:
```
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
import xxx # modules used only in type hints.
```
But it would be nice if I can avoid importing even "typing"
Doesn't explicitly setting it yourself still work?
```
TYPE_CHECKING = False
if TYPE_CHECKING:
import xxx # modules used only in type hints.
```
This seems to work for mypy, at least. Even just doing `if False:` works
correctly (and is arguably the most efficient at runtime).
_
That's a mypy-specific hack, not something that's guaranteed by a PEP --
but it works great with mypy!
On Mon, Jan 18, 2021 at 4:40 PM Brandt Bucher
wrote:
> Doesn't explicitly setting it yourself still work?
>
> ```
> TYPE_CHECKING = False
>
> if TYPE_CHECKING:
> import xxx # modules used
>
> what if we had special support for python -c (and maybe in some other
> places like exec(), but definitely not for source files) for the purpose of
> one-liners? Then the syntax wouldn't need to be suitable for general
> purpose use, and you could do something like "have ~{ ~} ~; as alternate
>
Thank you! I didn't know that.
I will use `if False: # TYPE_CHECKING` so the compiler will remove
all imports inner it.
But the official way is preferred so that all typing ecosystems follow it.
--
Inada Naoki
___
Python-ideas mailing list -- python
Hello,
On Tue, 19 Jan 2021 08:54:33 +0900
Inada Naoki wrote:
> Hi, all.
>
> I want to write type hints without worrying about runtime overhead.
> Current best practice is:
>
> ```
> from __future__ import annotations
>
> import typing
>
> if typing.TYPE_CHECKING:
> import xxx # modules u
15 matches
Mail list logo