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


Groups > comp.lang.python > #70698

Re: Help with changes in traceback stack from Python 2.7 to Python 3.x

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@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; 'subject:Python': 0.06; 'args': 0.07; 'defaults': 0.07; 'feature.': 0.09; 'seemed': 0.09; 'stack,': 0.09; 'subject:2.7': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'defaults,': 0.16; 'dict': 0.16; 'dictionaries': 0.16; 'dictionary,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'specify': 0.24; 'cc:2**0': 0.24; 'class.': 0.26; 'pass': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; 'subject:from': 0.34; 'subject:with': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'list': 0.37; 'implement': 0.38; 'liked': 0.60; 'simply': 0.61; 'provide': 0.64; 'love': 0.65; 'great': 0.65; 'actually,': 0.84; 'want:': 0.84; 'to:none': 0.92
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=tOdm/iznKRPdNEUDHxz89basVuHoLkoDlkuHLpV6XFI=; b=Sk6E+qOTaHmjS96dq7zAR+RVtG68Yd7MSU1pwdby4fg/JRjmpiiJ/50Er7wDituaHS 5k/4kJqCj+A/lPfxx6Pp10YiCM27+0196Cw9cp6bg1cZMyGODPUSky2teraWf+f+/BrP k+u5GJVd+gKqfr/iRvAanja3HDE5o5eevwjM1rAbVDz/BJhXM/TZLQEvCHSEL2dud/y3 HCU9jMXrdgiecUQ2UBlYZs8APYMXChicWMW5iw1h6Hg3SyLN2MbK+oXFPeVPQ1S8pAxv 3f2NVpszIJ0v0uFED3NMz4svg497X60cZ8cgkkv4OBj7M+uENwywCt3f/VFax6Dcpyx4 kXTw==
MIME-Version 1.0
X-Received by 10.58.105.105 with SMTP id gl9mr25660911veb.3.1398724890478; Mon, 28 Apr 2014 15:41:30 -0700 (PDT)
In-Reply-To <5f1efb2f-9b35-44bb-b9fc-ae03777a595a@me.com>
References <ljmaiq$3f8$1@ger.gmane.org> <5f1efb2f-9b35-44bb-b9fc-ae03777a595a@me.com>
Date Tue, 29 Apr 2014 08:41:30 +1000
Subject Re: Help with changes in traceback stack from Python 2.7 to Python 3.x
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.9563.1398724892.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398724892 news.xs4all.nl 2901 [2001:888:2000:d::a6]:53751
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70698

Show key headers only | View raw


On Tue, Apr 29, 2014 at 5:50 AM, Andrew Konstantaras <akonsta@icloud.com> wrote:
> Actually, that is one of the nice features of using a dictionary, I can
> check if the key is there and if it is pull it out.  As I was dusting off
> this old code, I considered trying to implement this functionality through
> by creating a class.  I never liked going through the stack, it seemed
> hacky, but I came to love using dictionaries as they have some great built
> in features.

In that case, consider using function named arguments. You can simply
list a whole lot of args with defaults, and then provide values for
the exact ones you want:

def f(a=1, b=2, c=3, d=4, e=5):
    print("My args are",a,b,c,d,e)

f() # all defaults, like an empty dict
f(d=123) # all defaults but one
f(10,20,e=7) # specify the early ones positionally if you always pass those

This is a really REALLY handy feature.

ChrisA

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


Thread

Re: Help with changes in traceback stack from Python 2.7 to Python 3.x Chris Angelico <rosuav@gmail.com> - 2014-04-29 08:41 +1000

csiph-web