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

Michael Selik michael.selik at gmail.com
Wed Jun 1 12:12:59 EDT 2016


On Wed, Jun 1, 2016 at 9:23 AM Sven R. Kunze <srkunze at mail.de> wrote:

> On 01.06.2016 08:25, Sjoerd Job Postmus wrote:
> >> On 31 May 2016, at 16:37, Sven R. Kunze <srkunze at mail.de> wrote:
> >>
> >> Btw. there would be huge use-case for Django development. So, given
> your explanation, it sounds useful.
> > Could you elaborate on that use-case, because I'm not seeing it. I think
> maybe you mean the ORM and declarative forms, correct?
>
> Exactly. That is one reason why Django needs metaclasses all over the
> place. Because fields just don't know their name.
>
> This is especially true for forms as django does not magic there. It
> always causes headaches if you need it.
>

Are you referring to code like this [0]?
    your_name = forms.CharField(label='Your name')

If so, I don't think we actually want the LHS to get passed in as the
label. Not all labels will be valid identifiers. If you're talking about
the CharField knowing what attribute it has been assigned to, I couldn't
find that code in the Django source. Could you point it out?

[0] https://docs.djangoproject.com/en/1.9/topics/forms/#the-form-class
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160601/2dedd16d/attachment.html>


More information about the Python-ideas mailing list