[Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Dayo Adewunmi
Hi all, This script I'm working on, should take all the image files in the current directory and generate an HTML thumbnails. import os import urllib # Generate thumbnail gallery def genThumbs(): # Get current directory name absolutePath = os.getcwd() urlprefix = "http://kili.org/~day

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Dayo Adewunmi
Shashwat Anand wrote: for dirname, subdirname, filenames in os.walk(absolutePath): for filename in filenames: print "" %(currentdir,filename,currentdir,filename) I see a small typo here. print "" %(currentdir,filename,currentdir,filename) should rather

[Tutor] Regex to find files ending with one of a given set of extensions

2010-02-21 Thread Dayo Adewunmi
Hi all I'm trying use regex to match image formats: import re def findImageFiles(): imageRx = re.compile('\.jpe?g$|\.png$|\.gif$|\.tiff?$', re.I) someFiles = ["sdfinsf.png","dsiasd.dgf","wecn.GIF","iewijiefi.jPg","iasjasd.py"] findImages = imageRx(someFiles) print "START: %s" %

Re: [Tutor] Regex to find files ending with one of a given set of extensions

2010-02-22 Thread Dayo Adewunmi
Steven D'Aprano wrote: On Mon, 22 Feb 2010 04:23:04 am Dayo Adewunmi wrote: Hi all I'm trying use regex to match image formats: Perhaps you should use a simpler way. def isimagefile(filename): ext = os.path.splitext(filename)[1] return (ext.lower() in (

[Tutor] Running PIL.Image on .svg file

2010-02-23 Thread Dayo Adewunmi
Hi all When i use PIL.Image in this script:http://dpaste.com/163588/ on an .svg file, I get this error:http://dpaste.com/163584/ How do i process .svg files in python? Thanks Dayo ___ Tutor maillist - Tutor@python.org To unsubscribe o

Re: [Tutor] Running PIL.Image on .svg file

2010-02-23 Thread Dayo Adewunmi
Eduardo Vieira wrote: On Tue, Feb 23, 2010 at 7:27 AM, Dayo Adewunmi wrote: Hi all When i use PIL.Image in this script:http://dpaste.com/163588/ on an .svg file, I get this error:http://dpaste.com/163584/ How do i process .svg files in python? Thanks Dayo

Re: [Tutor] PDF to text conversion

2009-04-21 Thread Dayo Adewunmi
Emile van Sebille wrote: Robert Berman wrote: Have any of you worked with such a library, or do you know of one or two I can download and work with? Hopefully, they have reasonable documentation. My development environment is: Python Linux Ubuntu version 8.10 I've used [r...@fcfw2 /]#

Re: [Tutor] how to compile python3.0

2009-04-24 Thread Dayo Adewunmi
Shaofeng NIu wrote: I tried to compile and install python3.0 from source,but after "make",it shows: Python build finished, but the necessary bits to build these modules were not found: _dbm _gdbm _hashlib _sqlite3 _ssl _tkinter b

Re: [Tutor] python books

2009-04-25 Thread Dayo Adewunmi
chinmaya wrote: On Mon, Apr 13, 2009 at 11:07 PM, sudhanshu gautam mailto:sudhanshu9...@gmail.com>> wrote: I am new in python , so need a good books , previously read python Bible and swaroop but not satisfied . so tell me good books in pdf format those contents good problems a

[Tutor] How to run a .py file or load a module?

2009-04-26 Thread Dayo Adewunmi
I'm looking at recursion in "Think Python", and this is the bit of code: #!/usr/bin/env python def countdown(n): if n <= 0: print 'Blastoff!' else: print n countdown(n-1) I've typed that in vim and saved as countdown.py, but I'm n

Re: [Tutor] How to run a .py file or load a module?

2009-04-28 Thread Dayo Adewunmi
David wrote: Norman Khine wrote: On Mon, Apr 27, 2009 at 12:07 AM, Sander Sweers wrote: Here is another one for fun, you run it like python countdown.py 10 #!/usr/bin/env python import sys from time import sleep times = int(sys.argv[1]) # The argument given on the command line def countdow

Re: [Tutor] How to run a .py file or load a module?

2009-04-28 Thread Dayo Adewunmi
module, and also the idea of from import as Thanks a lot, everybody. :-) Dayo -- spir wrote: Le Sun, 26 Apr 2009 22:35:36 +0100, Dayo Adewunmi s'exprima ainsi: How can I a) Open my shell, and do something like: $ python countdown.py but have it ta

Re: [Tutor] Triggering code on 1 minute intervale ..

2009-05-09 Thread Dayo Adewunmi
Alex Feddor wrote: .. What will be the best solution to trigger python code every minute as soon as PC in on. Cheers, Alex ___ Tutor maillist - Tutor@python.org http://mai

[Tutor] writing HTML code to a variable/file

2009-05-26 Thread Dayo Adewunmi
Hi, I'm extracting data from OpenLDAP, which needs to be formatted into hyperlinks. So far, I can print the generated HTML code: print "http://users.example.com/~"; + userName + ">" + lastName + ", " + firstName + "" However I want to write each line to a file first, so that I can alphabet

[Tutor] Sorting list of tuples in two passes

2011-08-28 Thread Dayo Adewunmi
Hi I have a list of tuples that each have four elements: [(firstName,lastName,userName,gidNumber),(.)] I'm trying to sort this list in two passes. First by gidNumber and then the subgroups by lastName. So far i've only been able to sort by gidNumber. But I can't seem to wrap my mind a

Re: [Tutor] Sorting list of tuples in two passes

2011-08-28 Thread Dayo Adewunmi
On 08/28/2011 06:23 PM, Hugo Arts wrote: On Sun, Aug 28, 2011 at 6:43 PM, Dayo Adewunmi wrote: Hi I have a list of tuples that each have four elements: [(firstName,lastName,userName,gidNumber),(.)] I'm trying to sort this list in two passes. First by gidNumber and then the subg

Re: [Tutor] Sorting list of tuples in two passes

2011-08-29 Thread Dayo Adewunmi
On 08/29/2011 01:59 AM, Hugo Arts wrote: On Mon, Aug 29, 2011 at 2:19 AM, Dayo Adewunmi wrote: On 08/28/2011 06:23 PM, Hugo Arts wrote: On Sun, Aug 28, 2011 at 6:43 PM, Dayo Adewunmi wrote: Hi I have a list of tuples that each have four elements: [(firstName,lastName,userName,gidNumber