Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18899 > unrolled thread

Re: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out)

Started byChris Rebert <pyideas@rebertia.com>
First post2012-01-12 22:22 -0800
Last post2012-01-12 22:22 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out) Chris Rebert <pyideas@rebertia.com> - 2012-01-12 22:22 -0800

#18899 — Re: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out)

FromChris Rebert <pyideas@rebertia.com>
Date2012-01-12 22:22 -0800
SubjectRe: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out)
Message-ID<mailman.4699.1326435748.27778.python-list@python.org>
On Thu, Jan 12, 2012 at 3:03 PM, Terry Reedy <tjreedy@udel.edu> wrote:
> On 1/12/2012 3:45 PM, Nathan Rice wrote:
<snip>
>>>>> print isinstance(3, const)
>>
>> True
>
>
> A Contraints instance defines a set. 'const' is the set 'odd_ge_3'
> It would look better if you used standard syntax and do the inclusion check
> in a __contains__ method.
>
>>>> 3 in odd_ge_3
>
> True

But what are types but abstract sets of values? Phrasing it as a
typecheck is perfectly sensible from a type-theoretic standpoint.
Also, the problem of representing `isinstance(X.attr, someclass)` [for
non-Constraint someclass, e.g. str] in a Constraint would still
remain, since there's no "__lcontains__" (thus precluding `X.attr in
str`).

<snip>
>> so your validations are checked using __instancecheck__.
>
> But it is a fake check in that 3 is not really an instance of the class,
> which has no instances.

The same can be true for abstract base classes, which have been
sufficiently accepted to warrant adding __instancecheck__() in the
first place and also to be added to the std lib (witness the `abc` and
`collections` modules). It may seem unfamiliar, but then again it was
only made possible starting with v2.6, which is pretty recent.

Cheers,
Chris
--
http://rebertia.com

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web