Hi everybody,
Almost weekend, hang in there.
I need some advice and hope somebody can help me.
I have the follow piece of code that I use to get some data from a https
webpage.
---
< some other stuff up here>
try:
return_object = urllib2.u
On Fri, Oct 7, 2011 at 9:38 AM, Dave Angel wrote:
> On 10/06/2011 12:21 PM, lina wrote:
>
>>
>>
>>
>>> As for splitting into functions, consider:
>>>
>>> #these two are capitalized because they're intended to be constant
>>> TOKENS = "BE"
>>> LINESTOSKIP = 43
>>> INFILEEXT = ".xpm"
>>> OUTFILEEX
On Fri, Oct 7, 2011 at 9:50 AM, Steven D'Aprano wrote:
> lina wrote:
>
> May I ask a further question:
>>
>> a
>
{'B': [4, 5, 6], 'E': {1, 2, 3}}
>>
>
> Why is a['B'] a list and a['E'] a set?
>
>
>
>
> How can I get the value of
>> set(a['E'])+set(a['B'])
>>
>> I mean, get a new dict
On Fri, Oct 7, 2011 at 3:39 PM, lina wrote:
>
>
> On Fri, Oct 7, 2011 at 9:50 AM, Steven D'Aprano wrote:
>
>> lina wrote:
>>
>> May I ask a further question:
>>>
>>> a
>>
> {'B': [4, 5, 6], 'E': {1, 2, 3}}
>>>
>>
>> Why is a['B'] a list and a['E'] a set?
>>
>>
>>
>>
>> How can I get th
On 07/10/11 09:08, lina wrote:
TOKENS="BE"
LINESTOSKIP=0
INFILEEXT=".xpm"
OUTFILEEXT=".txt"
def dofiles(topdirectory):
for filename in os.listdir(topdirectory):
processfile(filename)
def processfile(infilename):
results={}
base, ext =os.path.splitext(infilename)
if
On 10/07/2011 04:08 AM, lina wrote:
I thought it might be some loop reason made it double output the results, so
I made an adjustation in indent, now it showed:
$ python3 counter-vertically-v2.py
{'B': [0, 0, 0, 0, 0, 0], 'E': [1, 0, 1, 0, 1, 0]}
{'B': [0, 0, 0, 0, 0, 0], 'E': [1, 0, 1, 0, 1, 0]
On 10/07/2011 06:06 AM, Alan Gauld wrote:
On 07/10/11 09:08, lina wrote:
summary=[]
for a,b in zip(results['E'],results['B']):
summary.append(a+b)
I don't know why this gives a key error on 'E' (which basically means
that there is no key 'E') since the code above should gu
On Fri, Oct 7, 2011 at 6:25 PM, Dave Angel wrote:
> On 10/07/2011 06:06 AM, Alan Gauld wrote:
>
>> On 07/10/11 09:08, lina wrote:
>>
>>
>> summary=[]
>>> for a,b in zip(results['E'],results['B'])**:
>>> summary.append(a+b)
>>>
>>
>> I don't know why this gives a key error on 'E'
On Fri, Oct 7, 2011 at 6:25 PM, Dave Angel wrote:
> On 10/07/2011 06:06 AM, Alan Gauld wrote:
>
>> On 07/10/11 09:08, lina wrote:
>>
>>
>> summary=[]
>>> for a,b in zip(results['E'],results['B'])**:
>>> summary.append(a+b)
>>>
>>
>> I don't know why this gives a key error on 'E'
When I put it into a real case,
it showed me all as 0 0 0 s
The python code and the real one file can be accessed from below link:
https://docs.google.com/leaf?id=0B93SVRfpVVg3MjQ0YzEzOWUtYWU0MC00YzAwLWJiYTctY2E5YTEzY2U0NGI3&hl=en_GB
https://docs.google.com/leaf?id=0B93SVRfpVVg3MWMxZDg0MmItOTNi
On 2011-10-07 14:21, lina wrote:
I don't know why this gives a key error on 'E' (which basically means that
there is no key 'E') since the code above should guarantee that it exists.
Odd. I'm also not sure why the error occurs after it prints summary. Are you
sure the output is in the sequenc
On Fri, Oct 7, 2011 at 9:08 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> On 2011-10-07 14:21, lina wrote:
>
>> I don't know why this gives a key error on 'E' (which basically means
that
there is no key 'E') since the code above should guarantee that it
exists.
>>>
On Fri, Oct 7, 2011 at 4:08 PM, lina wrote:
>
>
> On Fri, Oct 7, 2011 at 3:39 PM, lina wrote:
>
>>
>>
>> On Fri, Oct 7, 2011 at 9:50 AM, Steven D'Aprano wrote:
>>
>>> lina wrote:
>>>
>>> May I ask a further question:
a
>>>
>> {'B': [4, 5, 6], 'E': {1, 2, 3}}
>>>
>>> Why
>
> Now fixed the excessive output.
>
> Thanks,
>
> but in another case, seems there is a problem, for the line actually is:
>
> "EEES~~EE~EE~EE~
>
> E~~EEE~E
>
On 07/10/11 11:25, Dave Angel wrote:
for a,b in zip(results['E'],results['B']):
summary.append(a+b)
I don't know why this gives a key error on 'E' (which basically means
that there is no key 'E') since the code above should guarantee that
it exists. Odd. I'm also not sure why the error occurs
On 07/10/11 13:21, lina wrote:
One simple explanation: it continued on to the next file, which has
neither "E" nor "B" in it.
In this directory, I only kept one file. try.xpm
$ more try.xpm
aaEbb
aEEbb
EaEbb
EaEbE
$ ls
counter-vertically-v2.py try.xpm
counter-vertically.py try.t
On Fri, Oct 7, 2011 at 11:03 PM, Alan Gauld wrote:
> On 07/10/11 13:21, lina wrote:
>
> One simple explanation: it continued on to the next file, which has
>>neither "E" nor "B" in it.
>>
>> In this directory, I only kept one file. try.xpm
>>
>> $ more try.xpm
>> aaEbb
>> aEEbb
>> EaEbb
what does the
for col, ch in enumerate(line):
enumerate(line) mean, I used idle3 test enumerate, it always showed me:
>>> a
'abcde'
>>> enumerate(a)
I don't have a deep understanding.
Thanks all of you, for your kindness of giving advice and your patience in
explaination.
also anothe
#!/usr/bin/python3
import os.path
import glob
TOKENS="BE"
LINESTOSKIP=0
INFILEEXT=".xpm"
OUTFILEEXT=".txt"
if __name__=="__main__":
for fileName in glob.glob('*.xpm'):
base, ext =os.path.splitext(fileName)
text=open(fileName).readlines()
text=text[LINESTOSKIP:]
> open(base+OUTFILEEXT,"w").write(str(summary))
Unless Python3 is different with respect to files, I would really change this
to explicitly close the file. In general, I think explicitly closing resources
(database connections, files, etc) are a Good Thing.
with open(base+OUTFILEEXT,"w") as f:
>what does the
>
>for col, ch in enumerate(line):
>
I highly recommend looking at web documentation when you can. It is not that I
have any problems answering any questions, but I know I get frustrated when I
am forced to learn things in 5 minute increments while waiting on people to
r
On Oct 8, 2011, at 0:33, "Prasad, Ramit" wrote:
>> what does the
>>
>> for col, ch in enumerate(line):
>>
>
> I highly recommend looking at web documentation when you can. It is not that
> I have any problems answering any questions, but I know I get frustrated when
> I am forced to l
On Oct 8, 2011, at 0:39, "Prasad, Ramit" wrote:
>> open(base+OUTFILEEXT,"w").write(str(summary))
> Unless Python3 is different with respect to files, I would really change this
> to explicitly close the file. In general, I think explicitly closing
> resources (database connections, files, etc)
Hello all,
I am trying to create some test data for a search module that I am building.
Since I dont want to hit performance related issues late in the game, I
decided to create half a million records in the DB.
My approach is create a csv file with valid UUIDs which I already have. Read
each rec
I need serious help with this Rock, Paper, Scissors program. The program runs
smoothly but I can't get the score to print. Please help me with this one
aspect! Here is my code right now:
import random
def computerrockPaperScissors():
selection = random.randint(0, 2)
if selection == 0
Hi,
I'm a beginner at Python and would really appreciate some help in how to
extract information from a vcf file.
The attached file consists of a lot of information on mutations, this one
though is just 2 rows and 10 columns (the real one has a lot more rows).
I want to extract the mRNA ID
On 10/7/11, rmntcver...@aol.com wrote:
> I need serious help with this Rock, Paper, Scissors program. The program
> runs smoothly but I can't get the score to print. Please help me with this
> one aspect! Here is my code right now:
>
>
>
> import random
>
>
> def computerrockPaperScissors():
>
On 07/10/11 16:40, lina wrote:
but today I was also discouraged, I was told that you should not have
learned python, you should focus on C or bash, or D, cause python is
going to be obsolete,
C is a great language for writing Operating Systems and other "near the
metal" code. But its not the
On 07/10/11 18:56, lina wrote:
On Oct 8, 2011, at 0:39, "Prasad, Ramit" wrote:
I would really change this to explicitly close the file.
with open(base+OUTFILEEXT,"w") as f:
f.write(str(summary))
Btw, I do notice lots of suggestions of closing file.
Does your above sentence close the fil
if col[x] == 'missense':
print col[withRefSeqID]
hth
From: Anna Olofsson
To: tutor@python.org
Sent: Friday, October 7, 2011 12:12 PM
Subject: [Tutor] vcf_files and strings
Hi,
I'm a beginner at Python and would really appreciate some help in how
On 10/7/2011 12:32 PM, rmntcver...@aol.com wrote:
I need serious help with this Rock, Paper, Scissors program. The
program runs smoothly but I can't get the score to print. Please help
me with this one aspect! Here is my code right now:
Welcome to Python Help.
In future please use a meaningfu
On 10/7/2011 2:19 PM, Guess?!? wrote:
Hello all,
I am trying to create some test data for a search module that I am
building. Since I dont want to hit performance related issues late in
the game, I decided to create half a million records in the DB.
My approach is create a csv file with vali
Hey Bob,
Thanks for the suggestions. There is no traceback/stacktrace errors that I
can see (may be there is a file that is generated in python or windows
directory due to run time failure but I am not able to locate it. Please let
me know if you know).
The run time error pops up in a windows dia
From: tutor-bounces+ramit.prasad=jpmorgan@python.org
[mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of
Guess?!?
Sent: Friday, October 07, 2011 4:32 PM
To: bob gailer
Cc: tutor@python.org
Subject: Re: [Tutor] Runtime error while Test data creation
Hey Bob,
Thanks for t
> The 'with' syntax above implicitly closes the file for you
> at the end of the block. If you use the
>
> f = open(...)
>
> style you are expected to explicitly close the file when you are finished
> with it. This is especially important when writing to a file because that
> will guarantee that
> C is a great language for writing Operating Systems and other "near the
> metal" code. But its not the best language for busiess apps, artificial
> intelligence and a host of other things. Bash is a good user shell, but its
> not even the best Unix shell for scripting (Thats probably ksh).
> D? W
On 10/7/2011 5:32 PM, Guess?!? wrote:
Hey Bob,
Thanks for the suggestions. There is no traceback/stacktrace errors
that I can see (may be there is a file that is generated in python or
windows directory due to run time failure but I am not able to locate
it. Please let me know if you know).
On 10/7/2011 5:32 PM, Guess?!? wrote:
A couple of suggestion below (inline with the code):
import pyodbc, random, datetime, uuid
#INT
conn = pyodbc.connect('DRIVER={SQL
Server};SERVER=SERVERNAME\INT_FOUNDATIONS;DATABASE=membership_service;UID=int_usr;PWD=blah')
c = conn
Another minor derived questions:
summary=[]
for a,b in zip(results['E'],results['B']):
summary.append(a+b)## now the summary is '[0,1, 3, 5,
6,0,0,0]'
del summary[0] ## here I wanna remove the first zero, which came
from the initial double quote "EB...E",
Still have a reading "multiple" files issue:
Traceback (most recent call last):
File "counter-vertically-WORKING.py", line 26, in
results[ch][col]+=1
IndexError: list index out of range
only one file ss_1.xpm was processed and wrote file, for the rest ss_2.xpm,
ss_3.xpm and following keep
Hello Tutors,
It's been quite some time since I last posted something here, and now I'm
back with a question:
I want to re-structure English so that the adjectives appear after the
nouns, instead of before.
If I have a sentence like:
The tall man plays well
I need to change it to
The man tall pla
Emad Nawfal (عمـ نوفل ـاد) wrote:
Hello Tutors,
It's been quite some time since I last posted something here, and now I'm
back with a question:
I want to re-structure English so that the adjectives appear after the
nouns, instead of before.
If I have a sentence like:
The tall man plays well
I n
On 2011-10-08 05:34, lina wrote:
Another minor derived questions:
summary=[]
for a,b in zip(results['E'],results['B']):
summary.append(a+b)## now the summary is '[0,1, 3, 5,
6,0,0,0]'
del summary[0] ## here I wanna remove the first zero, which came
f
On 2011-10-08 06:07, lina wrote:
Still have a reading "multiple" files issue:
Traceback (most recent call last):
File "counter-vertically-WORKING.py", line 26, in
results[ch][col]+=1
IndexError: list index out of range
only one file ss_1.xpm was processed and wrote file, for the rest ss
[I have already answered your first post but it seems you missed it]
On 2011-10-07 18:12, Anna Olofsson wrote:
Hi,
I'm a beginner at Python and would really appreciate some help in how
to extract information from a vcf file.
What does "beginner" mean?
Do you have experience in other language
> Still have a reading "multiple" files issue:
>>
>> Traceback (most recent call last):
>> File "counter-vertically-WORKING.**py", line 26, in
>> results[ch][col]+=1
>> IndexError: list index out of range
>>
>> only one file ss_1.xpm was processed and wrote file, for the rest
>> ss_2.xpm,
>>
Hi Steven ans Tutors,
Thanks for the code.
Actually I'm not a student at all. I'm an assistant professor of Arabic at
Suez Canal University in Egypt. I would appreciate more contributions from
you and the other list members.
2011/10/8 Steven D'Aprano
> Emad Nawfal (عمـ نوفل ـاد) wrote:
>
>> Hell
2011/10/8 Emad Nawfal (عمـ نوفل ـاد)
> Hi Steven ans Tutors,
> Thanks for the code.
> Actually I'm not a student at all. I'm an assistant professor of Arabic at
> Suez Canal University in Egypt. I would appreciate more contributions from
> you and the other list members.
>
>
> 2011/10/8 Steven D'
On 2011-10-08 08:25, lina wrote:
Still have a reading "multiple" files issue:
Traceback (most recent call last):
File "counter-vertically-WORKING.**py", line 26, in
results[ch][col]+=1
IndexError: list index out of range
only one file ss_1.xpm was processed and wrote file, for the
49 matches
Mail list logo