Hi everyone,
maybe, I am missing something here but is it possible to specify a
delimiter for list arguments in argparse:
https://docs.python.org/3/library/argparse.html
Usually, '--' is used to separate two lists (cf. git).
Cheers,
Sven
--
https://mail.python.org/mailman/listinfo/python-li
ction='append')
At least from my point of view, I don't any way to separate both lists
on this command call:
cool-script.py thing1 thing2 stuff1 stuff2
Do I miss something here?
Best
Sven
On 03.08.21 01:49, Dan Stromberg wrote:
Isn't -- usually used to signal the end o
On 10.09.2016 15:00, Chris Angelico wrote:
Some things are absolute hard facts. There is no way in which 1 will
ever be greater than 2, ergo "1 is less than 2" is strictly true, and
not a matter of opinion. If you hear someone trying to claim
otherwise, would you let him have his opinion, or woul
Not heard of any but I can recommend django-restframework. We've got
good experience with that.
On 28.03.2016 23:06, David Shi via Python-list wrote:
Has anyone done a recent reviews of creating REST services, in Python?
Regards.
David
--
https://mail.python.org/mailman/listinfo/python-list
On 29.03.2016 06:13, Michael Torrie wrote:
On 03/28/2016 06:44 PM, Steven D'Aprano wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/
I have the same problem as the writer. Working in Python makes me
really dislike working in any other language
On 29.03.2016 11:39, Peter Otten wrote:
My question to those who know a bit of C#: what is the state-of-the-art
equivalent to
"\n".join(foo.description() for foo in mylist
if foo.description() != "")
Using LINQ, I suppose:
https://en.wikipedia.org/wiki/Language_Inte
On 28.03.2016 17:34, ast wrote:
"Matt Wheeler" a écrit dans le message de
news:mailman.92.1458825746.2244.python-l...@python.org...
On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote:
On 24.03.2016 11:57, Matt Wheeler wrote:
>>>> import ast
>>>> s = "
On 27.03.2016 05:01, Steven D'Aprano wrote:
Am I the only one who has noticed that threading of posts here is severely
broken? It's always been the case that there have been a few posts here and
there that break threading, but now it seems to be much more common.
I agree. Didn't we both already
On 26.03.2016 18:06, Peter Otten wrote:
beliavsky--- via Python-list wrote:
I can use x[::n] to select every nth element of a list. Is there a
one-liner to get a list that excludes every nth element?
del x[::n]
;)
Actually quite nice.
--
https://mail.python.org/mailman/listinfo/python-list
On 29.03.2016 12:18, Sven R. Kunze wrote:
On 29.03.2016 11:39, Peter Otten wrote:
My question to those who know a bit of C#: what is the state-of-the-art
equivalent to
"\n".join(foo.description() for foo in mylist
if foo.description() != "")
U
On 29.03.2016 18:05, Peter Otten wrote:
Reformatting it a bit
String.Join(
"\n",
mylist.Where(
foo => !String.IsNullOrEmpty(foo.description)
).Select(
foo => foo.description))
this looks like a variant of Python's
str.join(
"\n",
map(lambda foo: foo.des
On 30.03.2016 01:43, Steven D'Aprano wrote:
On Tue, 29 Mar 2016 09:26 pm, Sven R. Kunze wrote:
On 27.03.2016 05:01, Steven D'Aprano wrote:
Am I the only one who has noticed that threading of posts here is
severely broken? It's always been the case that there have been a few
On 30.03.2016 01:29, Eric S. Johansson wrote:
On 3/29/2016 6:05 AM, Sven R. Kunze wrote:
Python = English
As someone who writes English text and code using speech recognition,
I can assure you that Python is not English. :-)
:D Interesting. Never thought of how Python sounds when spoken
On 30.03.2016 12:14, Tim Golden wrote:
Not that you quite meant this, but I'm always amused (and still a little
startled) when I listen to talks recorded from, say, PyCon and hear
people with American accents pronouncing Python with the stress on the
slightly longer second syllable.
(I don't kno
On 30.03.2016 12:21, BartC wrote:
On 30/03/2016 11:07, Sven R. Kunze wrote:
On 30.03.2016 01:29, Eric S. Johansson wrote:
On 3/29/2016 6:05 AM, Sven R. Kunze wrote:
Python = English
As someone who writes English text and code using speech recognition,
I can assure you that Python is not
On 31.03.2016 17:07, Steven D'Aprano wrote:
Sometimes people look for a method which is equivalent to dict.get, where
they can set a default value for when the key isn't found:
py> d = {1: 'a', 2: 'b'}
py> d.get(999, '?')
'?'
The equivalent for sequences such as lists and tuples is a slice. I
On 31.03.2016 18:30, Travis Griggs wrote:
British: http://www.oxforddictionaries.com/definition/english/python
American: http://www.dictionary.com/browse/python?s=t
That does it. If I ever make some sort of open source module for pythun/pythawn
I’ll be sure to call it either tuhmayto/tomawto
Hi Josh,
good question.
On 04.04.2016 18:47, Josh B. wrote:
My package, available at https://github.com/jab/bidict, is currently laid out
like this:
bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py
I'd
On 05.04.2016 03:43, Steven D'Aprano wrote:
The purpose of packages isn't enable Java-style "one class per file" coding,
especially since *everything* in the package except the top level "bidict"
module itself is private. bidict.compat and bidict.util aren't flagged as
private, but they should be
On 05.04.2016 19:59, Chris Angelico wrote:
On Wed, Apr 6, 2016 at 3:38 AM, Sven R. Kunze wrote:
Your package is currently under 500 lines. As it stands now, you could
easily flatten it to a single module:
bidict.py
I don't recommend this.
The line is blurry but 500 is definitely too
On 05.04.2016 20:40, Ethan Furman wrote:
(utils.py does export a couple of functions, but they should be in
the main
module, or possibly made into a method of BidirectionalMapping.)
Your package is currently under 500 lines. As it stands now, you could
easily flatten it to a single module:
b
On 06.04.2016 09:28, Michael Selik wrote:
On Wed, Apr 6, 2016, 2:51 AM Steven D'Aprano wrote:
On Wed, 6 Apr 2016 05:56 am, Michael Selik wrote:
[Michael]
When you made that suggestion earlier, I immediately guessed that you
were
using PyCharm. I agree that the decision to split into multip
On 06.04.2016 01:47, Chris Angelico wrote:
Generally, I refactor code not because the files are getting "too
large" (for whatever definition of that term you like), but because
they're stretching the file's concept. Every file should have a
purpose; every piece of code in that file should ideally
Hi everybody,
suppose, I need items sorted by two criteria (say timestamp and
priority). For that purpose, I use two heaps (heapq module):
heapA # items sorted by timestamp
heapB # items sorted by priority
Now my actual problem. When popping an item of heapA (that's the oldest
item), I need
thrown away once they are
too long in the queue.
On Fri, Jan 8, 2016 at 4:22 AM, Sven R. Kunze wrote:
Hi everybody,
suppose, I need items sorted by two criteria (say timestamp and priority).
For that purpose, I use two heaps (heapq module):
heapA # items sorted by timestamp
heapB # items
Hi Saski,
Python's dataset processing machine is *pandas*.
Have a look at this cookbook entry here:
http://nbviewer.ipython.org/github/jvns/pandas-cookbook/blob/v0.1/cookbook/Chapter%204%20-%20Find%20out%20on%20which%20weekday%20people%20bike%20the%20most%20with%20groupby%20and%20aggregate.ipyn
Thanks for your reply.
On 08.01.2016 14:26, Peter Otten wrote:
Sven R. Kunze wrote:
Hi everybody,
suppose, I need items sorted by two criteria (say timestamp and
priority). For that purpose, I use two heaps (heapq module):
heapA # items sorted by timestamp
heapB # items sorted by priority
r email.
I'm using minimum number has highest priority convention.
I like Web technology, so no problem here. :)
On Fri, Jan 8, 2016 at 10:15 PM, Sven R. Kunze wrote:
Thanks for your suggestion.
On 08.01.2016 14:21, srinivas devaki wrote:
You can create a single heap with primary key as
On 09.01.2016 19:32, Paul Rubin wrote:
"Sven R. Kunze" writes:
Basically a task scheduler where tasks can be thrown away once they
are too long in the queue.
I don't think there's a real nice way to do this with heapq. The
computer-sciencey way would involve separate bala
On 12.01.2016 03:48, Cem Karan wrote:
Jumping in late, but...
If you want something that 'just works', you can use HeapDict:
http://stutzbachenterprises.com/
I've used it in the past, and it works quite well. I haven't tested its
asymptotic performance though, so you might want to check int
On 13.01.2016 12:20, Cem Karan wrote:
On Jan 12, 2016, at 11:18 AM, "Sven R. Kunze" wrote:
Thanks for replying here. I've come across these types of
wrappers/re-implementations of heapq as well when researching this issue. :)
Unfortunately, they don't solve the unde
Hi Gert,
just upgrade to 5.03.
Best,
Sven
On 13.01.2016 18:38, Gert Förster wrote:
Ladies, Gentlemen,
using the PyCharm Community Edition 4.5.4, with Python-3-5-1-amd64.exe,
there is constantly a “Repair”-demand. This is “successful” when executed.
Without execution, there results an “Error
Hi,
On 29.01.2016 01:01, Fillmore wrote:
I look and Python and it looks so much more clean
add to that that it is the language of choice of data miners...
add to that that iNotebook looks powerful
All true. :)
Does Python have Regexps?
"import re"
https://docs.python.org/3.5/li
On 29.01.2016 23:49, Ben Finney wrote:
"Sven R. Kunze" writes:
On 29.01.2016 01:01, Fillmore wrote:
How was the Python 2.7 vs Python 3.X solved? which version should I
go for?
Python 3 is the new and better one.
More importantly: Python 2 will never improve; Python 3 is the onl
Hi again,
as the topic of the old thread actually was fully discussed, I dare to
open a new one.
I finally managed to finish my heap implementation. You can find it at
https://pypi.python.org/pypi/xheap + https://github.com/srkunze/xheap.
I described my motivations and design decisions at
Hi again,
as the topic of the old thread actually was fully discussed, I dare to
open a new one.
I finally managed to finish my heap implementation. You can find it at
https://pypi.python.org/pypi/xheap + https://github.com/srkunze/xheap.
I described my motivations and design decisions at
it is
brilliant of you to simply use __setitem__
Thanks. :)
On Sun, Jan 31, 2016 at 4:17 AM, Sven R. Kunze wrote:
Hi again,
as the topic of the old thread actually was fully discussed, I dare to open
a new one.
I finally managed to finish my heap implementation. You can find it at
On 31.01.2016 02:48, Steven D'Aprano wrote:
On Sunday 31 January 2016 09:47, Sven R. Kunze wrote:
@all
What's the best/standardized tool in Python to perform benchmarking?
timeit
Thanks, Steven.
Maybe, I am doing it wrong but I get some weird results:
>>> min(timeit.Ti
On 02.02.2016 01:48, srinivas devaki wrote:
On Feb 1, 2016 10:54 PM, "Sven R. Kunze" <mailto:srku...@mail.de>> wrote:
>
> Maybe I didn't express myself well. Would you prefer the sweeping
approach in terms of efficiency over how I implemented xheap currently?
&g
Hi,
as you might have noticed, I am working on
https://github.com/srkunze/xheap right now.
In order to make it even faster and closer to heapq's baseline
performance, I wonder if there is a possibility of creating fast
wrappers for functions.
Please compare
https://github.com/srkunze/xhe
On 03.02.2016 21:40, Bernardo Sulzbach wrote:
I am not entirely sure about what your question is.
Are you talking about the "heapreplace expected 2 arguments, got 1"
you get if you set replace = heapreplace?
Yes, I think so.
I might ask differently: why do I need to write wrapper method when
On 03.02.2016 22:06, Bernardo Sulzbach wrote:
I may say something wrong, but this is what I see going on:
When you get "replace = heapreplace" you are creating a data attribute
called replace (you will access it by self.replace or
variable.replace) that is an alias for heapreplace.
When you cal
On 03.02.2016 22:14, Bernardo Sulzbach wrote:
Thanks for quoting, for some reason my client always replies to the
person and not the list (on this list only).
I did what I could. I could show you a lambda function there, but it
doesn't solve anything. If there is a way to avoid a wrapper, I don'
On 03.02.2016 22:19, Peter Otten wrote:
You could try putting
self.heappush = functools.partial(heapq.heappush, self)
into the initializer.
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll keep that in mind. :)
--
https://mail.pytho
On 03.02.2016 22:15, Peter Otten wrote:
The technical reason is that functions written in C don't implement the
descriptor protocol. The bound method is created by invoking the __get__
method of the class attribute:
Good to know. :-/
It's sad. These functions just look so method-like.
Bes
On 03.02.2016 22:34, Bernardo Sulzbach wrote:
Did Peter's suggestion work?
Somewhat for a single Heap class.
However, it breaks inheritance.
--
https://mail.python.org/mailman/listinfo/python-list
On 04.02.2016 00:47, Random832 wrote:
On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote:
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll keep that in mind. :)
What about changing the class of the object to one which is inherited
On 04.02.2016 19:35, Random832 wrote:
On Thu, Feb 4, 2016, at 11:18, Sven R. Kunze wrote:
On 04.02.2016 00:47, Random832 wrote:
On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote:
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll
On 05.02.2016 01:12, Steven D'Aprano wrote:
On Fri, 5 Feb 2016 07:50 am, srinivas devaki wrote:
_siftdown function breaks out of the loop when the current pos has a valid
parent.
but _siftup function is not implemented in that fashion, if a valid
subheap is given to the _siftup, it will bring
On 05.02.2016 02:26, srinivas devaki wrote:
as I come to think of it again, it is not subheap, it actually heap cut at
some level hope you get the idea from the usage of _siftup. so even though
the `pos` children are valid the _siftup brings down the new element (i.e
the element which is at first
On 05.02.2016 15:48, Bernardo Sulzbach wrote:
On 02/05/2016 12:42 PM, Sven R. Kunze wrote:
PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.
Compet
Hi srinivas,
I wrote this simple benchmark to measure comparisons:
import random
from xheapimport RemovalHeap
class X(object):
c =0 def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c +=1 return self.x < other.x
n =10 for jjin range(5):
items = [X(i
r i in range(n)]
random.shuffle(items)
heap = RemovalHeap(items)
random.shuffle(items)
for i in items:
heap.remove(i)
print(X.c)
X.c = 0
(note to myself: never copy PyCharm formatting strings to this list).
On 05.02.2016 17:27, Sven R. Kunze wrote:
Hi srinivas,
On 08.02.2016 23:13, Marko Rauhamaa wrote:
As I stated in an earlier post, a normal subroutine may turn out to be
blocking. To make it well-behaved under asyncio, you then dutifully tag
the subroutine with "async" and adorn the blocking statement with
"await". Consequently, you put "await" in fro
Hi Cem,
On 08.02.2016 02:37, Cem Karan wrote:
My apologies for not writing sooner, but work has been quite busy lately (and
likely will be for some time to come).
no problem here. :)
I read your approach, and it looks pretty good, but there may be one issue with
it; how do you handle the s
Hi Srinivas,
On 16.02.2016 13:46, srinivas devaki wrote:
Hi,
a = b = c
as an assignment doesn't return anything, i ruled out a = b = c as
chained assignment, like a = (b = c)
SO i thought, a = b = c is resolved as
a, b = [c, c]
at-least i fixed in my mind that every assignment like operation
On 16.02.2016 14:05, Sven R. Kunze wrote:
Hi Srinivas,
I think the tuple assignment you showed basically nails it.
First, the rhs is evaluated.
Second, the lhs is evaluated from left to right.
Completely wrong?
Best,
Sven
As you mentioned swapping. The following two statements do the same
On 18.02.2016 07:59, Paul Rubin wrote:
Steven D'Aprano writes:
I suppose that it is objectively correct that it is harder to learn
than Python 2. But I don't think the learning curve is any steeper. If
anything, the learning curve is ever-so-slightly less steep.
I think py3 has more learning c
Hi everybody,
I've finally had the time to do the benchmarks and here you go:
http://srkunze.blogspot.com/2016/02/the-xheap-benchmark.html
The benchmark compares heapq, Heap, OrderHeap, RemovalHeap and XHeap
regarding their operation heapify, push and pop.
As expected wrapping results in so
On 20.02.2016 07:53, Christian Gollwitzer wrote:
If you have difficulties wit hthe overall concept, and if you are open
to discussions in another language, take a look at this video:
https://channel9.msdn.com/Shows/C9-GoingNative/GoingNative-39-await-co-routines
MS has added coroutine suppo
On 23.02.2016 01:48, Ian Kelly wrote:
On Mon, Feb 22, 2016 at 3:16 PM, Sven R. Kunze wrote:
Is something like shown in 12:50 ( cout << tcp_reader(1000).get() ) possible
with asyncio? (tcp_reader would be async def)
loop = asyncio.get_event_loop()
print(loop.run_until_complete(tcp_reade
On 23.02.2016 18:37, Ian Kelly wrote:
It's not entirely clear to me what the C++ is actually doing. With
Python we have an explicit event loop that has to be started to manage
resuming the coroutines. Since it's explicit, you could easily drop in
a different event loop, such as Tornado or curio,
On 20.02.2016 07:53, Christian Gollwitzer wrote:
If you have difficulties wit hthe overall concept, and if you are open
to discussions in another language, take a look at this video:
https://channel9.msdn.com/Shows/C9-GoingNative/GoingNative-39-await-co-routines
MS has added coroutine suppo
Hi everybody,
I recognized the following oddity (background story:
http://srkunze.blogspot.com/2016/02/lets-go-down-rabbit-hole.html).
Python sometimes seems not to hop back and forth between C and Python code.
Can somebody explain this?
class MyList(list):
count = 0
def __setitem__
On 26.02.2016 23:37, Ian Kelly wrote:
On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze wrote:
Python sometimes seems not to hop back and forth between C and Python code.
C code as a rule tends to ignore dunder methods. Those are used to
implement Python operations, not C operations.
Ah, good
On 27.02.2016 00:07, eryk sun wrote:
On Fri, Feb 26, 2016 at 4:08 PM, Sven R. Kunze wrote:
Python sometimes seems not to hop back and forth between C and Python code.
Can somebody explain this?
Normally a C extension would call PySequence_SetItem, which would call
the type's sq_ass
On 27.02.2016 12:48, Terry Reedy wrote:
On 2/27/2016 4:44 AM, Steven D'Aprano wrote:
On Sat, 27 Feb 2016 07:55 pm, Terry Reedy wrote:
In other words, when that doc says *list*, it means a *list*.
"To create a heap, use a list initialized to [], or you can transform a
populated list into a hea
On 28.02.2016 07:34, Steven D'Aprano wrote:
I think that's out-and-out wrong, and harmful to the developer community. I
think that we're stuck in the equivalent of the pre-WYSIWYG days of word
processing: you can format documents as nicely as you like, but you have to
use a separate mode to see i
On 01.03.2016 13:13, Steven D'Aprano wrote:
On Tue, 1 Mar 2016 09:38 am, Larry Martell wrote:
But what is reality?
Reality is that which, when you stop believing in it, doesn't go away.
Just like that.
--
https://mail.python.org/mailman/listinfo/python-list
Hi python-list, hi Srinivas,
I managed to implement the mark&sweep approach for fast removal from
heaps. This way, I got three pleasant results:
1) a substantial speed up!
2) an improved testsuite
3) discovery and fixing of several bugs
@Srinivas I would be honored if you could have a look at
Hi,
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 06.03.2016 19:53, Peter Otten wrote:
Sven R. Kunze wrote:
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
In Python 3 zip() can deal with infinite iterables -- what would you expect
On 06.03.2016 19:51, Tim Chase wrote:
So it looks like one needs to either
results = reversed(list(zip(...)))
or, more efficiently (doing it with one less duplication of the list)
results = list(zip(...))
results.reverse()
Nice idea. :) Unfortunately, I used it while drafting som
.80x) 4.41 (
0.78x) 43.86 ( 0.77x)')
So as the results are not much effected apart of __init__, i think you
should consider this.
Looks promising. I will
On 06.03.2016 14:59, Sven R. Kunze wrote:
Using the original xheap benchmark
<http://srkunze.blogspot.de/2016/02/the-xheap-benchmark.html>, I could
see huge speedups: from 50x/25x down to 3x/2x compared to heapq.
That's a massive improvement. I will publish an update soon.
An
On 09.03.2016 19:19, Sven R. Kunze wrote:
ps: there are two error's when i ran tests with test_xheap.
Damn. I see this is Python 2 and Python 3 related. Thanks for bringing
this to my attention. I am going to fix this soon.
Fixed.
--
https://mail.python.org/mailman/listinfo/python-list
On 12.03.2016 00:18, Fillmore wrote:
Playing with ArgumentParser. I can't find a way to override the -h and
--help options so that it provides my custom help message.
I remember everything being a lot easier using argh instead of argparse.
https://pypi.python.org/pypi/argh#examples
The doc
Hi,
a colleague of mine (I write this mail because I am on the list) has the
following issue:
for x in my_iterable:
# do
empty:
# do something else
What's the most Pythonic way of doing this?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 11:28, Joaquin Alzola wrote:
If len(my_iterable) is not 0:
for x in my_iterable:
# do
else:
# do something else
I am sorry, I should have been more precise here.
my_iterable is an iterator that's exhausted after a complete iteration
and cannot be restored.
I
Hi,
we got an interesting problem. We need to monkeypatch Django's reverse
function:
First approach:
urlresolvers.reverse = patched_reverse
Problem: some of Django's internal modules import urlresolvers.reverse
before we can patch it for some reasons.
Second approach:
urlresolvers.rev
On 16.03.2016 16:09, Joel Goldstick wrote:
symbol '|' in python. Can you elaborate
bitwise or
--
https://mail.python.org/mailman/listinfo/python-list
On 17.03.2016 01:27, Steven D'Aprano wrote:
That post describes the motivating use-case for the introduction
of "if...else", and why break skips the "else" clause:
for x in data:
if meets_condition(x):
break
else:
# raise error or do additional processing
It might help to r
On 18.03.2016 15:33, Sven R. Kunze wrote:
On 18.03.2016 15:23, Ian Kelly wrote:
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly
wrote:
Your patched version takes two extra arguments. Did you add the
defaults for those to the function's __defaults__ attribute?
And as an afterthought, you'
On 16.03.2016 17:56, Sven R. Kunze wrote:
On 16.03.2016 17:37, Random832 wrote:
On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
I can imagine that. Could you describe the general use-case? From
what I
know, "else" is executed when you don't "break" the loop. W
On 16.03.2016 17:20, Terry Reedy wrote:
On 3/16/2016 11:17 AM, Sven R. Kunze wrote:
On 16.03.2016 16:02, Tim Chase wrote:
Does it annoy me when I have to work in other languages that lack
Python's {for/while}/else functionality? You bet.
I can imagine that. Could you describ
On 16.03.2016 14:09, Tim Chase wrote:
If you can len() on it, then the obvious way is
if my_iterable:
for x in my_iterable:
do_something(x)
else:
something_else()
However, based on your follow-up that it's an exhaustible iterator
rather than something you can len(), I'd u
On 16.03.2016 14:58, alister wrote:
no , i just typed it, while trying to hold a conversation with swmbo
:-( apologies to the op if e could not see where i was intending to go
with this.
No problem, I perform quite well at guessing folk's intention.
So, yes, I can extrapolate what you meant.
On 16.03.2016 15:29, Sven R. Kunze wrote:
On 16.03.2016 13:57, Peter Otten wrote:
I'd put that the other way round: syntactical support for every pattern
would make for a rather unwieldy language. You have to choose
carefully, and
this requirement could easily be fulfilled by a fun
On 16.03.2016 13:08, Steven D'Aprano wrote:
Doing what? What is the code supposed to do? What's "empty" mean as a
keyword?
If you explain what your friends wants, then perhaps we can suggest
something. Otherwise we're just guessing. I can think of at least two
different meanings:
* run the "emp
On 16.03.2016 17:37, Random832 wrote:
On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
I can imagine that. Could you describe the general use-case? From what I
know, "else" is executed when you don't "break" the loop. When is this
useful?
for item in col
On 18.03.2016 15:23, Ian Kelly wrote:
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly wrote:
Your patched version takes two extra arguments. Did you add the
defaults for those to the function's __defaults__ attribute?
And as an afterthought, you'll likely need to replace the function's
__globals__
On 16.03.2016 19:53, Ben Finney wrote:
Do you think some better error message should be used?
Yes, I think that error message needs to be improved. Please file a bug
report in Python's issue tracker https://bugs.python.org/>.
For example a hint that "0" does work for the given argument.
I sug
On 18.03.2016 15:48, Ian Kelly wrote:
Well I didn't design it, so I'm not really sure. But it could be argued
that the defaults are intrinsic to the function declaration, not the code
object, as not all code objects even have arguments. It also makes it
straight-forward to create a new function t
On 16.03.2016 13:57, Peter Otten wrote:
I'd put that the other way round: syntactical support for every pattern
would make for a rather unwieldy language. You have to choose carefully, and
this requirement could easily be fulfilled by a function, first in your
personal toolbox, then in a public
On 18.03.2016 20:10, Palpandi wrote:
You can do like this.
if not my_iterable:
for x in my_iterable:
Thanks for you help here, however as already pointed out, my_iterable is
not necessarily a list but more likely an exhaustible iterator/generator.
Best,
Sven
--
https://mail.pyth
On 16.03.2016 11:47, Peter Otten wrote:
What would you expect?
A keyword filling the missing functionality? Some Python magic, I
haven't seen before. ;-)
class Empty(Exception): pass
...
def check_empty(items):
... items = iter(items)
... try:
... yield next(items)
...
On 18.03.2016 14:47, Ian Kelly wrote:
Your patched version takes two extra arguments. Did you add the
defaults for those to the function's __defaults__ attribute?
That's it! :-) Thanks a lot.
Just to understand this better: why is that not part of the code object
but part of the function?
On 16.03.2016 18:08, Random832 wrote:
Yeah, well, you can *almost* get there with:
try:
thing = next(item for item in collection if good(item))
except StopIteration:
thing = default
But the for/else thing seems like a more natural way to do it. Plus,
this is a toy example, if the body
On 16.03.2016 16:02, Tim Chase wrote:
On 2016-03-16 15:29, Sven R. Kunze wrote:
I would re-use the "for-else" for this. Everything I thought I
could make use of the "-else" clause, I was disappointed I couldn't.
Hmm...this must be a mind-set thing. I use the "els
On 19.03.2016 00:58, Matt Wheeler wrote:
I know you have a working solution now with updating the code &
defaults of the function, but what about just injecting your function
into the modules that had already imported it after the
monkeypatching?
Seems perhaps cleaner, unless you'd end up having
1 - 100 of 149 matches
Mail list logo