[Python-ideas] Re: while(tt--)

2023-08-04 Thread Simão Afonso
I'm not sure if you are trolling, but why not use "range"? Can't get more Pythonic than that. -- *Powertools Technologies, Lda* R. Alves Redol 9 * 1000-029 Lisboa * Portugal Phone: +351 214 009 555 * GPS: 38°44'10.927"N 9°8'26.757"W E-mail: cont...@powertools-tech.com * https://www.powertool

[Python-ideas] Re: Use 'bin' in virtual environments on Windows

2022-07-21 Thread Simão Afonso
On 2022-07-21 17:04:16, Svein Seldal wrote: > https://github.com/pypa/pip/blob/main/src/pip/_internal/locations/_distutils.py#L145-L148 This actually works great! If the "Scripts" folder does not exist, it uses "bin". > https://github.com/pypa/pip/blob/main/src/pip/_internal/utils/entrypoints.py#

[Python-ideas] Re: Use 'bin' in virtual environments on Windows

2022-07-21 Thread Simão Afonso
On 2022-07-21 12:00:18, Paul Moore wrote: > How would that work? Would the value of bin-name be stored somewhere and > then all tools would need to refer to that rather than just selecting based > on platform like now? You'd still need to change all the tools, or your > choice of directory simply w

[Python-ideas] Re: Use 'bin' in virtual environments on Windows

2022-07-21 Thread Simão Afonso
On 2022-07-21 09:55:21, Paul Moore wrote: > A practical approach may be to develop some form of library that "hides" > the difference behind some form of API for finding the correct value, get > that added to the stdlib and wait a few years until it's adopted everywhere > (because it's so well-desi

[Python-ideas] Re: dataclass field argument to allow converting value on init

2022-06-24 Thread Simão Afonso
On 2022-06-23 17:35:59, Steve Jorgensen wrote: > What if, instead, the `init` parameter could accept either a boolean > (as it does now) or a type? When given a type, that would mean that to > created the property and accept the argument but pass the argument ti > `__post_init__` rather than using

[Python-ideas] Re: dataclass field argument to allow converting value on init

2022-06-23 Thread Simão Afonso
On 2022-06-23 00:03:03, Paul Bryan wrote: > What type hint will be exposed for the __init__ parameter? Clearly, > it's not a `str` type in your example; you're passing it an `int` value > in your example. Presumably to overcome this, you'd need yet another > `field` function parameter to provide th

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-04 Thread Simão Afonso
On 2022-04-04 01:19:13, pyt...@shalmirane.com wrote: > This implies that it is only necessary to provide a package for > reading and writing physical quantities, and indeed such a package > exists: QuantiPhy. QuantiPhy came out of the ideas that were raised > the last time this topic was discussed

[Python-ideas] Re: List comprehension operators

2021-12-14 Thread Simão Afonso
On 2021-12-14 15:46:06, a.kolpakov2010--- via Python-ideas wrote: > It would be awesome to be able to create a list with just: > > li = [1—100] > > or > > li = [1 .. 100] What's wrong with > range(1, 100) Do you really want a list only to use in a for loop? What's wrong with the iterator? __

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-13 Thread Simão Afonso
On 2021-12-14 01:50:45, Steven D'Aprano wrote: > On Sun, Dec 12, 2021 at 12:23:54PM -0800, Christopher Barker wrote: > > And I note that Annotated flattens nested Annotated types, so having both a > > docstring and other use of Annotated could be a bit tricky. > > class MyClass: > """B

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-10 12:20:44, Ricky Teachey wrote: > I meant to ask about a (global) module member, not the module docstring > itself. Like MY_GLOBAL below: > > """This is the module docs""" > > MY_GLOBAL = None > """MY_GLOBAL docs""" > > class CLS: >"""CLS docs""" > >attr: int >

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-10 08:20:25, Ricky Teachey wrote: > Very very interesting that Sphinx already treats a bare string under the > parameter as documentation! I had no idea. Does it do the same thing at the > module level? Yes. > $ cat module.py > """This is the module docs""" > > class CLS: > """CL

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-09 12:47:28, Paul Bryan wrote: > On Thu, 2021-12-09 at 19:01 +0000, Simão Afonso wrote: > > I'm using docstrings bellow the attributes (analogous to functions > > and > > classes), I think it works well. > > It helps with distinguishing the class docs

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-09 Thread Simão Afonso
I'm using docstrings bellow the attributes (analogous to functions and classes), I think it works well. It helps with distinguishing the class docstring from the arguments. On 2021-12-08 13:25:55, Ricky Teachey wrote: > On Wed, Dec 8, 2021 at 1:20 PM Paul Bryan wrote: > > I believe a Annotated[..

[Python-ideas] Re: Type-hinting dictionaries for an arbitrary number of arbitrary key/value pairs? Counterpart to PEP 589?

2021-10-15 Thread Simão Afonso
Just a pointer related to this, typeguard is abandoned. kttps://github.com/agronholm/typeguard/issues/198 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailm

[Python-ideas] Re: Different exceptions for assert

2021-09-07 Thread Simão Afonso
On 2021-09-07 11:12:37, Juancarlo Añez wrote: > Basically, the proposal is to allow for an exception type and value to be > specified in *assert*, instead of the customary: > > if not assertion: > > raise ValueError('a message') What's wrong with: > if __debug__: > if not assertion: >

[Python-ideas] Re: startswith() and endswith() methods returning the matched value

2021-08-09 Thread Simão Afonso
On 2021-08-09 23:57:42, Chris Angelico wrote: > On Mon, Aug 9, 2021 at 10:32 PM Samuel Freilich wrote: > > Even without it being used in as complicated a way as that it's still not > > backward compatible because of the trivial case, as foo.endswith("") is > > True. > > I was talking specifical

[Python-ideas] Re: Extension methods in Python

2021-06-24 Thread Simão Afonso
On 2021-06-24 09:19:36, Christopher Barker wrote: > No -- we're not assuming Python users are idiots -- there is an important > difference here: > > from extensions import flatten > flatten(mylist) > > very clearly adds the name `flatten` to the current module namespace. That > itself can

[Python-ideas] Re: Extension methods in Python

2021-06-24 Thread Simão Afonso
On 2021-06-24 20:59:31, Steven D'Aprano wrote: > Seriously, there's a time to realise when arguments against a feature > devolve down to utterly spurious claims that Python programmers are > idiots who will be confused by: > > from extensions use flatten > mylist.flatten() > > but can i

[Python-ideas] Re: The name Ellipsis should be a constant

2021-05-31 Thread Simão Afonso
On 2021-05-31 16:16:59, MRAB wrote: > If you rebind str to int, the repr of str will say , so you can > tell that something's happened, but the repr of ... is always 'Ellipsis', > even though you've rebound Ellipsis. > >>> Ellipsis is ... > True > >>> Ellipsis = str > >>> Ellipsis is ... > False _

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Simão Afonso
On 2021-05-06 12:46:40, Shreyan Avigyan wrote: > But Python doesn't have pointers and getattr, settatr can be adjusted > to work with private members. Not really, this is explicitly mentioned on the docs. Here's an example: > >>> from dataclasses import dataclass > >>> @dataclass(frozen=True) >

[Python-ideas] Re: dataclasses keyword-only fields, take 2

2021-03-16 Thread Simão Afonso
> The problem is that if you have 1 normal parameter and 10 keyword-only > ones, you'd be forced to say: > > @dataclasses.dataclass > class LotsOfFields: > a: Any > b: Any = field(kw_only=True, default=0) > c: Any = field(kw_only=True, default='foo') > d: Any = field(kw_only=T