Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-16 Thread Andrés Delfino
IMHO, it would be much easier to learn and understand if keywords can only be used by escaping them, instead of depending where they occur. On Wed, May 16, 2018 at 9:13 AM, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > On 16.05.2018 02:41, Steven D'Aprano wrote: > >> >> Some

Re: [Python-ideas] Fwd: Pattern Matching Syntax

2018-05-13 Thread Andrés Delfino
sion-based constructs don't > feel that natural for Python. > > On Saturday, May 12, 2018 at 2:50:49 PM UTC, Andrés Delfino wrote: >> >> I find it weird for case statements to be "inside" match statements. >> There's isn't a statement "group

Re: [Python-ideas] Fwd: Pattern Matching Syntax

2018-05-12 Thread Andrés Delfino
I find it weird for case statements to be "inside" match statements. There's isn't a statement "group" that works this way right now, AFAIK. This would also be weird: match X: case Y: ... I thought a form based on try would make more coherent: match: suite case x: suite1 else: suite

Re: [Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-13 Thread Andrés Delfino
Oh, I get it now, thanks! On Fri, Apr 13, 2018 at 2:11 AM, Serhiy Storchaka wrote: > 12.04.18 22:42, Andrés Delfino пише: > >> I think the update method can (and personally, should) stay unchanged: >> >> spam.update(dict(x, y)) >> >> seems succinct a

Re: [Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-12 Thread Andrés Delfino
Storchaka wrote: > 09.04.18 00:18, Andrés Delfino пише: > >> I thought that maybe dict could accept several mappings as positional >> arguments, like this: >> >> class Dict4(dict): >> def __init__(self, *args, **kwargs): >> if len

Re: [Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-12 Thread Andrés Delfino
s over the > years to get a new one but it doesn't work: > > d3 = d1 + d2 # TypeError > > Thinking a bit, set union is probably a better analogue, but it doesn't > work either: > > d3 = d1 | d2 # TypeError > > Where the last value of any duplicate keys

Re: [Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-12 Thread Andrés Delfino
Extending the original idea, IMHO it would make sense for the dict constructor to create a new dictionary not only from several mappings, but mixing mappings and iterables too. Consider this example: x = [(1, 'one')] y = {2: 'two'} Now: {**dict(x), **y} Proposed: dict(x, y) I think this extensi

Re: [Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-09 Thread Andrés Delfino
Sorry, I didn't know that kwargs unpacking in dictionaries displays don't raise a TypeError exception. On Mon, Apr 9, 2018 at 8:23 AM, Daniel Moisset wrote: > In which way would this be different to {**mapping1, **mapping2, > **mapping3} ? > > On 8 April 2018 at 22:18,

[Python-ideas] Accepting multiple mappings as positional arguments to create dicts

2018-04-08 Thread Andrés Delfino
Hi! I thought that maybe dict could accept several mappings as positional arguments, like this: class Dict4(dict): > def __init__(self, *args, **kwargs): > if len(args) > 1: > if not all([isinstance(arg, dict) for arg in args]): > raise TypeError('Dict4 ex

[Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Andrés Delfino
Hi! I was thinking: perhaps it would be nice to be able to quicky split a string, do some slicing, and then obtaining the joined string back. Say we have the string: "docs.python.org", and we want to change "docs" to "wiki". Of course, there are a ton of simpler ways to solve this particular need