On Oct 13, 2019, at 22:54, Chris Angelico wrote:
>
> Mathematically, what's the difference between '1' and '1+0j' (or
> '1+0i')?
The details depend on what foundations you use, but let’s go with the most
common construction.
The natural number 1 is defined as 0 U {0}. Because 0 is defined as {
14.10.19 09:54, Chris Angelico пише:
On Mon, Oct 14, 2019 at 5:41 PM Serhiy Storchaka wrote:
14.10.19 03:47, Chris Angelico пише:
Though a set.__setitem__() method might be helpful here. If you set an
item to any truthy value, it is added to the set; set it to a falsy
value and it will be dis
Sorry, missed this part:
On Oct 13, 2019, at 22:54, Chris Angelico wrote:
isinstance(1, numbers.Complex)
> True
>
> Explain the difference?
`Complex` is an abstract type that defines an interface, which is loosely:
supporting all the complex-arithmetic operators, properties like `real`,
On Mon, Oct 14, 2019 at 7:04 PM Andrew Barnert wrote:
> If you’re wondering whether integers are something you could define the laws
> of complex algebra over, then no, it isn’t. For example, one of the laws is
> that every number besides 0 has a multiplicative inverse, which obviously
> isn’t
>
> On Oct 13, 2019, at 22:54, Chris Angelico wrote:
> >
> > Mathematically, what's the difference between '1' and '1+0j' (or
> > '1+0i')?
>
1 is perfectly valid natural number, rational number (equivalent to 1/1),
real number (equivalent to 1.0) and complex number (equivalent to
1.0+0.0i). Every
On Sun, Oct 13, 2019 at 09:53:41PM -0400, David Mertz wrote:
[in response to my comment]
> > (don't you have an IDE with a refactor command for that?^1 )
> > ^1 I don't, so I'm not entirely unsympathetic to this argument.
> >
>
> I really don't!
>
> It would be cool to have some keystrokes that
On 13/10/2019 20:20, Steve Jorgensen wrote:
Failing fast is good, but it is also a very common case to want to add an item
to a collection regardless of whether it is set-like or sequence-like.
I have to say that for "a very common case" it's something that I've
never needed. Never. Serious
Andrew Barnert wrote:
> On Oct 13, 2019, at 19:03, Steve Jorgensen [email protected] wrote:
> > That makes a lot of sense.
> > When you’re replying, it really helps to quote what you’re replying to. I
> > have no
> idea which of the messages in this thread you think makes sense (except that
> it
Chris Angelico wrote:
> On Mon, Oct 14, 2019 at 8:48 AM Steve Jorgensen [email protected] wrote:
[snip]
> You want to drill down into all containers except strings, so why not
> just say that?
> Scalar = (str, bytes)
A scalar is not just str or bytes though. It is also anything else that's not a
On 14/10/2019 12:13, Steve Jorgensen wrote:
A scalar is not just str or bytes though. It is also anything else
that's not a collection, so numbers, dates, booleans, and instances
of any other classes (standard or custom) that are not collections. A
string is just one of the few examples of someth
On Mon, Oct 14, 2019 at 10:14 PM Steve Jorgensen wrote:
> Assuming `Scalar` can't clean up every case we can imagine for this kind of
> ambiguity can come up with doesn't mean it's not potentially very helpful.
> After the discussion so far, I happen to still feel like this is a compelling
> id
On Mon, 14 Oct 2019 at 05:47, Andrew Barnert via Python-ideas
wrote:
>
> `1 in complex` is _not_ mathematically true. Simplifying a bit, the elements
> of the algebra of complex numbers are ordered pairs of real numbers, and `1`
> is not a pair. When you’re working in, say, complex analysis, you
On Mon, Oct 14, 2019 at 07:53:07PM +1100, Chris Angelico wrote:
> On Mon, Oct 14, 2019 at 7:04 PM Andrew Barnert wrote:
> > If you’re wondering whether integers are something you could define the
> > laws of complex algebra over, then no, it isn’t. For example, one of the
> > laws is that every
On Mon, Oct 14, 2019 at 12:54:13AM -0700, Andrew Barnert via Python-ideas wrote:
> On Oct 13, 2019, at 22:54, Chris Angelico wrote:
> >
> > Mathematically, what's the difference between '1' and '1+0j' (or
> > '1+0i')?
>
> The details depend on what foundations you use, but let’s go with the
> m
On Mon, Oct 14, 2019 at 12:23:43PM +0100, Rhodri James wrote:
> In practice I find that's almost never what I want. In the incredibly
> rare event that I'm throwing a string at an overly generic interface, I
> almost always want it to be treated as a sequence of characters.
For what it's worth
I completely agree that there is a problem to be solved here.
Unfortunately I don't think the Scalar ABC is the solution. I'm not
sure that there is a generic solution, since different applications will
have different ideas of what needs to be drilled down into.
E.g. a tuple representing coordi
On Oct 14, 2019, at 07:15, Steven D'Aprano wrote:
>
> Speaking of UserString, does anyone know why it isn't registered as a
> virtual subclass of str?
None of the concrete classes register virtual subclasses, so this would be a
unique exception.
Also, since 2.3, if you want a subclass of str
Steve Jorgensen wrote:
> What if, instead, there was an OrderedBag class that acts like a
> list and supports set operations.
> The advantage of this is that any hidden indexing that is used to optimize the
> operations could be efficiently created in the object that results from the
> set operati
On Oct 14, 2019, at 01:53, Chris Angelico wrote:
>
>> On Mon, Oct 14, 2019 at 7:04 PM Andrew Barnert wrote:
>> If you’re wondering whether integers are something you could define the laws
>> of complex algebra over, then no, it isn’t. For example, one of the laws is
>> that every number beside
On 14/10/2019 18:25, Andrew Barnert via Python-ideas wrote:
On Oct 14, 2019, at 01:53, Chris Angelico wrote:
On Mon, Oct 14, 2019 at 7:04 PM Andrew Barnert wrote:
If you’re wondering whether integers are something you could define the laws of
complex algebra over, then no, it isn’t. For examp
On Oct 14, 2019, at 06:07, Steven D'Aprano wrote:
>
>> On Mon, Oct 14, 2019 at 12:54:13AM -0700, Andrew Barnert via Python-ideas
>> wrote:
>>> On Oct 13, 2019, at 22:54, Chris Angelico wrote:
>>>
>>> Mathematically, what's the difference between '1' and '1+0j' (or
>>> '1+0i')?
>>
>> The detai
Andrew Barnert wrote:
> On Oct 14, 2019, at 07:15, Steven D'Aprano [email protected] wrote:
> > Speaking of UserString, does anyone know why it isn't
> > registered as a
> > virtual subclass of str?
> > None of the concrete classes register virtual subclasses, so this would be a
> unique excepti
On Oct 14, 2019, at 13:28, Steve Jorgensen wrote:
>
> Andrew Barnert wrote:
>>> On Oct 14, 2019, at 07:15, Steven D'Aprano [email protected] wrote:
>>> Speaking of UserString, does anyone know why it isn't
>>> registered as a
>>> virtual subclass of str?
>>> None of the concrete classes regist
Andrew Barnert wrote:
> On Oct 14, 2019, at 13:28, Steve Jorgensen [email protected] wrote:
> > Andrew Barnert wrote:
> > On Oct
> > 14, 2019, at 07:15, Steven D'Aprano [email protected] wrote:
> > Speaking of UserString, does anyone know why it isn't
> > registered as a
> > virtual subclass of
Chris Angelico wrote:
[snip]
> > You're assuming that everyone's definition of Scalar will be the same,
> though. I haven't seen that proven. In many cases, the correct check
> is "is iterable but is not str". In others, it's "is iterable but is
> not (str,bytes)". Some will see an os.stat() result
25 matches
Mail list logo