[Python-ideas] Restricting Python

2020-07-19 Thread Robert
of changes down the road, particularly to binary imports; that would have to be flushed out after the initial changes, and by third party module developers. That’s it; thank you for your consideration. Robert Kaplan ___ Python-ideas mailing list

[Python-ideas] Greetings from a lurker

2017-11-15 Thread Robert
Hi, I've been lurking for quite a time and just wanted to let you know I'm out here. Thanks for making Python the best! Robert Kaplan ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-25 Thread Robert Collins
On Mon, 24 Sep 2018 at 19:47, Marko Ristin-Kaufmann wrote: > > Hi, > > Thank you for your replies, Hugh and David! Please let me address the points > in serial. > > Obvious benefits > You both seem to misconceive the contracts. The goal of the > design-by-contract is not reduced to testing the c

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-25 Thread Robert Collins
On Wed, 26 Sep 2018 at 05:19, Marko Ristin-Kaufmann wrote: > > Hi Robert, ... >> Claiming that DbC annotations will improve the documentation of every >> single library on PyPI is an extraordinary claim, and such claims >> require extraordinary proof. > > &

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-26 Thread Robert Collins
On Thu, 27 Sep 2018 at 00:44, Marko Ristin-Kaufmann wrote: > > P.S. My offer still stands: I would be very glad to annotate with contracts a > set of functions you deem representative (e.g., from a standard library or > from some widely used library). Then we can discuss how these contracts. It

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-26 Thread Robert Collins
On Thu., 27 Sep. 2018, 11:00 Chris Angelico, wrote: > On Thu, Sep 27, 2018 at 8:53 AM Robert Collins > wrote: > > > > On Thu, 27 Sep 2018 at 00:44, Marko Ristin-Kaufmann > > wrote: > > > > > > P.S. My offer still stands: I would be very glad to annota

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-26 Thread Robert Collins
On 27 September 2018 at 11:50, Chris Angelico wrote: > Okay, but what is the contract that's being violated when you use > data= ? How would you define the contract that this would track? > That's what I'm asking. I don't know :). From a modelling perspective the correctness of the behaviour her

[Python-ideas] Introduce typing.SupportsFsPath

2018-10-08 Thread robert . hoelzl
__fspath__ protocol. Please note that "Path" is not a replacement for "SupportsFsPath", since the concept of PEP 519 is, that I could implement new objects (without dependency to "Path") that are implementing the __fspath__ protocol. robert

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-05 Thread Robert Collins
On Sun., 6 Jan. 2019, 13:39 Simon > I was writing some python code earlier, and I noticed that in a code that > looks somwhat like this one : > > try: > i = int("string") > print("continued on") > j = int(9.0) > except ValueError as e: > print(e) > > >>> "in

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-18 Thread Robert Collins
On Sun, 19 May 2019 at 12:17, Yonatan Zunger wrote: > > Hi everyone, > > I'd like to bounce this proposal off everyone and see if it's worth > formulating as a PEP. I haven't found any prior discussion of it, but as we > all know, searches can easily miss things, so if this is old hat please LMK

Re: [Python-ideas] zipfile refactor and AES

2019-06-03 Thread Robert Collins
This sounds like a valuable refactoring to me. Is it API compatible with the current zipfile module docs? On Mon, 3 Jun 2019, 20:23 Daniel Hillier, wrote: > Hi, > > I've written a package that can read and write zip files encrypted with > Winzip's AES encryption scheme (https://github.com/danif

[Python-ideas] Re: Canceling thread in python

2019-06-20 Thread Robert Collins
Do you have a link to that? Googling king .net threads got me some strange results 😁. What made it particularly sane? On Thu, 20 Jun 2019, 23:59 Michael Foord, wrote: > > > On Thu, 20 Jun 2019 at 06:15, Matúš Valo wrote: > >> Hi All, >> >> Currently it is not possible to "kill" thread which is

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-22 Thread Robert Collins
On Mon, 23 Sep 2019 at 10:14, Nutchanon Ninyawee wrote: > > Hi, Python community > I would like to discuss with you about the idea of "bidirectional Aliasing". > I am not good at English wording. I will try my best to communicate the idea I think the idea is clear enough, but what isn't clear is

[Python-ideas] Re: New syntax for dict literals

2020-06-11 Thread Robert DeLanghe
I like Atsou's suggestion of omitting the key for literals: d = {:name, :addr, ’tel': '123-4567’} but using empty kwargs feels gross: d = dict(=name, =addr, tel='123-456') And this feels like it could easily lead to confusion: d = dict(name, addr, tell='123-456') On Thu, Jun 11, 2020 at 4:05

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Robert DeLanghe
This is not really the best syntax, but I thought this generator expression might be of interest: counter = (d.update(n=d['n']+1) or d['n'] for d in [dict(n=-1)] for _ in iter(int,1)) It counts forever starting at 0. I was playing with only using generator syntax... On Fri, Jun 19, 2020 at 1:32

[Python-ideas] Re: "return if "

2020-06-19 Thread Robert DeLanghe
You can already do compact conditional returns with the current syntax: def foo(a, b): return (a != b or None) and a * b or even: foo = (lambda a, b: (a != b or None) and a * b) both return: foo(2, 5) # 10 foo(1, 1) # None ... but clarity would be better. On Fri, Jun 19, 2020 at 4:

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Robert Collins
On Sun, 26 Jul 2020 at 19:11, Vinay Sharma via Python-ideas wrote: > > Problem: > Currently, let’s say I create a shared_memory segment using > mulitprocessing.shared_memory.SharedMemory in Process 1 and open the same in > Process 2. > Then, I try to write some data to the shared memory segment

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Robert Collins
it. There's a lot of prior art on named locks of various sorts, I'd personally be inclined to give the things a name that can be used across different processes in some form and bootstrap from there. > Any thoughts on that ? > > > On 27-Jul-2020, at 3:50 PM, Robert Collin

Re: [Python-ideas] Deterministic iterator cleanup

2016-10-19 Thread Robert Collins
Hey Nathaniel - I like the intent here, but I think perhaps it would be better if the problem is approached differently. Seems to me that making *generators* have a special 'you are done now' interface is special casing, which usually makes things harder to learn and predict; and that more the net

Re: [Python-ideas] Please consider adding context manager versions of setUp/tearDown to unittest.TestCase

2017-08-24 Thread Robert Collins
So (wearing my maintainer hat for unittest) - very happy to consider proposals and patches; I'd very much like to fix some structural APIs in unittest, but I don't have the bandwidth to do so myself at this point. And what you're asking about is largely a structural issue because of the interaction

[Python-ideas] argparse.ArgumentParser: include arguments from files with relative paths

2017-08-29 Thread Robert Schindler
Sorry for doing it the wrong way around. Best regards Robert [1] https://github.com/python/cpython/pull/1698 signature.asc Description: PGP signature ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-

[Python-ideas] Pattern Matching Syntax

2018-05-03 Thread Robert Roskam
Hi Everyone, Never posted in here before, so I hope that I'm not violating any particular procedure for intros or something. Over time, there have been various switch or match statement proposal; some that have gotten as far as PEPs: 2001 Nov - https://www.python.org/dev/peps/pep-0275/ 2006 Jun

Re: [Python-ideas] Pattern Matching Syntax

2018-05-03 Thread Robert Roskam
> > > number = match x: > > 1 => "one" > > 2 => "two" > > 3 => "three" > > 10 => "ten" > > _ => "anything" > > > > number = { > > 1 => "one"

Re: [Python-ideas] Pattern Matching Syntax

2018-05-03 Thread Robert Roskam
Hey Chris, So I started extremely generally with my syntax, but it seems like I should provide a lot more examples of real use. Examples are hard. Here's my hastily put together example from an existing piece of production code: # Existing Production Code from datetime import timedelta, date f

Re: [Python-ideas] Pattern Matching Syntax

2018-05-03 Thread Robert Roskam
ow:date): return match unit: x if x in ('days', 'hours', 'weeks') => timedelta(**{unit: amount}) 'months' => timedelta(days=30 * amount) 'years' => timedelta(days=365 * amount) 'cal_years' => now - now.replace(year=n

Re: [Python-ideas] Pattern Matching Syntax

2018-05-11 Thread Robert Roskam
Hey Steven, I'm also at PyCon. Shall we take this off list and attempt to meet up and discuss? On Friday, May 11, 2018 at 12:36:32 PM UTC-4, [email protected] wrote: > > Hi everyone, I’m also a first time poster to python-ideas so I apologize > if reviving a week old thread is bad form. I emai

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Robert Kern
On 6/8/18 01:45, Robert Vanden Eynde wrote: - Thanks for pointing out a language (Julia) that already had a name convention. Interestingly they don't have a atan2d function. Choosing the same convention as another language is a big plus. For what it's worth, scipy calls them si

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-18 Thread Robert Kern
r -- if this is really such a good idea -- wouldn't someone have make a C lib that does it? Or has someone? Anyone looked? Certainly! scipy.special uses the functions implemented in the Cephes C library. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmle

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-28 Thread Robert Collins
On Sat, 26 Mar 2022 at 18:01, malmiteria wrote: > Hi, > > Before anything, i made a github repository about this topic here : > https://github.com/malmiteria/super-alternative-to-super > > The core of what i wanna discuss here is that i don't think mro and super > (mainly because it relies on mro

Re: [Python-ideas] As-do statements/anonymous blocks in python

2018-07-26 Thread Robert Vanden Eynde
> lumberjack(15, %) > # is equivalent to the expression > lambda x: lumberjack(15, %) You mean lambda x: lumberjack(15, x) ? So you'd want a better syntax for functools.partial, here your example is partial(lumberjack, 15). However this syntax you allow to write lumberjack(%, 15) which is only p

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-26 Thread Robert Vanden Eynde
Currently, what's the best way to implement a function f(OrderedDict([(1,2),(3,4)])) == '{1: 2, 3: 4}', works for all possible types, and also availaible for pprint with nice indent? If I could set a parameter in ipython or python repl that would print that, that would already be very useful. L

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-26 Thread Robert Vanden Eynde
8 à 07:58, Steven D'Aprano mailto:[email protected]>> a écrit : On Fri, Jul 27, 2018 at 05:30:35AM +, Robert Vanden Eynde wrote: > Currently, what's the best way to implement a function > f(OrderedDict([(1,2),(3,4)])) == '{1: 2, 3: 4}', works for all &

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Robert Vanden Eynde
ot;, pformat(od) could be "OrderedDict{1:2, 3,4}" or "OrderedDict({1:2, 3:4})" but I don't ask for repr or pprint to change, just curious about how to implement that. Le ven. 27 juil. 2018 à 11:53, Chris Angelico a écrit : > On Fri, Jul 27, 2018 at 7:45 PM, Thomas Jollans wr

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Robert Vanden Eynde
This is a functionality I sometimes need. Maybe you can do a pull request to more-itertools and that would be the end of it? I don't know if that's general enough for being added to the standard library, more-itertools seems the way to go for me. Go find out if raising a ValueError suits their Api

Re: [Python-ideas] Idea: Deferred Default Arguments?

2018-07-27 Thread Robert Vanden Eynde
> Someone wrote : > Thank you for your deferred default values idea, which we're now working on together. > https://github.com/petered/peters_example_code/blob/master/peters_example_code/deferral.py Allowing to write: from deferral import deferrable_args, deferred @deferrable_args def f(x, y=2, z

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Robert Vanden Eynde
Shortcuts designed for CLI are just to "be more mnemonic" have to be considered with caution. If gettext is a package, it means the whole python community shoud agree on that. msgfmt is part of gettext, so yes, python -m gettest.msgfmt is the best long lasting command. Or it could be 'python -m

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Robert Vanden Eynde
Shortcuts designed for CLI are just to "be more mnemonic" have to be considered with caution. If gettext is a package, it means the whole python community shoud agree on that. msgfmt is part of gettext, so yes, python -m gettest.msgfmt is the best long lasting command. Or it could be 'python -m

Re: [Python-ideas] With expressions

2018-08-02 Thread Robert Vanden Eynde
This brings the discussion of variable assignement in Expression. Functional programming community seems to be more interested in python. lines = (f.readlines() with open('hello') as f) digit = (int('hello') except ValueError: 5) value = (x+y**2 where x,y = (2,4)) values = [x+y**2 for x in range(5

Re: [Python-ideas] With expressions

2018-08-03 Thread Robert Vanden Eynde
Thanks for answering each line. If someone wants "too long didn't read", just check my code at the paragraph "readlines is a toy example, but maybe the code would be more creative". Le ven. 3 août 2018 à 03:07, Steven D'Aprano a écrit : > On Thu, Aug 02, 2018 a

Re: [Python-ideas] With expressions

2018-08-03 Thread Robert Vanden Eynde
> > Expressionization may break the "one and only on obvious way" guideline, > but it can offer concise, readable code in a lot of instances where a > statement-based version would be clumsy and noisy, and there's already some > precedent for it: > > function declaration => lambda > for-loops => ge

Re: [Python-ideas] With expressions

2018-08-04 Thread Robert Vanden Eynde
> I know what functional programming is. What I don't understand is what > you mean when you say that the F.P. community "seems to be more > interested in python". Surely they are more interested in functional > languages than a multi-paradigm language like Python which does not > privilege functio

Re: [Python-ideas] With expressions

2018-08-04 Thread Robert Vanden Eynde
> > > > > A with-statement is great for when you care about the > implementation details. Somebody has to care about the process of > opening a file, reading from it and closing it. But when you *don't* > care about those implementation details, a simple interface like a > read() function is superi

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-04 Thread Robert Vanden Eynde
The funcoperators lib on pypi does exactly that: from funcoperators import partially @partially def add(x: int, y: int) -> int: return x + y add_2 = add[2] @partiallymulti def stuff(x,y,z): return x - y + 2*z sort = partially(sorted) sort_by_x = sort.key(key=lambda element: element.x)

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-04 Thread Robert Vanden Eynde
> @partiallymulti > def stuff(x,y,z): > return x - y + 2*z > f = stuff[1,2] f(4) ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-04 Thread Robert Vanden Eynde
artiallymulti, and elipartial. Partially Multi allowing to write f[1, 2] as a sugar for f[1][2] (which is different than partial(f, (1,2)) ). Le dim. 5 août 2018 à 00:18, Daniel. a écrit : > That's an awesome library! Congratulation for doing this and thanks for > sharing! > &g

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-11 Thread Robert Vanden Eynde
Le sam. 11 août 2018 à 10:34, Vincent Maillol a écrit : > Hello, > > Currently the user defined functions are mutables, there can be existed > python codes like this: > > >>> def foo(): > ... pass > ... > >>> if not hasattr(foo, 'partial'): > ... foo.partial = {} > ... > > Adding a new me

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-11 Thread Robert Vanden Eynde
esn't return a new function (which has the advantage of keeping help(f)) Le sam. 11 août 2018 à 14:53, Robert Vanden Eynde a écrit : > > > Le sam. 11 août 2018 à 10:34, Vincent Maillol > a écrit : > >> Hello, >> >> Currently the user defined functions are mut

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-08-28 Thread Robert Vanden Eynde
> > > By the same logic, wouldn't such a naive user also expect: > > a, b, c = 0 > > to set three variables to 0? > > Let's notice that this syntax is valid: a = b = c = 0 But for += there is no such direct translation. ___ Python-ideas mailing lis

Re: [Python-ideas] Add recordlcass to collections module

2018-09-01 Thread Robert Vanden Eynde
What's the difference between you proposition and dataclasses ? Introduced in Python 3.7 ? Le sam. 1 sept. 2018 à 19:33, Jonathan Goble a écrit : > On Sat, Sep 1, 2018 at 1:08 PM Angus Hollands wrote: > >> As to the other questions, yes, do we need another module in the standard >> library? >>

Re: [Python-ideas] Keyword only argument on function call

2018-09-06 Thread Robert Vanden Eynde
I'm trying to see how it can be done with current python. from somelib import auto auto(locals(), function, 'a', 'b', 'c', d=5) auto(locals(), function).call('a', 'b', 'c', d=5) auto(locals(), function)('a', 'b', 'c', d=5) auto(locals()).bind(function).call('a', 'b', 'c', d=5) One of those synta

[Python-ideas] Python dialect that compiles into python

2018-09-07 Thread Robert Vanden Eynde
Many features on this list propose different syntax to python, producing different python "dialects" that can statically be transformed to python : - a,b += f(x) → _t = f(x); a += _t; b += _t; (augmented assignement unpacking) - a = 2x + 1 → a = 2*x + 1 (juxtaposition is product) - f(*, x, y) →

Re: [Python-ideas] Keyword only argument on function call

2018-09-07 Thread Robert Vanden Eynde
> > > I disagree. Keyword arguments are a fine and good thing, but they are > best used for optional arguments IMHO. Verbosity for the sake of > verbosity is not a good thing. I disagree, when you have more than one parameter it's sometimes complicated to remember the order. Therefore, when you

Re: [Python-ideas] Keyword only argument on function call

2018-09-07 Thread Robert Vanden Eynde
>7. root=abs(complex(root)) >8. j=complex(0,1) >9. x1=(-b+j+sqrt(root))/2*a >10. x2=(-b-j+sqrt(root))/2*a >11. return x1,x2 >12. else: >13. x1=(-b+sqrt(root))/2*a >14. x2=(-b-sqrt(root))/2*a >15. return x1,x2 > > > After that,

Re: [Python-ideas] Pattern Matching Syntax (reprise)

2018-09-18 Thread Robert Vanden Eynde
excuse my being late for properly responding to the last thread on > "Pattern Matching Syntax" [1]. As Robert Roskam has already pointed out at > the beginning of that thread, there has been much previous discussion about > adding pattern matching to Python, and several proposals ex

Re: [Python-ideas] Moving to another forum system where moderation is possible

2018-09-18 Thread Robert Vanden Eynde
As said 100 times in the list, email is powerful, configurable but needs a lot of configuration (especially hard on mobile) and has a lot of rules (don't top post, reply to the list, don't html, wait, html is alright) whereas a web based alternative is easier to grasp (more modern) but adds more ab

Re: [Python-ideas] Proposal for an inplace else (?=) operator

2018-09-22 Thread Robert Vanden Eynde
That's an idea that could be added to my thread "dialects of python" in order to compile some fancy or specific syntax to regular python. Le sam. 22 sept. 2018 à 13:53, Lee Braiden a écrit : > Could I get some feedback on this? I'd like to know if anyone thinks it > might make it through the pe

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Robert Vanden Eynde
That would be a feature in my "python dialect" future library. Taking one valid python program and producing another python program : def f(request): return HttpResponse('ok') → def f(request: HttpRequest): return HttpResponse('ok') The dialect options would include "all top functions in

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Robert Vanden Eynde
useful to everyone one day, it may come one day to the standard library so that everybody will have it. Cheers, Robert ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Robert Vanden Eynde
I think the same way about set.pop, list.pop. About .index I agree adding default= would make sense but that's not exactly the same thing as the others. Do we have somewhere else a place where a linear search already accepts a default= kwarg ? def index(self, x): for i,y in enumerate(self):

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Robert Vanden Eynde
Oooh, PEP463, you're reason with I switch to LBYL or write studpid try except functions so much times. Oh and also the local assignement "let/where/statement" :D x = (y+1 where y = 3.14) because x = [y+1 for y in [3.14]][0] is an overkill and ugly. Should I write a PEP even though I know it's go

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-31 Thread Robert Vanden Eynde
And with libraries like pip install funcoperators or pip install infix, you can even write it infix :D from funcoperators import infix @infix def superop(d1, sc): return {k: (v *superopp* sc) for k, v in d1.items()} print({'a': 8} *superop* 5) Le mer. 31 oct. 2018 à 18:35, Vladimir Filipovi

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Robert Vanden Eynde
> > > That said, though, you may well not need to go to that effort. What is > being asked for here (if I'm not misreading) is a relatively simple > enhancement to a method on a built-in type (or a small handful of > types). If that garners reasonable support, the next step wouldn't be > a PEP, it'

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
Just English Vocabulary, what do you mean by "being in the air at the moment" ? Like, that's a subject that a lot of people in here like to talk ? Yes, to merge or not to merge, but people can UpVote/DownVote can't they ? :D Le ven. 2 nov. 2018 à 01:15, Chris Angelico a écrit : > On Fri, Nov 2,

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > In this case, the governance model for the Python language is being > discussed. > This was the info I was missing, where is it discussed ? Not only on this list I assume ^^ > Upvotes and downvotes don't mean anything. [...] > Yes, that's why random people wouldn't vote. But like, voting be

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > There are a number of PEPs in the 8000s that would be worth reading. > Will read that *à l'occaz*, closing the disgression now ^^ ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Cond

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > Does it make sense to draw some sort of parallel between next(myiterator, > default="whatever") and mylist.pop(default="whatever")? They exhaust the > iterator/list then start emitting the default argument (if provided). > Yep that's what I just did in my previous mail. """ I think the same w

Re: [Python-ideas] dict.setdefault_call(), or API variations thereupon

2018-11-01 Thread Robert Vanden Eynde
> > The two are less connected than you seem to think. > Really ? What's the use mainstream use cases for setdefault ? I was often in the case of Alex. ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-

Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Robert Vanden Eynde
I'm wondering how your examples would go with from funcoperators import infix (https://pypi.org/project/funcoperators/) sum(1:6) # instead of sum(range(1, 6)) > > sum(1 /exclusive/ 6) list(1:6) > > list(1 /exclusive/ 6) set(1 /exclusive/ 1) Note that you can pick another name. Note that you can

Re: [Python-ideas] About the passing the function arguments in Keyword form.

2018-12-25 Thread Robert Vanden Eynde
It's very important that f(z=5) Raises an exception if z is not an argument. For your case, I'd do a wrapper, instead lf calling f(z=5) you can call UniversalCall(f, x=1, y=2, z=5) if you want to specify it on the caller side. Or else, you can create a decorator : @universal_callable def f(x, y)

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
> > > Personally what I find is perverse is that .join is a method of > strings > but does NOT call str() on the items to be joined. Yeah, that's a good reason to use .format when you have a fixed number of arguments. "{}, {}, {}, {}".format(some, random, stuff, here) And then there is

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
So you'd propose to add some kind of def Join(sep, *args): return sep.join(map(str, args)) To the standard lib ? Or to add another method to str class that do that ? class str: ... def Join(self, *args): return self.join(map(str, args)) I agree such a function is super

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
Oh and if you want to write ['a', 'b', 'c'].join('.') Check out pip install funcoperators and you can write : ['a', 'b', 'c'] |join('.') Given you defined the function below : from funcoperators import postfix def join(sep): return postfix(lambda it: sep.join(map(str, it)) You can even cho

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
+1 to that email !! (how to do that in email haha) On Tue, 29 Jan 2019, 21:50 Chris Barker via Python-ideas < [email protected] wrote: > A couple notes: > > On Tue, Jan 29, 2019 at 5:31 AM Jamesie Pic wrote: > >> can you clarify the documentation >> topic you think should be improved or cr

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
+1 Good performance analysis IMHO :) On Tue, 29 Jan 2019, 22:24 Jonathan Fine I've not been following closely, so please forgive me if I'm repeating > something already said in this thread. > > Summary: str.join allows us to easily avoid, when assembling strings, > 1. Quadratic running time. > 2.

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
+1 On Wed, 30 Jan 2019, 02:57 David Mertz "Not every five line function needs to be in the standard library" > > ... even more true for every one line function. I can think of a few > dozen variations of similar but not quite identical behavior to my little > stringify() that "could be useful."

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
> stringify = lambda it: type(it)(map(str, it)) > stringify(range(5)) doesn't work ^^ One advantage or having a standard function is that it has been designed by a lot of persons for all possible use cases :) ___ Python-ideas mailing list Python-ideas@p

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
On Wed, 30 Jan 2019, 04:46 David Mertz wrote: Of course not! [...] > I agree > Of course, it also doesn't work on dictionaries. [...] > I agree ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
I love it when the discussion goes fast like here! :D The messages are short or long-structured-and-explaining, I love it :) -- Sorry if I may look like a troll sometimes, I truly like the conversation and I want to share the excitement :) ___ Python-id

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
> > def stringify(self, sep): > return sep.join(str(i) for i in self) > = map(sep.join(map(str, self)) However some folks want: def stringify(*args, *, sep:str=SomeDefault): return sep.join(map(str, args)) In order to have: >>> stringify(1, 2, "3", sep="-") 1-2-3 And I agree about the

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Robert Vanden Eynde
> def stringify(*args, *, sep:str=SomeDefault): > I meant def stringify(*args, sep:str=SomeDefault) So an idea would use duck typing to find out if we have 1 iterable or a multiple stuff : def stringify(*args, sep:str=SomeDefault, fmt=''): it = args[0] if len(args) == 1 and hasattr(args[0], '

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-01-31 Thread Robert Vanden Eynde
I love moredots ❤️ With pip install funcoperators, one can implement the *dotmul* iff dotmul can be implemented as a function. L *dotmul* 1 Would work. Or even a simple tweak to the library would allow L *dot* s to be [x*s for x in L] and L /dot/ s to be [x/s for x in L]" I'd implement somethi

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Robert Vanden Eynde
That's a nice question ! The main thing is "is this list more EmailLike or MessengerLike" When I speak on Messenger (or any instantaneous conversation software) I send a lot of very small messages, like "+1", it's interactive, I'm expecting a short answer. If I say something stupid, I undo, if I

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Robert Vanden Eynde
Email Can be fast, as long as it is structured. The list only impose the structure of "Thread" ie. Two mails are in the same thread if they have the same subject. Each thread can have it's own format. Email use the quoting mechanism using leading ">" ane generally people do not like html (switch

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Robert Vanden Eynde
le one way, but actually post another way, that is precisely > the sort of confusing lack of clarity that this thread is about. > Indeed, mixing standards is bad, but on the other hand, people can think "Robert is Eafp", "Robert is more LBYL when writing long messages") ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Robert Vanden Eynde
* I didn't have time to read the whole convo' yet * I think linking to a tutorial on "how to use a mailing list" that shows some examples on popular email client like Gmail on android or Mail in iOS would be something really helpful to beginners. When they subscribe, a bot would send that link al

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-03 Thread Robert Vanden Eynde
On Sat, 2 Feb 2019, 21:46 Brendan Barnwell some_list @ str.lower @ tokenize @ remove_stopwords > → some_list @ to(str.lower) @ to(tokenize) @ to(remove_stopwords) Where from funcoperators import postfix as to ___ Python-ideas mailing list Python-ideas

Re: [Python-ideas] add fluent operator to everything

2019-02-19 Thread Robert Vanden Eynde
Heyy, it's funcoperators idea ! >>> [1,2,3].append(4)::sort()::max() +1 [1, 2, 3] |append(4) |to(sorted) |to(max) |to(plus1) You just have to : pip install funcoperators from funcoperators import postfix as to plus1 = postfix(lambda x: x+1) from funcoperators import postfix def append(x):

Re: [Python-ideas] add fluent operator to everything

2019-02-21 Thread Robert Vanden Eynde
In funcoperators, because the dot operator is just syntaxic sugar for functions getattr and setattr with a string, a.hello.world # can be implemented using infix a -o- 'hello' -o- 'world' # or using postfix a |dot('hello') |dot('world') # using from funcoperators import postfix, infix o = infix(g

Re: [Python-ideas] add fluent operator to everything

2019-02-21 Thread Robert Vanden Eynde
On Thu, 21 Feb 2019, 16:44 Rhodri James, wrote: > On 21/02/2019 15:31, Robert Vanden Eynde wrote: > > In funcoperators, because the dot operator is just syntaxic sugar for > > functions getattr and setattr with a string, > [snip hideousness] > > I have to say, that's

Re: [Python-ideas] Add a "week" function or attribute to datetime.date

2019-03-01 Thread Robert Vanden Eynde
Currently one can do week = d.isocalendar()[1] The iso definition of a week number has some nice properties. robertvandeneynde.be On Fri, 1 Mar 2019, 11:44 Antonio Galán, wrote: > The week number is usually refered to the week of the year, but the week > of the month is also interesting, for e

Re: [Python-ideas] Attribute-Getter Syntax Proposal

2019-03-09 Thread Robert Vanden Eynde
You can do : I suggest this syntax: > >>> map(.upper(), ['a', 'b', 'c']) > map(dot('upper'), 'a b c'.split()) map(dot('replace', 'x', 'y'), 'xo do ox'.split()) def dot(name, *args, **kwargs): return lambda self: getattr(self, name)(*args, **kwargs) > This would also work for attributes: >

Re: [Python-ideas] New explicit methods to trim strings

2019-03-26 Thread Robert Vanden Eynde
> And this really is simple enough that I don't want to reach for regex's > for it. That is, I'd write it by hand rather than mess with that. > Well, with re.escape it's not messy at all : import re def trim_mailto(s): regex = re.compile("^" + re.escape("mailto:";)) return regex.sub('', s) W

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Robert Vanden Eynde
robertvandeneynde.be Le mer. 10 avr. 2019 à 12:55, Krokosh Nikita a écrit : > I need smth like starstarmap('{a} / {b}/ {c}'.format, [{a:1, b:2, c:3}, > {a:4, b:5, c:6}, ...]) > That's def starstarmap(f, it): return (f(**x) for x in it) That looks like a recipe, not a basis function ^^ _

Re: [Python-ideas] contains_any_in and contains_all_in

2019-04-23 Thread Robert Vanden Eynde
Here comes funcoperators again : if master_string -contains_any_in- ['string1', 'string2', 'string3']: Given from funcoperators import infix @infix def contains_any_in(string, iterable): return any(item in string for item in iterable) pip install funcoperators https://pypi.org/project/funco

Re: [Python-ideas] contains_any_in and contains_all_in

2019-04-23 Thread Robert Vanden Eynde
> > Trivial with re module, which will answer thequestion in one pass. > re.search('|'.join(map(re.escape, ['string1', 'string2', 'string3'])), master_string) For those who might find it non trivial. ___ Python-ideas mailing list [email protected]

Re: [Python-ideas] Proposal: "?" Documentation Operator and easy reference to argument types/defaults/docstrings

2019-04-25 Thread Robert Vanden Eynde
Looks like a more complicated way to say : def f(x:'int : which does stuff' = 5, y:'int : which does more stuffs') The code reading the annotations (like the linter) might then parse it simply using .split. robertvandeneynde.be Le ven. 26 avr. 2019 à 00:41, Peter O'Connor a écrit : > Dear all

[Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-14 Thread Robert Vanden Eynde
Currently if one wants to provide positional arguments after keyword arguments, it's not possible, one must begin with positional arguments [1] or use keyword arguments [2] : ``` def f(x, *, long_name='foo'): return ... f(2, long_name='bar') # [1] f(long_name='bar', x=2) # [2] ``` The problem

Re: [Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-14 Thread Robert Vanden Eynde
Le mer. 15 mai 2019 à 07:37, Anders Hovmöller a écrit : > > > > On 15 May 2019, at 03:07, Robert Vanden Eynde > wrote: > > > > Currently if one wants to provide positional arguments after keyword > arguments, it's not possible, one must begin with positi

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-06 Thread Robert Vanden Eynde
> print([ > 3, > if False never_called() unless False, > if False never_called() unless False, > 2, > if True 5 unless False, > 4 >]) # => [3, 2, 5, 4] Do you mean this ?Currently what I use is the `*` operator on lists : ``` print([ 3, ] + ([never_called()

[Python-ideas] Re: Make $ a valid identifier and a singleton

2019-06-23 Thread Robert Vanden Eynde
I used "..." in my lib to do that : from funcoperators import bracket @bracket def foo(x, y): print(x, y) partialized = foo[..., 10] partialized(5) https://pypi.org/project/funcoperators/ Le dim. 23 juin 2019 à 21:34, James Lu a écrit : > > Make $ a valid identifier and a singleton. > > >

  1   2   >