RE: How to sort list of String without considering Special characters and with case insensitive

2012-11-27 Thread Prasad, Ramit
san wrote: > > Please let me know how to sort the list of String in either ascending / > descending order without considering > special characters and case. > ex: list1=['test1_two','testOne','testTwo','test_one'] > Applying the l

Re: How to sort list of String without considering Special characters and with case insensitive

2012-11-27 Thread MRAB
On 2012-11-27 17:31, san wrote: Please let me know how to sort the list of String in either ascending / descending order without considering special characters and case. ex: list1=['test1_two','testOne','testTwo','test_one'] Applying the list.so

How to sort list of String without considering Special characters and with case insensitive

2012-11-27 Thread san
Please let me know how to sort the list of String in either ascending / descending order without considering special characters and case. ex: list1=['test1_two','testOne','testTwo','test_one'] Applying the list.sort /sorted method results in sorted

Re: Converting List of String to Integer

2008-07-22 Thread Samir
Wow! Thanks for all of the great additional feedback and responses since I last checked in. The help this group provides is amazing. I'm glad I found it. @Andrew -- Thanks for the clarification on the nested for loop and how to intrepret it. Also, thanks for the information on generators. I ha

Re: Converting List of String to Integer

2008-07-22 Thread ptn
> n = [] > for k in a: >     n.append([int(v) for v in k]) > print n > > Does anyone know what I am doing wrong? > > Thanks in advance. > > Samir Use extend instead of append: * Append -> add the one item to the end of the list * Extend -> add the list of items to the end of the list -- http://ma

Re: Converting List of String to Integer

2008-07-22 Thread Rishabh Manocha
Just to throw my hat in the ring, this is another way you can do this: [(lambda x : [int(ii) for ii in x])(y) for y in a] However, I do think dusans way is more elegant. Best, R On Tue, Jul 22, 2008 at 4:58 PM, dusans <[EMAIL PROTECTED]> wrote: > >>> a = [['1', '2'], ['3'], ['4', '5', '6'], [

Re: Converting List of String to Integer

2008-07-22 Thread dusans
>>> a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']] >>> [map(int, i) for i in a] [[1, 2], [3], [4, 5, 6], [7, 8, 9, 0]] On Jul 21, 9:06 pm, Samir <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > I am relatively new to Python so please forgive me for what seems like > a basic question.

Re: Converting List of String to Integer

2008-07-21 Thread Andrew Freeman
Samir wrote: For my small list, I didn't notice a discernible increase in speed, but I may have to try it with a larger list size. About speed, and memory consumption: List comprehensions (http://docs.python.org/tut/node7.html#SECTION00714) are just shortcuts for for-loops.

Re: Converting List of String to Integer

2008-07-21 Thread Andrew Freeman
Samir wrote: On Jul 21, 6:15 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote: Samir wrote: On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: Samir wrote: Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic quest

Re: Converting List of String to Integer

2008-07-21 Thread Samir
On Jul 21, 6:15 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote: > Samir wrote: > > On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > > >> Samir wrote: > > >>> Hi Everyone, > > >>> I am relatively new to Python so please forgive me for what seems like > >>> a basic question. > > >>> Assume

Re: Converting List of String to Integer

2008-07-21 Thread Andrew Freeman
Samir wrote: On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: Samir wrote: Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations o

Re: Converting List of String to Integer

2008-07-21 Thread Samir
On Jul 21, 4:44 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Samir wrote: > > On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > > >> Samir wrote: > > >>> Hi Everyone, > > >>> I am relatively new to Python so please forgive me for what seems like > >>> a basic question. > > >>> Assume tha

Re: Converting List of String to Integer

2008-07-21 Thread Gary Herron
Samir wrote: On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: Samir wrote: Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations o

Re: Converting List of String to Integer

2008-07-21 Thread John Machin
On Jul 22, 6:11 am, Samir <[EMAIL PROTECTED]> wrote: [snip] > For some reason, the logic I posted seems to work ok while I'm using > the Python shell, but when used in my code, the program just hangs. > It never outputs the results. Below is the code in its entirety. Is > there a problem with my

Re: Converting List of String to Integer

2008-07-21 Thread Samir
On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Samir wrote: > > Hi Everyone, > > > I am relatively new to Python so please forgive me for what seems like > > a basic question. > > > Assume that I have a list, a, composed of nested lists with string > > representations of integers, suc

Re: Converting List of String to Integer

2008-07-21 Thread Gary Herron
Samir wrote: Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations of integers, such that a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']] I would l

Converting List of String to Integer

2008-07-21 Thread Samir
Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations of integers, such that a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']] I would like to convert

Re: regex with specific list of string

2007-09-26 Thread Steve Holden
james_027 wrote: > Hi all, > >> This is fine IMO since the OP didn't specify the opposite. >> > > Thanks for all your replies, though I don't understand quite well the > going argument? What do you mean when you say "the OP didn't specify > the opposite"? > > There reason for using regex is beca

Re: regex with specific list of string

2007-09-26 Thread james_027
Hi all, > This is fine IMO since the OP didn't specify the opposite. > Thanks for all your replies, though I don't understand quite well the going argument? What do you mean when you say "the OP didn't specify the opposite"? There reason for using regex is because I am going to use it in Django'

Re: regex with specific list of string

2007-09-26 Thread Steve Holden
Carsten Haese wrote: > On Wed, 2007-09-26 at 15:13 -0300, Pablo Ziliani wrote: >> Carsten Haese wrote: >>> Unfortunately, that also matches margarine, mayonnaise, and octopus, >>> just to name a few ;-) >> (and so does the solution you sent before :) > > No, it doesn't. > s = set(['jan', 'fe

Re: regex with specific list of string

2007-09-26 Thread Carsten Haese
On Wed, 2007-09-26 at 15:13 -0300, Pablo Ziliani wrote: > Carsten Haese wrote: > > Unfortunately, that also matches margarine, mayonnaise, and octopus, > > just to name a few ;-) > > (and so does the solution you sent before :) No, it doesn't. >>> s = set(['jan', 'feb', 'mar', 'apr', 'may', 'jun

Re: regex with specific list of string

2007-09-26 Thread Pablo Ziliani
Carsten Haese wrote: > On Wed, 2007-09-26 at 12:49 -0400, Steve Holden wrote: >> james_027 wrote: >>> hi, >>> >>> how do I regex that could check on any of the value that match any one >>> of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', >>> 'sep', 'oct', 'nov', 'dec' >>> >>> Th

Re: regex with specific list of string

2007-09-26 Thread Steve Holden
Carsten Haese wrote: > On Wed, 2007-09-26 at 12:49 -0400, Steve Holden wrote: >> james_027 wrote: >>> hi, >>> >>> how do I regex that could check on any of the value that match any one >>> of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', >>> 'sep', 'oct', 'nov', 'dec' >>> >>> Th

Re: regex with specific list of string

2007-09-26 Thread Carsten Haese
On Wed, 2007-09-26 at 12:49 -0400, Steve Holden wrote: > james_027 wrote: > > hi, > > > > how do I regex that could check on any of the value that match any one > > of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', > > 'sep', 'oct', 'nov', 'dec' > > > > Thanks > > >>> patr =

Re: regex with specific list of string

2007-09-26 Thread Pablo Ziliani
Carsten Haese wrote: > On Wed, 2007-09-26 at 15:42 +, james_027 wrote: > >> hi, >> >> how do I regex that could check on any of the value that match any one >> of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', >> 'sep', 'oct', 'nov', 'dec' >> > > Why regex? You can si

Re: regex with specific list of string

2007-09-26 Thread Steve Holden
james_027 wrote: > hi, > > how do I regex that could check on any of the value that match any one > of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', > 'sep', 'oct', 'nov', 'dec' > > Thanks >>> patr = re.compile('jan|feb|mar|apr|may|jun|jul|aug|sep|nov|oct|dec') >>> patr.mat

Re: regex with specific list of string

2007-09-26 Thread Carsten Haese
On Wed, 2007-09-26 at 15:42 +, james_027 wrote: > hi, > > how do I regex that could check on any of the value that match any one > of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', > 'sep', 'oct', 'nov', 'dec' Why regex? You can simply check if the given value is contained

regex with specific list of string

2007-09-26 Thread james_027
hi, how do I regex that could check on any of the value that match any one of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: List of string

2005-08-18 Thread bryanjugglercryptographer
BranoZ wrote: > "132443" is a 'subsubstring' "0134314244133" because: For the record, that's called a "subsequence". http://www.google.com/search?hl=en&q=subsequence -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: List of string

2005-08-18 Thread BranoZ
Dennis Lee Bieber wrote: > On Thu, 18 Aug 2005 13:30:45 +0200, Mohammed Altaj <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > Thanks , but , this work for an ordered substrings , just like what we > > had ['0132442\n', '13\n', '24\n'] , I would like to remove all > > su

Re: List of string

2005-08-18 Thread [EMAIL PROTECTED]
to quote you : "['0134314244133', '132443', '234'] 2nd and 3rd strings are also substrings from the 1st one , so it should be removed " Actually, no, the 2nd string does not substring match the first, nor does the 3rd. If you are referring to matching individual characters, then yes, characters

Re: List of string

2005-08-18 Thread Marco Aschwanden
> Thanks , but , this work for an ordered substrings , just like what we > had ['0132442\n', '13\n', '24\n'] , I would like to remove all > substrings from the list , example > > ['0134314244133', '132443', '234'] > > > 2nd and 3rd strings are also substrings from the 1st one , so it should > be

Re: List of string

2005-08-18 Thread Mohammed Altaj
> > > > > >Mohammed Altaj wrote: > > >>Hi All >> >>I am having problem with delete line if its belong to another one , example >> >> > >I think, you mean to remove all lines that are substrings of another >line. > >l =