What sort of code would be able to do anything useful with either a
sequence or a queue? Queues aren’t iterable. This seems a case of
hyper-generalization.
On Tue, Aug 24, 2021 at 22:19 Christopher Barker
wrote:
> Bringing this back on list:
>
> On Tue, Aug 24, 2021 at 9:58 PM David Mertz,
On Tue, Aug 24, 2021 at 10:12 PM Guido van Rossum wrote:
> “Container” is a kind of pun, it’s something with a __contains__ method.
> The thing you’re looking for is “Collection”.
>
Hmm, perhaps we should tweak the docs, the section is titled:
"Abstract Base Classes for Containers"
But yes,
Bringing this back on list:
On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D.
wrote:
> Sorry, I should have been more explicit. The several kinda of queues can
> all "contain" items, but do not respond to len().
>
yeah, I should have looked more closely at your list
Though i would consider
“Container” is a kind of pun, it’s something with a __contains__ method.
The thing you’re looking for is “Collection”, which is the base for
sequences, mappings and sets.
I also note that the discussion seems quite stuck.
—Guido
On Tue, Aug 24, 2021 at 21:55 Christopher Barker
wrote:
> It
On Tue, Aug 24, 2021 at 9:50 PM Guido van Rossum wrote:
> It was pointed out to me that numpy allows arrays that have no elements
> but a nonzero first dimension. People could disagree about whether that
> should be considered empty.
>
indeed -- you can kinda-sorta map an array to nested lists,
It seems the conversation has confused two related concepts:
1) The default bool() implementation (Truthiness) -- this is what the OP
said was recommended by PEP 8: "For sequences, (strings, lists, tuples),
use the fact that empty sequences are false:" -- there is some debate about
that whether
On Tue, Aug 24, 2021 at 7:23 PM MRAB wrote:
> On 2021-08-25 00:48, Guido van Rossum wrote:
> > Hi Tim,
> >
> > I'm sorry if this has been brought up before, but *aside from PEP 8* is
> > there anything wrong with using "if len(a)" for nonempty, or "if not
> > len(a)" for empty?
> >
> What is the
I wanted to do a survey of various "aggregates" in Python to see if any
stand out as making the usual `if stuff: ...` troublesome. I wrote a
little script at
https://github.com/DavidMertz/LanguagePractice/blob/main/python/aggregates.py
.
I'm being deliberately vague about an "aggregate." It
On 2021-08-25 00:48, Guido van Rossum wrote:
Hi Tim,
I'm sorry if this has been brought up before, but *aside from PEP 8* is
there anything wrong with using "if len(a)" for nonempty, or "if not
len(a)" for empty?
What is the cost of 'len'? If it's always O(1), then it's not a problem,
but
On Tue, Aug 24, 2021 at 9:08 AM Jon Kiparsky wrote:
> > Numbers in general are useful concepts that help us with real-world
> > problems, but it's really hard to pin them down.
>
> Not that hard, really. A number is just a hackenbush game :)
>
RIP Berlekamp, Conway and Guy. They all died within
Currently Python does not support using `@staticmethod` decorator along with
`@property` decorator.
I think that the it currently works is a bit misleading since it will not give
an error, but gives the following outcome.
```
class Foo:
@staticmethod
@property
def bar():
Hi Tim,
I'm sorry if this has been brought up before, but *aside from PEP 8* is
there anything wrong with using "if len(a)" for nonempty, or "if not
len(a)" for empty?
It would seem to work for numpy and pandas arrays, and it works for builtin
sequences. Also, it has the advantage of being 100%
On 8/24/21 4:35 PM, Cameron Simpson wrote:
> If we're chasing rough edges, consider queue.Queue:
>
> >>> from queue import Queue
> >>> Q = Queue()
> >>> Q.empty()
> True
> >>> if Q: print("Q is true")
> ...
> Q is true
>
> I would often like to treat Queues as a
On 24Aug2021 06:55, tim.hoffm...@mailbox.org wrote:
>Ethan Furman wrote:
>> > "has element-wise operations" protocol or an is_empty protocol.
>> > I consider emptiness-check a basic concept that should be consistent and
>> > easy to use across containers.
>
>> Python has an emptiness-check and
Ethan Furman wrote:
> On 8/24/21 3:03 PM, Tim Hoffmann via Python-ideas wrote:
> > **How do you check if a container is empty?**
> > IMHO the answer should not depend on the container.
> I think this is the fly in the ointment -- just about everything, from len()
> to bool(), to add, to iter()
On 8/24/21 3:03 PM, Tim Hoffmann via Python-ideas wrote:
> **How do you check if a container is empty?**
>
> IMHO the answer should not depend on the container.
I think this is the fly in the ointment -- just about everything, from len() to bool(), to add, to iter() /all/ depend
on the
Oh, if I'm going to be a smart-ass, I should probably remember that I need
a `not` in there. No need to correct me, I saw it as soon as pressing send.
Nonetheless, this is an unnecessary method or function. Truthiness is
non-emptiness for most purposes. And where it's not, you need something
more
Right but this doesn't work with bumpy or pandas
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
This is easy enough to put in your own toolkit:
>>> is_empty = bool
All done!
On Tue, Aug 24, 2021, 6:04 PM Tim Hoffmann via Python-ideas <
python-ideas@python.org> wrote:
> I also have the feeling that this is going round in circles. So let me get
> back to the core question:
>
> **How do you
I also have the feeling that this is going round in circles. So let me get back
to the core question:
**How do you check if a container is empty?**
IMHO the answer should not depend on the container. While emptiness may mean
different things for different types. The check syntax can and should
> Numbers in general are useful concepts that help us with real-world
> problems, but it's really hard to pin them down.
Not that hard, really. A number is just a hackenbush game :)
-jpk
___
Python-ideas mailing list -- python-ideas@python.org
To
Dear Developers,
Some of you may have noticed I updated my proposal on the subject
yesterday. I'm afraid it was too long without a summary, so here is
one. I hope this will be helpful to some people.
Summary of the refreshed proposal
-
(1) Simplify the syntax:
I have filed this at the issue tracker at
https://bugs.python.org/issue44983
Best regards,
Takuo
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
On Tue, 24 Aug 2021 at 12:07, Tim Hoffmann via Python-ideas
wrote:
> Just like length is. It's a basic concept and like __bool__ and __len__ it
> should be upon the objects to specify what empty means.
It feels like these arguments in the abstract are mostly going round
in circles. It's
On 21.08.2021 23:33, Tim Hoffmann via Python-ideas wrote:
> Hi all,
>
> The Programming Recommendations section in PEP-8 states
>
> "For sequences, (strings, lists, tuples), use the fact that empty sequences
> are false:"
>
> # Correct:
> if not seq:
> if seq:
>
> # Wrong:
> if
Christopher Barker wrote:
> But I see no reason to add a standardized way to check for an empty
> container- again “emptiness” may not be obviously defined either.
> Numpy arrays, (or Pandas Dataframes) are a good example here — there are
> more than one way to think of them as false - but maybe
On 24.08.2021 05:53, Steven D'Aprano wrote:
> At the moment, the handling of NANs in the statistics module is
> implementation dependent. In practice, that *usually* means that if your
> data has a NAN in it, the result you get will probably be a NAN.
>
> >>> statistics.mean([1, 2,
On Tue, Aug 24, 2021 at 4:31 PM Steven D'Aprano wrote:
> ... midnight is not the annihilating element (zero).
Unless you're Cinderella, of course.
> We conventionally represent clock times as numbers, but they're more
> akin to ordinal data. They have an order, but you can't do arithmetic on
>
Ethan Furman wrote:
> On 8/23/21 2:31 PM, Tim Hoffmann via Python-ideas wrote:
> > Ethan Furman wrote:
> > > It seems to me that the appropriate fix is for numpy to have an
> > > "is_empty()" function
> > that knows how to deal with arrays and array-like structures, not force
> > every container
On Mon, Aug 23, 2021 at 10:26:47PM -0700, Christopher Barker wrote:
> On Mon, Aug 23, 2021 at 6:54 AM Thomas Grainger wrote:
>
> > here's another fun one "A False midnight":
> > https://lwn.net/Articles/590299/
> > https://bugs.python.org/issue13936#msg212771
>
>
> This is a great example of
On Tue, Aug 24, 2021 at 3:27 PM Christopher Barker wrote:
>
> On Mon, Aug 23, 2021 at 6:54 AM Thomas Grainger wrote:
>>
>> here's another fun one "A False midnight": https://lwn.net/Articles/590299/
>> https://bugs.python.org/issue13936#msg212771
>
>
> This is a great example of the problem of
31 matches
Mail list logo