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
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
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,
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
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
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
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
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
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
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
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).
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
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:
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
14 matches
Mail list logo