Re: merits of Lisp vs Python

2006-12-23 Thread defcon8
All of you are nazis!

-- 
http://mail.python.org/mailman/listinfo/python-list


Ghostscript interface

2006-09-10 Thread defcon8
Does a ghostscript interface for python exist? I have searched google
quite a bit and all I have been able to find are command line hacks
from within python. Thanks in advance for any useful help.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing Documents

2006-09-07 Thread defcon8

Claudio Grondi wrote:
> defcon8 wrote:
> > How can I print html documents in Python on Windows?
> >
> ;-)
>
> 1. You start the Microsoft Internet Explorer and make some space on the
> Desktop for a Python shell window.
> 2. You start the Python shell and position it within the prepared space
> 3. Still looking at the Python shell you load the document into the
> Internet Explorer and then use its menu [File] -> [Print] to invoke
> printing (don't forget to keep your eye on the Python shell...)
>
> ;-)
>
> Claudio Grondi
> P.S. There are many options to automate usage of MSIE from Python, so
> maybe if you explain what you actually intend to achieve, someone else
> can give you a better advice.

I think the automation of opening of html in IE, then the printing of
it would be possible. Would you be able to tell me how that is done?

-- 
http://mail.python.org/mailman/listinfo/python-list


Printing Documents

2006-09-07 Thread defcon8
How can I print html documents in Python on Windows?

-- 
http://mail.python.org/mailman/listinfo/python-list


A game idea.

2006-06-26 Thread defcon8
I have had what I think is quite a nice game idea, but I don't really
have the experience or knowledge to go about it. Would anyone be
willing to start a game project? The game I am thinking about is a
virtual IRC stock exchange. There will be a bot in the channel which
gets the live stock quotes and also adds any effects of buying or
selling of the players. Everyone will have their own portfolio, which
they will be able to view on the web, and will be able to issue
commands from the irc channel. They'll be able to trade between
eachother, and also to the stock exchange. I know this sounds like
quite a big project, but I think this would be a highly fun game and
maybe it would become quite popular. I would be willing to help of
course with what I can, but obviously, an experienced developer would
be needed.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python database access

2006-06-26 Thread defcon8

arvind wrote:
> Hi all,
> I am going to  work on Python 2.4.3 and MSSQL database server on
> Windows platform.
> But I don't know how to make the connectivity or rather which module to
> import.
> I searched for the modules in the Python library, but I couldn't find
> which module to go for.
> Please help me out!

I think there are a few recipes for mssql in the activestate python
cookbook, or at least for odbc.

-- 
http://mail.python.org/mailman/listinfo/python-list


About python 2.5 and its try statement.

2006-06-26 Thread defcon8
I can't remember the proposal number, but many of you reading will have
probably read the features that will be added to python 2.5. The actual
part I wanted to talk about was the finally part of try. Isn't it
totally defeating a compiler's job by executing the finally part even
if there is an error in the previous statements? Or have I understood
something wrong?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and cellular automata (It works this time!)

2006-06-24 Thread defcon8
blog-of-justin.blogspot.com

Sorry for the error.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and cellular automata (It works this time!)

2006-06-24 Thread defcon8
Sorry about the code. It seems to have been truncated. I have it hosted
at

http://xahlee.org/x/realautomata.py

Thanks to Xah Lee.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python and cellular automata (It works this time!)

2006-06-24 Thread defcon8
I thought people would be interested in this little script I wrote to
reproduce the 256 simple automata that is shown in the first chapters
of "A New Kind of Science". You can see a few results without running
the script, at http://cooper-j.blogspot.com . And here is the code (You
will need PIL (Python Imaging Library)):

import Image

# Contract:
# To simulate simple cellular automata.

class calculations:
def __init__(self,which):
self.against = self.array_maker_2()[which]
self.check = self.array_maker_1()
self.array = self.array_maker_3(311)
self.calculator()

def binary(self, n, size): ## This is the Int -> str(BINARY)
converter
assert n >= 0
bits = []
while n:
bits.append('01'[n&1])
n >>= 1
bits.reverse()
result = ''.join(bits) or '0'
for iteration in range(len(result),size):
result = "0" + result
return result

def array_maker_1(self): # This makes the array that represents the
8 different permutations of 3 cells. Itself, its left and its right.
return [self.binary(n, 3) for n in range(8)]

def array_maker_2(self): # This makes the array that represents
every single different rule. If for instance the second element in one
# of these rules is 1, then the corresponding permutation that may
be found in the result array (array_maker_3), will be 1 (black).
return [self.binary(n, 8) for n in range(256)]

def array_maker_3(self, y): # This is the array for all the
results. The automaton starts from the middle of the first row
x = [["0" for x in range((2*y)+1)] for n in range(y)]
x[0][(2*y+1)/2] = "1"
return x

def calculator(self): # This cycles over all of the cells, and
scans one row at a time, and changes the next row according to the
current cell.
self.buff_result = ["0","0","0"] # This is the current permutation
buffer to be checked against the corresponding arrays.
for i in range(len(self.array)-1):
for j in range(1, len(self.array[0])-1):
self.step1(j,i)
self.step2(j,i)
self.step3(j,i)
y = self.check.index(''.join(self.buff_result))
self.array[i+1][j] = self.against[y]

# The steps update the result buffer.
def step1(self, step, y):
self.buff_result[0] = self.array[y][step-1]

def step2(self, step, y):
self.buff_result[1] = self.array[y][step]

def step3(self, step, y):
self.buff_result[2] = self.array[y][step+1]

for number in range(256):
objo = calculations(number)
x = objo.array
y = []
for num,zo in enumerate(x):
for com,wo in enumerate(zo):
x[num][com] = int(wo)

nim = Image.new("1", (623,311))

for n in x: #converting the array of arrays into a single array so
putdata can take it.
for p in n:
y.append(p)
nim.putdata(y)
nim.resize((6230/2,3110/2)).save("output" + str(number) + ".png")
print number


-- 
http://mail.python.org/mailman/listinfo/python-list


PIL problems

2006-06-23 Thread defcon8
Hello. I have been trying to use PIL's .putdata() method and I have
been having some problems. The error I get is:

Traceback (most recent call last):
  File "realautomata.py", line 72, in ?
nim.putdata(y)
  File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1120, in
putdata
self.im.putdata(data, scale, offset)
TypeError: too many data entries

The code is:

import Image

# Contract:
# To simulate simple cellular automata.

class calculations:
def __init__(self):
self.against = self.array_maker_2()[110]
print self.against
self.check = self.array_maker_1()
self.array = self.array_maker_3(31)
self.calculator()

def binary(self, n, size): ## This is the Int -> str(BINARY)
converter
assert n >= 0
bits = []
while n:
bits.append('01'[n&1])
n >>= 1
bits.reverse()
result = ''.join(bits) or '0'
for iteration in range(len(result),size):
result = "0" + result
return result

def array_maker_1(self): # This makes the array that represents the
8 different permutations of 3 cells. Itself, its left and its right.
return [self.binary(n, 3) for n in range(8)]

def array_maker_2(self): # This makes the array that represents
every single different rule. If for instance the second element in one
# of these rules is 1, then the corresponding permutation that may
be found in the result array (array_maker_3), will be 1 (black).
return [self.binary(n, 8) for n in range(256)]

def array_maker_3(self, y): # This is the array for all the
results. The automaton starts from the middle of the first row
x = [["0" for x in range(2*y+1)] for n in range(y)]
x[0][(2*y-1)/2] = "1"
return x

def calculator(self): # This cycles over all of the cells, and
scans one row at a time, and changes the next row according to the
current cell.
self.buff_result = ["0","0","0"] # This is the current permutation
buffer to be checked against the corresponding arrays.
for i in range(len(self.array)-1):
for j in range(1, len(self.array[0])-1):
self.step1(j,i)
self.step2(j,i)
self.step3(j,i)
y = self.check.index(''.join(self.buff_result))
self.array[i+1][j] = self.against[y]

# The steps update the result buffer.
def step1(self, step, y):
self.buff_result[0] = self.array[y][step-1]

def step2(self, step, y):
self.buff_result[1] = self.array[y][step]

def step3(self, step, y):
self.buff_result[2] = self.array[y][step+1]

objo = calculations()
x = objo.array
y = []
for num,zo in enumerate(x):
for com,wo in enumerate(zo):
x[num][com] = int(wo)

nim = Image.new("1", (62,31))

for n in x: #converting the array of arrays into a single array so
putdata can take it.
for p in n:
y.append(p)
print y
nim.putdata(y)

nim.resize((620,310)).save("output.png")

can someone tell me why I get the error?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python keywords vs. English grammar

2006-05-24 Thread defcon8
1. Does it matter?
2. Is it affecting your productivity.
3. Are you not trying to programme?
4. It is open source, change it and stop whining.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting URL's

2006-05-18 Thread defcon8
Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Getting URL's

2006-05-18 Thread defcon8
How do I get all the URL's in a page?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: saving file permission denied on windows

2006-05-15 Thread defcon8
Have you checked the persmissions to the folder? You can look from the
properties of the folder to see.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-14 Thread defcon8
Actually never mind either. I guessed I needed to append all values
after eachother in one row list:
x = []
for y in buff:
for z in y:
x.append(z)

thanks for the help

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-14 Thread defcon8
Sorry this is the latest, the previous didn't work so well:

import Image
x = []
buff = []

buff = [[0 for y in range(41)] for x in range(21)]
buff[0][(len(buff[0])-1)/2] = 1
def rule1():
for i in range(len(buff)-1):
for j in range(len(buff[0])-1):
if i == len(buff)-1:
break
elif j == 0:
if buff[i][j+1] == 1:
buff[i+1][j] = 1
elif j == len(buff[0])-1:
if buff[i][j-1] == 1:
buff[i+1][j] = 1
elif buff[i][j-1] == 1:
buff[i+1][j] = 1
elif buff[i][j+1] == 1:
buff[i+1][j] = 1

def rule2():
for i in range(len(buff)-1):
for j in range(len(buff[0])-1):
if i == len(buff)-1:
break
elif j == 0:
if buff[i][j+1] == 1:
buff[i+1][j] = 1
elif j == len(buff[0])-1:
buff[i+1][j] = 1
elif buff[i][j-1] == 1 and buff[i][j+1] != 1:
buff[i+1][j] = 1
elif buff[i][j+1] == 1 and buff[i][j-1] != 1:
buff[i+1][j] = 1
elif buff[i][len(buff[0])-1] == 1 or buff[i][0]  == 1:
break


rule2()
nim = Image.new("1", (50,50))
nim.putdata(buff)
nim.resize((400,600)).save("output.png")

for a in buff:
for x in a:
   if x == 1:
print "X",
   elif x == 0: print " ",
print ""
   
for a in buff:
print a

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-14 Thread defcon8
import Image
x = []
buff = []

buff = [[0 for y in range(41)] for x in range(21)]
buff[0][(len(buff)-1)/2] = 1
def rule1():
for i in range(len(buff)-1):
for j in range(len(buff[0])-1):
if i == len(buff)-1:
break
elif j == 0:
if buff[i][j+1] == 1:
buff[i+1][j] = 1
elif j == len(buff[0])-1:
if buff[i][j-1] == 1:
buff[i+1][j] = 1
elif buff[i][j-1] == 1:
buff[i+1][j] = 1
elif buff[i][j+1] == 1:
buff[i+1][j] = 1

def rule2():
for i in range(len(buff)-1):
for j in range(len(buff[0])-1):
if i == len(buff)-1:
break
elif j == 0:
if buff[i][j+1] == 1:
buff[i+1][j] = 1
elif j == len(buff[0])-1:
buff[i+1][j] = 1
elif buff[i][j-1] == 1 and buff[i][j+1] != 1:
buff[i+1][j] = 1
elif buff[i][j+1] == 1 and buff[i][j-1] != 1:
buff[i+1][j] = 1


rule2()
nim = Image.new("1", (400,600))
nim.putdata(buff)
nim.resize((400,600)).save("output.png")

for a in buff:
for x in a:
   if x == 1:
print "X",
   else: print " ",
print ""

That is my code. Could you tell me what maybe is wrong? Rule2 makes the
fibonacci triangle btw.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-14 Thread defcon8
It seemed to work with a 1d list but not with 2d.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-14 Thread defcon8
Thank you very much. That is highly simple, useful and it works.

-- 
http://mail.python.org/mailman/listinfo/python-list


Cellular automata and image manipulation

2006-05-13 Thread defcon8
Hello. I have recently been experimenting with cellular automata and I
would like to know how I could convert a 2d list of 0's and 1's into
white and black squares on an image. I have tried to install matplotlib
and also NumTut but both to no avail. There seem to be bugs in their
installation and I have not been able to figure out how to resolve
them. I would be happy for someone to suggest a library and maybe give
a simple example of how to do what I want to do.

-- 
http://mail.python.org/mailman/listinfo/python-list