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


Groups > comp.lang.python > #102191

Re: class attribute

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Subject Re: class attribute
Date Thu, 28 Jan 2016 11:04:46 -0500
Lines 43
Message-ID <mailman.61.1453997090.2338.python-list@python.org> (permalink)
References <56aa1474$0$27833$426a74cc@news.free.fr> <n8d6mm$i5k$1@ger.gmane.org> <CAPTjJmobmjaRmTMADhfPutTCkdsW38PK2PQPEcPfSutTO-FJEg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de uJQ8C4ktcP35u++dFQMUaQWJQ0+WhYbToesw2lIupb3w==
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
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; 'read.': 0.13; 'django': 0.13; 'thu,': 0.15; '"les': 0.16; '&quot;les': 0.16; '2016': 0.16; 'created.': 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; '&gt;': 0.18; 'email addr:gmail.com&gt;': 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; 'chris': 0.26; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'specify': 0.27; 'values': 0.28; '&quot;': 0.29; 'sont': 0.29; 'url:mailman': 0.30; 'guess': 0.31; 'probably': 0.31; 'class': 0.33; 'url:python': 0.33; 'int': 0.33; 'similar': 0.33; 'url:listinfo': 0.34; 'structure': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'clear': 0.35; 'files,': 0.35; 'instance': 0.35; 'protocol': 0.35; 'saved': 0.35; 'too': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'whatever': 0.39; 'url:mail': 0.40; 'details,': 0.60; 'further': 0.62; 'here.': 0.62; 'great': 0.63; 'article': 0.77; 'book:': 0.84; 'chrisa': 0.84; 'examples.': 0.84; 'todd': 0.84; 'to:none': 0.91; 'joel': 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; bh=FJAlcFi97LyNVmWSmrcewDWDbF/RsUE7RIvJfiNSK9c=; b=wq2wWkpif13+FvqI2l11MsBtizJu4Oe0e3QbS03dwULMi5yY0/Lcqih/ZrGIXkxTWB cd0NMMFkmks8aoYn/iLX893qDNgDljOlzbu+5a90UikxOKwKlLKGvzj/qVVEDtEAcBOq 8Zlf8ctpcFLniJA0m/b5KBN51AXuwb+RTlMVb3J3lhWTyRR+B4KxOBsvtzH0Vr4XOe2n DRhQYc3j0Sl8ekK/aXqq0z4LdSlhvDhQUwbRkD/+4q5CdVAyqQBzbMPRkpMnapG0oUjS Yjkk5x7MNiy5seeNZt/orTGET65r/8OQeLE0jXbs+RM2DdXIdV1N09Yfgq5t/jo+e/wX gq/w==
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; bh=FJAlcFi97LyNVmWSmrcewDWDbF/RsUE7RIvJfiNSK9c=; b=I01zlGk79HbZgg/HUuwL8ivusDtKFjKv+klFOZ5ugabJiCY4yYkr7MmeJ8RB+ix0Xt 4xSwvH1RiuIgZUV8FGMg0aEtBsPwdy85i7rdKfF4Muc/Ea0NMtXeG3gr8Za0iXz0Ozkc DxA1f3nZM9tmZvZ6C//KNVgmKFF4VaFHYBGym8SEJ4qKJo3t4Hx8fHj15Ss3U5C0+UYg WA2xPft38lA3/pcWZ+AcYO+MVZj7CJa86Pcg4ZvxPUoEIIo8mttb/vcWHZFq0aDO7Yz6 ZycIECXBtFQAqowAw1UyGzTgWVuM5whgMUKzqhKIabUvf0DxQIoJOq7TM9N1Mv7WQrCb 1ZaA==
X-Gm-Message-State AG10YOShaMvO6PksgbDDsQ5OXJraIQRlBKX/4zmRPQnjgR+c+jeKhAWIWEKu72fZTQ3sByPELaJMGHpUQVJEKw==
X-Received by 10.107.137.204 with SMTP id t73mr4489411ioi.125.1453997087026; Thu, 28 Jan 2016 08:04:47 -0800 (PST)
In-Reply-To <CAPTjJmobmjaRmTMADhfPutTCkdsW38PK2PQPEcPfSutTO-FJEg@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.20+
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:102191

Show key headers only | View raw


On Thu, Jan 28, 2016 at 9:56 AM, Chris Angelico <rosuav@gmail.com> wrote:

> 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
> --
> https://mail.python.org/mailman/listinfo/python-list
>

There is an excellent django book: http://prodjango.com/

There is a section that explains how models are created.  Its a great and
clear read.

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


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