Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
G'day Alan, >However I'll refrain from saying much more since I do think the >namespaces topic could be significantly improved if only I could >find better words and examples. > >So please everyone, feel free to try to explain this idea to Payal >so that I can steal your ideas for the tutorial!!

Re: [Tutor] Tutor FAQ

2006-04-26 Thread Mike Hansen
Thanks Kent. I'll make those additions/corrections and rework the question about private and public attributes and methods. Mike On Apr 26, 2006, at 7:42 PM, Kent Johnson wrote: > Mike Hansen wrote: >> Here's the next batch of questions and answers for the tutor FAQ. If >> you have any clarific

Re: [Tutor] Tutor FAQ

2006-04-26 Thread Kent Johnson
Mike Hansen wrote: > Here's the next batch of questions and answers for the tutor FAQ. If > you have any clarifications or corrections, please let me know. I'll > try to post this on the web site in a couple of days. Thanks Mike! > -

Re: [Tutor] SOAP Modules - I need a little direction.

2006-04-26 Thread Kent Johnson
doug shawhan wrote: > I am in preparation mode for creating a script which uses SOAP. > > I have been looking at the various SOAP modules: soapy, soap.py, ZSI, > pywebsvcs. > > I'm very confused as to the status of these projects. Most seem to be > only partially supported, if not abandoned com

[Tutor] Tutor FAQ

2006-04-26 Thread Mike Hansen
Here's the next batch of questions and answers for the tutor FAQ. If you have any clarifications or corrections, please let me know. I'll try to post this on the web site in a couple of days. - How do I get data out of HTML?

Re: [Tutor] cycle w/ shuffle

2006-04-26 Thread Kent Johnson
kevin parks wrote: > it seems to me that i need something like itertools cycle, except that > i need to keep track of when i have exhausted my list and then call > random.shuffle() on my sequence. > > def cycle(iterable): > saved = [] > for element in iterable: > yield

Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread Alan Gauld
"Payal Rathod" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In Alan's tutorial I haven't got the example of print42() even after > reading the explanation. > I get 110 if I use it as a function. > spam = 42 def print42(): print spam > ... spam = 110 print42() >

[Tutor] cycle w/ shuffle

2006-04-26 Thread kevin parks
I am trying to write a loop that iterates over a sequence and do something x number of times. But sometimes i will need more events (larger number x) than i have have items in the sequence, so if i need more events that i have stuff in my sequence i would like to have the loop reload and shuffl

Re: [Tutor] cycle w/ shuffle

2006-04-26 Thread kevin parks
I am trying to write a loop that iterates over a sequence and do something x number of times. But sometimes i will need more events (larger number x) than i have have items in the sequence, so if i need more events that i have stuff in my sequence i would like to have the loop reload and shuffl

Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
G'day Payal, I had trouble understanding the namespaces section of the tutorial too but it all clicked the other day when Alan explained the difference between import first and from first import * John >Hi, >In Alan's tutorial I haven't got the example of print42() even after >reading the expl

[Tutor] SOAP Modules - I need a little direction.

2006-04-26 Thread doug shawhan
I am in preparation mode for creating a script which uses SOAP. I have been looking at the various SOAP modules: soapy, soap.py, ZSI, pywebsvcs. I'm very confused as to the status of these projects. Most seem to be only partially supported, if not abandoned completely. Thre appears to have been a

[Tutor] Cheetah

2006-04-26 Thread Mike Hansen
I'm having a little trouble populating a cheetah template. I thought I'd ask here first before checking the cheetah mailing list or c.l.p. I have a simple template This is a test $title #for $item in $items category: $item.category name: $item.name price: $item.pric

Re: [Tutor] Checking in lists

2006-04-26 Thread Alan Gauld
> Basically it's not evaluating it the way you think it is: > >Your first example really equates to: > > if (1 or 5) in rollList: Not quite, its doing: if 1 or 5 in rollList: We can demonstrate that with: >>> if 1 or 0 in [6,2,3]: print 'True' ... True >>> if (1or 0) in [6,2,3]: print 'True' ..

[Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread Payal Rathod
Hi, In Alan's tutorial I haven't got the example of print42() even after reading the explanation. I get 110 if I use it as a function. >>> spam = 42 >>> def print42(): print spam ... >>> spam = 110 >>> print42() 110 Why do you get 42 when you use it as module? I haven't understood the explantai

Re: [Tutor] A Python idiom that I don't get

2006-04-26 Thread Don Taylor
w chun wrote: > it sounds like you did not develop the original code. it seems to > work... why are you trying to replace it? are you refactoring? No it is not my code. I am trying to get it running in Jython which does not support the bool function. I may refactor it after I get it working i

Re: [Tutor] Checking in lists

2006-04-26 Thread Kent Johnson
Jason Massey wrote: > John, > > Basically it's not evaluating it the way you think it is: Right. > > Your first example really equates to: > > if (1 or 5) in rollList: >etc... > > (1 or 5) equals 1 and 1 isn't in the your list. Not quite. It's if 1 or (5 in rollList): Since 1 evaluat

Re: [Tutor] Checking in lists

2006-04-26 Thread Jason Massey
John,Basically it's not evaluating it the way you think it is:Your first example really equates to:if (1 or 5) in rollList:   etc...(1 or 5) equals 1  and 1 isn't in the your list. On 4/26/06, John Connors <[EMAIL PROTECTED]> wrote: G'day,I found something today that has me confused. I'm making a l

Re: [Tutor] Regex across multiple lines

2006-04-26 Thread Kent Johnson
Liam Clarke wrote: > To the Tutor list - can't re.MULTILINE also be used? I've never really > used that flag. re.MULTILINE affects the meaning of ^ and $ - do they match only the beginning and end of the target string (the default) or do they match the beginning or end of any line in the string

[Tutor] Checking in lists

2006-04-26 Thread John Connors
G'day, I found something today that has me confused. I'm making a list of 6 random dice rolls and I want to check if any 1's or 5's were rolled. I tried this way first and it returns true even if there are no 1's or 5's. I'll use a roll of all 2's as an example. rollList = [2,2,2,2,2,2] if 1

Re: [Tutor] Regex across multiple lines

2006-04-26 Thread Liam Clarke
Hi Frank, just bear in mind that the pattern: patObj = re.compile(".*", re.DOTALL) will match This is my title But, it'll also match This is my title Some content here Another title; not going to happen with a title tag in HTML, but more an illustration All of that. Got to wa

Re: [Tutor] Regex across multiple lines

2006-04-26 Thread Frank Moore
Kent Johnson wrote: >Use your compiled regex for the sub(), so it will have the DOTALL flag set: >html_text = p.sub(replace_string, html_text) > > Kent, I was trying to work out how to use the DOTALL flag with the sub method, but couldn't figure it out. It's so obvious once someone points it o

Re: [Tutor] Regex across multiple lines

2006-04-26 Thread Kent Johnson
Frank Moore wrote: > Hi, > > Can anyone tell me how to do a regex substitution across multiple lines > in HTML? > I can search for the piece of HTML I want to substitute, for instance: > > > This is my title > > > using > > html_text = file('some.html', 'r').read() > search_string = '.*'

Re: [Tutor] Livewires

2006-04-26 Thread Kent Johnson
ryan luna wrote: > Hey, > So i decided to check out this Livewires Modules, but > while running through the tutorial i run into a > problem, > When i was trying to do the graphics stuff, > when i try and use this code > > circle(300,195, endpoints = ((280,180),(320,180))) > > and i get this error

Re: [Tutor] A Python idiom that I don't get

2006-04-26 Thread Kent Johnson
w chun wrote: >>> prefix = os.path.commonprefix(filter( bool, lines )) > > that is an interesting and yes, not very optimal way of saving the set > of non-blank lines. the commonprefix() function takes a list of > pathnames and returns the longest prefix that all strings have in > common, pr

Re: [Tutor] Web-templating systems

2006-04-26 Thread Kent Johnson
Winfried Tilanus wrote: > On 04/25/2006 Kent Johnson wrote: >> Many. See this page, the sections Templating Engines, HTML Shorthand >> Processors and HTML Generation class libraries: >> http://wiki.python.org/moin/WebProgramming > > Hmmm,lets toss in my own problem: > I know the list mentioned ab

[Tutor] Regex across multiple lines

2006-04-26 Thread Frank Moore
Hi, Can anyone tell me how to do a regex substitution across multiple lines in HTML? I can search for the piece of HTML I want to substitute, for instance: This is my title using html_text = file('some.html', 'r').read() search_string = '.*' p = re.compile(search_string, re.DOTALL) But

[Tutor] Livewires

2006-04-26 Thread ryan luna
Hey, So i decided to check out this Livewires Modules, but while running through the tutorial i run into a problem, When i was trying to do the graphics stuff, when i try and use this code circle(300,195, endpoints = ((280,180),(320,180))) and i get this error Traceback (most recent call last):

[Tutor] Web-templating systems (was: Re: Generating static WEB sites)

2006-04-26 Thread Winfried Tilanus
On 04/25/2006 Kent Johnson wrote: > Many. See this page, the sections Templating Engines, HTML Shorthand > Processors and HTML Generation class libraries: > http://wiki.python.org/moin/WebProgramming Hmmm,lets toss in my own problem: I know the list mentioned above, and it is too long for me to t

Re: [Tutor] seq looping

2006-04-26 Thread kevin parks
Bob ... i used my kludge which defines some bounds and tests for it... but your idea of stuffing that into a seperate black box as golden in that it made me think of the problem as input --> doit --> result. and made my loops simpler and easier to read... and i use that same gap making typing

Re: [Tutor] getting system temporary directory.

2006-04-26 Thread Tim Golden
[Keo Sophon] | Does python has any function to get a system tempdir of an OS? You want to be looking at the tempfile module (and in particular at the gettempdir). http://docs.python.org/lib/module-tempfile.html TJG This e