[Python-ideas] Re: Addition of a "plus-minus" binary numeric operator

2021-09-14 Thread Ir. Robert Vanden Eynde
Add you can call this function plusminus Then use the funcoperators module to write : upper, lower = a +plusminus- b pip install funcoperators Le mar. 14 sept. 2021 à 16:02, Paul Moore a écrit : > I doubt it, it seems way too specialised to be worth making into a > language feature. > > If

[Python-ideas] Re: symbolic math in Python

2021-05-19 Thread Ir. Robert Vanden Eynde
> solve(x**2 == 1/2) pip install funcoperators >>> solve(x ** 2 |Equals| 1/2) <<< Equals = infix(Eq) <<< from sympy import Eq Le mer. 19 mai 2021 à 08:40, Martin Teichmann a écrit : > Hi list, > > as you might have noticed, I am trying to improve the syntax and semantics > for symbolic math

[Python-ideas] Re: symbolic math in Python

2021-05-19 Thread Ir. Robert Vanden Eynde
SUB Hello everyone, what is the usual way to "like" a mail in the maillist and subscribing to the thread ? By sending a message it adds me to the "Participants" in the webapp which is neat (I can then search for my messages) I could do it in the webapp but not everybody will see it Le mer. 19

[Python-ideas] Re: Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`

2021-05-18 Thread Ir. Robert Vanden Eynde
Static analysis and factorisation, I sub ! :D Le mar. 11 mai 2021 à 01:47, Rob Cliffe via Python-ideas < python-ideas@python.org> a écrit : > > > On 10/05/2021 12:43, Chris Angelico wrote: > > On Mon, May 10, 2021 at 9:36 PM Steven D'Aprano > wrote: > >> On Mon, May 10, 2021 at 10:04:58AM

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-18 Thread Ir. Robert Vanden Eynde
There it is : https://mail.python.org/archives/list/python-ideas@python.org/message/B4EPUQA3GCAXYWB6YMMNAJPMWP5L3QUH/ Le mar. 18 mai 2021 à 12:43, Ir. Robert Vanden Eynde a écrit : > This thread seems related to the other thread I just answered I don't > find, I wrote "julia&q

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-18 Thread Ir. Robert Vanden Eynde
This thread seems related to the other thread I just answered I don't find, I wrote "julia" there, hmmm Le mar. 18 mai 2021 à 12:41, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> a écrit : > David Mertz writes: > > On Fri, May 14, 2021, 4:31 PM Jonathan Fine > wrote: > > > > >

[Python-ideas] Re: Python 3.10: ranges in pattern matching

2021-05-18 Thread Ir. Robert Vanden Eynde
Scala also has "match" cases that are Class redefinable, used for regex for example About integers ranges, we already have the master class : builtins.range pip install funcoperators deals with the issue like this : for i in 1 /irange/ 5: print(i) # will print 1 2 3 4 5 Where irange =

[Python-ideas] Re: Fractions vs. floats - let's have the cake and eat it

2021-05-18 Thread Ir. Robert Vanden Eynde
Julia has these kind of builtin things. The main problem is backward compatibility. However your tool is useful as a python-to-python parser (from the) (I remember some static analysis tools like "mpy"?) pip install funcoperators solve the problem

[Python-ideas] Re: Bringing the print statement back

2020-10-23 Thread Robert Vanden Eynde
That makes me think of ruby where you can omit some of the function call. On Wed, Jun 10, 2020, 02:08 Guido van Rossum wrote: > In Python 3.10 we will no longer be burdened by the old parser (though 3rd > party tooling needs to catch up). > > One thing that the PEG parser makes possible in

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Robert Vanden Eynde
On Another Subject, we could also have a language change staying that those two lines are equivalent : something"hello" something("hello") So that, any callable in the context can be used as a prefix ? On Tue, Aug 27, 2019, 01:11 wrote: > In Python strings are allowed to have a number of

[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. > > >

[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, ] +

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 positional

[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] 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

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

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

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] 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)

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] 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

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 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 =

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] 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

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

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Robert Vanden Eynde
> > > I honestly cannot tell if you are being rhetorical, or if you are > so technically naive that you genuinely don't know that this is an email > mailing list rather than instant messenger or IRC or some other form of > instantaneous chat. > Both :p Newcomers that never spoke on a forum are

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

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

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

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] 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

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 :) ___

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 Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

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

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
+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. >

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 < python-ideas@python.org 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

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

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
> > > 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] 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,

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] 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 Python-ideas@python.org

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

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 Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of

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

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

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

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

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] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Robert Vanden Eynde
Julien, your article is very pleasant to read (and funny) but as other say the mailing list is not there to share some articles, but for proposition to the standard python library, do our own lib on github and pypi first if you want to Share some code to the world ! And if project becomes super

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

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

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

2018-09-18 Thread Robert Vanden Eynde
Needless to say it's interesting to see what others language have (pros and cons), I'm thinking about Scala for example (but I'm sure perl can show us a long list of pros and cons). Le mar. 18 sept. 2018 à 13:38, Tobias Kohn a écrit : > Hello Everyone, > > Please excuse my being late for

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

2018-09-07 Thread Robert Vanden Eynde
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, explain why forcing all callers to name their

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

[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-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

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] 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

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

2018-08-11 Thread Robert Vanden Eynde
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 mutables, the

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

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

2018-08-04 Thread Robert Vanden Eynde
tial. 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! > > Em sáb, 4 de ago de 2018 às

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 Python-ideas@python.org 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
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] 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

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

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 =>

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 at 03:13:25

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

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] 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,

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

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

2018-07-27 Thread Robert Vanden Eynde
(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 wrote: > > On 27

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

2018-07-27 Thread Robert Vanden Eynde
Aprano mailto:st...@pearwood.info>> 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 > possible types, and also availaible

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.

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

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-23 Thread Robert Vanden Eynde
The default could be at the end with an argument to unboxing : favorite = NoneAware(cfg).user.profile.food.unbox("Spam") Le lun. 23 juil. 2018 à 17:26, Paul Moore a écrit : > On 23 July 2018 at 16:12, David Mertz wrote: > > The need addressed by PEP 505 is real; it's also MUCH more niche and

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Robert Vanden Eynde
If we're about to use a new keyword, it could be infix too: a = b ifnone c Although the assignment version looks unusual: b ifnone= c Then with the "default b = c" would look like this: ifnone b = c Le jeu. 19 juil. 2018 à 15:30, Calvin Spealman a écrit : > Operators that only vary by case

Re: [Python-ideas] Unicode Name Aliases keyword argument abbreviation in unicodedata.name for missing names

2018-07-12 Thread Robert Vanden Eynde
> I like your alias(...) function, with that one, an application > could code my function like try name(x) expect > alias(x).abbreviations[0]. If the abbreviation list is sorted by > AdditionToUnicodeDate. I don't understand why that's particularly useful, especially in the Han case (see

Re: [Python-ideas] Add the imath module

2018-07-12 Thread Robert Vanden Eynde
About the name, why not intmath ? And why not using sage ? Or create a package on pypi ? Le jeu. 12 juil. 2018 à 15:11, Serhiy Storchaka a écrit : > 12.07.18 14:55, Serhiy Storchaka пише: > > What are your thoughts about adding a new imath module for integer > > mathematics? It could contain

Re: [Python-ideas] Unicode Name Aliases keyword argument abbreviation in unicodedata.name for missing names

2018-07-12 Thread Robert Vanden Eynde
I like your alias(...) function, with that one, an application could code my function like try name(x) expect alias(x).abbreviations[0]. If the abbreviation list is sorted by AdditionToUnicodeDate. Or try: return name(x) expect: if category(x) == 'Cc': return

Re: [Python-ideas] Unicode Name Aliases keyword argument abbreviation in unicodedata.name for missing names

2018-07-12 Thread Robert Vanden Eynde
Yes, my gmail client transformed unicodata . name to a url. I hope the mobile gmail client won't do it here. Yes current version is 11. I noticed it after sending the mail, I've compared to the version 6 and all my arguments are still valid (they just added some characters in the "correction"

[Python-ideas] Unicode Name Aliases keyword argument abbreviation in unicodedata.name for missing names

2018-07-11 Thread Robert Vanden Eynde
unicodedata.name raises KeyError for a few unicode characters like '\0' or '\n', altough the documentation is very clear on the implementation, this is often not what people want, ie. a string describing the character. In Python 3.3, the name aliases became accepted in

Re: [Python-ideas] anyone need a frozenset or bytearray literal?

2018-07-11 Thread Robert Vanden Eynde
{1,2,7}.freeze() or {1,2,7}.to_frozenset() seem very natural and if this can be optimized to avoid the copy, it's perfect. For bytearray, one use case would be to optimise bytearray([1,2,7,2]) in something like [1,2,7,2].to_byterray(). About bytes, one could have (1,2,7,2).to_bytes() instead of

Re: [Python-ideas] anyone need a frozenset or bytearray literal?

2018-07-11 Thread Robert Vanden Eynde
I completely get your pain, the Copy seems like a waste of ressource. However I think making an optimisation on the C-Level is better than introducing the litteral, because Python is a general purpose langauge and most of the appplication don't need frozenset or bytearrays and that would clutter

Re: [Python-ideas] datetime.timedelta literals

2018-06-26 Thread Robert Vanden Eynde
I found it fun to be able to write minutes(50) alongside with 50 * minutes so I did that : from datetime import date, time, datetime, timedelta class CallableTimedelta(timedelta): def __call__(self, x): return self * x seconds, milliseconds, microseconds, days, hours, minutes,

Re: [Python-ideas] Alternative spelling for list.append()

2018-06-17 Thread Robert Vanden Eynde
I understand the view from the poster, most basic list operations are using brackets, ie reading and writing with [], delete with del L[], why not append ? And being used extensively, that brackets are annoying. And yes, += [] is more "concise" than .append() so some people would think it's more

Re: [Python-ideas] Alternative spelling for list.append()

2018-06-17 Thread Robert Vanden Eynde
Some api (in c++ at least) use "<<" for appending. A = [1,2,7,2] A <<= 5 A == [1,2,7,2,5] The A[] = syntax has it's benefits being used in php (and I think some other lang). Le dim. 17 juin 2018 à 19:12, Michael Selik a écrit : > On Sun, Jun 17, 2018, 10:01 AM Mikhail V wrote: > >> The idea

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

2018-06-13 Thread Robert Vanden Eynde
Then of you also want 45, you could do % 15 ? :D Le mer. 13 juin 2018 à 12:07, Stephan Houben a écrit : > 2018-06-13 12:00 GMT+02:00 Robert Vanden Eynde : > >> What was wrong with my initial implementation with a lookup table ? :D >> >> def sind(x): >> if x %

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

2018-06-13 Thread Robert Vanden Eynde
What was wrong with my initial implementation with a lookup table ? :D def sind(x): if x % 90 == 0: return (0, 1, 0, -1)[int(x // 90) % 4] else: return sin(radians(x)) If you want to support multiples of 30, you can do % 30 and // 30. Le mer. 13 juin 2018 à 09:51,

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

2018-06-12 Thread Robert Vanden Eynde
As mentioned, with complex numbers the radians make more sense and of course cmath.sind(x) + 1j * cmath.sind(x) != cmath.exp(1j * x). However, adding degrees version for cmath (import cmath) is still useful, cmath.rectd, cmath.phased, cmath.polard etc. 2018-06-11 19:24 GMT+02:00 Michael Selik

[Python-ideas] Fwd: Trigonometry in degrees

2018-06-10 Thread Robert Vanden Eynde
at the implementation of scipy.special.sindg and friends to see if/how they have optimisations for exact values. Le dim. 10 juin 2018 à 16:44, Stephan Houben mailto:stephan...@gmail.com>> a écrit : 2018-06-09 8:18 GMT+02:00 Robert Vanden Eynde mailto:robertvandeney...@hotmail.com>>: Fo

Re: [Python-ideas] A "within" keyword

2018-06-09 Thread Robert Vanden Eynde
Classes Provide already some features of a namespace : class cool_namespace: A = 8 @staticmethod def f(): return "yo" @staticmethod def g(): return (1 + cool_namespace.A) * cool_namespace.f() And if you're tired of writing @staticmethod, you can write a

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Robert Vanden Eynde
- 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. - Adding trig function using floats between 0 and 1 is nice, currently one needs to do sin(tau * t)

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Robert Vanden Eynde
uot;sin" function that'd take degrees, therefore I look for a new function name (sindeg). Le ven. 8 juin 2018 à 00:17, Hugh Fisher a écrit : > > Date: Thu, 7 Jun 2018 12:33:29 + > > From: Robert Vanden Eynde > > To: python-ideas > > Subject: [Python-ideas] Trigon

[Python-ideas] Trigonometry in degrees

2018-06-07 Thread Robert Vanden Eynde
I suggest adding degrees version of the trigonometric functions in the math module. - Useful in Teaching and replacing calculators by python, importing something is seen by the young students much more easy than to define a function. - Special values could be treated, aka when the angle is a

Re: [Python-ideas] datetime.timedelta literals

2018-06-05 Thread Robert Vanden Eynde
second, minute, hour (singular) timedelta objects in the module are a good idea, one could do 5 * minute to get a timedelta or one could do value / minute to get a float. a = datetime.now() b = datetime(2018, 2, 3) + 5 * minute print((a - b).total_seconds()) print((a - b) / minute) Le mar. 5

  1   2   >