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


Groups > comp.lang.python > #70698 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2014-04-29 08:41 +1000
Last post2014-04-29 08:41 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

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

FromChris Angelico <rosuav@gmail.com>
Date2014-04-29 08:41 +1000
SubjectRe: Help with changes in traceback stack from Python 2.7 to Python 3.x
Message-ID<mailman.9563.1398724892.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web