> > I have a string which is returned by a C extension.
> >
> > mystring = '(1,2,3)'
> >
> > HOW can I read the numbers in python ?
>
> re.findall seems the safest and easiest solution:
>
> >>> re.findall(r'(\d+)', '(1, 2, 3)')
> ['1', '2', '3']
> >>> map(int, re.findall(r'(\d+)', '(1, 2, 3)'))
>
On 1/8/2017, Steven D'Aprano wrote:
> Suppose you have an expensive calculation that gets used two or
> more times in a loop. The obvious way to avoid calculating it
> twice in an ordinary loop is with a temporary variable:
>
> result = []
> for x in data:
> tmp = expensive_calculation(x)
>
On 1/18/2017, Peter Otten wrote:
> with partite.txt looking like this
>
> > 74' Kessie'
> > 90' + 4' D'alessandro
> > 51' Mchedlidze
> > 54' Banega
> > 56' Icardi
> > 65' Icardi
> > 14' Sau
>
>
> Assuming you want to perform a numerical sort on the numbers before the '
> you can just apply sor
On 3/1/2017, Sayth Renshaw wrote:
> How can I flatten just a specific sublist of each list in a list of lists?
>
> So if I had this data
>
>
> [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']],
> ['46295', 'Dark Eyes', '5', '59', '83', ['6', '4', '1', '0 $105625.00
On 3/7/2017, Sayth Renshaw wrote:
> I have got this dictionary comprehension and it
> works but how can I do it better?
>
> from collections import Counter
>
> def find_it(seq):
> counts = dict(Counter(seq))
> a = [(k, v) for k,v in counts.items() if v % 3 == 0]
> return a[0][0]
>