Re: [Tutor] Unable to retreive the stock code

2015-11-16 Thread Cameron Simpson
On 16Nov2015 15:41, Crusier wrote: I am currently trying to download the stock code. I am using Python 3.4 and the code is as follows: [...] for link in soup.find_all("a"): stock_code = re.search('/d/d/d/d/d', "1" ) print(stock_code, '', link.text) [...] I am trying to r

Re: [Tutor] Unable to retreive the stock code

2015-11-16 Thread Peter Otten
Crusier wrote: > Dear All, > > I am currently trying to download the stock code. I am using Python > 3.4 and the code is as follows: > > from bs4 import BeautifulSoup > import requests > import re > > url = > 'https://www.hkex.com.hk/eng/market/sec_tradinfo/stockcode/eisdeqty.htm' > > def web_

[Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
Hi Guys, OS = SuSE Enterprise Linux Python V2.7 My code is as follows # this list contains system process ID's pidst=[1232, 4543, 12009] pmap_str=[] command="pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print $1}'" for i in range(len(pids)): pmap_str.append(os.popen("(command) %

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
The following code seems to be pointing me to the right direction, BUT, my list has 0's instead of the output generated. >>> for i in range(len(pids)): ... final.append(subprocess.call(["sudo pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print $1}'" % pids[i]], shell=True)) ... 60772

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
SOLVED> the code I used was. for i in range(len(pids)): final.append(subprocess.Popen(["sudo pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print $1}'" % pids[i]], shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]) Allowed me to append the subprocess output

[Tutor] Debugging in Python

2015-11-16 Thread Sajjadul Islam
Hello forum, I am trying Python 3.4 on Ubuntu and I am a bit confused with the debugging scope of python in general. I wrote a small function and then I tried to run with the following call: /// import hilbert hilbert.hilbert(3) /// Please note

Re: [Tutor] Debugging in Python

2015-11-16 Thread Alan Gauld
On 16/11/15 09:55, Sajjadul Islam wrote: Hello forum, I am trying Python 3.4 on Ubuntu and I am a bit confused with the debugging scope of python in general. I wrote a small function and then I tried to run with the following call: /// import hilbert hilbert.hilbert(3)

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Alan Gauld
On 16/11/15 14:05, Vusa Moyo wrote: SOLVED> the code I used was. for i in range(len(pids)): final.append(subprocess.Popen(["sudo pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print $1}'" % pids[i]], shell=True, Glad you solved it and using subprocess is fine for the pmap stuff.

Re: [Tutor] Debugging in Python

2015-11-16 Thread Chris Warrick
On 16 November 2015 at 15:43, Alan Gauld wrote: > Thats not an IDE its just a raw interpreter. > IDLE is a full IDE that includes a debugger. It’s an awful piece of garbage that pretends to be an IDE. >> I encountered some error in the source , then I fixed it and tried to run >> the module with

Re: [Tutor] Debugging in Python

2015-11-16 Thread Alan Gauld
On 16/11/15 15:42, Chris Warrick wrote: On 16 November 2015 at 15:43, Alan Gauld wrote: Thats not an IDE its just a raw interpreter. IDLE is a full IDE that includes a debugger. It’s an awful piece of garbage that pretends to be an IDE. Would you care to expand. Its been doing a fair impres

[Tutor] question about "__main__"

2015-11-16 Thread CUONG LY
Hello, I’m learning Python. I want to know what does the following line represent and why I see some python codes have two of them ? if __name__ == ‘__main__’: Thanks in advance Cuong ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] question about "__main__"

2015-11-16 Thread Alan Gauld
On 16/11/15 15:30, CUONG LY wrote: Hello, I’m learning Python. Hello, welcome. I want to know what does the following line represent if __name__ == ‘__main__’: The short answer is that it tests whether the file is being imported as a module or executed as a program. If its being imported a