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, float('na
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 mo
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 len(s
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 possible
I have filed this at the issue tracker at
https://bugs.python.org/issue44983
Best regards,
Takuo
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/list
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:
> 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 -- [email protected]
To unsubsc
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
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 <
[email protected]> 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
Right but this doesn't work with bumpy or pandas
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
ht
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
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 containe
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() /al
On 24Aug2021 06:55, [email protected] 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 nu
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 contai
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% b
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():
retu
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
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 i
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 migh
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
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 th
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, e
“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 seem
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 th
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, Co
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, Ph.D.
On Tue, Aug 24, 2021 at 11:55:21PM -, Henry Harutyunyan wrote:
> Currently Python does not support using `@staticmethod` decorator
> along with `@property` decorator.
What is the purpose of using both staticmethod and property? Is it just
to avoid type "self" in the parameter list?
> I t
Properties couldn't work with static methods as they need to access
the instance or its type.
And properties are not class-properties by design, because you may
want to access directly to the fields of the property object.
But you can define your own descriptor type to make a kind of
class-propert
29 matches
Mail list logo