Re: [Tutor] Question about resetting values

2005-11-11 Thread Hugo González Monteverde
There may be more than one way to have it get a zero value. But in languages like Python readability and clarity are valued, and clearly var = 0 is the clearest way to do it, although var = var^var comes to mind, *grin* Hugo Nathan Pinno wrote: > Never mind all. I was just being stupid as u

[Tutor] Using CGIHTTPServer on Windows to run Perl & Python scripts - POST to Perl fails

2005-11-11 Thread Python
The perl scripts use cgi.pm. The Python scripts use the cgi module. Everything runs OK on Linux, where fork is available. On Windows the run_cgi method uses os.popen3 to run the script and writes the post data to the script's input file. The Python scripts are OK. The Perl scripts do not receiv

[Tutor] File extension for CGI scripts written in Python

2005-11-11 Thread Carroll, Barry
Greetings: I am writing the first of the handler routines for my test system web interface. They will be Common Gateway Interface (CGI) scripts written in Python. In the literature I have studied, I have seen the extensions .cgi and .py applied to such files. Is one preferred over the other, or

Re: [Tutor] dictionary question

2005-11-11 Thread Alan Gauld
> I should have known. sheesh python is so kewl. I keep forgetting most > times, > it will do stuff directly and you don't have to assign.. Whether thats 'kewl' depends on your viewpoint. >From a pure computing point of view returning a value is more consistent and correct in a functional program

Re: [Tutor] simple report writing? -- Thanks!

2005-11-11 Thread CPIM Ronin
Yes Johan, I did! Both the report and sort suggestions worked! Thanks to everyone who replied! FP >From: Johan Geldenhuys <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: CPIM Ronin <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] simple report writing? >Date: Fri, 11 Nov 2

[Tutor] Newbie Anxiety

2005-11-11 Thread Terry Kemmerer
Ah, memory lane time again :-) Oh, you had advanced BASIC - it allowed nested for loops! :-) My first BASIC only allowed for loops that could be written in a single line...Anything more complex you had to call a subroutine with GOSUB. Ha! Yes! As Monte Python would say, "Well..It got

Re: [Tutor] Does a module for DirectFB exist?

2005-11-11 Thread Roger Merchberger
Rumor has it that Roger Merchberger may have mentioned these words: >DirectFB is short for Direct Frame Buffer, and allows access to a graphical >frame buffer system in *nix (and I think maybe MacOSX) from a text prompt >without going through X. > >Anyone know of a module to access this through Pyt

Re: [Tutor] dictionary question

2005-11-11 Thread Eric Walker
ahh man, I should have known. sheesh python is so kewl. I keep forgetting most times, it will do stuff directly and you don't have to assign.. Thanks Python Newbie On Friday 11 November 2005 02:59 pm, DS wrote: > You almost have it. Do this instead. > > d = {'first':[]} > d['first'].appe

Re: [Tutor] dictionary question

2005-11-11 Thread DS
You almost have it. Do this instead. d = {'first':[]} d['first'].append("string") Append acts on the list, so assignment is unnecessary. ds Eric Walker wrote: >All, >I have a dictionary say: >d = {'first':[]} >I am going through another list and depending on whats going on, >I want to add to t

Re: [Tutor] dictionary question

2005-11-11 Thread Shi Mu
On 11/11/05, Eric Walker <[EMAIL PROTECTED]> wrote: > All, > I have a dictionary say: > d = {'first':[]} > I am going through another list and depending on whats going on, > I want to add to the empty list. I have tried the following to noavail. > > d['first'] = d['first'].append("string") > > I wo

[Tutor] dictionary question

2005-11-11 Thread Eric Walker
All, I have a dictionary say: d = {'first':[]} I am going through another list and depending on whats going on, I want to add to the empty list. I have tried the following to noavail. d['first'] = d['first'].append("string") I would think this would result in the dictionary key first's empty list

Re: [Tutor] testing: doctest and unittest

2005-11-11 Thread Kent Johnson
Kent Johnson wrote: > Alex Hunsley wrote: >>Where do you seasoned pythonites see unittest and doctest in relation to >>each other? Do you only use one or the other? > > > I think it is mostly personal preference. Doctest is nice where you > create examples for others, maybe not so nice where you

Re: [Tutor] two ways

2005-11-11 Thread Shi Mu
thanks! On 11/11/05, Gregor Lingl <[EMAIL PROTECTED]> wrote: > Liam Clarke schrieb: > > >Hi Shi, > > > >For what you're doing, nothing at all. > > > >When you use a colon, slice syntax, it defaults to [start:end] so p = > >a[:] is the same as > >p = a[0:len(a)] > > > > > > > But in fact there is a

Re: [Tutor] Newbie Anxiety

2005-11-11 Thread Alan Gauld
Ah, memory lane time again :-) >A good natured word of explanation for Chris and others: > 10 FORN=1TO10:?N:NEXTN: REM It is bad form not to name N after NEXT to > label which FOR NEXT loop is being incremented. Oh, you had advanced BASIC - it allowed nested for loops! :-) My first BASIC only al

Re: [Tutor] two ways

2005-11-11 Thread Alan Gauld
> what is the difference between the two ways of assigning the list? > p=a vs. p=a[:] The first makes p point at the same list as a. The second makes p point at a *copy* of the list pointed to by a. You will see the difference if you try to modify the lists after assignment. In the first case mod

Re: [Tutor] logging to a database

2005-11-11 Thread Kent Johnson
captnswing wrote: > Hello all, > I would like to log messages to a database (mysql) > I found the example log_test14.py that comes with python logging > module http://www.red-dove.com/python_logging.html > but that example is a bit greek for me ... :) and it doesnt work with > mysql Have you u

Re: [Tutor] two ways

2005-11-11 Thread Liam Clarke
Oooh... that's a gotcha. Shi Mu - did you understand that? There is a crucial difference as Gregor pointed out, that I missed, and I do apologise. On 11/11/05, Gregor Lingl <[EMAIL PROTECTED]> wrote: > Liam Clarke schrieb: > > >Hi Shi, > > > >For what you're doing, nothing at all. > > > >When you

Re: [Tutor] two ways

2005-11-11 Thread Gregor Lingl
Liam Clarke schrieb: >Hi Shi, > >For what you're doing, nothing at all. > >When you use a colon, slice syntax, it defaults to [start:end] so p = >a[:] is the same as >p = a[0:len(a)] > > > But in fact there is a difference. I'll show you: >>> a=range(5)### creates a list-object >>> id(a)

Re: [Tutor] Percentage

2005-11-11 Thread Sean Perry
Johan Geldenhuys wrote: > Hi all, > > What is the syntax if I want to work out what percentage 42 is out of 250? > 42 is x percent of 250. (is / of) = (x / 100) one of those formulas from school I will always remember. (42 / 250) = (x / 100.0) 250x = 4200.0 x = 4200.0 / 250 x = 16.8%

Re: [Tutor] two ways

2005-11-11 Thread Liam Clarke
Hi Shi, For what you're doing, nothing at all. When you use a colon, slice syntax, it defaults to [start:end] so p = a[:] is the same as p = a[0:len(a)] Regards, Liam Clarke On 11/11/05, Shi Mu <[EMAIL PROTECTED]> wrote: > what is the difference between the two ways of assigning the list? > p=