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


Groups > comp.lang.python > #64043

Re: Python declarative

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'explicitly': 0.05; 'subject:Python': 0.06; 'args': 0.07; 'categories.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separating': 0.09; 'yeah,': 0.09; 'def': 0.12; 'jan': 0.12; 'child.': 0.16; 'copying.': 0.16; 'icon': 0.16; 'optional': 0.16; 'properties,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'world",': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'possible,': 0.19; 'thu,': 0.19; 'widget': 0.19; '>>>': 0.22; 'saying': 0.22; 'separate': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'specify': 0.24; 'title,': 0.24; 'this:': 0.26; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'properties': 0.29; 'matching': 0.30; 'allows': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'maybe': 0.34; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'possible.': 0.35; 'something': 0.35; 'but': 0.35; 'keyword': 0.36; 'should': 0.36; 'error.': 0.37; 'two': 0.37; 'being': 0.38; 'button': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'either': 0.39; 'received:org': 0.40; 'called': 0.40; 'received:173': 0.61; 'back': 0.62; 'name': 0.63; 'real': 0.63; 'such': 0.63; 'happen': 0.63; 'size.': 0.65; 'worth': 0.66; 'potentially': 0.81; 'bitmap': 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Python declarative
Date Wed, 15 Jan 2014 22:35:43 -0500
References <1389805328.32401.6.camel@linux-fetk.site> <CAPTjJmqnMaavYx7HyCKaPkj_Kcwp-gQZPjNm-k=KR_FSgEYysQ@mail.gmail.com> <lb73pm$78v$1@ger.gmane.org> <CAPTjJmo+PccoGQoWMa2T6dxySC2HowK59w9xjVvBTX4Whr7yBg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-254-207.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <CAPTjJmo+PccoGQoWMa2T6dxySC2HowK59w9xjVvBTX4Whr7yBg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.5564.1389843360.18130.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389843360 news.xs4all.nl 2829 [2001:888:2000:d::a6]:44926
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64043

Show key headers only | View raw


On 1/15/2014 6:09 PM, Chris Angelico wrote:
> On Thu, Jan 16, 2014 at 9:58 AM, Terry Reedy <tjreedy@udel.edu> wrote:
>> class Window:
>>      def __init__(self, title, *kwds)  # or title='Window title'
>>          self.title = title
>>          self.__dict__.update(kwds)
>
> Does that want a second asterisk, matching the Button definition?

I must have changed to **kwds after copying.
>
>>> Possible, but potentially messy; if you happen to name your button
>>> "icon", it might be misinterpreted as an attempt to set the window's
>>> icon, and cause a very strange and incomprehensible error.
>>
>> Puns are always a problem with such interfaces. Validate the args as much as
>> possible. An icon should be a bitmap of appropriate size. Optional args
>> should perhaps all be widgets (instances of a Widget baseclass).
>
> Yeah, but you'd still get back an error saying "icon should be a
> bitmap" where the real problem is "icon should be called something
> else".

One could say so in the message

InterfaceError("The icon object must be a bitmap or else the non-bitmap 
object should be called something else.)

> It might be worth explicitly adorning properties, or separating
> them into two categories. Since the keyword-named-children system has
> the other problem of being hard to lay out (how do you specify the
> order?), I'd look at keyword args for properties and something
> separate for children - either the layout I used above with .add(),
> which allows extra args as necessary, or something like this:
>
> myWindow = Window(
>       title="Hello World",
>       children=[Button(
>           label="I'm a button",
>           onClick=exit
>       )]
> )
> Or maybe allow "child=" as a shortcut, since a lot of widgets will
> have exactly one child.


-- 
Terry Jan Reedy

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


Thread

Re: Python declarative Terry Reedy <tjreedy@udel.edu> - 2014-01-15 22:35 -0500

csiph-web