[Tutor] still not getting 'it'

2005-10-05 Thread Rosalee Dubberly
I am having problems with changing the parameters in my second function. I want the second function to run the same as the first, but take different parameters. What am I doing wrong def firstpart(): """Define a function that takes no parameters and does the following: Returns (not

Re: [Tutor] Handling Objects

2005-10-05 Thread Andrew P
To do: $color = "Green"; print "$color apple.\n"; You would want: color = "Green" print "%s apple." % color Both of which would print "Green apple."  That is actually something I like about Perl, but it reinforces some bad habits, at least for me.  Boilerplate coding, as it were, when doing qui

Re: [Tutor] regExpress

2005-10-05 Thread Eric Walker
Thanks so much Kent.. Eric ... --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Eric Walker wrote: > > All, > > If I have something like this: > > import re > > sample = 'myboss:isbad' > > express = re.compile('(.*):(.*)) > > answer = re.match(express,sample) > > > > how do I get it to tell me if

Re: [Tutor] Getting name scope

2005-10-05 Thread Bernard Lebel
Thanks for the answer. I have to confess this question is driven only by curiosity, I was not even hoping to get such a function. I was reading some stuff about the scopes in JScript and somehow this question arose in my mind. For the record, the tutorial I am watching said that a name exists *on

Re: [Tutor] Getting name scope

2005-10-05 Thread Kent Johnson
Bernard Lebel wrote: > Hello, > > Anyone know if it is possible to find out in what scope lies a name? > For instance, let say I'm using a name in a function, but the name is > actually in the global scope. I would like to know if this name was > found in what scope. Is it possible at all? Look f

Re: [Tutor] Embedding

2005-10-05 Thread Kent Johnson
You might be interested in this article about making a game in a week using Python and Pygame: http://www.gamedev.net/reference/articles/article2259.asp Joseph Quigley wrote: > Hi, > Ok, I'll try to convince them to try python... but still, would it be > best to just: > Program in C with Python

[Tutor] Getting name scope

2005-10-05 Thread Bernard Lebel
Hello, Anyone know if it is possible to find out in what scope lies a name? For instance, let say I'm using a name in a function, but the name is actually in the global scope. I would like to know if this name was found in what scope. Is it possible at all? Thanks Bernard ___

Re: [Tutor] Handling Objects

2005-10-05 Thread Eric Walker
Thanks Kent.. I think that would work for what I am doing. So is it safe to say that python doesn't do variable interpolation like perl..? Thanks in advance. Python Newbie... On Wednesday 05 October 2005 05:20 pm, Kent Johnson wrote: > Eric Walker wrote: > > Well, > > I think I probably can do

Re: [Tutor] regExpress

2005-10-05 Thread Kent Johnson
Eric Walker wrote: > All, > If I have something like this: > import re > sample = 'myboss:isbad' > express = re.compile('(.*):(.*)) > answer = re.match(express,sample) > > how do I get it to tell me if it was a match or not. I have tried > answer.match . It just gives me an object pointer or som

Re: [Tutor] How to write this to a file?

2005-10-05 Thread Dick Moores
Kent Johnson wrote at 16:32 10/5/2005: >Dick Moores wrote: > > I have a script that writes it's output to a file. I also print the > time with > > > > print "Time was %.4g seconds" % (timeEnd - timeStart) > > > > How could I also have the same output of the print expression, > written to > > the

Re: [Tutor] Handling Objects

2005-10-05 Thread Kent Johnson
Eric Walker wrote: > Thanks Kent.. I think that would work for what I am doing. So is it safe to > say that python doesn't do variable interpolation like perl..? I think so, though I don't really speak perl. The closest approximation is the string formatting operation and the string.Template cla

[Tutor] regExpress

2005-10-05 Thread Eric Walker
All, If I have something like this: import re sample = 'myboss:isbad' express = re.compile('(.*):(.*)) answer = re.match(express,sample) how do I get it to tell me if it was a match or not. I have tried answer.match . It just gives me an object pointer or something. Thanks Python Newbie... _

Re: [Tutor] How to write this to a file?

2005-10-05 Thread Kent Johnson
Dick Moores wrote: > I have a script that writes it's output to a file. I also print the time with > > print "Time was %.4g seconds" % (timeEnd - timeStart) > > How could I also have the same output of the print expression, written to > the file? The formatting part of the print is just an expr

Re: [Tutor] Console output

2005-10-05 Thread Kent Johnson
Oliver Maunder wrote: > Just what I needed - thanks everyone. I never realised '\r' was actually > good for something other than Windows line breaks! Hmm, just have to say something about the old days when 'carriage return' and 'line feed' really meant something :-) Kent __

Re: [Tutor] Handling Objects

2005-10-05 Thread Kent Johnson
Eric Walker wrote: > Well, > I think I probably can do this easier in perl but I took a vow I would try > and > learn python. I know I am using classes here and really don't need objects. > This is just another way for me to learn how to work with classes within > python. My object actually wi

[Tutor] How to write this to a file?

2005-10-05 Thread Dick Moores
I have a script that writes it's output to a file. I also print the time with print "Time was %.4g seconds" % (timeEnd - timeStart) How could I also have the same output of the print expression, written to the file? Thanks, Dick Moores ___ Tutor mai

Re: [Tutor] Python Shell Not Saved Problem

2005-10-05 Thread Alan Gauld
> Also, someone advised that the Shell window not be used that way anyway. > I > think I agree and will operate from Pythonwin from now on. The same applies in Pythonwin. You cannot run the interactive shell buffer because Python will try to execute all the output from the commands - they get exe

Re: [Tutor] Accessing Variables

2005-10-05 Thread Alan Gauld
> If I have ONE.py file with some variable a, and ONE imports TWO, which > has a variable b, can TWO access variable a (I don't think so, but I > just thought I'd check). Correct you can't do it. And quite rightly so because trying to do so would indicate a faulty design! When we import a module i

Re: [Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS)algorithm help]

2005-10-05 Thread Kent Johnson
Michael Cotherman wrote: > def UnStuffData(src,dst,len): > >for code in src: > for i in range(1,code): > dst.append(i) > > if code < 0xff > dst.append('\0') > > the above is the below code uncommented... > it(and the original code) just seem to find the end

Re: [Tutor] Console output

2005-10-05 Thread Marcin Komorowski
- Original Message - From: "Roel Schroeven" <[EMAIL PROTECTED]> To: Sent: Wednesday, October 05, 2005 2:53 PM Subject: Re: [Tutor] Console output > Oliver Maunder wrote: >> Does anyone know how I can update a line of console output without >> creating a new line? I'm not explaning this

Re: [Tutor] Handling Objects

2005-10-05 Thread Eric Walker
Well, I think I probably can do this easier in perl but I took a vow I would try and learn python. I know I am using classes here and really don't need objects. This is just another way for me to learn how to work with classes within python. My object actually will be storing like 5 or 6 differ

Re: [Tutor] Accessing Variables

2005-10-05 Thread Kent Johnson
Matt Williams wrote: > Dear List, > > I'm trying to clarify something about accessing variables. > > If I have ONE.py file with some variable a, and ONE imports TWO, which > has a variable b, can TWO access variable a (I don't think so, but I > just thought I'd check). You are right. TWO can imp

Re: [Tutor] Handling Objects

2005-10-05 Thread Kent Johnson
Eric Walker wrote: > New to Python and trying to do some class stuff with a simple task. > Problem: > 1) get a list of file names in a directory > 2) create variables with the same name of each filename pulled from the > directory. > 3) Create an object for each and pass into the __init__ method

[Tutor] Python Shell Not Saved Problem

2005-10-05 Thread Steve Haley
Dear folks,   Just wanted to thank everyone for the help.  I think I know what was going on with that “The buffer for Python Shell is not saved” message I was getting when I tried to run a script.  Apparently you need to open the module before you run the script and also to re-open it eac

Re: [Tutor] Accessing Variables

2005-10-05 Thread paul brian
Sort ofnot really When a module is imported the following things happen import ONE a module object (dict essentially) named ONE is created. This is the module ONE.py's namespace. The module object is added to sys.modules the code in the object is executed inside the ONE dict (namespace) now

Re: [Tutor] Accessing Variables

2005-10-05 Thread Adam
What you can do is if ONE.py has a class with the variable a, in it, you can pass the class instance (ie. self) and then you can call any function or get any global class variable. eg def foo(parent):     print parent.aOn 05/10/05, Matt Williams <[EMAIL PROTECTED]> wrote: Dear List,I'm trying to cl

[Tutor] Handling Objects

2005-10-05 Thread Eric Walker
New to Python and trying to do some class stuff with a simple task. Problem: 1) get a list of file names in a directory 2) create variables with the same name of each filename pulled from the directory. 3) Create an object for each and pass into the __init__ method the stringname of the file nam

Re: [Tutor] need help to understand terms for desinging a program

2005-10-05 Thread paul brian
I would suggest that you look firstly at qmails own built in ruleset. something like that must be achieveable without writing a special plugin. qmail control files are usually in /var/qmail/control. Nothing obvious in the man pages i am afraid. Good luck On 10/5/05, Hameed U. Khan <[EMAIL PROTE

[Tutor] Accessing Variables

2005-10-05 Thread Matt Williams
Dear List, I'm trying to clarify something about accessing variables. If I have ONE.py file with some variable a, and ONE imports TWO, which has a variable b, can TWO access variable a (I don't think so, but I just thought I'd check). I guess the way round this is just to make some classes & obj

Re: [Tutor] Console output

2005-10-05 Thread Alan Gauld
> 14% [===> ] 344,192 16.28K/s ETA 02:19 > > All the figures and the progress bar get continously updated. The only way > I > know of sending output to the console is to use print or > sys.stdout.write(), > but that would give me: > 14% [===> ] 344,192 16.28K/s ETA 02:19 > 18% [=>

Re: [Tutor] Console output

2005-10-05 Thread Oliver Maunder
Just what I needed - thanks everyone. I never realised '\r' was actually good for something other than Windows line breaks! Olly ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] New Python book

2005-10-05 Thread Dick Moores
Andrew Fant wrote at 11:41 10/5/2005: >Kent Johnson wrote: > > Dick Moores wrote: > > > >>Magnus Lie Hetland's new book, _Beginning Python: From Novice to > >>Professional_ was published by Apress on Sept. 26 (in the U.S.). Very > >>much worth a look, IMHO. But what do the tutors think? > >> > >>

Re: [Tutor] Console output

2005-10-05 Thread Johan Geldenhuys
This might help. Never used it though. Johan Christian Wyglendowski wrote: > -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Maunder Sent: Wednesday, October 05, 2005 1:13 PM To: tutor@python.org Subject: [Tutor] Console output Does anyon

Re: [Tutor] need help to understand terms for desinging a program

2005-10-05 Thread Hameed U. Khan
On 10/5/05, paul brian <[EMAIL PROTECTED]> wrote: > This is a pretty big question, and it would be easier to answer if you > can give us more details about what you want to do. > > It seems you want to inspect outgoing mails (possibly rewrite their > addresses?) before the mails are sent out. > > I

Re: [Tutor] Console output

2005-10-05 Thread python-tutor
>>> import sys >>> import time >>> myList=range(10) >>> for x in myList: ... sys.stdout.write(str(x) + "\r") ... sys.stdout.flush() ... time.sleep(1) The "\r" causes a return without a newline feed. Flush forces the text to be output (instead of getting buffered) Enjoy! Todd Maynard

Re: [Tutor] Console output

2005-10-05 Thread Roel Schroeven
Oliver Maunder wrote: > Does anyone know how I can update a line of console output without > creating a new line? I'm not explaning this too well, so here's an example. > > When you download a file with wget, the console display looks like this: > > 14% [===>

Re: [Tutor] Console output

2005-10-05 Thread Christian Wyglendowski
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Maunder > Sent: Wednesday, October 05, 2005 1:13 PM > To: tutor@python.org > Subject: [Tutor] Console output > > Does anyone know how I can update a line of console output > without creating a

Re: [Tutor] New Python book

2005-10-05 Thread Andrew Fant
Kent Johnson wrote: > Dick Moores wrote: > >>Magnus Lie Hetland's new book, _Beginning Python: From Novice to >>Professional_ was published by Apress on Sept. 26 (in the U.S.). Very >>much worth a look, IMHO. But what do the tutors think? >> >>

Re: [Tutor] New Python book

2005-10-05 Thread Kent Johnson
Dick Moores wrote: > Magnus Lie Hetland's new book, _Beginning Python: From Novice to > Professional_ was published by Apress on Sept. 26 (in the U.S.). Very > much worth a look, IMHO. But what do the tutors think? > > This seems to be an up

[Tutor] Console output

2005-10-05 Thread Oliver Maunder
Does anyone know how I can update a line of console output without creating a new line? I'm not explaning this too well, so here's an example. When you download a file with wget, the console display looks like this: 14% [===>    ] 344,192  

[Tutor] New Python book

2005-10-05 Thread Dick Moores
Magnus Lie Hetland's new book, _Beginning Python: From Novice to Professional_ was published by Apress on Sept. 26 (in the U.S.). Very much worth a look, IMHO. But what do the tutors think? Dick Moores [EMAIL PROTECTED]

Re: [Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS)algorithm help]

2005-10-05 Thread Michael Cotherman
def UnStuffData(src,dst,len): for code in src: for i in range(1,code): dst.append(i) if code < 0xff dst.append('\0') the above is the below code uncommented... it(and the original code) just seem to find the end and puts a zero there... I do not see the exis

Re: [Tutor] FW: Help Needed

2005-10-05 Thread Carroll, Barry
Alan is right. According to section 3.5.2 of "Learning Python, 2nd Edition", by David Ascher and Mark Lutz: Run scripts from text edit windows, not the interactive window. To run a file of code under IDLE, always select the Edit/RunScript menu option from within the text

Re: [Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS)algorithm help]

2005-10-05 Thread Michael Cotherman
This is exactly what i was looking for For those following, the \x00 added at the end of the packet is just imaginary and represents in the meantime, I made the following that just 'decobs' a series of packets (only 8-10 bytes) that are coming in over the com port. (my incoming packets also b

Re: [Tutor] Line continuation with readlines

2005-10-05 Thread bob
At 07:20 PM 10/3/2005, Craig MacFarlane wrote: >Hello, > >Is there a way to make line continuation work with >the readlines function? > >i.e. Do you mean e.g.? > this is \ > one line. I assume the above is a 2 line file you wish to read using a file object's readlines method. There is not

Re: [Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS)algorithm help]

2005-10-05 Thread Kent Johnson
Alan Gauld wrote: >> return (UINT)(dst - dstStart); >> } > > > This looks odd, I don't think I understand what it does. > It seems to return an address thats potentially (probably?!) > before the start of the original dst... It's returning the length of dst. Kent __

Re: [Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS)algorithm help]

2005-10-05 Thread Alan Gauld
> I am a noob to converting pointers in C++ to arrays in > python, although the first time I see it done, I will > have no problem. Can you help converting the below > (what I think is the 'decoder' section) to python? It won't be working code but I think this is whats happening... > UINT CCobsPa

[Tutor] [Fwd: Re: Consistant Overhead Byte Stuffing (COBS) algorithm help]

2005-10-05 Thread Kent Johnson
Forwarding to the list Original Message Subject: Re: [Tutor] Consistant Overhead Byte Stuffing (COBS) algorithm help Date: Tue, 4 Oct 2005 13:20:18 -0700 (PDT) From: Michael Cotherman <[EMAIL PROTECTED]> To: Kent Johnson <[EMAIL PROTECTED]> Thanks for the response, the .NET code

Re: [Tutor] Consistant Overhead Byte Stuffing (COBS) algorithm help

2005-10-05 Thread Kent Johnson
Michael Cotherman wrote: > I am a noob to converting pointers in C++ to arrays in > python, although the first time I see it done, I will > have no problem. Can you help converting the below > (what I think is the 'decoder' section) to python? OK I'll bite. Your code is copying from a src buffer t

Re: [Tutor] How to strip both single and double quotes

2005-10-05 Thread Dick Moores
Alan Gauld wrote at 04:38 10/5/2005: > > how to use strip just once to get rid of both kinds of quotes, single > and > > double. It seems necessary to do it something like this: > >JUst escape the quote character: > >s.strip('\'"') That did it! Thanks, Dick Moores _

Re: [Tutor] htmllib

2005-10-05 Thread Ed Singleton
You're like some kind of god! That's exactly what I need. Thanks Ed On 05/10/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Singleton wrote: > > I want to dump a html file into a python object. Each nested tag > > would be a sub-object, attributes would be properties. So that I can > > use

Re: [Tutor] How to strip both single and double quotes

2005-10-05 Thread Mark Thomas
On 10/5/05, Dick Moores <[EMAIL PROTECTED]> wrote: > The text will contain "words" beginning or ending with non-alphabetic > characters. To strip them off I use string.strip([chars]). My question is > how to use strip just once to get rid of both kinds of quotes, single and > double. It seems neces

Re: [Tutor] htmllib

2005-10-05 Thread Kent Johnson
Ed Singleton wrote: > I want to dump a html file into a python object. Each nested tag > would be a sub-object, attributes would be properties. So that I can > use Python in a similar way to the way I use JavaScript within a web > page. I don't know of a way to run Python from within a web page.

Re: [Tutor] How to strip both single and double quotes

2005-10-05 Thread Alan Gauld
> how to use strip just once to get rid of both kinds of quotes, single and > double. It seems necessary to do it something like this: JUst escape the quote character: s.strip('\'"') HTH, Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld

[Tutor] htmllib

2005-10-05 Thread Ed Singleton
I want to dump a html file into a python object. Each nested tag would be a sub-object, attributes would be properties. So that I can use Python in a similar way to the way I use JavaScript within a web page. I looked at htmllib, but the documentation seems quite limited, and as far as I can tel

Re: [Tutor] Help Needed

2005-10-05 Thread Kent Johnson
Steve Haley wrote: > When I am in Python Shell of the IDLE GUI, when I click Edit/Run Script, > I am getting a dialog box that is titled “Not saved” and states “The > buffer for Python shell is not saved. Please save it first.” With an > “OK” button that just takes me back to the Shell window.

Re: [Tutor] Trying to prevent ftplib from locking my script

2005-10-05 Thread Kent Johnson
Andrew P wrote: > Normally I wouldn't pipe up here because threads really can be very > tricky. But check out: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435883 > > I use this recipe, originally from "Python in a Nutshell", all the time, > to solve exactly your problem. Slow

[Tutor] How to strip both single and double quotes

2005-10-05 Thread Dick Moores
I'm writing a script that takes any text and outputs to a file a list of duples (k, word) where k is the number of occurrences of word in the text. The text will contain "words" beginning or ending with non-alphabetic characters. To strip them off I use string.strip([chars]). My question is how

Re: [Tutor] FW: Help Needed

2005-10-05 Thread Alan Gauld
> When I am in Python Shell of the IDLE GUI, when I click Edit/Run You shouldn't be running scripts when in the shell, it executes them immediately. You use edit/run when working in a script file window. HTH, Alan G ___ Tutor maillist - Tu

Re: [Tutor] need help to understand terms for desinging a program

2005-10-05 Thread paul brian
This is a pretty big question, and it would be easier to answer if you can give us more details about what you want to do. It seems you want to inspect outgoing mails (possibly rewrite their addresses?) before the mails are sent out. If you are looking to send out emails to a list then I suggest

[Tutor] need help to understand terms for desinging a program

2005-10-05 Thread Hameed U. Khan
Hi, I need to make a program which will accomplish following. I dont need the code. I want to make it myself. But I need guidance from you people because I am not a good programmer. I need help in understanding following terms. " qmail-queue reads a mail message from descriptor 0. It

Re: [Tutor] Help Needed

2005-10-05 Thread Pujo Aji
hi,   make sure in the option/general/Startup preferences/at startup/open edit windowoption/general/Startup preferences/autosave preferences/NoPrompt   run the program by clicking F5   Cheers, pujo  On 10/5/05, Steve Haley <[EMAIL PROTECTED]> wrote: Hello,   I am trying to learn Python which I a

Re: [Tutor] FW: Help Needed

2005-10-05 Thread Daniel Watkins
When I am in Python Shell of the IDLE GUI, when I click Edit/Run Script, I am getting a dialog box that is titled “Not saved” and states “The buffer for Python shell is not saved. Please save it first.” With an “OK” button that just takes me back to the

Re: [Tutor] Line continuation with readlines

2005-10-05 Thread Danny Yoo
On Mon, 3 Oct 2005, Craig MacFarlane wrote: > Is there a way to make line continuation work with > the readlines function? > > i.e. > > this is \ > one line. Hi Craig, readline() doesn't look at the content of lines, so no, not out of the box. However, would it be satisfactory if you wr

[Tutor] Help Needed

2005-10-05 Thread Steve Haley
Hello,   I am trying to learn Python which I am brand new to.  I have run into a problem that I would appreciate help with.   When I am in Python Shell of the IDLE GUI, when I click Edit/Run Script, I am getting a dialog box that is titled “Not saved” and states “The buffer for Python s

Re: [Tutor] Beautiful soup

2005-10-05 Thread Oliver Maunder
On 10/4/05, Andrew P <[EMAIL PROTECTED]> wrote: Oops, Paul is probably right.  I thought urllib2 opened local files in the absence of an identifier like "http://".  Bad assumption on my part.  I remembered that behavior from somewhere else, maybe urllib. The following function could be useful here

[Tutor] Line continuation with readlines

2005-10-05 Thread Craig MacFarlane
Hello, Is there a way to make line continuation work with the readlines function? i.e. this is \ one line. Thank you, Craig __ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.ya

Re: [Tutor] Mod_python greedy url matching

2005-10-05 Thread Danny Yoo
On Wed, 5 Oct 2005, Jay Loden wrote: > 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 h