Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102187
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: class attribute |
| Date | Fri, 29 Jan 2016 01:56:40 +1100 |
| Lines | 26 |
| Message-ID | <mailman.57.1453993003.2338.python-list@python.org> (permalink) |
| References | <56aa1474$0$27833$426a74cc@news.free.fr> <n8d6mm$i5k$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de 05nMLCnjoilUMDQValgwoQ2YdF2+3rbZpP8QNc6elJzg== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'attributes': 0.07; 'cc:addr:python-list': 0.09; 'descriptor': 0.09; "django's": 0.09; 'jan': 0.11; 'django': 0.13; '"les': 0.16; '2016': 0.16; 'created.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'jmp': 0.16; 'magic': 0.16; 'metaclass': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'sqlalchemy': 0.16; 'subject:class': 0.16; 'way;': 0.16; 'wrote:': 0.16; 'documented': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'assign': 0.22; 'class,': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'specify': 0.27; 'values': 0.28; 'sont': 0.29; 'guess': 0.31; 'probably': 0.31; 'class': 0.33; 'int': 0.33; 'similar': 0.33; 'structure': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'files,': 0.35; 'instance': 0.35; 'protocol': 0.35; 'saved': 0.35; 'too': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'whatever': 0.39; 'details,': 0.60; 'further': 0.62; 'here.': 0.62; 'article': 0.77; 'chrisa': 0.84; 'examples.': 0.84; 'todd': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=3CIpqkrbqNtwt1CRYAGeNnYhjHlrJ/PTK/jobV68vhw=; b=k/+OUSuD3k5gcLfWKm7UxlJKaSKyPkjVHgZraMN2kpK9gSmH2z8ptcWGInu0GDZvGt U5O0ahbazJxvX64UjkB0E9jVWYpBdo1K182LdBQLkMTuWQ5OQ9YPwngje0KDlZ1JMWNV an6cgIsFULybPXnGUD7Bx4s2YEapAyor5cHaS+qm4iplGED+NH9KQEXDEBaV18hKUTHr zjDoFm3EoH3Y9SEu7JPklh4PCMpZsbPoV0z3Xz384C/ApJDjqFvmIQSuxEZTn3K5Ky43 TXUtuiEtNJ+yJjyxXgIPQErWvx1a2DxpS4rSQSeSVddMvw4wEsWSBRbFdZS7odHJx57P k+sA== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type:content-transfer-encoding; bh=3CIpqkrbqNtwt1CRYAGeNnYhjHlrJ/PTK/jobV68vhw=; b=bbCUw0vJTCWS/FBhFnXvxTir94aTChW8+HmYf1Yg1xBXNy//NekbzSozAycIZHBZsk gsSrgmIaKfvus4+iSGP27RgXAq7HTZpunXuWwwpzRyOGgVdFAF9YRRBrml+pYvNVnzrK MHxHBsFKcsKmASBhcjIuPwEcz1L7LLf0dYRgGFFYp0aXuMBQS8aPcW8ExYSE9w0pgjUy PwuJhQtCSk3mZg3OVt4gKJ59ckv87KmRSVDgSH1KfFq0SM508lps+AOscg3MEtX3GRMq IzBfC4j+q2aUfgX+AR8ROo0oc+47ptx6zG4gJI9/KrsaB++v6vp8mZ045kJG50OEB4B5 pzkA== |
| X-Gm-Message-State | AG10YOQzPM564iejSz4yl+WmoqLJeUjzaztDRUh7zxL+nG0uw1OC1Lzk301shuNbkCkmslVAuBgWxt5Pv1hHyA== |
| X-Received | by 10.107.47.162 with SMTP id v34mr4136374iov.19.1453993000109; Thu, 28 Jan 2016 06:56:40 -0800 (PST) |
| In-Reply-To | <n8d6mm$i5k$1@ger.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102187 |
Show key headers only | View raw
On Fri, Jan 29, 2016 at 12:56 AM, jmp <jeanmichel@sequans.com> wrote: > My guess is that models.Model has a metclass. Without going too much int > details, the metaclass may change the class structure when it's created. > > django is very specific and very database oriented. > > " > article = Article(titre="Bonjour", auteur="Maxime") > article.contenu = "Les crêpes bretonnes sont trop bonnes !" > " > > this is probably the wrong way to assign a value to 'contenu'. You should > have a look at django help files, from what I remember it's very well > documented with a lot of examples. > I suspect Django's using the descriptor protocol or other magic here. SQLAlchemy works in a similar way; when you create the class, you put a bunch of attributes on it to specify columns, and then you can simply assign to those attributes on an instance to set the values for a row to be saved to the database. As Todd explains in further detail, the metaclass gets to do whatever it likes. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
class attribute "ast" <nomail@invalid.com> - 2016-01-28 14:15 +0100 Re: class attribute jmp <jeanmichel@sequans.com> - 2016-01-28 14:56 +0100 Re: class attribute Todd Dembrey <todd.dembrey@gmail.com> - 2016-01-28 14:13 +0000 Re: class attribute "ast" <nomail@invalid.com> - 2016-01-28 15:24 +0100 Re: class attribute Chris Angelico <rosuav@gmail.com> - 2016-01-29 01:56 +1100 Re: class attribute Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-28 11:04 -0500
csiph-web