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 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 2011-10-05 21:29, Anna Olofsson wrote:
vcf file: 2 rows, 10 columns.
The important column is 7 where the ID is, i.e.
refseq.functionalClass=missense. It's a missense mutation, so then I
want to extract refseq.name=NM_003137492, or I want to extract only
the ID, which in this case is NM_003137
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 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 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
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
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 2011-10-08 09:53, Peter Otten wrote:
Emad Nawfal (عمـ نوفل ـاد) wrote:
Here is the function as I used it, and it works fine:
def swap(sentence):
buffer = []
adjectives = []
for word in sentence.split():
if word.endswith('/ADJ'):
adjectives.append(word)
On 2011-10-08 11:11, Andreas Perstinger wrote:
def swap(sentence):
s = sentence.split()
for i in reversed(range(len(s))):
if s[i].endswith("/N") and s[i-1].endswith("/ADJ"):
s[i], s[i-1] = s[i-1], s[i]
return s
Oops, noticed a littl
On 2011-10-09 07:16, col speed wrote:
The part of the script that is causing the problem is as follows:
def point(num):
while True:
raw_input("Roll")
uno, dos = random.choice(dice), random.choice(dice)
three = uno+dos
print "{0} + {1} = {2}".format(uno, d
On 2011-10-09 08:25, col speed wrote:
Thanks for your prompt reply! Here's the whole thing:
import random
message = """Welcome to craps Place your bet
and roll the dice.
7 or 11 wins.
2, 3 or 12 loses.
Others are "point"."""
player = "
On 2011-10-12 05:31, lina wrote:
I tried to write one (not working one) as below, so many problems here.
Just some quick remarks:
#!/usr/bin/python3
import os.path
LINESTOSKIP=0
CHAINID="CDEFGHI"
INFILENAME="pdbone.pdb"
DICTIONARYFILE="itpone.itp"
mapping={}
valuefromdict={}
def sortfile()
On 2011-10-12 10:27, lina wrote:
$ python3 map-to-itp.py
{'O4': '2', 'C19': '3', 'C21': '1'}
{'C': '3'}
{'C': '2'}
{'C': '1'}
for print(mapping) part, {'O4': '2', 'C19': '3', 'C21': '1'} the value
doesn't keep the 1, 2, 3 order any more.
That's fine, because "mapping" is a dictionary which h
On 2011-10-13 15:09, lina wrote:
$ python3 map-to-itp.py
{'O4': '2', 'C19': '3', 'C21': '1'}
C
Traceback (most recent call last):
File "map-to-itp.py", line 55, in
sortfile()
File "map-to-itp.py", line 17, in sortfile
sortoneblock(chainid,intext,OUTFILENAME)
File "map-to-itp.py
On 2011-10-24 20:04, Johan Martinez wrote:
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value.
s = "First"
print s.__class__
print s
First
s = "Second"
print s
Second
Dave, Sander and Wayne
On 2011-10-28 20:45, Eric Schles wrote:
The help steven gave me makes sense, except I don't know what it means. How
do you run the command as root?
When I try to run the command in the command line, I get the following
error:
C:\>easy_install SQLObject
'easy_install' is not recognized as an inte
On 2011-11-01 06:31, Rinu Boney wrote:
def add_book(b):
fo=open('books.dat','wb')
pickle.dump(b,fo)
fo.close()
The Display After Unpickling Shows only the last Class Instance.
How To Display All The Data In The File ?
You haven't shown us the complete program (how to you call "a
On 2011-11-04 20:59, Albert-Jan Roskam wrote:
It seems that you are not opening the file properly. You could do
f = file('///Users/joebatt/Desktop/python3.txt','r')
or:
withfile('///Users/joebatt/Desktop/python3.txt','r') as f:
OP is using Python 3, where "file" is removed. Thus, you have to us
On 2011-11-10 09:26, lina wrote:
atoms=[]
def fetchonefiledata(infilename):
for line in open(infilename,"r"):
parts=line.strip().split()
atoms=parts[2]
print(atoms[0])
First you define "atoms" as an empty list, but in the line
atoms
On 2011-11-10 21:54, Cranky Frankie wrote:
What is the easiest way in Python 3.x to write output positionally?
For example I have one literal I want in column 1, the next one in
column 40, the third one in column 50. I've tried usings tabs and I'm
not getting what I want. Is it something to do wi
On 2011-11-11 05:14, lina wrote:
def LongestCommonSubstring(S1, S2):
M = [[0]*(1+len(S2)) for i in xrange(1+len(S1))] ## creat 4*5 matrix
longest, x_longest = 0, 0
for x in xrange(1,1+len(S1)): ## read each row
for y in xrange(1,1+len(S2)): ## r
First, just a little rant :-)
It doesn't help to randomly change some lines or introduce some new
concepts you don't understand yet and then hope to get the right result.
Your chances are very small that this will be succesful.
You should try to understand some basic concepts first and build on
Please just post plain-text (no html) and use a meaningful subject!
On 2011-11-11 22:40, Nic Jaworski wrote:
def calc(days):
n=0
d=1
while n>days:
n+1
d**(n)
d*2
You are just calculating some expressions with "n" and "d" but you don't
assign the results. Thus "n" and "d" wil
On 2011-11-12 05:16, Nathaniel Trujillo wrote:
They gave me a website to go and download a version of
livewires that would work (www.courseptr.com/downloads) and I went there
but I could not find that download anywhere.
http://www.delmarlearning.com/companions/content/1435455002/downloads/index
On 2011-11-12 10:33, Alan Gauld wrote:
On 11/11/11 22:17, Andreas Perstinger wrote:
I don't know about windows but if you want to run the script from the
command line you have to add:
if __name__ == "__main__":
main()
No, you only need to do that if you plan on usin
On 2011-11-12 16:24, lina wrote:
Thanks, ^_^, now better.
No, I'm afraid you are still not understanding.
I checked, the sublist (list) here can't be as a key of the results (dict).
"result" isn't a dictionary. It started as an empty list and later
becomes a null object ("NoneType").
You
On 2011-11-11 14:44, lina wrote:
You are right, I did not think of this parts before. and actually the
initiative wish was to find possible paths, I mean, possible
substrings, all possible substrings. not the longest one, but at
least bigger than 3.
I had some time today and since you have chan
On 2011-11-11 16:53, Jerry Hill wrote:
There's nothing wrong with writing your own code to find the longest common
substring, but are you aware that python has a module in the standard
library that already does this? In the difflib module, the SequenceMatcher
class can compare two sequences and
On 2011-11-23 05:15, Chris Kavanagh wrote:
I was going over one of Derek Banas' tutorials on youtube, and came
across something I hadn't seen before. A variable with a list beside it
(see code below). He sets the variable, customer , equal to a dict. Then
uses the variable with ['firstname'],['la
On 2011-11-25 13:40, lina wrote:
On Fri, Nov 25, 2011 at 7:19 PM, Steven D'Aprano wrote:
f = open("some file")
dehydrons = {}
occurrence = {}
pairs = {}
for line in f.readlines():
parts = line.split()
# convert to ints
parts = [int(s) for s in parts]
pair = frozenset(pa
On 2011-11-25 14:46, stm atoc wrote:
Here is the new version of the program:
zvalues = [-200] # starting value
hvalues = [10] # starting value
increments = [1, 1, 1, 1, 1, 1, 1, 1]
for N in increments:
h = hvalues[-1] - N
hvalues.append(h)
z = zvalues[-1] + h
zv
On 2011-11-26 03:49, lina wrote:
for k, v in occurence.items():
print(v,k)
292 frozenset({66, 69})
222 frozenset({24, 27})
How can I let the result like:
292 {66,69}
222 {24,27}
don't output the frozenset
If you want to use your own output format you have to provide
On 2011-11-27 17:58, Mic wrote:
Say that I want to try and open 10 files. If none of these exists, I want an
error
message to appear. But only if NONE of these files exists.
I know how to handle this with one file. But I don't know how to do that
with more than one.
So the program should try and
On 2011-11-27 21:45, Deanna Wilson wrote:
Project 4: Parsing rhinoceros sightings
Please confirm that this is homework. At least I've found this site:
https://www.e-education.psu.edu/geog485/node/144
[snip]
sample of my code:
What are your problems?
I've skimmed your sample and found a nu
On 2011-11-27 23:17, myles broomes wrote:
#get the users input for the list of words, one by one
first_word = input("Please enter your first word: ")
second_word = input("Please enter your second word: ")
third_word = input("Please enter your third word: ")
fourth_word = input("Please enter your
[Please reply to the list. Your indentation also got lost during the
mail delivery.]
On 2011-11-27 23:21, Deanna Wilson wrote:
Yes it is homework, but not from Penn state. It is a Geog690 class. I'm
having difficulties with determining where the rhino is referenced in the
split line, determinin
On 2011-11-28 13:22, surya k wrote:
I am building a multiplayer game (Game:Bingo) where friends(players)
connect over internet. In this particular game, users sends a
"character/ number" to all other players..
Can you please shed some light on it. I've been looking into 'Core
Python Programming'
[Please don't top-post. Put your answers below the text you cite.]
On 2011-12-01 09:01, stm atoc wrote:
The output of the print len(Conc[0]), len(z) is 100 3600.
Now I changed Conc[0] to Conc[1], and the output is: 100 100
So, you've changed the line
print len(Conc[0]), len(z)
to
print len(
[Still top-posting :-( ]
On 2011-12-01 11:13, stm atoc wrote:
Well, I did also change the line in the python script to this:
plot(Conc[0],z,'r-',label='initial')
plot(Conc[1],z,'b-',label='after 20s')
to see both Conc[0] and [1].
And did it work?
I will send the output data attaches to thi
On 2011-12-01 14:30, stm atoc wrote:
With your help, I have a good script from the previous discussion:
**
from pylab import *
Have you used MATLAB before and are used to its syntax? In general "star
imports" (from xxx import *) are a bad practice and IMHO should be avoided.
import
On 2011-12-01 19:20, stm atoc wrote:
Thanks for all information/websites and advice. Yes the graph is
exactly like the one you mentioned. Also, I would like to have them in
one not two, but I think since the dimension of the x and y are not
same, I have no choice.
What I like to do now is comp
On 2011-12-02 08:22, Michael Hall wrote:
I am still not understanding what it is I am being asked to do.
Ok, forget about your working program and just concentrate on question 1a):
> # a) write a function, getDivisors(), that returns a list of all
> # of the positive divisors of a given number
On 2011-12-02 00:30, Charles Karl Becker wrote:
So the main thing I'm looking for are pointers on how I could
optimize/refactor this, and any resources on this and how to 'think'
more in the right way for this type of thing. Also, please let me
know what's good about it :P
def build_line(part):
On 2011-12-07 19:31, Christopher Spears wrote:
I do need to be able to save the chart as an image file, so it can be
linked to the wiki. My only complaint about matplotlib is that I
have not figured out a way to save a graph as an image using a python
script.
You can save a graph with "matplot
On 2011-12-09 20:46, Alan Gauld wrote:
On 09/12/11 19:24, Alan Gauld wrote:
In February 1991, after just over a year of development, I decided to
post to USENET. The rest is in the Misc/HISTORY file.
=
Hopefully that clarifies rather than condfusing! :-)
The H
On 2011-12-10 18:12, Alan Gauld wrote:
On 10/12/11 16:29, Andreas Perstinger wrote:
Hmm, I just went to check the HISTORY file and I can't find it.
It used to come with the source tarball, but I haven't downloaded
the source for years!...
http://hg.python.org/cpython/file/e3
On 2011-12-10 20:22, Walter Prins wrote:
Is the example wrong, or is this something to do with how Windows
handles stdout that is causing this not to work as designed? I am
using Python 3.2 on Windows Vista Home Premium.
It seems the example may be wrong -- the __exit__ method, as stated
by th
On 2011-12-23 12:02, lina wrote:
for i in range(len(result)):
for j in range(len(result[i])):
print(result[i][j])
still have a little problem about print out,
I wish to get like
a a
b b
c c
which will show in the same line,
not as
a
b
c
a
b
c
So you wish to print a
On Wed, 8 Feb 2012 23:54:58 -0800 (PST) ken brockman
wrote:
> I'm back on the list again, and if not too late, here is the asked
> for trace. i've managed to replicate the original error msg, by
> removing the pickled file Genfacts.p, from the directory.
> Traceback (most recent call last):
> File
On Sun, 12 Feb 2012 21:31:57 +0800
daedae11 wrote:
> The code is:
> from nntplib import NNTP
> s = NNTP('news.gmane.org')
> resp, count, first, last, name = s.group
> ('gmane.comp.python.committers') print 'Group', name, 'has', count,
> 'articles, range', first, 'to', last resp, subs = s.xhdr('su
[You've forgot to include the list in your reply]
On Mon, 13 Feb 2012 00:04:54 +0800 daedae11 wrote:
> Sorry, I'm not sure I know your viewpoint. Could you give me a
> detailed explanation about "you need more than about 6-7 seconds (on
> my computer) to type the third line."? Thank you very muc
On 2012-02-23 01:59, Saad Javed wrote:
I am learning python and need guidance for writing some code. I've written
a simple program (with pointers from people) that parses an tv show xml
feed and prints their values in plain text after performing some string
operations.
[CODE]feed = urllib.urlope
On Thu, 12 Apr 2012 09:06:53 -0700
Michael Lewis wrote:
> Here's the "pattern" portion that I don't understand:
>
> re.findall("[^A-Z]+[A-Z]{3}([a-z])[A-Z]{3}[^A-Z]+"
>
You have 5 different parts here:
1) [^A-Z]+ - this matches one or more non-uppercase characters.
The brackets [] describe a
On 2012-04-14 17:46, Karim Gorjux wrote:
But I can't get any of these forms! I need the first form so I tried
br.select_form(nr=0)
but I get None!
With "br.select_form()" you set the current form which is accessible
through the "br.form" attribute. The method itself doesnt't return
anything
On 2012-04-19 21:51, James Stauble wrote:
I have seen in a few places where this means my program is essentially in an
endless loop, but as far as I can see it is formatted correctly. Any help would
be greatly appreciated. Thanks in advance.
[snip]
#This function gets the tip which will be ad
On Mon, 21 May 2012 13:04:26 -0700
Jeremy Traurig wrote:
> I have already tried creating a numpy array of integers using this
> code:
>
> import time
> time_format = %m/%d/%Y %H:%M:%S
> for x in range(len(datetime_IN)):
> junk = time.strptime(datetime[x],time_format)
> junk2 = [y for y i
On Tue, 12 Jun 2012 09:07:13 +0100
Bod Soutar wrote:
> C:\>python cheatsheet.py --list
> done
> here?
> Traceback (most recent call last):
> File "cheatsheet.py", line 167, in
> main()
> File "cheatsheet.py", line 165, in main
> ca.parseArgs()
> File "cheatsheet.py", line 39, in p
On Sun, 24 Jun 2012 18:11:10 +0200
David wrote:
> I have a list that I wish to reorganise into fewer list items.
> What happens is that some of the items belong together:
> not ['keine', 'Antwort'] but ['Keine Antwort'].
>
> I am not aware of any list methods that can help me here, and would
>
On 22.08.2012 03:39, Ray Jones wrote:
Does anyone know of a link to a really good tutorial that would help me
with subprocess.Popen? a tutorial that uses really small words and more
examples than explanation? After 15 years of scripting, I'm ashamed to
say that I'm still not all that familiar wit
[Please don't send HTML to this list. Just use plain text]
On 09.01.2013 07:56, ken brockman wrote:
I was looking through some lab material from a computer course
offered at UC Berkeley and came across some examples in the form of
questions on a test about python. 1 and 2 and 3 answer 3 I've gog
On 16.01.2013 01:23, Scurvy Scott wrote:
> After playing with your example I keep being told that list has no
> attribute int_to_note. I know what the problem is, I just don't know
> how to fix it.
[SNIP]
> So right now my code is:
>
> import mingus.core.notes as notes
On 20.01.2013 00:27, Polo Heysquierdo wrote:
I'm getting the following error on my script for conky.
"Traceback (most recent call last):
File "/home/troll/.gmail/gmail.py", line 1, in
import urllib.request
ImportError: No module named request"
What's your python version?
(Type "python
Please use a meaningful subject.
On 22.03.2013 13:37, Arijit Ukil wrote:
I have the following data points.
data = [1,2,0,9,0,1,4]
I like to store in an array and print the odd-indexed points, i.e. 2, 9,1
(considering index starts at 0)
You can simply slice your list:
>>> data = [1, 2, 0, 9, 0
Sayan Chatterjee wrote:
>I know this error occurs when one tries to multiply a string with a
>fraction i.e float. In my case , I can't figure out how can a numpy
>floating point array be a string.
The problem is not that the numpy array is a string but that you append
the array to a python list:
On 28.05.2013 19:25, sparkle Plenty wrote:
I need to catch and handle 10057 exceptions when they occur and keep
running. I know 10057 is a WinError, which is a subset of OSError, I
just can't find the right syntax for it. I would appreciate some
help on this one.
I have neither Windows nor Py
On 28.05.2013 21:37, sparkle Plenty wrote:
If I use an if statement, I cannot use continue after I do my error
handling, so I am really trying to use the except errorname: instead of an
if statement.
I think you haven't understood the code snippet I've posted. The
if-statement is inside the ex
On 29.05.2013 05:20, Jim Mooney wrote:
On 28 May 2013 19:34, Steven D'Aprano wrote:
The standard method for assembling a string from a collection
of substrings is to do it in one go, using the join method,
Wow, that means I can do this: print ''.join('But this parrot is dead!')
But why
On 01.06.2013 07:47, Sarma Tangirala wrote:
I had a quick question on how string compare works. If did '1001' <= '999'
I get true. I know how the string compare works but I was wondering why it
were so. Why doesn't the string length factor into the comparison?
Because usually you are interested
On 13.06.2013 17:09, Albert-Jan Roskam wrote:
I have a string of the form "required optional3 optional2 optional1
optional3" ('optional' may be any kind of string, so it's not simply
'optional\d+'.
I would like to use a regex so I can distinguish groups. Desired
outcome: ('required', 'optional3',
On 14.06.2013 10:48, Albert-Jan Roskam wrote:
I am trying to create a pygments regex lexer.
Well, writing a lexer is a little bit more complex than your original
example suggested.
> Here's a simplfied example of the 'set' command that I would like to
> parse.
s = 'set workspace = 6148 he
Jim Mooney wrote:
>When I try to get the keys of a dictionary, such as d.keys(), I get
>the below instead of a plain list, and it's not very usable. How can I
>use the keys from this like it was a list, or is this basically
>useless other than to see the keys or values?
If you really need a list
On 16.06.2013 19:21, Jim Mooney wrote:
Speaking of which, I put "Python class hierarchy" in Google but just
got a bunch of specific wheeze. What I want is a
list of the whole tree. Is there such, or a way I can generate it?
I'm not sure if that's what you are looking for but the language
refer
On 09.10.2013 00:37, Alan Gauld wrote:
On 08/10/13 19:33, Rabah Abdallah wrote:
Hi
I am using dive in python book to to learn python programing languege on mac
in one of the examples is odbchelper imported but when i start debugging I
recieved
ImportError: No module named odbchelper
ODBC
On 31.10.2013 04:00, bob gailer wrote:
On 10/30/2013 1:08 PM, Peter O'Doherty wrote:
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element
excedes a certain value.
import itertools
series =
Anton Gilb wrote:
>Not sure what I'm doing wrong, here are the problems and what I have
>for answers so far.
You should tell us what's wrong with your solutions.
Do you get an error? Then please show us the complete traceback (error
message).
Does your code something else than you expect? Then
Rafael Knuth wrote:
>I am trying to figure out how exactly variables in nested loops are
>generated, and don't get it 100% right yet. Here's my code:
Maybe it's easier if you look at a simpler example like:
for i in range(4):
for j in range(4):
print("i: {}, j: {}".format(i, j))
Do
On 16.12.2013 09:49, Rafael Knuth wrote:
That's the tiny little detail I am confused about: What does return
exactly do? Does it return only the first value within a loop or does
it iterate through all values within a loop? (unless a given condition
is met)
The return statement has nothing to d
[Please don't top-post and trim the quoted message to the essential.
See http://www.catb.org/~esr/jargon/html/T/top-post.html ]
Amrita Kumari wrote:
>My data file is something like this:
>
[SNIP]
>can you suggest me how to produce nested dicts like this:
[SNIP]
What's the current version of your
Gabriele Brambilla wrote:
>it's because my problem is not so simple:
>imagine that in a100 contains not integer sorted in a good way but a
>random float numbers.
>How could I display only one item every 10?
You can provide a step size if you slice a list:
>>> l = list(range(10))
>>> l[0:10:2]
[0
82 matches
Mail list logo