lina wrote:
On Fri, Oct 7, 2011 at 9:38 AM, Dave Angel mailto:d...@davea.name>> wrote:
On 10/06/2011 12:21 PM, lina wrote:
Yes. I understand this part now. But how can I print a list consists of the
value of key B + E.
For {'B': [4, 5, 6], 'E': [1, 2, 3]}
I wanna get the summ
Just wanna say a quick thanks to all of you here,
Very informative.
Thanks,
On Sun, Oct 9, 2011 at 11:08 AM, Steven D'Aprano wrote:
> Walter Prins wrote:
>
> As for the compiler/interpreter argument, I'll just point out again that
>> actually Python in its various forms can either be compiled
Walter Prins wrote:
As for the compiler/interpreter argument, I'll just point out again that
actually Python in its various forms can either be compiled and/or
interepreted, it depends on you really. For compiled Python flavours, see
for example Cython (http://cython.org/) which provides a way
Hi Lina,
On 8 October 2011 18:18, lina wrote:
> I write mainly critical speed code and large memory code that are meant to
> run as hug jobs over cluster (transportability is an issue;
> my C code is really faster than my Maple code; interpreter language are
> good for development of algorithm
Lina,
Just a couple of comments on the topic of Python vs other languages to add
to what others have said:
On 7 October 2011 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
>
On Sat, Oct 8, 2011 at 11:34 PM, Alan Gauld wrote:
> On 08/10/11 14:17, lina wrote:
>
> You will never say, "Gosh, I wish I knew FEWER programming languages!"
>> Ha Ha ...
>>
>> regarding the python and C, I was told that python is good for interface
>> and others, but slow. and further was su
On Sat, Oct 8, 2011 at 11:34 PM, Alan Gauld wrote:
> On 08/10/11 14:17, lina wrote:
>
> You will never say, "Gosh, I wish I knew FEWER programming languages!"
>> Ha Ha ...
>>
>> regarding the python and C, I was told that python is good for interface
>> and others, but slow. and further was su
On Sat, Oct 8, 2011 at 10:50 PM, Alan Gauld wrote:
> On 08/10/11 11:27, Alan Gauld wrote:
>
> What you want, I think, is to join the original list
>> with spaces(and maybe add a newline for writing to file)
>>
>> summary = ' '.join(summary) + \n
>>
>
> But you need to make the original items stri
On 08/10/11 14:17, lina wrote:
You will never say, "Gosh, I wish I knew FEWER programming languages!"
Ha Ha ...
regarding the python and C, I was told that python is good for interface
and others, but slow. and further was suggested to write the main part
in C and wrapped in python.
The m
On 08/10/11 11:27, Alan Gauld wrote:
What you want, I think, is to join the original list
with spaces(and maybe add a newline for writing to file)
summary = ' '.join(summary) + \n
But you need to make the original items strings first
so it should be:
summary = ' '.join( map(str,summary) ) +
On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld wrote:
> On 08/10/11 04:34, lina wrote:
>
> print(summary) ### output is [1,3,5,6]
>> summary='\n'.join(str(summary)**.split(','))
>>
>
> This line is wrong.
> This is converting summary to a string -> '[1,3,5,6]'
> Then splitting by co
On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld wrote:
> On 08/10/11 04:34, lina wrote:
>
> print(summary) ### output is [1,3,5,6]
>> summary='\n'.join(str(summary)**.split(','))
>>
>
> This line is wrong.
> This is converting summary to a string -> '[1,3,5,6]'
> Then splitting by co
On Sat, Oct 8, 2011 at 4:43 PM, Steven D'Aprano wrote:
> Alan Gauld wrote:
>
>> 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,
>>>
>>
>>
On 08/10/11 04:34, lina wrote:
print(summary) ### output is [1,3,5,6]
summary='\n'.join(str(summary).split(','))
This line is wrong.
This is converting summary to a string -> '[1,3,5,6]'
Then splitting by commas to create a new list -> [ '[1', '3', '5', 6]' ]
Notice the fir
Alan Gauld wrote:
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" cod
On 2011-10-08 09:12, lina wrote:
$ python3 counter-vertically-WORKING.py
[26, 22, 28, 30, 32, 27, 30, 29, 28, 30, 32, 24, 27, 27, 28, 30, 32, 30, 33,
27, 33, 32, 34, 31, 28, 34, 33, 32, 25, 35, 30, 32, 30, 32, 25, 30, 26, 24,
33, 28, 27, 26, 23, 27, 27, 28, 27, 25, 24, 23, 23, 27, 24, 27, 26, 23,
On Sat, Oct 8, 2011 at 2:50 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> 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
On Sat, Oct 8, 2011 at 2:50 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> 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
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
> 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,
>>
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
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
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
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",
> 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
> 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
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
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 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)
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
>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
> 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:
#!/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:]
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
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
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 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
>
> 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 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
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 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
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 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'
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 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 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 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 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 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
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 'B+E':[5,7,9]
You are confusing different things into one question, as if I had asked:
"How
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"
OUTFILEEXT = ".txt"
def dofiles(topdirectory):
for filename in os.listdr(topdirectory):
>
>
> As for splitting into functions, consider:
>
> #these two are capitalized because they're intended to be constant
> TOKENS = "BE"
> LINESTOSKIP = 43
> INFILEEXT = ".xpm"
> OUTFILEEXT = ".txt"
>
> def dofiles(topdirectory):
>for filename in os.listdr(topdirectory):
>processfile(f
On 2011-10-06 16:11, lina wrote:
I still don't know how to (standard) convert the list values to a string.
def writeonefiledata(outname,results):
outfile = open(outname,"w")
for key, value in results.items():
print(value)
outfile.write(str(results[key]))
Is it a wrong
On Thu, Oct 6, 2011 at 4:33 AM, Prasad, Ramit wrote:
> >>yes, you're iterating over the keys of a dictionary. Since it only has
> the key "E", that's what you get. Try printing dir(results) to see what
> methods might return something other than the key. Make the language work
> for you.
>
> >S
On Thu, Oct 6, 2011 at 1:39 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> On 2011-10-06 05:46, lina wrote:
>
>> On Thu, Oct 6, 2011 at 4:33 AM, Prasad,
>> Ramit
>> >wrote:
>>
>>> Dictionaries {} are containers for key/value based pairs like { key :
>>>
>>> value, another_key : v
On Thu, Oct 6, 2011 at 5:18 PM, Alan Gauld wrote:
> On 06/10/11 04:54, lina wrote:
>
> If you use IDLE, the standard IDE that comes with Python, you should
>>find that hitting tab (or pausing briefly) in a file editor will
>>bring up a pick list of options.
>>
>> Just tried the idle-p
On 06/10/11 04:54, lina wrote:
If you use IDLE, the standard IDE that comes with Python, you should
find that hitting tab (or pausing briefly) in a file editor will
bring up a pick list of options.
Just tried the idle-python2.6,
Q1: Is it bound with certain python version, such as
On 2011-10-06 05:46, lina wrote:
On Thu, Oct 6, 2011 at 4:33 AM, Prasad, Ramitwrote:
Dictionaries {} are containers for key/value based pairs like { key :
value, another_key : value(can be same or repeated) }
For example:
{'B': [0, 0, 0, 0, 0, 0], 'E': [2, 1, 4, 0, 1, 0]}
The keys here are
On Thu, Oct 6, 2011 at 2:01 AM, Alan Gauld wrote:
> On 05/10/11 13:46, lina wrote:
>
> another question, you know in linux, when use TAB, can automatically
>> input something,
>> so in python3, are there some way they can intelligent give some hints
>> or fill the left.
>>
>
> What development to
On Thu, Oct 6, 2011 at 4:33 AM, Prasad, Ramit wrote:
> >>yes, you're iterating over the keys of a dictionary. Since it only has
> the key "E", that's what you get. Try printing dir(results) to see what
> methods might return something other than the key. Make the language work
> for you.
>
> >S
>>yes, you're iterating over the keys of a dictionary. Since it only has the
>>key "E", that's what you get. Try printing dir(results) to see what methods
>>might return something other than the key. Make the language work for you.
>Sorry I am not smart. value?
Dictionaries {} are container
On 05/10/11 13:46, lina wrote:
another question, you know in linux, when use TAB, can automatically
input something,
so in python3, are there some way they can intelligent give some hints
or fill the left.
What development tool are you using?
If you use IDLE, the standard IDE that comes with P
> I ask again. What did results look like when you print it out. I'm
> referring to the argument to writeonefiledata().
>
>> def writeonefiledata(outname,**results):
>>
> put the lines here:
>print ("results is: ", results)
>print("repr is:", repr(results))
$ python3 c
On 10/05/2011 08:46 AM, lina wrote:
On Wed, Oct 5, 2011 at 8:21 PM, Dave Angel wrote:
#these two are capitalized because they're intended to be constant
TOKENS = "BE"
LINESTOSKIP = 43
INFILEEXT = ".xpm"
OUTFILEEXT = ".txt"
def dofiles(topdirectory):
for filename in os.listdr(topdirector
On Wed, Oct 5, 2011 at 8:21 PM, Dave Angel wrote:
>
>
>>
>>> #these two are capitalized because they're intended to be constant
>>> TOKENS = "BE"
>>> LINESTOSKIP = 43
>>> INFILEEXT = ".xpm"
>>> OUTFILEEXT = ".txt"
>>>
>>> def dofiles(topdirectory):
>>>for filename in os.listdr(topdirectory):
On 10/05/2011 02:51 AM, lina wrote:
On Wed, Oct 5, 2011 at 1:42 PM, Dave Angel wrote:
On 10/04/2011 11:13 PM, lina wrote:
On Wed, Oct 5, 2011 at 10:45 AM, Dave Angel wrote:
On 10/04/2011 10:22 PM, lina wrote:
On Wed, Oct 5, 2011 at 1:30 AM, Prasad, Ramit
*com
w
SyntaxError: inva
On Wed, Oct 5, 2011 at 1:42 PM, Dave Angel wrote:
> On 10/04/2011 11:13 PM, lina wrote:
>
>> On Wed, Oct 5, 2011 at 10:45 AM, Dave Angel wrote:
>>
>> On 10/04/2011 10:22 PM, lina wrote:
>>>
>>> On Wed, Oct 5, 2011 at 1:30 AM, Prasad, Ramit>>> *com
> w
>
>>>
SyntaxError:
On 2011-10-05 05:13, lina wrote:
$ python3 counter-vertically.py
^^^
File "counter-vertically.py", line 20
print item
^
SyntaxError: invalid syntax
In Python 3 print is a function: print(item)
In another message in this thread you've said:
"Sorry, I am still lac
On 10/04/2011 11:13 PM, lina wrote:
On Wed, Oct 5, 2011 at 10:45 AM, Dave Angel wrote:
On 10/04/2011 10:22 PM, lina wrote:
On Wed, Oct 5, 2011 at 1:30 AM, Prasad,
Ramit
w
SyntaxError: invalid syntax
for fileName in os.listdir("."):
if os.path.isfile(fileName) and os.path.splitext(
On Wed, Oct 5, 2011 at 10:45 AM, Dave Angel wrote:
> On 10/04/2011 10:22 PM, lina wrote:
>
>> On Wed, Oct 5, 2011 at 1:30 AM, Prasad,
>> Ramit
>> >wrote:
>>
>> But I still don't know how to get the
statistic result of each column,
>>> Thanks.
>>> try:
>>>cols = len( text[0] ) # Fi
On 10/04/2011 10:22 PM, lina wrote:
On Wed, Oct 5, 2011 at 1:30 AM, Prasad, Ramitwrote:
But I still don't know how to get the
statistic result of each column,
Thanks.
try:
cols = len( text[0] ) # Find out how many columns there are (assuming
each row has the same number of columns)
except
On Wed, Oct 5, 2011 at 1:30 AM, Prasad, Ramit wrote:
> >But I still don't know how to get the
> >statistic result of each column,
>
> Thanks.
>
> try:
>cols = len( text[0] ) # Find out how many columns there are (assuming
> each row has the same number of columns)
> except IndexError:
>ra
On 04/10/11 18:09, lina wrote:
But I still don't know how to get the
statistic result of each column,
Let's ignore the traversal of files issue for now.
Let's look at processing one file:
You want a list of totals of equal length to the number of columns.
We can find that number using len(line
On 04/10/11 17:38, lina wrote:
For file:
aaEbb
aEEbb
EaEbb
EaEbE
the expected output is
2 1 0 1
I expected
2 1 4 0 1
In the first column there is 2 E, so the output is 2 E, second column is
1 E.
But the 3rd is all E so why miss out the 4?
I'm still confused - and I thought I was gettin
On 10/04/2011 01:09 PM, lina wrote:
But I still don't know how to get the
statistic result of each column,
Thanks for further suggestions,
Best regards,
lina
As I said before, your current code counts across a line at a time,
while you need to count vertically. That could be done by transpo
>But I still don't know how to get the
>statistic result of each column,
try:
cols = len( text[0] ) # Find out how many columns there are (assuming each
row has the same number of columns)
except IndexError:
raise # This will make sure you can see the error while developing;
But I still don't know how to get the
statistic result of each column,
Thanks for further suggestions,
Best regards,
lina
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tut
On Wed, Oct 5, 2011 at 12:59 AM, Marc Tompkins wrote:
> On Tue, Oct 4, 2011 at 8:48 AM, lina wrote:
>
>> if os.path.isfile(fileName) and os.path.splitext(fileName)[1]==".xpm":
>> filedata = open(fileName)
>> text=filedata.readlines()
>> for line in text[0:]:
>>
On Tue, Oct 4, 2011 at 8:48 AM, lina wrote:
> if os.path.isfile(fileName) and os.path.splitext(fileName)[1]==".xpm":
> filedata = open(fileName)
> text=filedata.readlines()
> for line in text[0:]:
> result.append({t:line.strip().count(t) for t in tokens})
>
For file:
aaEbb
aEEbb
EaEbb
EaEbE
the expected output is
2 1 0 1
In the first column there is 2 E, so the output is 2 E, second column is 1
E.
#!/bin/python
import os.path
tokens=['B','E']
for fileName in os.listdir("."):
result=[]
if os.path.isfile(fileName) and os.path.splitext(f
On 10/04/2011 10:26 AM, lina wrote:
On Thu, Sep 29, 2011 at 11:28 PM, Dave Angel wrote:
(Please don't top-post. Put your remarks AFTER the part you're quoting
from the previous message)
On 09/29/2011 10:55 AM, lina wrote:
import os.path
tokens=['E']
result=[]
for fileName in os.listdir(
On Tue, Oct 4, 2011 at 11:27 PM, Dave Angel wrote:
> On 10/04/2011 10:26 AM, lina wrote:
>
>> On Thu, Sep 29, 2011 at 11:28 PM, Dave Angel wrote:
>>
>> (Please don't top-post. Put your remarks AFTER the part you're quoting
>>> from the previous message)
>>>
>>>
>>> On 09/29/2011 10:55 AM, lina
On Thu, Sep 29, 2011 at 11:28 PM, Dave Angel wrote:
> (Please don't top-post. Put your remarks AFTER the part you're quoting
> from the previous message)
>
>
> On 09/29/2011 10:55 AM, lina wrote:
>
>> import os.path
>>
>> tokens=['E']
>> result=[]
>>
>> for fileName in os.listdir("."):
>> if
Hi Alan,
On 29 September 2011 18:12, Alan Gauld wrote:
> On 29/09/11 17:00, Walter Prins wrote:
>
> email. By the way, a question to the list adminstrators: why does the
>> default reply to address for this mailing list not default to the
>> mailing list?
>>
>
> This is an oft debated issue an
>This is an oft debated issue and there are arguments for both options.
>The current setup allows easier replies to either originator or list by
>simply selecting which Reply button you use. If you set default reply to
>the list how do you reply to just the originator when you want to?
I would h
On 29/09/11 17:00, Walter Prins wrote:
email. By the way, a question to the list adminstrators: why does the
default reply to address for this mailing list not default to the
mailing list?
This is an oft debated issue and there are arguments for both options.
The current setup allows easier r
On 29/09/11 15:22, lina wrote:
I want to read a bunch of *.doc file in present working directory,
What format are the doc files?
If they are word processor files they may well be in binary format so
you will need to either decode them (using struct?) or find a module
that can read them, or a
On Fri, Sep 30, 2011 at 12:31 AM, Walter Prins wrote:
> Hi,
>
> On 29 September 2011 17:07, lina wrote:
>
>> I found one thing a bit weird, Here is the one:
>>
>> import os.path
>>
>> tokens=['E']
>> result=[]
>>
>> """
>> for fileName in os.listdir("."):
>> if os.path.isfile(fileName) and o
Hi,
On 29 September 2011 17:07, lina wrote:
> I found one thing a bit weird, Here is the one:
>
> import os.path
>
> tokens=['E']
> result=[]
>
> """
> for fileName in os.listdir("."):
> if os.path.isfile(fileName) and os.path.splitext(fileName)[1]==".xpm":
> """
> filedata = open("1.xpm")
>
On Thu, Sep 29, 2011 at 11:57 PM, Walter Prins wrote:
> Hi,
>
> On 29 September 2011 16:39, lina wrote:
>
>>
>> Or you can get lines 24-28, with text[24, 29] (look up slices in the
>>> Python doc)
>>>
>>
> Dave probably meant: text[24:29]
>
>
>
>> >>> print splitext.__doc__
>> Traceback (mos
Hi,
On 29 September 2011 16:39, lina wrote:
> Traceback (most recent call last):
> File "", line 1, in
> NameError: name 'slices' is not defined
>
Sorry I meant to include a link to relevant documentation:
http://docs.python.org/tutorial/introduction.html
(And apologies for forgetting to re
Hi,
On 29 September 2011 16:39, lina wrote:
>
> Or you can get lines 24-28, with text[24, 29] (look up slices in the
>> Python doc)
>>
>
Dave probably meant: text[24:29]
> >>> print splitext.__doc__
> Traceback (most recent call last):
> File "", line 1, in
> NameError: name 'splitext'
Or you can get lines 24-28, with text[24, 29] (look up slices in the Python
doc)
>>> print splitext.__doc__
Traceback (most recent call last):
File "", line 1, in
NameError: name 'splitext' is not defined
>>> print slices.__doc__
Traceback (most recent call last):
File "", line 1, in
Na
On Thu, Sep 29, 2011 at 11:28 PM, Dave Angel wrote:
> (Please don't top-post. Put your remarks AFTER the part you're quoting
> from the previous message)
>
>
> On 09/29/2011 10:55 AM, lina wrote:
>
>> import os.path
>>
>> tokens=['E']
>> result=[]
>>
>> for fileName in os.listdir("."):
>> if
(Please don't top-post. Put your remarks AFTER the part you're quoting
from the previous message)
On 09/29/2011 10:55 AM, lina wrote:
import os.path
tokens=['E']
result=[]
for fileName in os.listdir("."):
if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
fileda
On Thu, Sep 29, 2011 at 11:18 PM, Walter Prins wrote:
>
>
> On 29 September 2011 16:13, lina wrote:
>
>> mport os.path
>>
>> tokens=['E']
>> result=[]
>>
>> for fileName in os.listdir("."):
>> if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
>> filedata = open(fileN
On 29 September 2011 16:13, lina wrote:
> mport os.path
>
> tokens=['E']
> result=[]
>
> for fileName in os.listdir("."):
> if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
> filedata = open(fileName,'r')
>
> text=filedata.readlines()
> for line in te
mport os.path
tokens=['E']
result=[]
for fileName in os.listdir("."):
if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
filedata = open(fileName,'r')
text=filedata.readlines()
for line in text:
print line
why here I print nothing out?
The
On Thu, Sep 29, 2011 at 10:55 PM, lina wrote:
> import os.path
>
> tokens=['E']
> result=[]
>
>
> for fileName in os.listdir("."):
> if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
> filedata = open(fileName)
> text=filedata.readlines()
> for line in
1 - 100 of 105 matches
Mail list logo