def MatInv(arr,file):
f = open('file.txt','w')
f.write(arr)
f.close()
So I'm trying to write a module that will take a matrix (arr) and write it
to a text file.
The above module is called MatrixIO.py
#first I import it
import MatrixIO
#Then i call the function MatInv with matrix(a)
On Monday 2012 November 12 21:07, you wrote:
> I tried it with i == n as well and it still doesnt work :/
Check the documentation on range and xrange and you will find out why i never
equals n.
>>> n = 5
>>> range(n)
[0, 1, 2, 3, 4]
>>> for i in xrange(n): print i
...
0
1
2
3
4
>>>
--
Yonder no
On Monday 2012 November 12 19:56, Rufino Beniga wrote:
> def IterateLogistic(x,r,n):
> for i in xrange(n):
> x = r*(1-x)
> if i = n:
> print x
>
> I want this function to take in x and r which can be any two real numbers
> and after a certain number of iterations (n)
def IterateLogistic(x,r,n):
for i in xrange(n):
x = r*(1-x)
if i = n:
print x
I want this function to take in x and r which can be any two real numbers
and after a certain number of iterations (n), the function should print the
current state which is x. I tried this
> 2. Why use a class in the first place? What is the purpose of
> constructing a class instead of just writing a program with a bunch
> of functions?
Sometimes, you DO just write programs with functions.
A class can be useful if you have a bunch of a thing. Like a monster.
Each monster can know
On 13/11/2012 02:49, brandon w wrote:
I have been trying to understand classes. I have been studying from a book
I picked up recently.
I have two questions about them.
1. I saw in the book an assignment written like this:
class HumanBeing:
def makeName(self, name):
*
I have been trying to understand classes. I have been studying from a book
I picked up recently.
I have two questions about them.
1. I saw in the book an assignment written like this:
class HumanBeing:
def makeName(self, name):
*self.name = name*
*
*
Why is it not writte
hello,
i have this piece of code (http://pastie.org/5366200) which uses
BeatifulSoup to scrape content from a site, the html for the example
can be seen here http://pastie.org/5366172
short_description = soup.find('div', attrs={"class":
"short-description"})
if short
Op 12-11-12 09:29, Khalid Al-Ghamdi schreef:
Hi all,
How would you go about adding items from a cursor to a dictionary?
There is a nice buitin way, with example here:
http://docs.python.org/2/library/sqlite3.html#sqlite3.Row
It's not a real dictionary though, but it can act like it. Also, the
On 12/11/12 08:29, Khalid Al-Ghamdi wrote:
Hi all,
How would you go about adding items from a cursor to a dictionary?
i tried this but to no avail:
>>> cur.execute('select * from schedule limit 10')
>>> for i in range(len(cur.fetchall())):
d[i]=cur.fetchall()[i]
The second fetchall() won'
Hi all,
How would you go about adding items from a cursor to a dictionary?
i tried this but to no avail:
>>> cur.execute('select * from schedule limit 10')
>>> for i in range(len(cur.fetchall())):
d[i]=cur.fetchall()[i]
Traceback (most recent call last):
File "", line 2, in
d[i]=cur.fetc
11 matches
Mail list logo