Received: from localhost (HELO mail.python.org) (127.0.0.1)
by albatross.python.org with SMTP; 18 Dec 2012 05:48:55 +0100
Received: from mail-pb0-f45.google.com (mail-pb0-f45.google.com
[209.85.160.45])
(using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits))
(No client certificate requested)
by mail.python.org (Postfix) with ESMTPS
for <capi-sig-+ZN9ApsXKcEdnm+***@public.gmane.org>; Tue, 18 Dec 2012 05:48:54 +0100 (CET)
Received: by mail-pb0-f45.google.com with SMTP id mc8so133954pbc.32
for <capi-sig-+ZN9ApsXKcEdnm+***@public.gmane.org>; Mon, 17 Dec 2012 20:48:53 -0800 (PST)
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:to
:content-type; bh=CjX2OMN2oc3nc0u2jWkI8Oioxt+M67z7vpmsheTqa4c=;
b=jT/+OHO7buhR4E6e6OzPgt2osd1Zq1DU31XP7mJZ+TJ6vO+vI3FxfI92QXbcf6oN/R
MXD1EOqQpVnEmwB/hSLw/gcRW4Uayf1RQwoUmJtdbtFmkcbFNIqkBGo/FERdeAw7czgW
XQo5Fw9Kzu1no72ZMdlHgQEk529vDOezazS/u99aV8gHDxLh/x0WTWQvThA0Ovz8WmKp
1SsAeG4jLLmFGgDgUdSpRs9WrFnm81ZX/+sCtKgRZBuHnjuu2PhG8lwpPAERNoTb6Moi
VjxfAOQOiG5JkFtCUs4k4gEu8h/A1VtZbivx2bpRCNU20F2ZyYpHNP3rSLE5t9DxHUpa
r9iA==
Received: by 10.68.197.8 with SMTP id iq8mr2760863pbc.56.1355806133353; Mon,
17 Dec 2012 20:48:53 -0800 (PST)
Received: by 10.66.232.74 with HTTP; Mon, 17 Dec 2012 20:48:53 -0800 (PST)
In-Reply-To: <CAO-CpEJuMeJ-T=u1OX=2RFcuza=O135z_d+THa+V81uknQxFfw-JsoAwUIsXosN+***@public.gmane.org>
X-BeenThere: capi-sig-+ZN9ApsXKcEdnm+***@public.gmane.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Mailing list for discussing the Python/C API <capi-sig.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/capi-sig>,
<mailto:capi-sig-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/capi-sig/>
List-Post: <mailto:capi-sig-+ZN9ApsXKcEdnm+***@public.gmane.org>
List-Help: <mailto:capi-sig-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/capi-sig>,
<mailto:capi-sig-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=subscribe>
Errors-To: capi-sig-bounces+gcpc-capi-sig=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Sender: "capi-sig" <capi-sig-bounces+gcpc-capi-sig=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.python.capi/131>
It depends, sometimes you wont want to allow this for attribute
assignment since it can be misleading.
eg:
foo.bar = []
Post by Gustavo CarneiroYou are not wrong. On the other hand, I often depend on the fact that an
empty list or dictionary is false, and true if not empty. It is quite
convenient, and I find it reasonably logical.
Post by Campbell BartonTake care using PyObject_IsTrue since it will accept many PyObject's
(floats, lists, dicts etc), if you want to be strict with checking
your input its not always so good.
Instead you can use PyLong_AsLong() this works for True/False and any int type.
int param = PyLong_AsLong(value);
if (param == -1 && PyErr_Occurred()) {
.... error out ...
}
... check the int now ...
--
- Campbell
_______________________________________________
capi-sig mailing list
http://mail.python.org/mailman/listinfo/capi-sig
--
Gustavo J. A. M. Carneiro
"The universe is always one step beyond logic." -- Frank Herbert
--
- Campbell