[Python-ideas] Quick idea: defining variables from functions that take the variable name

Michael Selik michael.selik at gmail.com
Wed Jun 1 15:48:56 EDT 2016


On Wed, Jun 1, 2016 at 3:14 PM Sven R. Kunze <srkunze at mail.de> wrote:

> On 01.06.2016 18:24, Michael Selik wrote:
>
> I don't see how that would be improved by a special syntax for the [RHS]
> to know the identifier it's being assigned to. Could you clarify that?
>
> I was referring to the issue that fields don't know neither their
> containing form classes nor their form instances. In some circumstances,
> one need to do that in order to correctly work with the field (think of the
> prefix of the form which needs to be reflected in the field but there are
> more missing pieces of information).
>
> As mentioned to Steven, in this case the name does not suffices at all.
> So, I am not sure how to handle this right now. This might belong to a
> greater issue of referring back which currently needs to be handled
> manually in all cases.
>

I always find bi-directional has-a relationships to be troublesome. If it
were necessary frequently, I'd expect the Form metaclass to loop over the
declared_fields and set some .form attribute to the new_class. Django is
way too big for me to grok from light reading, so I won't presume to
understand the choices made there.

https://github.com/django/django/blob/master/django/forms/forms.py#L27
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160601/e48be266/attachment-0001.html>


More information about the Python-ideas mailing list