[Python-ideas] Object grabbing

Joshua Morton joshua.morton13 at gmail.com
Mon May 2 21:43:01 EDT 2016


The latter, the former isn't currently syntax (as in `with [a, b, c]"` will
throw an error). This was, however, mainly if we were using a variant of
the with syntax, since having

 But take the following example:

    def func(ctx):
        with ns:  # namespace
            with ctx:  # only known at runtime
                 .attr

You can't have that be a compile time error. Which actually makes the
specific syntax of a bare `with` a strong -1 now, since mixing it with
normal context managers is incredibly ambiguous. This would either need to
be `in` or `given` as mentioned elsewhere, or something like with
`Magic_Namespace_Object(ns):`

--Josh

On Mon, May 2, 2016 at 7:26 PM Erik <python at lucidity.plus.com> wrote:

> On 02/05/16 23:28, Joshua Morton wrote:
> >  > It is not reasonable to expect an error to be generated at runtime:
> >  > because each and every object would have to be queried as to whether
> >  > they have the attribute to know if there is ambiguity on each and
> every
> >  > reference to an attribute.
> >
> > It absolutely is:
>
> It almost certainly is not ;)
>
> > if you're using an "inferred" syntax like
> >
> > in object:
> >      .value
> >
> > but there are multiple such objects to look at, Python immediately
> > throws an error,
>
> It is not clear what you mean by "multiple such objects". Do you mean
> that 'object' can be some sort of sequence, or do you mean that the
> syntax used for multiple objects is "in object0, object1:" or similar?
>
> If the latter, then given the choice between the two, I would agree with
> some sort of compile time error over a runtime exception. Why wait until
> runtime?
>
> If the former (which might mean a runtime error is appropriate), then
> you need to explain what you are suggesting in a lot more detail.
>
> Regards, E.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160503/4eb2c0c1/attachment-0001.html>


More information about the Python-ideas mailing list