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
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-
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
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.
>
>
&
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
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
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
__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
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
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
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
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
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
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
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
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:
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
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
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
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
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-
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
>
> > number = match x:
> > 1 => "one"
> > 2 => "two"
> > 3 => "three"
> > 10 => "ten"
> > _ => "anything"
> >
> > number = {
> > 1 => "one"
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
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
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
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
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
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
> 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
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
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
&
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
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
> 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
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
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
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
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
>
> 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
> 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
>
>
>
>
> 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
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)
> @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/
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
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
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
>
>
> 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
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?
>>
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
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) →
>
>
> 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
>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,
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
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
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
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
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
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):
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
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
>
>
> 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'
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,
>
> 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
>
> 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
>
> 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
>
> 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-
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
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)
>
>
> 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
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
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
+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
+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.
+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."
> 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
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
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
>
> 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
> 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], '
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
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
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
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/
* 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
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
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):
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
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
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
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:
>
> 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
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 ^^
_
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
>
> 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]
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
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
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
> 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()
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 - 100 of 163 matches
Mail list logo