Re: Alternative to python -u for binary upload to cgi on windows?

2007-12-22 Thread cameron . walsh
On Dec 14, 6:58 pm, Cameron Walsh [EMAIL PROTECTED] wrote: Hi all, Using a pythoncgiscript such as the one below to handle uploaded binary files will end up with atruncatedfile (truncates when it hits ^Z) on Windows systems. On linux systems the code works and the file is nottruncated

Alternative to python -u for binary upload to cgi on windows?

2007-12-14 Thread Cameron Walsh
Hi all, Using a python cgi script such as the one below to handle uploaded binary files will end up with a truncated file (truncates when it hits ^Z) on Windows systems. On linux systems the code works and the file is not truncated. One solution for Windows is to use the -u flag, i.e.

Re: webbrowser

2007-11-13 Thread Cameron Walsh
Antonio Ceballos wrote: Hello, I am trying to open a URL on a new browser or new tab from an HTML page created from a python cgi script. import cgitb; cgitb.enable() # Will save you hours of debugging. Prints error messages and exceptions to the client, wrapped in pretty html. On Apache

Re: manually cutting a picture

2007-11-07 Thread Cameron Walsh
Amit Khemka wrote: Cut image by m X m grid (bigger the m, the more varied shapes you would be able to generate), this will give you m*m square pieces. With each piece store a vector which represents the polygon (say by storing co-ordinates of the corners). Now visualize this set of pieces as

Re: how to iterate through each set

2007-11-04 Thread Cameron Walsh
Tom_chicollegeboy wrote: I figured out problem. here is my code. now it works as it should! Thank you everyone! I decided my 4th clue earlier was too much, so I removed it before posting. It looks like you got it anyway =) You've now solved it the way the course instructor intended you to

Re: Python good for data mining?

2007-11-04 Thread Cameron Walsh
Jens wrote: Thanks a lot! I'm not sure I completely understand your description of how to integrate Python with, say PHP. Could you please give a small example? I have no experience with Python web development using CGI. How easy is it compared to web development in PHP? I still havent't

Re: Python good for data mining?

2007-11-03 Thread Cameron Walsh
Jens wrote: I'm starting a project in data mining, and I'm considering Python and Java as possible platforms. I'm concerned by performance. Most benchmarks report that Java is about 10-15 times faster than Python, and my own experiments confirms this. I could imagine this to become a

Re: how to iterate through each set

2007-11-03 Thread Cameron Walsh
Tom_chicollegeboy wrote: snip! Here is my code: def speed(): infile = open('speed.in', 'r') line = infile.readline() read = int(line) print line i = 0 t0 = 0 v = 0 while iread: line = infile.readline() list = line.split()

Re: how to do the mapping btw numpy arrayvalues and matrix columns

2007-11-02 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: hi i am looking for some info about mapping btw values in an array and corresponding columns of a matrix i have an numpy array=[11.0,33.0,22.0,55.0,44.0] and a numpy matrix object= matrix(([1.3,2.5,3.2,6.7,3.1],

Re: python in academics?

2007-11-01 Thread Cameron Walsh
sandipm wrote: seeing posts from students on group. I am curious to know, Do they teach python in academic courses in universities? Sydney University teaches user interface design, some data mining and some natural language processing in Python. Software development is still largely a Java

Re: Logging output from python

2006-12-07 Thread Cameron Walsh
Barry wrote: Hi, guys Basiclly, it is automated testing system. There is a main python script that handles the testing campagin. This main script will call another script that will in turn runs a few hundered individual python scripts. Here is my problem. I want to log everything

Re: newb: Join two string variables

2006-12-05 Thread Cameron Walsh
johnny wrote: How do I join two string variables? I want to do: download_dir + filename. download_dir=r'c:/download/' filename =r'log.txt' I want to get something like this: c:/download/log.txt Hi Johnny, This is actually two questions: 1.) How do I concatenate strings 2.) How do

Re: PIL throws exception when reading bitmap/pnm data

2006-11-30 Thread Cameron Walsh
Cameron Walsh wrote: Hi all, I'm trying to extract the data from a bitmap or .pnm file using the following code: import Image img = Image.open(test.bmp,r) data=img.getdata() Unfortunately I get the following exception on Linux, but not on Windows: data=img.getdata() Traceback

PIL throws exception when reading bitmap/pnm data

2006-11-29 Thread Cameron Walsh
Hi all, I'm trying to extract the data from a bitmap or .pnm file using the following code: import Image img = Image.open(test.bmp,r) data=img.getdata() Unfortunately I get the following exception on Linux, but not on Windows: data=img.getdata() Traceback (most recent call last): File

Re: splitting a long string into a list

2006-11-27 Thread Cameron Walsh
ronrsr wrote: I have a single long string - I'd like to split it into a list of unique keywords. Sadly, the database wasn't designed to do this, so I must do this in Python - I'm having some trouble using the .split() function, it doesn't seem to do what I want it to - any ideas? thanks

Re: splitting a long string into a list

2006-11-27 Thread Cameron Walsh
ronrsr wrote: still having a heckuva time with this. here's where it stand - the split function doesn't seem to work the way i expect it to. longkw1,type(longkw): Agricultural subsidies; Foreign aid;Agriculture; Sustainable Agriculture - Support; Organic Agriculture; Pesticides, US,

Re: reading csv problem

2006-11-14 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: Hello, I use csv to take information from file. import csv reader = csv.reader(open('t.csv')) for row in reader: print row # it is perfectly OK - But If I use this code I have problem

Re: Printing to file, how do I do it efficiently?

2006-11-10 Thread Cameron Walsh
Robert Kern wrote: Cameron Walsh wrote: Hi all, I have a numpy.array of 89x512x512 uint8's, set up with code like this: numpy questions are best asked on the numpy list, not here. At first I thought it was a generic python question, since it had more to do with writing array data to file

Printing to file, how do I do it efficiently?

2006-11-09 Thread Cameron Walsh
Hi all, I have a numpy.array of 89x512x512 uint8's, set up with code like this: data=numpy.array([],dtype=uint8) data.resize((89,512,512)) # Data filled in about 4 seconds from 89 image slices snip lots of processing code I first tried writing this data to a binary raw format (for use in a

Re: Python cgi Apache os.system()

2006-11-08 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: Hello :) I have installed Apache on windows... The server work well, and my python script also but when I want in my python script to run a System command like os.system(my_command) the script doesn't do anything! here the error.log [Wed Nov 08 14:19:30

Re: Python to tell what is the IP of my PC .

2006-11-08 Thread Cameron Walsh
Gabriel Genellina wrote: At Wednesday 8/11/2006 21:18, Nicolas G wrote: How can I use python to get the real IP address of my DSL router (when my PC is part of the local home LAN) ?

Re: How to Split Chinese Character with backslash representation?

2006-10-27 Thread Cameron Walsh
limodou wrote: On 10/27/06, Wijaya Edward [EMAIL PROTECTED] wrote: Thanks but my intention is to strictly use regex. Since there are separator I need to include as delimiter Especially for the case like this: str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR' field = list(str) print field

Re: Cards deck problem

2006-10-27 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: Dennis Lee Bieber wrote: On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton [EMAIL PROTECTED] declaimed the following in comp.lang.python: This may seem pendantic, but CS is mostly about thinking about (and thus snicker Someday I should arrange to do a lost-wax

Re: Sorting by item_in_another_list

2006-10-26 Thread Cameron Walsh
Paul McGuire wrote: J. Clifford Dyer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ZeD wrote: Paul Rubin wrote: A = [0,1,2,3,4,5,6,7,8,9,10] B = [2,3,7,8] desired_result = [2,3,7,8,0,1,4,5,6,9,10] How about: desired_result = B + sorted(x for x in A if x not in B) this.

Re: Sorting by item_in_another_list

2006-10-26 Thread Cameron Walsh
Steven Bethard wrote: As you noted, you'll get an error if you try to concatenate B as a set to the list. Steve Whoops, remind me to check things work before I type them. In the mean time, here are some more interesting timing results: With a larger data set, 500 elements instead of

Re: Insert Content of a File into a Variable

2006-10-26 Thread Cameron Walsh
Wijaya Edward wrote: Hi, How can we slurp all content of a single file into one variable? I tried this: myfile_content = open('somefile.txt') print myfile_content, open file 'somefile.txt', mode 'r' at 0xb7f532e0 But it doesn't print the content of the file. help(open)

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Cameron Walsh
Wijaya Edward wrote: Hi all, I was trying to split a string that represent chinese characters below: str = '\xc5\xeb\xc7\xd5\xbc' print str2, ??? fields2 = split(r'\\',str) print fields2, ['\xc5\xeb\xc7\xd5\xbc'] But why the split function here doesn't seem to do the job for

Re: python GUIs comparison (want)

2006-10-24 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: Now i began to learn GUI programming. There are so many choices of GUI in the python world, wxPython, pyGTK, PyQT, Tkinter, .etc, it's difficult for a novice to decide, however. Can you draw a comparison among them on easy coding, pythonish design, beautiful and

Re: Sorting by item_in_another_list

2006-10-24 Thread Cameron Walsh
Delaney, Timothy (Tim) wrote: Cameron Walsh wrote: Hi, I have two lists, A and B, such that B is a subset of A. I wish to sort A such that the elements in B are at the beginning of A, and keep the existing order otherwise, i.e. stable sort. The order of elements in B will always

Sorting by item_in_another_list

2006-10-23 Thread Cameron Walsh
Hi, I have two lists, A and B, such that B is a subset of A. I wish to sort A such that the elements in B are at the beginning of A, and keep the existing order otherwise, i.e. stable sort. The order of elements in B will always be correct. for example: A = [0,1,2,3,4,5,6,7,8,9,10] B =

Re: Sorting by item_in_another_list

2006-10-23 Thread Cameron Walsh
Cameron Walsh wrote: Hi, I have two lists, A and B, such that B is a subset of A. I wish to sort A such that the elements in B are at the beginning of A, and keep the existing order otherwise, i.e. stable sort. The order of elements in B will always be correct. for example

Re: Sorting by item_in_another_list

2006-10-23 Thread Cameron Walsh
Paul McGuire wrote: Cameron Walsh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I have two lists, A and B, such that B is a subset of A. I wish to sort A such that the elements in B are at the beginning of A, and keep the existing order otherwise, i.e. stable sort

Re: Cannot import a module from a variable

2006-10-18 Thread Cameron Walsh
Hi, This has actually been answered in a previous post (user modules started by myself), for which I was very grateful. I have since expanded on their solutions to create the following code, of which parts or all may be useful. You'll probably be most interested in the last part of the code,

Re: Cannot import a module from a variable

2006-10-18 Thread Cameron Walsh
Gabriel Genellina wrote: At Wednesday 18/10/2006 22:51, Cameron Walsh wrote: previous_directory = os.getcwd() try: os.chdir(directory) [ ... ] return modules finally: os.chdir(previous_directory) Woah, that actually works? Having the finally

Re: How to share session with IE

2006-10-10 Thread Cameron Walsh
John J. Lee wrote: Bernard [EMAIL PROTECTED] writes: zdp wrote: [...] However, now I need to process some pages by a python program. When I use urllib.urlopen(theurl), I can only get a page which told me I need login. I think It's reasonable, becuase I wasn't in a loggined session which as

Re: How to share session with IE

2006-10-10 Thread Cameron Walsh
I just thought, your original question was whether or not it was possible to share your browser session with IE. Unless you do this explicitly, you may require a different login for your Python program and for your IE user. If the Python program does not get the same cookie as used by IE, or

user modules

2006-10-05 Thread Cameron Walsh
Hi, I'm writing a python program to analyse and export volumetric data. To make development and extension easier, and to make it more useful to the public when it is released (LGPL), I would like to enable users to place their own python files in a user_extensions directory. These files

Re: user modules

2006-10-05 Thread Cameron Walsh
Tuomas wrote: Cameron Walsh wrote: Hi, I'm writing a python program to analyse and export volumetric data. To make development and extension easier, and to make it more useful to the public when it is released (LGPL), I would like to enable users to place their own python files

Re: user modules

2006-10-05 Thread Cameron Walsh
Juho Schultz wrote: Juho Schultz wrote: Cameron Walsh wrote: Hi, I'm writing a python program to analyse and export volumetric data. To make development and extension easier, and to make it more useful to the public when it is released (LGPL), I would like to enable users to place