remove the last character or the newline character?

2006-09-28 Thread Daniel Mark
Hello all: I have the following snippet: In [1]: fileName = 'Perfect Setup.txt\n' In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' character In [3]: fileName Out[3]: 'Perfect Setup.txt' Question one: Does python provide any function that can remove the last character of a stri

How to save High Quality JPG image by setting Image module from PIL

2006-09-25 Thread Daniel Mark
hello all: I am using Image module from PIL to save created image as JPG format. Is there any option I could set for function Image.save so that the stored image will have the highest quality. Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Question about the article "py2exe compiler" in Python Cookbook by Alexander Semenov

2006-09-22 Thread Daniel Mark
Hello all: I follow the following tutorial http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/108598 Description: script for making executables with py2exe ## from distutils.core import setup import sys, os, py2exe name = sys.argv[1] sys.argv[1] = 'py2exe' sys.path.append(os.pat

Does Python provide "Struct" data structure?

2006-09-22 Thread Daniel Mark
Hello all: I have found a useful module in IPython, named 'from IPython.ipstruct import Struct". So I can use it as follows: from IPython.ipstruct import Struct mystruct = Struct(echo = 1, verb = 'Verbose', filedir

How does IPython modify the sys.path?

2006-09-21 Thread Daniel Mark
Hello all: I installed IPython on my XP machine today and find that my sys.path has been changed as follows: >> import sys >> print sys.path ['', 'C:\\Program Files\\Python24\\scripts', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\Documents and Settings\\Daniel\\Desktop', 'C:\\Program Files\

How to evaluate the memory usage of a python program?

2006-09-20 Thread Daniel Mark
Hello all: I have a python program and would like to find out the maximum memory used by this program. Does Python provide such module so I could check it easily? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Do we need to delete "ImageDraw.Draw" after using it?

2006-09-20 Thread Daniel Mark
Hello all: I am looking the sample code posted on PIL website http://www.pythonware.com/library/pil/handbook/imagedraw.htm <> import Image, ImageDraw im = Image.open("lena.pgm") draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) dra

How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Daniel Mark
Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

How to draw a rectangle with gradient?

2006-09-16 Thread Daniel Mark
Hello all: I am using PIL to draw a rectangle filled with color blue. Is there anyway I could set the fill pattern so that the drawn rectangle could be filled with gradient blue? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

How to change font direction?

2006-09-15 Thread Daniel Mark
Hello all: I am using PIL to draw some graphics and I need to draw some texts in vertical direction rather than the default left-to-right horizontal direction. Is there anyway I could do that? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

How to handle wrong input in getopt package in Python?

2006-08-25 Thread Daniel Mark
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect input D:\>python AddArrowOnImage.py --imageDi Traceback (most recent call last): File "AddArrowOnImage.py", li

py2exe: cannot identify image file

2006-08-18 Thread Daniel Mark
Hello all: I have following code that works well under command line, but it doesn't work after I convert it as exe application. ### file: testPath.py import getopt, math, sys, os, Image, ImageDraw, aggdraw def processline(): try: imgDir = 'c:/' lumenImageName = '0

How to draw line on Image?

2006-08-18 Thread Daniel Mark
Hello all: I want to draw some shapes, such as lines, circles on an image. The input to the program is an image and the output from the program is a superimposed image. what kind of document or functions I should take a look for searching this question? The program doesn't show the image, but

Re: Why XP can not run Python after being setting the PATH?

2006-07-28 Thread Daniel Mark
Dear John: > Have a look in each of those folders (including the root!!) and see > what you find there. [If I were forced to bet, I'd put my money on > cygwin]. You are a genius!!! My machine was intalled python in cygwin:) I didn't expect that I could get so much helps from this forum. My hear

Re: Why XP can not run Python after being setting the PATH?

2006-07-28 Thread Daniel Mark
Hello John: I did try, however, it doesn't work on my machine. Thank you -Daniel John Salerno wrote: > Daniel Mark wrote: > > > Maybe there is not solution to this problem:)? > > Did you not try Sybren's suggestion? Remove the space between the > semicolon and

Re: Why XP can not run Python after being setting the PATH?

2006-07-28 Thread Daniel Mark
u, is Python there? > > Cheers > Ray > > Daniel Mark wrote: > > Hello all: > > > > I have set the PATH for Python as follows: > > > > My Computer->Properties->Advanced->Environment Variables->System > > Variables->Path > > >

Re: Why XP can not run Python after being setting the PATH?

2006-07-28 Thread Daniel Mark
Hello Dennis: > A second suggestion would be: don't install Python in "Program > Files", but put it at the top level of the partition (ie; C:\Python24\) > I guess your comment is right. However, I would like to install Python under directory "C:\Program Files\Python24" Also, I list some scr

Why XP can not run Python after being setting the PATH?

2006-07-27 Thread Daniel Mark
Hello all: I have set the PATH for Python as follows: My Computer->Properties->Advanced->Environment Variables->System Variables->Path ...; C:\Program Files\Python24; Then I try to run python under command line C:\>python C:\>python.exe I got nothing:) It works iff I run as follows: C:\>"P