Re: [Tutor] How does this work?

2006-03-13 Thread Kent Johnson
Christopher Spears wrote: > > if p[start:indexpepper].strip(): > continue > > What is that supposed to accomplish? If the program > can remove whitespace between red and pepper, it's > supposed to move on? Not quite - p[start:indexpepper] is a string. p[start:indexpepper].strip

[Tutor] How does this work?

2006-03-13 Thread Christopher Spears
Out of Learning Python, I was given this text: This is a paragraph that mentions bell peppers multiple times. For one, here is a red pepper and dried tomato salad recipe. I don't like to use green peppers in my salads as much because they have a harsher flavor. This second paragraph mentions red

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Alan Gauld
> For website, I can't really see how I can not have a dynamic > structure. There's no way I'm writing a function for each "folder". Hmm, this may be a CherryPie concept thing but the vast majority of websites do not have dynamic structures. It really shouldn't be necessary. Why would you need to

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Kent Johnson
Ed Singleton wrote: > On 13/03/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > I've just discovered with a little playing, that you can do: > > def z(v): > > ... def f(x): > ... print x * v > ... return f > ... > c = z(3) c(1) > > 3 > funcdict = dict(foo = z

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Ed Singleton
On 13/03/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Singleton wrote: > > On 10/03/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > > > >>Ed Singleton wrote: > >>>I want to use this in a few different places. For example Faces, the > >>>Python Project Management Planner Tool Thingy, uses nested

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Kent Johnson
Kent Johnson wrote: > Why not just use nested dicts? > > MyProject = dict( >start = "2006-03-06", >resource = Me, >Task1 = dict(start = "2006-03-13"), >Task2 = dict(effort = "1w"), > ) or nest class instances directly: MyProject = Project( start = "2006-03-06", resource =

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Kent Johnson
Ed Singleton wrote: > On 10/03/06, Alan Gauld <[EMAIL PROTECTED]> wrote: >>Dynamic site structure shouldn't need dynamic creation of functions >>although the structure might need to be dynamically loaded into a >>data structure in the code. It might also be a parameter of the functions. > > > Doe

Re: [Tutor] *args consumption

2006-03-13 Thread Smith
| From: "Anna Ravenscroft" | Subject: Re: [Tutor] *args consumption | To: "Kent Johnson" | | Thanks for a great example of what decorators are good for. DITTO! I've been wondering when those would be useful, and having a need in hand, I'm likely to learn it now. Thanks for explaining the useage

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Ed Singleton
On 10/03/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > How does one go about creating functions, classes, or callable objects > > when you don't know their name in advance? (For example you want to > > read their names in from a text file or database). > > First point, names of functions are no dif

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Kent Johnson
Ed Singleton wrote: > On 10/03/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Ed Singleton wrote: >>>I want to use this in a few different places. For example Faces, the >>>Python Project Management Planner Tool Thingy, uses nested functions >>>to put tasks within a project: >>> >>>def MyProject

Re: [Tutor] Dynamically naming functions

2006-03-13 Thread Ed Singleton
On 10/03/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Singleton wrote: > > How does one go about creating functions, classes, or callable objects > > when you don't know their name in advance? (For example you want to > > read their names in from a text file or database). > > > > I want to use