[Tutor] need help planning website updates

2005-01-20 Thread Jay Loden
I have a sort of simple CMS system on my website made from a conglomeration of scripts. On the left column, I want to add a feature that shows the last five items updated (only html & exe files in the /var/www/html/ for example) directory that I have updated, with each item as a link to the pag

Re: [Tutor] need help planning website updates

2005-01-20 Thread Jay Loden
Adding it into the PHP that creates the html would create too much overhead since it loads each page individually upon request, and that would mean running the modified time check on every page load.   But I was thinking about this after I sent the mail, and I think you have a point with just o

[Tutor] glob or filter help

2005-01-21 Thread Jay Loden
I have the following code in my updates script (gets the five most recent updated files on my site) def get_fles(exts, upd_dir): '''return list of all the files matching any extensions in list exts''' fle_list = [] for each in exts: cmd = upd_dir + "*." + each ext_ls = glob.glob(cmd) fl

Re: [Tutor] read line x from a file

2005-01-21 Thread Jay Loden
One simple solution is to do: fle = open(file) contents = file.readlines() file.close() print contents[x] #or store this in a variable, whatever -Jay On Friday 21 January 2005 11:22, J. M. Strother wrote: > I have a text file containing 336 records. > I can read and print out the whole file w

Re: [Tutor] New to Python

2005-01-26 Thread Jay Loden
I also recommend the book "Dive Into Python" - it gets awesome reviews, and the book is under Creative Commons license, so it's free to download and distribute. http://diveintopython.org I also have the book "Core Python Programming" which is pretty good, and has a nice way of leaping right

Re: [Tutor] files in a directory

2005-01-30 Thread Jay Loden
There's a few ways to accomplish this...the way that comes to mind is: ## import glob files = glob.glob("/path/to/director/*.dml") # assuming you want only .dml def spot(file): '''search for intensity spots and report them to an output

Re: [Tutor] sys.argv[1: ] help

2005-02-25 Thread Jay Loden
Should be: import sys def main(): '''prints out the first command line argument''' print sys.argv[1] main() On Friday 25 February 2005 04:35 pm, Richard gelling wrote: > Hi, > > I am reading ' Learning Python second edition' by Mark Lutz and David > Ascher, and I trying the code examples

Re: [Tutor] Newbie simple question

2005-02-25 Thread Jay Loden
You want readlines() not readline() and it should work something like this: remailfile = open("remail2.txt", r) remails = remailfile.readlines() for line in remails: #do something -Jay On Friday 25 February 2005 05:14 pm, Valone, Toren W. wrote: > I need to know how to read the next line whil

[Tutor] Prepend to a list?

2005-03-19 Thread Jay Loden
How can I prepend something to a list? I thought that I could do list.prepend() since you can do list.append() but apparently not. Any way to add something to a list at the beginning, or do I just have to make a new list? -Jay ___ Tutor maillist -

[Tutor] random import errors?

2005-04-01 Thread Jay Loden
I have a python script that runs on my webserver every fifteen minutes. It has run for several months with absolutely no problems. Suddenly, yesterday morning I got an email from cron with an import error for sre_constants (see below) I logged in with ssh, manually ran the script and got the

Re: [Tutor] Re: random import errors

2005-04-05 Thread Jay Loden
Only one version installed, and I could copy it over from elsewhere, but I wouldn't be inclined to do so since it works right now. -Jay On Tuesday 05 April 2005 10:22 pm, Lee Harr wrote: > >I have a python script that runs on my webserver every fifteen minutes. > > It has run for several month

Re: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Jay Loden
Ok, it's a logic error in the while loop. Starting at the beginning: you can't compare the value of "password" until the user inputs the value, which is why it's requiring you to put password = "foobar" at the top. Otherwise, password has no value, and as far as the interpreter is concerned, i

Re: [Tutor] how to display an image using python

2005-04-14 Thread Jay Loden
If you don't mind using an external program, you could use the 'display' command from ImageMagick. -Jay On Thursday 14 April 2005 07:59 pm, Ertl, John wrote: > All, > > I have asked this question before, but one more time most have commented > about manipulation but displaying the image has bec

Re: [Tutor] Installation Routines (Joseph Quigley)

2005-04-21 Thread Jay Loden
Rpm does in fact have dependency resolution, and rpm-based distributions use a package manager that can download the dependencies and install them for you - urpmi on mandrake, yum or apt4rpm on Fedora and Redhat, Yast on Suse I've used all of these, they are all rpm based, and they all install

Re: [Tutor] Python and Web Pages?

2005-04-23 Thread Jay Loden
I use both Python and PHP on my website to do a variety of tasks. Some things PHP can do much easier than Python, but if you're doing simple things like form handling, Python will do nicely. If you're comfortable with Python, use it. I find Python much easier to work with than PHP for a lot

[Tutor] getopt matching incorrect options

2005-07-11 Thread Jay Loden
I have an app that takes a command line argument of -l or --list. It uses the getopt module to parse the arguments, and I just noticed that for some reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in below) Is this normal behavior, and if so, is there any way to avoid

[Tutor] getopt matching incorrect options

2005-07-11 Thread Jay Loden
I have an app that takes a command line argument of -l or --list. It uses the getopt module to parse the arguments, and I just noticed that for some reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in below) Is this normal behavior, and if so, is there any way to avoi

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Jay Loden
I don't believe it does...some time ago I asked about this when I was creating a list and I wanted the opposite of list.append() - if you search "prepend to a list" you should find the responses I was sent. The only solutions Python offers that I'm aware of are to either use list.insert() at t

Re: [Tutor] How do I add an argument too...

2005-08-03 Thread Jay Loden
I think it was just a typo for "the python distro" that came out as "the epython distro"... On Thursday 21 July 2005 9:15 pm, Danny Yoo wrote: > On Thu, 21 Jul 2005, Joseph Quigley wrote: > > optparse.. Can I download that as a module or do I have to download > > epython? > > Hi Joseph, > > optpa

[Tutor] Zope/Python web devel

2005-08-03 Thread Jay Loden
I've been considering some web projects recently, but I have some concerns about selecting the tools I plan to use. I like Python, and I was immediately thinking of using Zope to build on. However, I am concerned about performance, resource usage, and scalability. Does anyone here have any expe

Re: [Tutor] while loops

2005-08-08 Thread Jay Loden
> coin = random.randrange(2) That's the problem there...you've got coin assigned outside the while loop, so it is assigned 0 or 1 once, before the loop, and then you're running 100 checks on the same value. If you move > coin = random.randrange(2) to inside the while loop before the if state

Re: [Tutor] Invoking bash from within a python program

2005-09-02 Thread Jay Loden
Watch yourself on this one, slocate can often return some unexpected results for file searches, and the last thing you want to do is delete something important while trying to remove the latest game you installed. Also, if you're installing from source you can often run "make uninstall" to rem

[Tutor] Python equiv to PHP "include" ?

2005-09-29 Thread Jay Loden
I've not been able to find an answer to this conundrum anywhere: My current website is done in PHP with a setup something like this: ::PHP TEMPLATE CODE:: include('file.htm') ::PHP TEMPLATE CODE:: This way, I can have PHP embedded in my htm files and it will be processed as part of the scri

Re: [Tutor] Python equiv to PHP "include" ?

2005-09-29 Thread Jay Loden
Alan, thanks for your responses, they're quite helpful. I suspect the real problem I'm having is simply trying to switch modes of thinking to CGI style or mod_python style instead of the PHP style embedded code. The whole point of this exercise for me was to decide which language I prefer for

[Tutor] Mod_python greedy url matching

2005-10-04 Thread Jay Loden
I'm having trouble with Apache and Mod_python - mod_python is set to use /var/www/html and pass all *.htm files on to the handler I wrote. Unfortunately, mod_python does a greedy match, so /var/www/html/subdirectory/file.htm still gets passed to the handler! Is there some way to limit the hand

Re: [Tutor] hand-holding for web development

2005-10-17 Thread Jay Loden
You need an Apache config section to tell it what to use mod_python on and how. For example, in httpd.conf or a separate file in your conf.d directory for apache: AddHandler mod_python .py PythonHandler test PythonDebug On tells Apache to use mod_python on all .py f

Re: [Tutor] hand-holding for web development

2005-10-24 Thread Jay Loden
Sorry, didn't see your reply until now... the directory section can go either in your main apache config file (in my case, /etc/httpd/conf/httpd.conf ) OR in a separate file in the conf.d directory. In my case, I have a python.conf file in /etc/httpd/conf.d/ that contains the following: LoadM