[Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Joshua Harper
Ok, so I am trying to learn python, and I am reading many tutorial type things and I am kind of stuck with implementing some of the code... so for example the tutorial says "*To get the examples working properly, write the programs in a text file and then run that with the interpreter*" Alright...s

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Michael Connors
2009/8/6 Joshua Harper > Ok, so I am trying to learn python, and I am reading many tutorial type > things and I am kind of stuck with implementing some of the code... so for > example the tutorial says "*To get the examples working properly, write > the programs in a text file and then run that w

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Robert Berman
On Thu, 2009-08-06 at 03:44 -0400, Joshua Harper wrote: > Ok, so I am trying to learn python, and I am reading many tutorial > type things and I am kind of stuck with implementing some of the > code... so for example the tutorial says "To get the examples working > properly, write the programs i

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Dave Angel
Michael Connors wrote: 2009/8/6 Joshua Harper Ok, so I am trying to learn python, and I am reading many tutorial type things and I am kind of stuck with implementing some of the code... so for example the tutorial says "*To get the examples working properly, write the programs in a text fil

[Tutor] easy way to pupulate a dict with functions

2009-08-06 Thread Albert-Jan Roskam
Hi, I was playing with the code below, and I was wondering if there was a way to populate the dictionary called 'commands' (in the function 'check_command()'). Suppose I would add another function, which I would also like to store as a value in 'commands', could it simply be programmed, or woul

Re: [Tutor] easy way to populate a dict with functions

2009-08-06 Thread bob gailer
Please start a new email when starting a new topic. Otherwise it gets linked to the previous one in email clients that follow threads! To avoid that here I am responding in a new email. Also fixed spelling in subject. Albert-Jan Roskam wrote: Hi, I was playing with the code below, and I was

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Alan Gauld
"Joshua Harper" wrote Ok, so I am trying to learn python, and I am reading many tutorial type If you are just learning Python downgrade from 3.1 to v2.6. Most tutorials are not up to 3.1 yet and there are many differences. v3.1 was a big change to the language. eg. The following code is for

Re: [Tutor] easy way to populate a dict with functions

2009-08-06 Thread Albert-Jan Roskam
Hi Bob, Very neat solution, thanks a lot! I didn't know the inspect module, but it's just what's needed here. Cool! And sorry about not starting a new mail. I'll keep it in mind for next time. Best wishes, Albert-Jan --- On Thu, 8/6/09, bob gailer wrote: > From: bob gailer > Subject: RE:

Re: [Tutor] easy way to populate a dict with functions

2009-08-06 Thread Albert-Jan Roskam
...Still one more question: cmds = inspect.getmembers(commands, inspect.isfunction) print cmds #will generate [('bletch', ), ('foo', ), ('romans', ), ('stilton', )] This looks okay, but the order in which the functions appear in the module (commands.py) is different: foo, bletch, stilton, romans

[Tutor] monitor number of files in a folder

2009-08-06 Thread pedro
Hi I am rendering image sequences on a basic render farm that I am building. Once all the files in the sequence have been rendered I would like to make a quicktime of the sequence automatically. The problem I am having is that if one of the computers on the farm is rendering slow the quicktime

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Che M
> Start a CMD window and run the python command by typing the command > at the DOS prompt. > > eg > > C:\Windows> python some\path\to\myscript.py > > > That way you will still see the error message after the > program finishes. Or what about using IDLE? _

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > >>> What is the recommended way to configure my application find the various >> database and/or configuration files it needs? >> >> Recommemded by whom? A lot depends on the OS. Apple for example have one set >> of >> recommendations for MacOS, Windows has another an

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Wayne
On Thu, Aug 6, 2009 at 2:33 PM, pedro wrote: > Hi I am rendering image sequences on a basic render farm that I am > building. Once all the files in the sequence have been rendered I would like > to make a quicktime of the sequence automatically. The problem I am having > is that if one of the com

Re: [Tutor] easy way to populate a dict with functions

2009-08-06 Thread bob gailer
Albert-Jan Roskam wrote: Hi Bob, Very neat solution, thanks a lot! I didn't know the inspect module, but it's just what's needed here. Cool! Great. Regarding the ordering of functions in the list - variable names in namespaces (such as modules) are stored in dictionaries. Any ordering is l

[Tutor] Noobish Syntay Error?

2009-08-06 Thread Anna - Sophie Maeser
Hi! I want to ask you a quick question.. when I type in print '' hello world'' and then press enter, it says there is a syntax error... I really don't know what im doing wrong. I downloaded python 3.1 and am using IDLE with it.. im using mac. Please help me findt he problem because its a ver

[Tutor] Fwd: Noobish Syntay Error?

2009-08-06 Thread Wayne
Forgot reply-all -- Forwarded message -- From: Wayne Date: Thu, Aug 6, 2009 at 3:32 PM Subject: Re: [Tutor] Noobish Syntay Error? To: Anna - Sophie Maeser On Thu, Aug 6, 2009 at 2:08 PM, Anna - Sophie Maeser < annasop...@dautzenberg.org> wrote: > Hi! > I want to ask you a quic

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread pedro
On 2009-08-06 15:49:35 -0400, Wayne said: On Thu, Aug 6, 2009 at 2:33 PM, pedro wrote: Hi I am rendering image sequences on a basic render farm that I am building. Once all the files in the sequence have been rendered I would like to make a quicktime of the sequence automatically. The prob

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread pedro
On 2009-08-06 15:49:35 -0400, Wayne said: On Thu, Aug 6, 2009 at 2:33 PM, pedro wrote: Hi I am rendering image sequences on a basic render farm that I am building. Once all the files in the sequence have been rendered I would like to make a quicktime of the sequence automatically. The prob

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > As a follow-up question, how do give my modules stored under ./lib access to > the data in my ConfigParser object? (For instance, database connection > string, storage path, etc.) > > I guess a global ConfigParser object would work, but that seems wrong. > And yet

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Dave Angel
pedro wrote: On 2009-08-06 15:49:35 -0400, Wayne said: On Thu, Aug 6, 2009 at 2:33 PM, pedro wrote: Hi I am rendering image sequences on a basic render farm that I am building. Once all the files in the sequence have been rendered I would like to make a quicktime of the sequence automat

[Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread chase pettet
I am trying to write a script to work our LVS implementation. I want to be able to have user do something like this "./script SITE SERVER" and have the script look up the ip value of the site on that server and issue the command to pull the status from LVS. I am almost there but for some reason

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Sander Sweers
2009/8/6 Dave Angel : > > You have to choose your poison. I prefer no poison. This is exactly what inotiy was made for and although I never used it there is a python module for it [1]. It would be great if you can post your experience with it. Greets Sander [1] http://trac.dbzteam.org/pyinotify/

Re: [Tutor] Noobish Syntay Error?

2009-08-06 Thread Dave Angel
Anna - Sophie Maeser wrote: Hi! I want to ask you a quick question.. when I type in print '' hello world'' and then press enter, it says there is a syntax error... I really don't know what im doing wrong. I downloaded python 3.1 and am using IDLE with it.. im using mac. Please help me findt he

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread vince spicer
On Thu, Aug 6, 2009 at 3:18 PM, chase pettet wrote: > I am trying to write a script to work our LVS implementation. I want to be > able to have user do something like this "./script SITE SERVER" and have > the script look up the ip value of the site on that server and issue the > command to pul

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread vince spicer
On Thu, Aug 6, 2009 at 3:42 PM, vince spicer wrote: > > > On Thu, Aug 6, 2009 at 3:18 PM, chase pettet wrote: > >> I am trying to write a script to work our LVS implementation. I want to >> be able to have user do something like this "./script SITE SERVER" and have >> the script look up the ip

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread Νικόλαος Ράπτης
Hmmm.. First of all.. In the non working code: a = LVS_Site() z = sys.argv[2] b = b["%s" % (sys.argv[1])] c = a.show(b) . Did you really mean b = b["%s" % (sys.argv[1])] or perhaps b = z["%s" % (sys.argv[1])] Also, I can't see why your doing the string formatting in there: b = z[sys.a

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread Dave Angel
chase pettet wrote: I am trying to write a script to work our LVS implementation. I want to be able to have user do something like this "./script SITE SERVER" and have the script look up the ip value of the site on that server and issue the command to pull the status from LVS. I am almost ther

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Dave Angel
Sander Sweers wrote: 2009/8/6 Dave Angel : You have to choose your poison. I prefer no poison. This is exactly what inotiy was made for and although I never used it there is a python module for it [1]. It would be great if you can post your experience with it. Greets Sander [1] http:

[Tutor] clear screen inside python interpreter

2009-08-06 Thread Monte Milanuk
Okay, simple question: is there anything similar to to 'clear' or 'cls' to clean up a console window full of commands in the python shell? Short of exiting and restarting the interpreter I'm not having a lot of luck here. Thanks, Monte ___ Tutor mailli

Re: [Tutor] clear screen inside python interpreter

2009-08-06 Thread Nick Raptis
I don't think there's a Python command to do this. You can always print enough newlines to clear your view of the window: print "\n" * 80 or use os.system to issue a command the shell/terminal/cmd will understand import os os.system("cls") or import os os.system("clear") I resently made a

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Allen Fowler
> > Assuming the application could be invoked in odd ways that may alter the > notion of the current working directory, how do I unambiguously find the > absolute path to the current python source file? (So I can load the nearby > .ini) > > I use a helper function that calculates the absol

[Tutor] need help

2009-08-06 Thread jonathan wallis
i am in the process of creating a simple python program, and i have come across a problem which i can not solve, here is the code *import pygame from pygame.locals import * from pygame.color import THECOLORS if not pygame.font: print 'Atention, there are no fonts.' if not pygame.mixer:

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Allen Fowler
> Martin Walsh > > Allen Fowler wrote: > > > > > > > As a follow-up question, how do give my modules stored under ./lib access > > to > the data in my ConfigParser object? (For instance, database connection > string, > storage path, etc.) > > > > I guess a global ConfigParser object w

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Νικόλαος Ράπτης
Well, os.listdir doesn't include "." or ".." anyway as you can see here So, just a simplelen(os.listdir(my_directory))will suffice.. A couple more points: -It's better looking and more readable (to me that means Pythonic) to store that

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Allen Fowler
> > Something like this ... > > # lib/mypaths.py > # -- > > import os > > def script_path(base): > return os.path.realpath(os.path.abspath(base)) > > def script_dir(base): > return os.path.dirname(script_path(base)) > > def join_relative(base, path): > return os.pa

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Alan Gauld
"Che M" wrote C:\Windows> python some\path\to\myscript.py That way you will still see the error message after the program finishes. Or what about using IDLE? Good point, although IDLE can bring its own problems. But for this case IDLE would be a good choice. -- Alan Gauld Author o

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Alan Gauld
"Allen Fowler" wrote For an object that needs many settings, what about passing in an instance of ConfigParser? (Or should I extract the settings to a dict, first?) Personally I usually extract an ini type settings to either global variables or an object or a dict at start up., I then pa

Re: [Tutor] clear screen inside python interpreter

2009-08-06 Thread Alan Gauld
"Monte Milanuk" wrote Okay, simple question: is there anything similar to to 'clear' or 'cls' to clean up a console window full of commands in the python shell? Short of exiting and restarting the interpreter I'm not having a lot of luck here. Terminal control is very system dependant. Fre

Re: [Tutor] need help

2009-08-06 Thread Alan Gauld
"jonathan wallis" wrote from pygame.locals import * from pygame.color import THECOLORS if not pygame.font: print 'Atention, there are no fonts.' if not pygame.mixer: print 'Atention, there is no sound.' pygame.init() blue = (0, 0, 255) red = (255, 0, 0) black = (0, 0, 0) window_widt

[Tutor] regex problem with colon

2009-08-06 Thread Tim Johnson
using python 2.5. I'm having a problem with including a colon as part of a substring bounded by whitespace or beginning of line. Here's an example: p = re.compile(r'\bcc:\b',re.IGNORECASE) >>> res = p.findall('malicious cc: here CC: there') >>> res [] ## Darn! I'd hope that the 'cc:' and 'CC:' subs

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > >> Something like this ... >> >> # lib/mypaths.py >> # -- >> >> import os >> >> def script_path(base): >> return os.path.realpath(os.path.abspath(base)) >> >> def script_dir(base): >> return os.path.dirname(script_path(base)) >> >> def join_relative(

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > >> Martin Walsh >> > >> Allen Fowler wrote: >>> As a follow-up question, how do give my modules stored under ./lib access >>> to >> the data in my ConfigParser object? (For instance, database connection >> string, >> storage path, etc.) >>> I guess a global ConfigPa

Re: [Tutor] regex problem with colon

2009-08-06 Thread Kent Johnson
On Thu, Aug 6, 2009 at 8:47 PM, Tim Johnson wrote: > using python 2.5. > I'm having a problem with including a colon as part of a substring > bounded by whitespace or beginning of line. > Here's an example: > p = re.compile(r'\bcc:\b',re.IGNORECASE) res = p.findall('malicious cc: here CC: ther

Re: [Tutor] regex problem with colon

2009-08-06 Thread Tim Johnson
* Kent Johnson [090806 18:31]: > On Thu, Aug 6, 2009 at 8:47 PM, Tim Johnson wrote: > > using python 2.5. > > I'm having a problem with including a colon as part of a substring > > bounded by whitespace or beginning of line. > > Here's an example: > > p = re.compile(r'\bcc:\b',re.IGNORECASE) > >>>