dividing tuple elements with an int or float

2008-03-19 Thread royG
hi i am trying to resize some images.First i'd read the size as a 2 tuple and then i want to divide it by 2 or 4 or 2.5 etc.. suppose origsz=(400,300) i want to divide the origsize by 2.5 so i can resize to (160,120) scale=2.5 how can i get the newsz? obviously origsz/2.5 won't work .. thanks R

how to remove suffix from filename

2008-03-19 Thread royG
hi when parsing a list of filenames like ['F:/mydir/one.jpg','F:/mydir/ two.jpg'] etc i want to extract the basename without the suffix...ie i want to get 'one','two' etc and not 'one.jpg' is there a function in python to do this or do i have tosplit it ..? thanks RG -- http://mail.python.or

changing names of items in a list

2008-03-19 Thread royG
hi i am trying to rename extension of files in a directory..as an initial step i made a method in class ConvertFiles: def __init__(self,infldr,outfldr): self.infldr=infldr self.outfldr=outfldr self.origlist=os.listdir(infldr) def renamefiles(se

need a function to create eigenface image

2008-03-18 Thread royG
hi while trying to make an eigenface image from a numpy array of floats i tried this from numpy import array import Image imagesize=(200,200) def makeimage(inputarray,imagename): inputarray.shape=(-1,) newimg=Image.new('L', imagesize) newimg.putdata(inputarray) newimg.save

Re: rmdir problem

2008-03-11 Thread royG
On Mar 11, 3:37 pm, Paul > Have a look at shutil.rmtree > thanks Paul RG -- http://mail.python.org/mailman/listinfo/python-list

rmdir problem

2008-03-11 Thread royG
hi i am checking if a directory exists and if it does i want to delete it and its contents.then i want to create the directory before creating files in it. def myfolderops(): testdir='..\mytestdir' #if dir exist remove it if isdir(testdir): rmdir(testdir) #again create dire

Re: parsing directory for certain filetypes

2008-03-10 Thread royG
On Mar 10, 8:03 pm, Tim Chase wrote: > In Python2.5 (or 2.4 if you implement the any() function, ripped > from the docs[1]), this could be rewritten to be a little more > flexible...something like this (untested): > that was quite a good lesson for a beginner like me.. thanks guys in the versio

parsing directory for certain filetypes

2008-03-10 Thread royG
hi i wrote a function to parse a given directory and make a sorted list of files with .txt,.doc extensions .it works,but i want to know if it is too bloated..can this be rewritten in more efficient manner? here it is... from string import split from os.path import isdir,join,normpath from os imp

dot() and tensordot()

2008-03-09 Thread royG
non member and so doesn't show up :-( royG -- http://mail.python.org/mailman/listinfo/python-list