[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Christopher Barker
On Fri, Jun 30, 2023 at 8:34 AM Chris Angelico wrote: > > Totally different topic, but I do think that a "curated" package repo > would be helpful -- there is a lot of cruft on PyPi :-( > > > > That idea gets thrown around every once in a while, but there are a > few problems with it. Well yes,

[Python-ideas] Re: else without except

2023-06-30 Thread MRAB
On 2023-06-30 14:55, Daniel Walker wrote: As most of you probably know, you can use else with try blocks: try:     do_stuff() except SomeExceptionClass:    handle_error() else:    no_error_occurred() Here, no_error_occurred will only be called if do_stuff() didn't raise an exception. Howe

[Python-ideas] else without except

2023-06-30 Thread Daniel Walker
As most of you probably know, you can use else with try blocks: try: do_stuff() except SomeExceptionClass: handle_error() else: no_error_occurred() Here, no_error_occurred will only be called if do_stuff() didn't raise an exception. However, the following is invalid syntax: try: do

[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Chris Angelico
On Sat, 1 Jul 2023 at 01:15, Christopher Barker wrote: > Totally different topic, but I do think that a "curated" package repo would > be helpful -- there is a lot of cruft on PyPi :-( > That idea gets thrown around every once in a while, but there are a few problems with it. When you "bless" on

[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Christopher Barker
Google: "python more collections pypi" gets quite a few hits -- I haven't checked out any of them though. Depending on a third party package does take some thought -- but for something like this you could simply "vendor" a particular class (i.e. include the code with yours). Totally different t

[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Dom Grigonis
In my experience, the implementation of bijective dict is largely application specific. 1. Unique-valued dict is fairly straight forward and there is little ambiguity on implementation using 2 dicts. 2. However, if values are not to be unique, then it largely depends on application. (best (as i

[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Barry Scott
> On 30 Jun 2023, at 02:50, Andre Delfino wrote: > > A dict method to retrieve the key of a value from a bijective dict would have > come in handy to me in several occasions: > names = {'one': 1} names.inverse()[1] > 'one' names = {'one': 1, 'uno': 1} names.inverse()[1] >