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

2014-05-17 Thread Albert van der Horst
In article , Andrew Konstantaras wrote: >-=-=-=-=-=- > >I guess I am missing something big as I am looking for a shorthand way >of doing the following: > > dctA = dict(x=x, y=y, ... n=n) > >This is, as I understand it a very natural way of using a dictionary. >It seems that this syntax

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

2014-04-28 Thread Chris Angelico
On Tue, Apr 29, 2014 at 5:50 AM, Andrew Konstantaras 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 creati

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

2014-04-28 Thread Andrew Konstantaras
On Apr 28, 2014, at 12:36 PM, Ned Batchelder wrote: On 4/27/14 5:51 PM, Andrew Konstantaras wrote: > I guess I am missing something big as I am looking for a shorthand way > of doing the following: > > dctA = dict(x=x, y=y, ... n=n) > Yes, your makeDict(x,

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

2014-04-28 Thread Ned Batchelder
On 4/27/14 5:51 PM, Andrew Konstantaras wrote: I guess I am missing something big as I am looking for a shorthand way of doing the following: dctA = dict(x=x, y=y, ... n=n) Yes, your makeDict(x, y) is a shorthand for dict(x=x, y=y), but there are many things you can do with dict

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

2014-04-28 Thread Steven D'Aprano
On Mon, 28 Apr 2014 12:19:02 +1000, Chris Angelico wrote: > On Mon, Apr 28, 2014 at 12:11 PM, Steven D'Aprano > wrote: >> Suppose we could pass variables directly to the constructor, like this: >> >> a = b = 2 >> L = [1, 2, 3] >> dctA = dict(a, b, L[1], 2, 1+1) >> >> Obviously all five values are

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

2014-04-27 Thread Chris Angelico
On Mon, Apr 28, 2014 at 12:11 PM, Steven D'Aprano wrote: > Suppose we could pass variables directly to the constructor, like this: > > a = b = 2 > L = [1, 2, 3] > dctA = dict(a, b, L[1], 2, 1+1) > > Obviously all five values are 2, but what are the keys? > > The dict construct > receives five argu

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

2014-04-27 Thread Steven D'Aprano
On Sun, 27 Apr 2014 21:51:54 +, Andrew Konstantaras wrote: > I guess I am missing something big as I am looking for a shorthand way > of doing the following: > >dctA = dict(x=x, y=y, ... n=n) > > This is, as I understand it a very natural way of using a dictionary. Would you pr

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

2014-04-27 Thread Chris Angelico
On Mon, Apr 28, 2014 at 7:51 AM, Andrew Konstantaras wrote: > I will give the locals approach a try, it seems a little more clumsy than > simply passing the variables to the function. This is your fundamental misunderstanding that's led to all of this. You do not "pass variables to a function"; y

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

2014-04-27 Thread Andrew Konstantaras
I guess I am missing something big as I am looking for a shorthand way of doing the following: dctA = dict(x=x, y=y, ... n=n) This is, as I understand it a very natural way of using a dictionary. It seems that this syntax is unnecessarily redundant and hence my goal of writing someth

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

2014-04-27 Thread Chris Angelico
On Mon, Apr 28, 2014 at 4:56 AM, Andrew Konstantaras wrote: > Thanks for the response and I can certainly see that this old code can be > improved, but I respectfully disagree on the utility of this function. The > flexibility of passing any number of arguments to the function and returning > a d

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

2014-04-27 Thread Andrew Konstantaras
Thanks for the response and I can certainly see that this old code can be improved, but I respectfully disagree on the utility of this function. The flexibility of passing any number of arguments to the function and returning a dictionary is much easier than writing out dict(x=x, y=y, ...n=n).

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

2014-04-26 Thread Ian Kelly
On Apr 26, 2014 8:12 AM, "Ned Batchelder" wrote: > Looking at your code, I see: > > > tplArgs = map(None, lstVarNames, args) > > I didn't realize map accepted a callable of None (TIL!), but it no longer does in Python 3. You'll have to do this a different way. The Python 3 replacement for ma

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

2014-04-26 Thread Ned Batchelder
On 4/26/14 1:50 AM, Andrew Konstantaras wrote: I wrote the following code that works in Python 2.7 that takes the variables passed to the function into a dictionary. The following call: strA = 'a' intA = 1 dctA = makeDict(strA, intA) produces the following dictionary:

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

2014-04-25 Thread Andrew Konstantaras
I wrote the following code that works in Python 2.7 that takes the variables passed to the function into a dictionary. The following call: strA = 'a' intA = 1 dctA = makeDict(strA, intA) produces the following dictionary: {'strA':'a', 'intA':1} To access the names passed int