Re: Splitting a string

2010-04-04 Thread Patrick Maupin
On Apr 4, 2:37 am, Steven D'Aprano wrote: > In any case, the *right* test would be: > > a = 1 > assert a == 1 and a*5==5 and str(a)=='1' and [None,a,None][a] is a You're right. I was very tired when I wrote that, and forgot the last 3 assertions... -- http://mail.python.org/mailman/listinfo/py

Re: Splitting a string

2010-04-04 Thread Patrick Maupin
On Apr 4, 4:58 am, Peter Otten <__pete...@web.de> wrote: > Personally, though, I prefer unit tests over assertions. IMO, the primary use cases for assertions and unit tests are not the same. When I have a well-defined, clearly understood specification that I am coding to and fully implementing w

Re: Splitting a string

2010-04-04 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 03 Apr 2010 11:17:36 +0200, Peter Otten wrote: > >>> That's certainly faster than a list comprehension (at least on long >>> lists), but it might be a little obscure why the "if not s:" is needed, >> >> The function is small; with a test suite covering the corner

Re: Splitting a string

2010-04-04 Thread Steven D'Aprano
On Sat, 03 Apr 2010 20:10:20 -0700, Patrick Maupin wrote: > On Apr 3, 10:00 pm, Steven D'Aprano cybersource.com.au> wrote: >> Tests which you know can't fail are called assertions, pre-conditions >> and post-conditions. We test them because if we don't, they will fail >> :) > > Well, yes, but th

Re: Splitting a string

2010-04-03 Thread Patrick Maupin
On Apr 3, 10:00 pm, Steven D'Aprano wrote: > Tests which you know can't fail are called assertions, pre-conditions and > post-conditions. We test them because if we don't, they will fail :) Well, yes, but that can get rather tedious at times: a = 1 assert 0 < a < 2 b = a + 3 assert 2 < b - a < 4

Re: Splitting a string

2010-04-03 Thread Alf P. Steinbach
* Steven D'Aprano: Tests which you know can't fail are called assertions, pre-conditions and post-conditions. We test them because if we don't, they will fail :) :-) It's the umbrella law. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 11:17:36 +0200, Peter Otten wrote: >> That's certainly faster than a list comprehension (at least on long >> lists), but it might be a little obscure why the "if not s:" is needed, > > The function is small; with a test suite covering the corner cases and > perhaps a comment*

Re: Splitting a string

2010-04-03 Thread Patrick Maupin
On Apr 3, 4:17 am, Peter Otten <__pete...@web.de> wrote: > Patrick Maupin wrote: > > On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote: > > >> _split = re.compile(r"(\d+)").split > >> def split(s): > >>     if not s: > >>         return () > >>     parts = _split(s) > >>     parts[1::2] = map

Re: Splitting a string

2010-04-03 Thread Peter Otten
Patrick Maupin wrote: > On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote: > >> _split = re.compile(r"(\d+)").split >> def split(s): >> if not s: >> return () >> parts = _split(s) >> parts[1::2] = map(int, parts[1::2]) # because s is non-empty parts contains at l

Re: Splitting a string

2010-04-02 Thread Patrick Maupin
On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote: > _split = re.compile(r"(\d+)").split > def split(s): >     if not s: >         return () >     parts = _split(s) >     parts[1::2] = map(int, parts[1::2]) >     if parts[-1] == "": >         del parts[-1] >     if parts[0] == "": >        

Re: Splitting a string

2010-04-02 Thread Peter Otten
Thomas Heller wrote: > Thanks to all for these code snippets. Peter's solution is the winner - > most elegant and also the fastest. With an additional list comprehension > to remove the possible empty strings at the start and at the end I get > 16 us. Interesting is that Xavier's solution (whic

Re: Splitting a string

2010-04-02 Thread Thomas Heller
Patrick Maupin schrieb: > On Apr 2, 6:24 am, Peter Otten <__pete...@web.de> wrote: >> Thomas Heller wrote: >> > Maybe I'm just lazy, but what is the fastest way to convert a string >> > into a tuple containing character sequences and integer numbers, like >> > this: >> >> > 'si_pos_99_rep_1_0.ita'

Re: Splitting a string

2010-04-02 Thread Bearophile
I don't know how fast this is (Python 2.x): >>> from itertools import groupby >>> t = 'si_pos_99_rep_1_0.ita' >>> tuple(int("".join(g)) if h else "".join(g) for h,g in groupby(t, >>> str.isdigit)) ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita') It doesn't work with unicode strings. Bye, bearophile

Re: Splitting a string

2010-04-02 Thread Terry Reedy
On 4/2/2010 6:21 AM, Shashwat Anand wrote: >>> s = 'si_pos_99_rep_1_0.ita' >>> res = tuple(re.split(r'(\d+)', s)) >>> res ('si_pos_', '99', '_rep_', '1', '_', '0', '.ita') This solves the core of the problem, but is not quite there ;-). Thomas requested conversion of int literals to ints, wh

Re: Splitting a string

2010-04-02 Thread Patrick Maupin
On Apr 2, 6:24 am, Peter Otten <__pete...@web.de> wrote: > Thomas Heller wrote: > > Maybe I'm just lazy, but what is the fastest way to convert a string > > into a tuple containing character sequences and integer numbers, like > > this: > > > 'si_pos_99_rep_1_0.ita'  -> ('si_pos_', 99, '_rep_', 1,

Re: Splitting a string

2010-04-02 Thread Peter Otten
Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character sequences and integer numbers, like > this: > > > 'si_pos_99_rep_1_0.ita' -> ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita') >>> parts = re.compile("([+-]?\d+)").split('s

Re: Splitting a string

2010-04-02 Thread Alex Willmer
On Apr 2, 11:12 am, Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character sequences and integer numbers, like this: > > 'si_pos_99_rep_1_0.ita'  -> ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita') > This is very probably not the

Re: Splitting a string

2010-04-02 Thread Xavier Ho
Oops, minor update: >>> def split_number(string): ... output = [string[0]] ... for character in string[1:]: ... if character.isdigit() != output[-1].isdigit(): ... if output[-1].isdigit() is True: ... output[-1] = int(output[-1]) ... output.a

Re: Splitting a string

2010-04-02 Thread Xavier Ho
Best I can come up with: >>> def split_number(string): ... output = [string[0]] ... for character in string[1:]: ... if character.isdigit() != output[-1].isdigit(): ... output.append('') ... output[-1] += character ... return tuple(output) ... >>> split_numb

Re: Splitting a string

2010-04-02 Thread Shashwat Anand
>>> s = 'si_pos_99_rep_1_0.ita' >>> res = tuple(re.split(r'(\d+)', s)) >>> res ('si_pos_', '99', '_rep_', '1', '_', '0', '.ita') >>> On Fri, Apr 2, 2010 at 3:42 PM, Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character se

Re: Splitting a string into substrings of equal size

2009-08-17 Thread Gregor Lingl
Simon Forman schrieb: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Simon Forman
On Aug 14, 8:22 pm, candide wrote: > Suppose you need to split a string into substrings of a given size (except > possibly the last substring). I make the hypothesis the first slice is at the > end of the string. > A typical example is provided by formatting a decimal string with thousands > separ

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Gregor Lingl
Mark Tolonen schrieb: "Gregor Lingl" wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 15, 6:28 pm, MRAB wrote: > >      >>> for z in ["75096042068045", "509", "12024", "7", "2009"]: > >            print re.sub(r"(?<=.)(?=(?:...)+$)", ",", z) > > >     75,096,042,068,045 > >     509 > >     12,024 > >     7 > >     2,009 > > The call replaces a zero-width match with a comma,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread MRAB
Brian wrote: On Sat, Aug 15, 2009 at 4:06 PM, MRAB > wrote: ryles wrote: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substr

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Brian
On Sat, Aug 15, 2009 at 4:06 PM, MRAB wrote: > ryles wrote: > >> On Aug 14, 8:22 pm, candide wrote: >> >>> Suppose you need to split a string into substrings of a given size >>> (except >>> possibly the last substring). I make the hypothesis the first slice is at >>> the >>> end of the string. >

Re: Splitting a string into substrings of equal size

2009-08-15 Thread MRAB
ryles wrote: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with thousands

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 14, 8:22 pm, candide wrote: > Suppose you need to split a string into substrings of a given size (except > possibly the last substring). I make the hypothesis the first slice is at the > end of the string. > A typical example is provided by formatting a decimal string with thousands > separ

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Mark Tolonen
"Gregor Lingl" wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for i

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for ii in range(0,len(jj),3)]) '123,456,789,012,345,678,9' >>> Emile Less beautiful but more correct:

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Emile van Sebille
On 8/14/2009 5:22 PM candide said... Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with thousands separator.

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Jan Kaliszewski
Dnia 15-08-2009 o 08:08:14 Rascal wrote: I'm bored for posting this, but here it is: def add_commas(str): str_list = list(str) str_len = len(str) for i in range(3, str_len, 3): str_list.insert(str_len - i, ',') return ''.join(str_list) For short strings (for sure most

Re: Splitting a string into substrings of equal size

2009-08-15 Thread candide
Thanks to all for your response. I particularly appreciate Rascal's solution. -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string into substrings of equal size

2009-08-14 Thread Rascal
I'm bored for posting this, but here it is: def add_commas(str): str_list = list(str) str_len = len(str) for i in range(3, str_len, 3): str_list.insert(str_len - i, ',') return ''.join(str_list) -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string into substrings of equal size

2009-08-14 Thread Jan Kaliszewski
15-08-2009 Jan Kaliszewski wrote: 15-08-2009 candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal str

Re: Splitting a string into substrings of equal size

2009-08-14 Thread Jan Kaliszewski
15-08-2009 candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with thousands separator. I'd

Re: Splitting a string into substrings of equal size

2009-08-14 Thread Gabriel Genellina
En Fri, 14 Aug 2009 21:22:57 -0300, candide escribió: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string wi

Re: splitting a string into an array using a time value

2008-10-14 Thread Gabriel Genellina
En Tue, 14 Oct 2008 18:08:53 -0300, Joe Python <[EMAIL PROTECTED]> escribió: I want to find a way to split a string into an array using a time value. s = r""" 8/25/2008 11:10:08 AM Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed imperdiet luctus nisl. ipsum vel arcu

Re: Splitting a string

2007-05-15 Thread HMS Surprise
Thanks everyone. The shell's display really threw me off. Don't really understand why it looks different typing t vs print t. Now that I can see past that split works just as advertised. Not real clear on triple quotes but I have seen it used and I can see where triple is needed to differentiate fr

Re: Splitting a string

2007-05-15 Thread HMS Surprise
On May 15, 2:04 pm, Nick Vatamaniuc <[EMAIL PROTECTED]> wrote: > On May 15, 2:28 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > > > > > The string s below has single and double qoutes in it. For testing I > > surrounded it with triple single quotes. I want to split off the > > portion before the fir

Re: Splitting a string

2007-05-15 Thread Gary Herron
HMS Surprise wrote: > The string s below has single and double qoutes in it. For testing I > surrounded it with triple single quotes. I want to split off the > portion before the first \, but my split that works with shorter > strings does not seem to work with this one. > > Ideas? > > Thanks, > jv

Re: Splitting a string

2007-05-15 Thread Duncan Booth
HMS Surprise <[EMAIL PROTECTED]> wrote: > The string s below has single and double qoutes in it. For testing I > surrounded it with triple single quotes. I want to split off the > portion before the first \, but my split that works with shorter > strings does not seem to work with this one. > > I

Re: Splitting a string

2007-05-15 Thread HMS Surprise
I found my problem, the backslash isn't really there. It is just the way it was displayed in the shell after being split from a larger string. Printing it yields D132259','','status=no,location=no,width=630,height=550,left=200,top=100')" target="_blank" class="dvLink" title="Send an Email to select

Re: Splitting a string

2007-05-15 Thread Nick Vatamaniuc
On May 15, 2:28 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > The string s below has single and double qoutes in it. For testing I > surrounded it with triple single quotes. I want to split off the > portion before the first \, but my split that works with shorter > strings does not seem to work wi

Re: Splitting a string with extra parameters

2006-04-06 Thread Andrew Gwozdziewycz
On Apr 6, 2006, at 7:38 AM, Amit Khemka wrote: > I guess you should use "re" module ... In this case re.split("\D,\D", > YOUR_STRING) should work. (splits only when "," is between two > non-digits). This works assuming all line elements are quoted. This would fail if (and this too my knowledg

Re: Splitting a string with extra parameters

2006-04-06 Thread Amit Khemka
I guess you should use "re" module ... In this case re.split("\D,\D", YOUR_STRING) should work. (splits only when "," is between two non-digits). for details and more options see python-docs. cheers, amit. On 4/6/06, Fulvio <[EMAIL PROTECTED]> wrote: > Alle 11:23, giovedì 06 aprile 2006, Chris

Re: Splitting a string with extra parameters

2006-04-06 Thread Fulvio
Alle 11:23, giovedì 06 aprile 2006, Chris P ha scritto: > when splitting based on a delimiter of "," the above string gets broken up > in 5 "columns" instead of 4 due to the "," in the money amount. There should be cvs package in the python directory. Why don't you try that way? Reading some help

Re: Splitting a string

2006-02-14 Thread Nico Grubert
> re.split("(?i)\s*(and not|and|or)\s*", s) Thanks, Frederik for the step by step howto! And also thanks to you, Dylan. re.split("(?i)\s*(and not|and|or)\s*", s) is almost right. I changed it to: words = re.split("(?i)\s*( and not | and | or )\s*", s) in order to handle words containing "or"

Re: Splitting a string

2006-02-14 Thread Christoph Zwerschke
Nico Grubert wrote: > I'd like to split a string where 'and', 'or', 'and not' occurs. > Example string: > s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green' Here is a solution without using the re module: s.replace(' AND NOT ', ' OR ').replace(' AND ', ' OR ').split(' OR ') --

Re: Splitting a string

2006-02-14 Thread Paul Rubin
Nico Grubert <[EMAIL PROTECTED]> writes: > I'd like to split a string where 'and', 'or', 'and not' occurs. Other people have suggested how to do this splitting. But don't you really want a parser? -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string

2006-02-14 Thread Peter Otten
Fredrik Lundh wrote: re.split("(?i)\s*(?:and not|and|or)\s*", s) > ['Smith, R.', 'White', 'Blue, T.', 'Black', 'Red', 'Green'] This fails for people with nasty names: >>> s = "James White or Andy Grove and Jack Orr and not James Grand" >>> re.split("(?i)\s*(?:and not|and|or)\s*", s) ['Jame

Re: Splitting a string

2006-02-14 Thread Dylan Moreland
Woops! Thanks for the correction. I was assuming greediness for some reason. Fredrik Lundh wrote: > Dylan Moreland wrote: > > > So I would try something like: > > > > pat = re.compile(r" (?:AND|OR|AND NOT) ") > > pat.split(string) > > footnote: this yields: > > ['Smith, R.', 'White', 'Blue, T.

Re: Splitting a string

2006-02-14 Thread Fredrik Lundh
Dylan Moreland wrote: > So I would try something like: > > pat = re.compile(r" (?:AND|OR|AND NOT) ") > pat.split(string) footnote: this yields: ['Smith, R.', 'White', 'Blue, T.', 'Black', 'Red', 'NOT Green'] (the | operator picks the first (leftmost) alternative that results in an overall m

Re: Splitting a string

2006-02-14 Thread Xie Yanbo
On 2/14/06, Nico Grubert <[EMAIL PROTECTED]> wrote: > Dear Python users, > > I'd like to split a string where 'and', 'or', 'and not' occurs. > > Example string: > s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green' > > I need to split s in order to get this list: > ['Smith, R.', 'W

Re: Splitting a string

2006-02-14 Thread Dylan Moreland
Take a look at: http://docs.python.org/lib/node115.html#l2h-878 So I would try something like: pat = re.compile(r" (?:AND|OR|AND NOT) ") pat.split(string) Compile the regular expression with re.IGNORECASE if you like. Nico Grubert wrote: > Dear Python users, > > I'd like to split a string wher

Re: Splitting a string

2006-02-14 Thread Fredrik Lundh
Nico Grubert wrote: > I'd like to split a string where 'and', 'or', 'and not' occurs. > > Example string: > s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green' > > I need to split s in order to get this list: > ['Smith, R.', 'White', 'Blue, T.', 'Back', 'Red', 'Green'] > > Any ide

Re: Splitting a string into groups of three characters

2005-08-08 Thread John Machin
William Park wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >>Hi, >> >>Is there a function that split a string into groups, containing an "x" >>amount of characters? >> >>Ex. >>TheFunction("Hello World",3) >> >>Returns: >> >>['Hell','o W','orl','d'] >> >> >>Any reply would be truly apprec

Re: Splitting a string into groups of three characters

2005-08-08 Thread Gregory Piñero
I guess this question has already been thouroughly answered but here is my version: def split(string,n): outlist=[] for bottom in range(0,len(string),n): top=min(bottom+n,len(string)) outlist.append(string[bottom:top]) return outlist On 8/8/05, William Park <[EMAIL

Re: Splitting a string into groups of three characters

2005-08-08 Thread William Park
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a function that split a string into groups, containing an "x" > amount of characters? > > Ex. > TheFunction("Hello World",3) > > Returns: > > ['Hell','o W','orl','d'] > > > Any reply would be truly appreciated. Look into 're' mo

Re: Splitting a string into groups of three characters

2005-08-08 Thread Cyril Bazin
Another solution derived from an old discussion about the same problem? def takeBy(s, n):     import itertools     list(''.join(x) for x in itertools.izip(*[iter(s)]*n)) (Hoping len(s) % n = 0) CyrilOn 8 Aug 2005 11:04:31 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:Yes i know i made a mi

Re: Splitting a string into groups of three characters

2005-08-08 Thread [EMAIL PROTECTED]
Yes i know i made a mistake, >['Hell','o W','orl','d'] but you know what I mean lol, I'll probly use John Machin's def nsplit(s, n): return [s[k:k+n] for k in xrange(0, len(s), n)] It seems fast, and does not require any imports. But anyways, thank you for all your help, you rock! :) --

Re: Splitting a string into groups of three characters

2005-08-08 Thread [EMAIL PROTECTED]
Yes i know i made a mistake, >['Hell','o W','orl','d'] but you know what I mean lol, I'll probly use John Machin's def nsplit(s, n): return [s[k:k+n] for k in xrange(0, len(s), n)] It seems fast, and does not require any imports. But anyways, thank you for all your help, you rpck! :) --

Re: Splitting a string into groups of three characters

2005-08-08 Thread Maksim Kasimov
import re str = '123456789983qw' re.findall("(.{3})", str)+[str[-(len(str) % 3):]] [EMAIL PROTECTED] wrote: > Hi, > > Is there a function that split a string into groups, containing an "x" > amount of characters? > > Ex. > TheFunction("Hello World",3) > > Returns: > > ['Hell','o W','orl','d']

Re: Splitting a string into groups of three characters

2005-08-07 Thread John Machin
gene tani wrote: > Um, you shd 1st search cookbook, or Vaults Parnassu, dmoz python > section, pypackage: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347689 which includes e.g. def each_slice_lol(listin,n): """non-overlapp'g slices, return (list of lists) """ len_listin=le

Re: Splitting a string into groups of three characters

2005-08-07 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a function that split a string into groups, containing an "x" > amount of characters? There have been previous threads giving various solutions (which generally are not specific to strings). You might find some some by sear

Re: Splitting a string into groups of three characters

2005-08-07 Thread [EMAIL PROTECTED]
Thank You, For your help, I guess I will just make a couple of these functions and find out which one is that fastest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string into groups of three characters

2005-08-07 Thread gene tani
Um, you shd 1st search cookbook, or Vaults Parnassu, dmoz python section, pypackage: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347689 http://www.codezoo.com/ http://www.vex.net/parnassus/ http://www.pypackage.org/packages -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string into groups of three characters

2005-08-07 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > > Is there a function that split a string into groups, containing an "x" > amount of characters? > > Ex. > TheFunction("Hello World",3) > > Returns: > > ['Hell','o W','orl','d'] > > > Any reply would be truly appreciated. > > Thank You, > Maybe, somewhere o