On Fri, 15 Oct 2010 03:09:57 pm Colleen Glaeser wrote:
[...]
> So far, my program is as follows:
>
> Data = [[3,1],[4,3],[6, 4],[7, 6],[8, 8],[9, 8]]
>
> def X():
> accX = 0
> for item in Data:
> [x,y] = item
> accX = accX + x
> print (accX)
I see four problems with thi
"Colleen Glaeser" wrote
I am in a beginning-level computer science class in college
and am running into problems with an assignment.
Because its homework we can't give you a fiull solution
but can give hints so...
The regression line is then given by
where m and b may be obtained by
BTW, the error message my program gives me for the B and M functions is:
Traceback (most recent call last):
File "I:\Lab 7 wierd stat data.py", line 49, in
B()
File "I:\Lab 7 wierd stat data.py", line 44, in B
((Y() * Q()) - (P() * X())) / ((6 * Q()) - (X()**2))
TypeError: unsupported
Dear tutors,
I am in a beginning-level computer science class in college and am running
into problems with an assignment.
The assignment is as follows:
Statisticians are fond of drawing regression lines. In statistics and other
fields where people analyze lots of data, one of the most commonly
>>> But what if I want it to serve one client, go to another and then go back.
>>> How does that work?
>
> You do some I/O multi-plexing or multi-processing/threading.
>
> You might want to do some reading on this.
The very last example on http://docs.python.org/library/socketserver.html may
he
On 10/14/10, Steven D'Aprano wrote:
> On Fri, 15 Oct 2010 01:30:56 pm Alex Hall wrote:
>> Hi all,
>> Alright: after a few months letting it rest, I am trying this
>> Battleship thing again. I found a p2p library (attached) and have
>> tried to implement it (p2p.py). However, I am always getting th
On Fri, 15 Oct 2010 01:30:56 pm Alex Hall wrote:
> Hi all,
> Alright: after a few months letting it rest, I am trying this
> Battleship thing again. I found a p2p library (attached) and have
> tried to implement it (p2p.py). However, I am always getting the same
> error: errno2: no connection could
Hi all,
Alright: after a few months letting it rest, I am trying this
Battleship thing again. I found a p2p library (attached) and have
tried to implement it (p2p.py). However, I am always getting the same
error: errno2: no connection could be made because the target machine
actively refused it.
I
On Fri, 15 Oct 2010 05:19:57 am Sander Sweers wrote:
> So you want convert string u'1,2,3,4' to a list of ints [1,2,3,4]?
> Then the below will work.
>
> [int(n) for n in u'1,2,3,4'.replace(',', '')]
That will break if you have u'100,2,3,4'.
Better is:
>>> s = '1, 200 , -3,4' # or whatever
>>
On Fri, 15 Oct 2010 04:43:46 am David Hutto wrote:
> Fixed with:
>
> self.lines = self.newplot.plot(eval(self.plot))
Anytime you use eval, chances are that it isn't fixed at all, but just
badly and dangerously papered over.
I really, really wish that eval and exec weren't built-ins. They're
po
On Fri, Oct 15, 2010 at 11:22 AM, chris wrote:
>> But what if I want it to serve one client, go to another and then go back.
>> How does that work?
You do some I/O multi-plexing or multi-processing/threading.
You might want to do some reading on this.
cheers
James
--
-- James Mills
--
-- "Pro
On 10/14/2010 12:49 PM, Evert Rol wrote:
Hi Chris,
Bit hard to comment on the actual code, as it was in attachments, but the
important bit is here:
class Handler(SocketServer.BaseRequestHandler): #the handler
'''A handler which calls %s in the handle method.'''%handle_func
"David Hutto" wrote
it's not necessary to worry about insertion of data other than my
own
inputs.
But can you be sure that you won't accidentally mistype something
that eval can read as valid code but that does something unexpected
- even if its only throw an apparently bizarre error dump a
"David Hutto" wrote
In other words I needed (1,2,3,4) not u'(1,2,3,4)' to be inserted
for variable self.plot
You appear to be making this much more difficult than it needs to be.
The values you retrieve from the database are strings (forget about
the unicode aspect its not really relevant he
On Thu, Oct 14, 2010 at 6:43 PM, Alan Gauld wrote:
>
> "Roelof Wobben" wrote
>
>
>
> print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
>>
>> So I thought that this would be the same :
>>
>> for p in zpp:
>> test = zf.getinfo(p).comment
>> print ''.join(test)
>>
>> But it see
"Roelof Wobben" wrote
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
print ''.join(test)
But it seems not to work
Can anyone explain why not ?
Because it's not the same. test
Hey all,
It's mostly solved. The program prints out to the screen just fine except
for the new line return. Here is what I ended up using:
#Merges two files into one using dictionaries
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals in g
I sent both emails and may have confused things:
1. PIDS.has_key(ID) returns True/False. you need to make sure the dictionary
has the key before you fetch PIDS[NotAKey] and get a KeyError.
2. line.split() splits at and removes whitespace, leaving commas.
line.split(",") splits at and removes comma
On 14/10/10 20:33, David Hutto wrote:
On Thu, Oct 14, 2010 at 3:31 PM, David Hutto wrote:
On Thu, Oct 14, 2010 at 3:24 PM, Adam Bark wrote:
On 14/10/10 20:21, David Hutto wrote:
On Thu, Oct 14, 2010 at 2:58 PM, Adam Barkwrote:
Actually, I needed
On Thu, Oct 14, 2010 at 3:31 PM, David Hutto wrote:
> On Thu, Oct 14, 2010 at 3:24 PM, Adam Bark wrote:
>> On 14/10/10 20:21, David Hutto wrote:
>>>
>>> On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark wrote:
>>>
> Actually, I needed it to be converted to something without a string
> atta
On Thu, Oct 14, 2010 at 3:24 PM, Adam Bark wrote:
> On 14/10/10 20:21, David Hutto wrote:
>>
>> On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark wrote:
>>
>>>
Actually, I needed it to be converted to something without a string
attached to it. See a post above, and it was fixed by eval(),
To take a string of comma separated integers and convert to a list of
floats:
>>> x = u'1,2,3,4'
>>> y = x.split(',')
>>> z = [float(f) for f in y]
>>> z
[1.0, 2.0, 3.0, 4.0]
>>>
--
Joel Goldstick
___
Tutor maillist - Tutor@python.org
To unsubscribe
On Thu, Oct 14, 2010 at 3:02 PM, Sander Sweers wrote:
> On 14 October 2010 20:29, David Hutto wrote:
>> Actually, I needed it to be converted to something without a string
>> attached to it. See a post above, and it was fixed by eval(),
>
> Using eval is a big security risk and is generally not r
On 14/10/10 20:21, David Hutto wrote:
On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark wrote:
Actually, I needed it to be converted to something without a string
attached to it. See a post above, and it was fixed by eval(),
Thanks though. And I'm sure at some point this morning in a moment of
On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark wrote:
> On 14/10/10 19:29, David Hutto wrote:
>>
>> On Thu, Oct 14, 2010 at 2:19 PM, Sander Sweers
>> wrote:
>>
>>>
>>> On 14 October 2010 16:14, David Hutto wrote:
>>>
(u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>
Adam,
I am going to try and sort through the pseudocode you provided to see if
I can get things up and running that way has well. This a part of a larger
workflow thing and needs to be in the format that I have. Sticking all this
into a database is down the road a ways.
*for every line in ONE:
Emile,
I modified the code to this:
for line in xml:
ID = line.split()[1]
rslt = "%s,%s"% (line,PIDS[ID])
print rslt
and ended up with this error:
Traceback (most recent call last):
File "/Users/ara/Desktop/biopy_programs/merge2.py", line 16, in
rslt = "%s,%s"% (line,PIDS[ID])
Ke
On 14 October 2010 21:02, Sander Sweers wrote:
> If you really want (you really don't) to use eval() then at least use
Oops, hit send to soon. "(you really don't)" should have been "(you
really don't need to use it)".
Greets
Sander
___
Tutor maillist
On 14 October 2010 20:29, David Hutto wrote:
> Actually, I needed it to be converted to something without a string
> attached to it. See a post above, and it was fixed by eval(),
Using eval is a big security risk and is generally not recommended for
any production code. What do you think eval() r
On 14/10/10 19:29, David Hutto wrote:
On Thu, Oct 14, 2010 at 2:19 PM, Sander Sweers wrote:
On 14 October 2010 16:14, David Hutto wrote:
(u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
Which is a tuple of unicode strings. From this I
need to place portions o
Whoops:
1) dictionary.has_key() ???
2) I don't know if it's a typo or oversight, but there's a comma in you
dictionary key, line.split(',')[0].
3) Forget the database if it's part of a larger workflow unless your job is
to adapt a biological workflow database for your lab.
On Thu, Oct 14, 2010
Either way; nest the for loops and index with protein IDs or dictionary one
file and write the other with matches to the dictionary:
non-python pseudocode:
for every line in TWO:
get the first protein ID
for every line in ONE:
if the second protein ID is the same as the first:
On Thu, Oct 14, 2010 at 2:19 PM, Sander Sweers wrote:
> On 14 October 2010 16:14, David Hutto wrote:
>> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>>
>> Which is a tuple of unicode strings. From this I
>> need to place portions of the tuple into other fields,
>> but n
On 14 October 2010 16:14, David Hutto wrote:
> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>
> Which is a tuple of unicode strings. From this I
> need to place portions of the tuple into other fields,
> but not as unicode strings, but literals no ''.
>
> For example if
On Thu, Oct 14, 2010 at 11:16 AM, David Hutto wrote:
> On Thu, Oct 14, 2010 at 10:14 AM, David Hutto wrote:
>> Hey Buddy Pals,
>>
>> I receive the following output from a sqlite db
>>
>> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>>
>> Which is a tuple of unicode stri
Hi Chris,
Bit hard to comment on the actual code, as it was in attachments, but the
important bit is here:
class Handler(SocketServer.BaseRequestHandler): #the handler
'''A handler which calls %s in the handle method.'''%handle_func
def handle(self): #the handle method
On 14-Oct-10 08:32, ALAN GAULD wrote:
gzip - aka gunzip GNU opensource version - probably your best bet.
This is not correct. Gzip zip's format is not the same as the pkzip
related format used by Winzip and other "zip" utilities. Gzip also
only compresses, it does not deal
>
>gzip - aka gunzip GNU opensource version - probably your best bet.
>>
>This is not correct. Gzip zip's format is not the same as the pkzip related
>format used by Winzip and other "zip" utilities. Gzip also only compresses,
>it
>does not deal with multiple files.
>
>
>Ah yes, I forgot g
On 10/14/2010 7:48 AM Ara Kooser said...
Morning all,
I took the pseudocode that Emile provided and tried to write a python
program. I may have taken the pseudocode to literally.
So what I wrote was this:
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals
"join" operates on lists. It "joins" the elements of the list using the
leading character or string as the delimiter. In this case it is NUL.
Try putting a character or string, like 'XX\n' in front of the ".join" in
both places. It should illustrate what's really happening.
"XX\n".jo
On Thu, Oct 14, 2010 at 10:14 AM, David Hutto wrote:
> Hey Buddy Pals,
>
> I receive the following output from a sqlite db
>
> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>
> Which is a tuple of unicode strings. From this I
> need to place portions of the tuple into oth
Morning all,
I took the pseudocode that Emile provided and tried to write a python
program. I may have taken the pseudocode to literally.
So what I wrote was this:
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals in gen:
ID = proteinVals.split()[0]
Morning all,
I took the pseudocode that Emile provided and tried to write a python
program. I may have taken the pseudocode to literally.
So what I wrote was this:
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals in gen:
ID = proteinVals.split()[0]
Hello,
I found this answer to a problem for me :
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
print ''.join(test)
But it seems not to work
Can anyone explain why not ?
P
Hey Buddy Pals,
I receive the following output from a sqlite db
(u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
Which is a tuple of unicode strings. From this I
need to place portions of the tuple into other fields,
but not as unicode strings, but literals no ''.
For exa
On 10/14/2010 6:50 AM Roelof Wobben said...
Hello,
I found this answer to a problem for me :
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
This isn't transcribed properly
On Thu, Oct 14, 2010 at 9:50 AM, Roelof Wobben wrote:
>
>
> Hello,
>
> I found this answer to a problem for me :
>
>
> print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
>
> So I thought that this would be the same :
>
> for p in zpp:
> test = zf.getinfo(p).comment
> print '
On Thu, Oct 14, 2010 at 3:50 PM, Roelof Wobben wrote:
>
>
> Hello,
>
> I found this answer to a problem for me :
>
>
> print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
>
Look at the argument given to join here. It is a list comprehension.
The result of a list comprehension is a list
Hello,
I found this answer to a problem for me :
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
print ''.join(test)
But it seems not to work
Can anyone explain why not ?
Hi Walter!
I already looked at the code you suggested me to accomplish my goal, I made
some changes on it to match mine, your code is very neat and nice. Here are
some lines I changed:
- First I did the file search
file_list = []
folders = None
for root, folde
Ok, now I see what I did. Legacy from when the get_rain_data function
returned precipitation and error. I forgot to remove the brackets from
the 'return [precip]' statement.
It works perfectly now. Thanks for all the help.
2010/10/14, Evert Rol :
>> Thanks for the reply. I've tried your suggestio
> Thanks for the reply. I've tried your suggestion and am still getting
> an error (posted below code). Since my posting, I've also added the
> code to convert the numpy array to a list. My complete script is:
>
> -
> # -*- coding: utf-8 -*-
>
> import pupynere
> import os
> import csv
> impo
Hi Evert,
Thanks for the reply. I've tried your suggestion and am still getting
an error (posted below code). Since my posting, I've also added the
code to convert the numpy array to a list. My complete script is:
-
# -*- coding: utf-8 -*-
import pupynere
import os
import csv
import glob
de
Alan,
On 14 October 2010 09:51, Alan Gauld wrote:
> gzip - aka gunzip GNU opensource version - probably your best bet.
>
This is not correct. Gzip zip's format is not the same as the pkzip related
format used by Winzip and other "zip" utilities. Gzip also only compresses,
it does not deal with
"Hanlie Pretorius" wrote
# file_details[0] is the date and file_details[1] is the time
writer.writerow(('%s' % (file_details[0]),'%s' %
(file_details[1]),'%f' % (data[0])))
Instead, I get an error
TypeError: float argument required, not numpy.ndarray
Try using %s instead of %f just to see w
wrote
Back to the module for zip, do I have to import it into my code for
use?
It actually works on two lists as you rightly said.
zip is a command so does not need to be imported,
but it does not do what you want. You need the zipfile module
which does need to be imported.
I am supposed
I have the Winzip so I can actually view zip folders.
What I want is for my backups to be wrapped in such folder.
Thanks Walter
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: Walter Prins
Date: Thu, 14 Oct 2010 09:29:30
To:
Cc: tutor
Subject: Re: [Tutor] Zip
> I have a numpy array ('data') that is the result of reading a netCDF
> file, and it typically looks like this:
>
> array([ 0., 0., 0., 0.], dtype=float32)
>
>
> I want to write this, after a date and time, to a CSV file, so the CSV
> file would have the entry:
>
>2000-02-01,09:00,0.0,0
On 14 October 2010 07:12, wrote:
> Does window os have a zip command for python like linux and unix.
> If yes, please what is it.
> If no, please what does it use to create a zip folder.
> I am working on an example in byte of python but the zip command is from
> linux but I use windows.
> Thank
Hi,
I have a numpy array ('data') that is the result of reading a netCDF
file, and it typically looks like this:
array([ 0., 0., 0., 0.], dtype=float32)
I want to write this, after a date and time, to a CSV file, so the CSV
file would have the entry:
2000-02-01,09:00,0.0,0.0,0.0,0.0
T
Thanks to start with.
A byte f python is a book by Swaroop C.H. It is also a book for beginners.
Back to the module for zip, do I have to import it into my code for use?
It actually works on two lists as you rightly said.
I am supposed to create a back up files from 2 directories into another
sep
wrote
Does window os have a zip command for python like linux and unix.
If yes, please what is it.
Yes, zip
If no, please what does it use to create a zip folder.
But the zip command does nmot create a "zip folder" - in fact I'm
not even sure what you mean by a zip folder. I know about
62 matches
Mail list logo