On 16/05/11 17:25, Tracubik wrote:
pls help me fixing this:
import re
s = "linka la baba"
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)
print re_s.findall(s)
output:
['link', 'l']
why?
i want my re_s to find linka and la, he just find link and l and forget
about the ending a.
The round br
On 16.05.2011 18:25, Tracubik wrote:
pls help me fixing this:
import re
s = "linka la baba"
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)
print re_s.findall(s)
output:
['link', 'l']
why?
As the docs say:
"If one or more groups are present in the pattern, return a list of
groups;"
http
On 5/16/11 11:25 AM, Tracubik wrote:
pls help me fixing this:
import re
s = "linka la baba"
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)
print re_s.findall(s)
output:
['link', 'l']
why?
i want my re_s to find linka and la, he just find link and l and forget
about the ending a.
can anyone
pls help me fixing this:
import re
s = "linka la baba"
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)
print re_s.findall(s)
output:
['link', 'l']
why?
i want my re_s to find linka and la, he just find link and l and forget
about the ending a.
can anyone help me? trying the regular expressio
On Sat, 06 Dec 2008 23:33:35 -0800, 5lvqbwl02 wrote:
> I'm trying to solve the 9-tile puzzle using as functional an approach as
> possible. I've recently finished reading SICP and am deliberately
> avoiding easy python-isms for the more convoluted scheme/functional
> methods. The following funct
[EMAIL PROTECTED] writes:
> I'm trying to solve the 9-tile puzzle using as functional an approach
> as possible. I've recently finished reading SICP and am deliberately
> avoiding easy python-isms for the more convoluted scheme/functional
> methods. The following function is trivial to do with f
James Stroud wrote:
def linear_search(array, truth_func, loc=(0,0)):
idx1, idx2 = loc
if idx1 >= len(array):
return None
if idx2 >= len(array[idx1]):
return linear_search(array, truth_func, (idx1+1, 0))
value = array[idx1][idx2]
tf = truth_func(value)
if tf:
return loc
e
[EMAIL PROTECTED] wrote:
I'm trying to solve the 9-tile puzzle using as functional an approach
as possible. I've recently finished reading SICP and am deliberately
avoiding easy python-isms for the more convoluted scheme/functional
methods. The following function is trivial to do with for loops
I'm trying to solve the 9-tile puzzle using as functional an approach
as possible. I've recently finished reading SICP and am deliberately
avoiding easy python-isms for the more convoluted scheme/functional
methods. The following function is trivial to do with for loops and
directly accessing arr
I'm trying to solve the 9-tile puzzle using as functional an approach
as possible. I've recently finished reading SICP and am deliberately
avoiding easy python-isms for the more convoluted scheme/functional
methods. The following function is trivial to do with for loops and
directly accessing arr
Ant wrote:
> So how do python app's typically embed python? For example things like
> Zope and idle are scripted using Python - presumably they restrict the
> execution of the scripts to a restricted set of modules/objects - but
> how is this done?
why? anyone capable of adding code to idle alre
> As Fredrik points out, embedded Python isn't the same as running
> untrusted code. The reality is, Python has not been designed for running
> untrusted code safely.
So how do python app's typically embed python? For example things like
Zope and idle are scripted using Python - presumably they r
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>Ant wrote:
>> It seems that there must be a way to use eval safely, as there are
>> plenty of apps that embed python as a scripting language - and what's
>> the point of an eval function if impossible to use safely, and you have
>> to write your own Python
On Fri, 07 Jul 2006 09:39:38 -0700, Ant wrote:
>
>> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
>> [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
>> # line injected by a malicious user
>> "__import__('os').system('echo if I were bad I could do worse')"
>> [('recId', 7 ), ('pars
On Fri, 07 Jul 2006 19:57:02 +0200, Fredrik Lundh wrote:
> Steven D'Aprano wrote:
>
>> Personally, I would never use eval on any string I didn't write myself. If
>> I was thinking about evaluating a user-string, I would always write a
>> function to parse the string and accept only the specific s
Steven D'Aprano wrote:
> Personally, I would never use eval on any string I didn't write myself. If
> I was thinking about evaluating a user-string, I would always write a
> function to parse the string and accept only the specific sort of data I
> expected. In your case, a quick-and-dirty unteste
Ant wrote:
> It seems that there must be a way to use eval safely, as there are
> plenty of apps that embed python as a scripting language - and what's
> the point of an eval function if impossible to use safely, and you have
> to write your own Python parser!!
embedding python != accepting scrip
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
> # line injected by a malicious user
> "__import__('os').system('echo if I were bad I could do worse')"
> [('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})]
I'm curious, if you
On Thu, 06 Jul 2006 03:34:32 -0700, manstey wrote:
> Hi,
>
> I have a text file called a.txt:
>
> # comments
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})]
>
> I read it
> hint 1:
hint 1b:
>>> eval("[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]")
[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
>>> eval("[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]\n")
[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
>>> eval("[('recId', 3), ('parse
manstey schreef:
> Hi,
>
> I have a text file called a.txt:
>
> # comments
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})]
>
> I read it using this:
>
> filAnsMorph = code
"manstey" <[EMAIL PROTECTED]> wrote:
> That doesn't work. I just get an error:
>
>x = eval(line.strip('\n'))
> File "", line 1
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
>
> SyntaxError: unexpected EOF while parsing
>
> any other ideas?
hint 1:
>>> eval("[('recId', 3), ('p
manstey wrote:
> That doesn't work. I just get an error:
>
> x = eval(line.strip('\n'))
>File "", line 1
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
>
> SyntaxError: unexpected EOF while parsing
>
is the last line of your file empty ??
what with
for line in filA
That doesn't work. I just get an error:
x = eval(line.strip('\n'))
File "", line 1
[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
SyntaxError: unexpected EOF while parsing
any other ideas?
Bruno Desthuilliers wrote:
> manstey wrote:
> > Hi,
> >
> > I have a text file called
manstey wrote:
> Hi,
>
> I have a text file called a.txt:
>
> # comments
> [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
> [('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})]
>
> I read it using this:
>
> filAnsMorph = codecs
Hi,
I have a text file called a.txt:
# comments
[('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})]
[('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})]
[('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})]
I read it using this:
filAnsMorph = codecs.open('a.txt', 'r', 'utf-8') # Initiali
Jan Danielsson wrote:
> Gary Herron wrote:
>>... a more recent addition to the language is Sets, ...
>from sets import Set
>Set([1,2,3,4,5,6]) - Set([2,3,6])
>>
>>Set([1, 4, 5])
If you are using 2.4 or later, you can simply use "set" without
importing anything.
set(['apple', 'orange'
Gary Herron wrote:
[---]
>> I just tried typing the above in Python, and it - obviously - doesn't
>> work, so it must be some other syntax.
>>
>>
> Not with tuples, lists or dictionaries. However a more recent addition
> to the language is Sets, and they support set differences:
>
from s
Jan Danielsson wrote:
> Hello all,
>
>I'm 100% sure that I saw an example which looked something like this
> recently:
>
>
a=(1, 2, 3, 4, 5, 6)
b=(2, 3, 6)
a - b
>
> (1, 4, 5)
>
>The only new language I have been involved in lately is Python. Is my
> memory failing me, or h
On Mon, 13 Jun 2005 20:52:43 -0400, Gary Herron wrote
(in article <[EMAIL PROTECTED]>):
> Jan Danielsson wrote:
>
>> Hello all,
>>
>> I'm 100% sure that I saw an example which looked something like this
>> recently:
>>
>>
>>
> a=(1, 2, 3, 4, 5, 6)
> b=(2, 3, 6)
> a - b
>
Jan Danielsson wrote:
>Hello all,
>
> I'm 100% sure that I saw an example which looked something like this
>recently:
>
>
>
a=(1, 2, 3, 4, 5, 6)
b=(2, 3, 6)
a - b
>(1, 4, 5)
>
> The only new language I have been involved in lately is Python. Is my
>memory failin
Hello all,
I'm 100% sure that I saw an example which looked something like this
recently:
>>> a=(1, 2, 3, 4, 5, 6)
>>> b=(2, 3, 6)
>>> a - b
(1, 4, 5)
The only new language I have been involved in lately is Python. Is my
memory failing me, or have I seen such an Python-example somewhere? I
32 matches
Mail list logo