Re: function call questions

2016-10-23 Thread chenyong20000
在 2016年10月22日星期六 UTC+8下午9:15:06,Frank Millman写道: > wrote in message > news:[email protected]... > > > I have read Anssi's post already before I sent the post. To be frankly, I > can't understand why he got the right answer. I'm sorry for my silly. "So > when we

Re: function call questions

2016-10-22 Thread Frank Millman
wrote in message news:[email protected]... I have read Anssi's post already before I sent the post. To be frankly, I can't understand why he got the right answer. I'm sorry for my silly. "So when we assign to r again, it's the empty dict inside t (the one acc

Re: function call questions

2016-10-22 Thread chenyong20000
在 2016年10月22日星期六 UTC+8下午5:06:22,Frank Millman写道: > wrote in message > news:[email protected]... > > 在 2016年10月20日星期四 UTC+8下午11:04:38,Frank Millman写道: > > wrote in message > > news:[email protected]... > > > > Hi Frank, > > >

Re: function call questions

2016-10-22 Thread Frank Millman
wrote in message news:[email protected]... 在 2016年10月20日星期四 UTC+8下午11:04:38,Frank Millman写道: wrote in message news:[email protected]... Hi Frank, thanks for your kind help. What confused me is at this line: >>> r = r.set

Re: function call questions

2016-10-22 Thread chenyong20000
在 2016年10月20日星期四 UTC+8下午11:04:38,Frank Millman写道: > wrote in message > news:[email protected]... > > 在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: > > wrote in message > > news:[email protected]... > > > > > Let's see if I

Re: function call questions

2016-10-21 Thread Frank Millman
"Anssi Saari" wrote in message news:[email protected]... OK, so what happens is that now t references the dictionary with {'a': {}} and r references the empty dict inside that. So when we assign to r again, it's the empty dict inside t (the one accessed by key 'a') that change

Re: function call questions

2016-10-21 Thread Anssi Saari
"Frank Millman" writes: > Let's see if I can explain. I am using 't' and 'r' instead of 'tree' > and 'root', but otherwise it is the same as your original example. > t = {} r = t id(t) > 2542235910088 id(r) > 2542235910088 > > At this point, t and r are both references to the

Re: function call questions

2016-10-20 Thread Frank Millman
wrote in message news:[email protected]... 在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: wrote in message news:[email protected]... > Let's see if I can explain. I am using 't' and 'r' instead of 'tree' and > 'root', bu

Re: function call questions

2016-10-20 Thread chenyong20000
在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: > wrote in message > news:[email protected]... > > 在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道: > > [email protected] wrote: > > > > > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: > > >> On 2016-10-19 03:15,

Re: function call questions

2016-10-19 Thread Frank Millman
wrote in message news:[email protected]... 在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道: [email protected] wrote: > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: >> On 2016-10-19 03:15, [email protected] wrote: >> > Thanks Peter and Anssi for your ki

Re: function call questions

2016-10-19 Thread chenyong20000
在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道: > [email protected] wrote: > > > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: > >> On 2016-10-19 03:15, [email protected] wrote: > >> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first > >> > question. But the second questi

Re: function call questions

2016-10-19 Thread Peter Otten
[email protected] wrote: > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: >> On 2016-10-19 03:15, [email protected] wrote: >> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first >> > question. But the second question still confused me. Why "it seems that >> > after root =

Re: function call questions

2016-10-18 Thread chenyong20000
在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: > On 2016-10-19 03:15, [email protected] wrote: > > Thanks Peter and Anssi for your kind help. Now I'm ok with the first > > question. But the second question still confused me. Why "it seems that > > after root = root.setdefault(ch,{}) tree['a'] and

Re: function call questions

2016-10-18 Thread MRAB
On 2016-10-19 03:15, [email protected] wrote: Thanks Peter and Anssi for your kind help. Now I'm ok with the first question. But the second question still confused me. Why "it seems that after root = root.setdefault(ch,{}) tree['a'] and root are the same object" and follows tree['a']['b']?

Re: function call questions

2016-10-18 Thread chenyong20000
Thanks Peter and Anssi for your kind help. Now I'm ok with the first question. But the second question still confused me. Why "it seems that after root = root.setdefault(ch,{}) tree['a'] and root are the same object" and follows tree['a']['b']? Thanks. -- https://mail.python.org/mailman/listinf

Re: function call questions

2016-10-18 Thread Peter Otten
[email protected] wrote: >> > My question is: >> > (1) why root is always {}? >> >> Because that's what you bind it to in the line >> >> > ... root = root.setdefault(ch,{}) >> >> See >> for a description of the the s

Re: function call questions

2016-10-18 Thread chenyong20000
> > My question is: > > (1) why root is always {}? > > Because that's what you bind it to in the line > > > ... root = root.setdefault(ch,{}) > > See > for a description of the the setdefault() method. I'm still confused h

Re: function call questions

2016-10-18 Thread Anssi Saari
[email protected] writes: > My question is: > (1) why root is always {}? Because that's what you wrote. root.setdefault(ch, {}) returns {} and you assign that to root. You probably want to do just root.setdefault(ch, {}) instead of root = root.setdefault(ch, {}). > (2) why tree is {'a': {'

Re: function call questions

2016-10-18 Thread Peter Otten
[email protected] wrote: > Hi, > I got a function call as this: > def add_to_tree(root,value_string): > ...print "root is %s, value_string is %s" % (root, value_string) > ...for ch in value_string: > ... print "ch is %s" % ch > ... root = root.setdefault(ch,{}) > ...

Re: Function call arguments in stack trace?

2011-06-07 Thread Gabriel Genellina
En Tue, 07 Jun 2011 15:09:54 -0300, Dun Peal escribió: In a stack trace, is it possible to somehow get the arguments with which each function was called? So for example, if function `foo` in module `bar` was called with arguments `(1, [2])` when it raised an exception, then instead of:

Re: Function call arguments in stack trace?

2011-06-07 Thread Neil Cerutti
On 2011-06-07, Dun Peal wrote: > On Jun 7, 1:23?pm, Neil Cerutti wrote: >> Use pdb. > > Neil, thanks for the tip; `pdb` is indeed a great debugging > tool. > > Still, it doesn't obviate the need for arguments in the stack > trace. For example: > > 1) Arguments in stack trace can expedite a debugg

Re: Function call arguments in stack trace?

2011-06-07 Thread Irmen de Jong
On 7-6-2011 21:31, Dun Peal wrote: > On Jun 7, 1:23 pm, Neil Cerutti wrote: >> Use pdb. > > Neil, thanks for the tip; `pdb` is indeed a great debugging tool. > > Still, it doesn't obviate the need for arguments in the stack trace. If you can't use pdb perhaps you can use the following: Pyro ha

Re: Function call arguments in stack trace?

2011-06-07 Thread Ian Kelly
On Tue, Jun 7, 2011 at 1:31 PM, Dun Peal wrote: > On Jun 7, 1:23 pm, Neil Cerutti wrote: >> Use pdb. > > Neil, thanks for the tip; `pdb` is indeed a great debugging tool. > > Still, it doesn't obviate the need for arguments in the stack trace. Your program could use sys.excepthook to generate a

Re: Function call arguments in stack trace?

2011-06-07 Thread Dun Peal
On Jun 7, 1:23 pm, Neil Cerutti wrote: > Use pdb. Neil, thanks for the tip; `pdb` is indeed a great debugging tool. Still, it doesn't obviate the need for arguments in the stack trace. For example: 1) Arguments in stack trace can expedite a debugging session, and even obviate it completely: "Wh

Re: Function call arguments in stack trace?

2011-06-07 Thread Neil Cerutti
On 2011-06-07, Dun Peal wrote: > Hi, > > In a stack trace, is it possible to somehow get the arguments with > which each function was called? > > So for example, if function `foo` in module `bar` was called with > arguments `(1, [2])` when it raised an exception, then instead of: > > Traceback

Re: function call overhead

2009-02-03 Thread Default User
The original message in this thread was posted with the intent to disrupt comp.lang.c by setting follow-ups there. Please either ignore this thread or change the distribution. Thanks, and sorry our troll has caused problems in your group. Brian -- http://mail.python.org/mailman/listinfo/python

Re: function call overhead

2009-02-03 Thread Christian Heimes
Eddie Watson schrieb: > What's the Python function call overhead like? Like 6, maybe 7 *scnr* -- http://mail.python.org/mailman/listinfo/python-list

Re: function call - default value & collecting arguments

2008-04-03 Thread Primoz Skale
"OKB (not okblacke)" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Primoz Skale wrote: > >> OK, everything allright till so fair. But! :) Now define third >> function as: >> >> def f(*a): >>print a[0] >> >> In this case, function only prints first argument in the tuple: >> >>>

Re: function call - default value & collecting arguments

2008-04-03 Thread Primoz Skale
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2 avr, 22:32, "Primoz Skale" <[EMAIL PROTECTED]> wrote: >> >> I also understand (fairly) how to collect arguments. For example, >> >> let's >> >> define another function: >> >> >> def f(*a): >> >>print a >> >> > This means that

Re: function call - default value & collecting arguments

2008-04-02 Thread OKB (not okblacke)
Primoz Skale wrote: > OK, everything allright till so fair. But! :) Now define third > function as: > > def f(*a): >print a[0] > > In this case, function only prints first argument in the tuple: > >>>f(1,2,3) > 1 >>>f(3) > 3 >>>f()#no arguments passed > Traceback (most recent call last

Re: function call - default value & collecting arguments

2008-04-02 Thread [EMAIL PROTECTED]
On 2 avr, 22:32, "Primoz Skale" <[EMAIL PROTECTED]> wrote: > >> I also understand (fairly) how to collect arguments. For example, let's > >> define another function: > > >> def f(*a): > >>print a > > > This means that f takes any number of optional positional arguments. > > If nothing is passed

Re: function call - default value & collecting arguments

2008-04-02 Thread Primoz Skale
>> I also understand (fairly) how to collect arguments. For example, let's >> define another function: >> >> def f(*a): >>print a > > This means that f takes any number of optional positional arguments. > If nothing is passed, within f, 'a' will be an empty tuple. Note that > this is *not* the

Re: function call - default value & collecting arguments

2008-04-02 Thread [EMAIL PROTECTED]
On 2 avr, 21:03, "Primoz Skale" <[EMAIL PROTECTED]> wrote: > Hello! > > I am fairly new to Python, so I apologise if this is a 'newbie' question. > > First define a simple function: > > def f(a=0): > print a > > >> f(1) > 1 > >>f() > > 0 > > Argument a in function f() is set at default value of

Re: function call - default value & collecting arguments

2008-04-02 Thread Terry Reedy
"Primoz Skale" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | def f(*a=(0,)): | print a[0] #this should come next, but we get error msg instead, saying | | SyntaxError: invalid syntax | | but it does not work this way. Now my 'newbie' question: Why not? :) Possibly beca

Re: function call problem in class?

2007-11-14 Thread Davy
On Nov 14, 4:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 14 Nov 2007 04:51:57 -0300, Davy <[EMAIL PROTECTED]> escribió: > > > I have write a simple class, I want the function two() to call private > > function __one(), but there is an error : > > NameError: global name '_simple_

Re: function call problem in class?

2007-11-14 Thread Gabriel Genellina
En Wed, 14 Nov 2007 04:51:57 -0300, Davy <[EMAIL PROTECTED]> escribió: > I have write a simple class, I want the function two() to call private > function __one(), but there is an error : > NameError: global name '_simple__one' is not defined, how to work > around it > > class simple: > def __

Re: function call

2007-09-04 Thread ianaré
> > Every reasonable use case for this (and several unreasonable ones) > > that I've encountered (and some that I've just imagined) can be better > > addressed with a trace function (sys.set_trace) than by trying to do > > this at the point of call. > > Indeed. Thanks for the correction. > > > rel

Re: function call

2007-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2007 13:17:39 -0700, ianaré wrote: > Hey all, > > Is there a way of printing out how a function was called? In other words > if I do the following: > > def someFunction(self): > self.someOtherFunction(var1, var2) > > > I would get something like "someOtherFunction: called by

Re: function call

2007-09-04 Thread Bruno Desthuilliers
Chris Mellon a écrit : > On 9/3/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>ianaré a écrit : >> >>>Hey all, >>> >>>Is there a way of printing out how a function was called? In other >>>words if I do the following: >>> >>>def someFunction(self): >>>self.someOtherFunction(var1, var2)

Re: function call

2007-09-04 Thread Chris Mellon
On 9/3/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > ianaré a écrit : > > Hey all, > > > > Is there a way of printing out how a function was called? In other > > words if I do the following: > > > > def someFunction(self): > > self.someOtherFunction(var1, var2) > > > > > > I would get so

Re: function call

2007-09-04 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > ianaré a écrit : > >> Hey all, >> >> Is there a way of printing out how a function was called? In other >> words if I do the following: >> >> def someFunction(self): >> self.someOtherFunction(var1, var2) >> >> >> I would get something like "someOtherFunction: ca

Re: function call

2007-09-04 Thread kyosohma
On Sep 4, 3:17 pm, ianaré <[EMAIL PROTECTED]> wrote: > Hey all, > > Is there a way of printing out how a function was called? In other > words if I do the following: > > def someFunction(self): > self.someOtherFunction(var1, var2) > > I would get something like "someOtherFunction: called by: >

Re: function call

2007-09-04 Thread Bruno Desthuilliers
ianaré a écrit : > Hey all, > > Is there a way of printing out how a function was called? In other > words if I do the following: > > def someFunction(self): > self.someOtherFunction(var1, var2) > > > I would get something like "someOtherFunction: called by: > someFunction, args are: var1,