Re: String handling and the percent operator

2006-07-14 Thread Erik Max Francis
Tom Plunket wrote: > I know that the message didn't have enough formatters, that's why I > asked. (Although I would have assumed that the generator would get > automatically converted to a sequence that was consumable by the > interpolation operator...) That's because:: aFormatString %

Re: String handling and the percent operator

2006-07-14 Thread Tom Plunket
Erik Max Francis wrote: > > For enrichment purposes, is there a way to do this sort of thing with > > a generator? E.g. something like: > > > > def SentenceGenerator(): > >words = ['I', 'have', 'been', 'to', 'the', 'fair'] > >for w in words: > > yield w > > > > message = "%s %s %

Re: String handling and the percent operator

2006-07-14 Thread Erik Max Francis
Tom Plunket wrote: > Excellent. Thanks. Has this been around long? I "learned" Python in > the 1.6 days iirc, but haven't done much except simple scripting with > it since... Yep. Been around since at least 1.5.x. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San

Re: String handling and the percent operator

2006-07-14 Thread Tom Plunket
Justin Azoff wrote: > Of course.. > > I should read the python documentation at > http://docs.python.org/lib/typesseq-strings.html Excellent. Thanks. Has this been around long? I "learned" Python in the 1.6 days iirc, but haven't done much except simple scripting with it since... -tom! -- h

Re: String handling and the percent operator

2006-07-14 Thread Anthra Norell
- Original Message -From: "Tom Plunket" <[EMAIL PROTECTED]>Newsgroups: comp.lang.pythonTo: <python-list@python.org>Sent: Friday, July 14, 2006 12:49 AMSubject: String handling and the percent operator> I have some code to autogenerate some boilerplate code so

Re: String handling and the percent operator

2006-07-14 Thread Bruno Desthuilliers
Tom Plunket wrote: > I have some code to autogenerate some boilerplate code so that I don't > need to do the tedious setup stuff when I want to create a new module. > > So, my script prompts the user for the module name, then opens two > files and those files each get the contents of one of these

Re: String handling and the percent operator

2006-07-13 Thread Simon Forman
Tom Plunket wrote: > Simon Forman wrote: > > > strings have a count() method. > > thanks! > > For enrichment purposes, is there a way to do this sort of thing with > a generator? E.g. something like: > > def SentenceGenerator(): >words = ['I', 'have', 'been', 'to', 'the', 'fair'] >for w in

Re: String handling and the percent operator

2006-07-13 Thread Brett g Porter
Justin Azoff wrote: > Tom Plunket wrote: >> boilerplate = \ >> """ > [big string] >> """ >> >> return boilerplate % ((module,) * 3) >> [deletia...] > Of course.. > stuff = {'lang': 'python', 'page': 'typesseq-strings.html'} print """I should read the %(lang)s documentation at

Re: String handling and the percent operator

2006-07-13 Thread Justin Azoff
Tom Plunket wrote: > boilerplate = \ > """ [big string] > """ > > return boilerplate % ((module,) * 3) > > My question is, I don't like hardcoding the number of times that the > module name should be repeated in the two return functions. Is there > an straight forward (inline-appropria

Re: String handling and the percent operator

2006-07-13 Thread Erik Max Francis
Tom Plunket wrote: > For enrichment purposes, is there a way to do this sort of thing with > a generator? E.g. something like: > > def SentenceGenerator(): >words = ['I', 'have', 'been', 'to', 'the', 'fair'] >for w in words: > yield w > > message = "%s %s %s %s" > > print messag

Re: String handling and the percent operator

2006-07-13 Thread Tom Plunket
Simon Forman wrote: > strings have a count() method. thanks! For enrichment purposes, is there a way to do this sort of thing with a generator? E.g. something like: def SentenceGenerator(): words = ['I', 'have', 'been', 'to', 'the', 'fair'] for w in words: yield w message = "%s %

Re: String handling and the percent operator

2006-07-13 Thread Simon Forman
Tom Plunket wrote: > I have some code to autogenerate some boilerplate code so that I don't > need to do the tedious setup stuff when I want to create a new module. > > So, my script prompts the user for the module name, then opens two > files and those files each get the contents of one of these f

String handling and the percent operator

2006-07-13 Thread Tom Plunket
I have some code to autogenerate some boilerplate code so that I don't need to do the tedious setup stuff when I want to create a new module. So, my script prompts the user for the module name, then opens two files and those files each get the contents of one of these functions: def GetPyContents