What is not working with my "map" usage?

2018-09-21 Thread Viet Nguyen via Python-list
Hi, I want to add up all of the list elements. But when I use the "map" function, it didn't seem to work as I expect. Could someone point out how "map" can be applied here then? def add_all_elements (*args): total = 0 for i in args: print(type(i)) print("i = %s" % i)

Re: Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
t.__next__() > (4, 1) > >>> aList.__next__() > (5, 8) > >>> aList.__next__() > Traceback (most recent call last): > File "", line 1, in > StopIteration > >>> > > > -Original Message- > From: Python-list > [mailt

Re: Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote: > On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list > wrote: > >>>> numList > > [2, 7, 22, 30, 1, 8] > > > >>>> aList = enumerate(numList) > > > >>&g

Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
>>> numList [2, 7, 22, 30, 1, 8] >>> aList = enumerate(numList) >>> for i,j in aList:print(i,j) 0 2 1 7 2 22 3 30 4 1 5 8 >>> for i,j in aList:print(i,j) >>> -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to display source code for Python function?

2014-10-03 Thread Viet Nguyen
On Friday, October 3, 2014 12:48:08 AM UTC-7, Peter Otten wrote: > Viet Nguyen wrote: > > > > > On Thursday, October 2, 2014 10:34:15 PM UTC-7, Viet Nguyen wrote: > > >> Hi, > > >> > > >> > > >> > > &g

Re: Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
On Thursday, October 2, 2014 10:47:28 PM UTC-7, Ian wrote: > On Thu, Oct 2, 2014 at 11:34 PM, Viet Nguyen > > wrote: > > > Hi, > > > > > > When I am debug mode, is there some command which will help display the > > source code for a Python functi

Re: Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
On Thursday, October 2, 2014 10:34:15 PM UTC-7, Viet Nguyen wrote: > Hi, > > > > When I am debug mode, is there some command which will help display the > source code for a Python function of interest? Much like you'd use "info > proc" to display con

Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
Hi, When I am debug mode, is there some command which will help display the source code for a Python function of interest? Much like you'd use "info proc" to display contents of Tcl proc. Thanks, Viet -- https://mail.python.org/mailman/listinfo/python-list

Why captured match is displayed as part of pexpect ".after" ?

2014-09-13 Thread Viet Nguyen
Hi, If any is familiar with pexpect, please help to point out why my script seems to fail to capture the desired text. Here, I want to log into a server 172.27.161.19. Once I see "Username: ", I will type in my userid "admin". The problem here is I have a list of keywords for pexpect to match

Re: Why command os.popen works in python interactive mode but not in script debugger mode?

2014-09-12 Thread Viet Nguyen
On Thursday, September 11, 2014 10:15:57 PM UTC-7, Viet Nguyen wrote: > Can anyone give me hint or reason why same command behaves differently in > debugger mode from interactive mode: > > > > From interactive mode: > > > > >>> import os >

Why command os.popen works in python interactive mode but not in script debugger mode?

2014-09-11 Thread Viet Nguyen
Can anyone give me hint or reason why same command behaves differently in debugger mode from interactive mode: >From interactive mode: >>> import os >>> p = os.popen('date') >>> p.read() 'Thu Sep 11 11:18:07 PDT 2014\n' But from debugger mode in a script: >>> import os (Pdb) p = os.popen('date'