Re: Webpy vs Django?
wow now i have django running. now i see... -- http://mail.python.org/mailman/listinfo/python-list
catastrophic regexp, help!
pat = re.compile("(\w* *)*") this matches all sentences. if fed the string "are you crazy? i am" it will return "are you crazy". i want to find a in a big string a sentence containing Zlatan Ibrahimovic and some other text. ie return the first sentence containing the name Zlatan Ibrahimovic. patzln = re.compile("(\w* *)* zlatan ibrahimovic (\w* *)*") should do this according to regexcoach but it seems to send my computer into 100%CPU-power and not closable. -- http://mail.python.org/mailman/listinfo/python-list
web2py forum or mailing list?
i cant find a web2py mailing list or forum, not by googling and not on the web2py homepage. (yes thats right im asking about web2py not webpy). this framework seems great and i installed and it seems like all i wished for. easy to install, easy to use, fast, etc. just an overall better, complete and more professional framework than anything else out there. do id like to discuss it somewhere, is there such a place? -- http://mail.python.org/mailman/listinfo/python-list
Re: web2py forum or mailing list?
web2py > django mailing list: http://groups.google.com/group/web2py -- http://mail.python.org/mailman/listinfo/python-list
Re: catastrophic regexp, help!
On 11 Juni, 17:04, TheSaint <[EMAIL PROTECTED]> wrote: > On 12:20, mercoledì 11 giugno 2008 cirfu wrote: > > > patzln = re.compile("(\w* *)* zlatan ibrahimovic (\w* *)*") > > I think that I shouldn't put anything around the phrase you want to find. > > patzln = re.compile(r'.*(zlatan ibrahimovic){1,1}.*') > > this should do it for you. Unless searching into a special position. > > In the other hand, I'd like to understand how I can substitute a variable > inside a pattern. > > if I do: > import os, re > EOL= os.linesep > > re_EOL= re.compile(r'[?P\s+2\t]')) > > for line in open('myfile','r').readlines(): >print re_EOL.sub('',line) > > Will it remove tabs, spaces and end-of-line ? > It's doing but no EOL :( > > -- > Mailsweeper Home :http://it.geocities.com/call_me_not_now/index.html it returns all the sentences. i just want the one containing zlatan ibrahimovic. -- http://mail.python.org/mailman/listinfo/python-list
Re: catastrophic regexp, help!
On 11 Juni, 10:25, Chris <[EMAIL PROTECTED]> wrote: > On Jun 11, 6:20 am, cirfu <[EMAIL PROTECTED]> wrote: > > > pat = re.compile("(\w* *)*") > > this matches all sentences. > > if fed the string "are you crazy? i am" it will return "are you > > crazy". > > > i want to find a in a big string a sentence containing Zlatan > > Ibrahimovic and some other text. > > ie return the first sentence containing the name Zlatan Ibrahimovic. > > > patzln = re.compile("(\w* *)* zlatan ibrahimovic (\w* *)*") > > should do this according to regexcoach but it seems to send my > > computer into 100%CPU-power and not closable. > > Maybe something like this would be of use... > > def sentence_locator(s, sub): > cnt = s.upper().count(sub.upper()) > if not cnt: > return None > tmp = [] > idx = -1 > while cnt: > idx = s.upper().find(sub.upper(), (idx+1)) > a = -1 > while True: > b = s.find('.', (a+1), idx) > if b == -1: > b = s.find('.', idx) > if b == -1: > tmp.append(s[a+1:]) > break > tmp.append(s[a+1:b+1]) > break > a = b > cnt -= 1 > return tmp yes, seems very unpythonic though :) must be a simpler way that isnt slow as hell. -- http://mail.python.org/mailman/listinfo/python-list
weird iteration/assignment problem
for i in xrange(0, len(texts)): texts[i] = "yes" for i in texts: i = "no" why is the first one working but not the second. i mean i see why the firts one works but i dont udnerstand why the second doesnt. -- http://mail.python.org/mailman/listinfo/python-list
advanced listcomprehenions?
I am wondering if it is possible to write advanced listcomprehensions. For example: """Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".""" Obv it doesnt have to be a list according tot hat definition but suppose i want to generate that list. >>> [["Fizzbuzz",x] for x in xrange(1,101) if x%3 == 0 and x%5 == 0] [['Fizzbuzz', 15], ['Fizzbuzz', 30], ['Fizzbuzz', 45], ['Fizzbuzz', 60], ['Fizzbuzz', 75], ['Fizzbuzz', 90]] is not what i want. the following does the trick but is ldo not a listcomprehension: for i in xrange(1,101): s = "" if i%3 == 0: s += "Fizz" if i%5 == 0: s += "Buzz" if s: print "%d : %s" % (i,s) else: print i or to generate a lisrt but not by listcomprehsnion: map(lambda x: (not x%3 and not x%5 and "FizzBuzz") or (not x%3 and "Fizz") or (not x%5 and "Buzz") or x, xrange(1,101)) -- http://mail.python.org/mailman/listinfo/python-list
Installing Python 3.0 no probs running 2.5 at the same time?
Can I install 3.0 without breaking 2.5? Meaning does it overwrite some bindings or something or it just installs 3.0 in a different folder as a completely separate program? -- http://mail.python.org/mailman/listinfo/python-list
Re: Google-like "Did you mean... ?" search algorithm
On 20 Juni, 00:14, [EMAIL PROTECTED] wrote: > This is a wee bit OT, but I am looking for algorithms to implement > search suggestions, similar to Google's "Did you mean... ?" feature. > Can anyone point me to web pages, journal articles, implementations > (preferably in Python!), or any other resources in this area? > > Thanks! if you mean a spellchecker check peter norvigs homepage. http://norvig.com/spell-correct.html -- http://mail.python.org/mailman/listinfo/python-list
rightclick-copy in IDLE?
when i rightclick in python idle i get set breakpoint or something. n options i dont find a way to change to the normal copy/paste options. -- http://mail.python.org/mailman/listinfo/python-list
listcomprehension, add elements?
[a+b for a,b in zip(xrange(1,51), xrange(50,0,-1))] [51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51] i want to add all the elemtns a s well. can i do this all in a listcomprehension? i can do this ofc: reduce(lambda x,y:x+y,[a+b for a,b in zip(xrange(1,51), xrange(50,0,-1))]) but reduce is a functional way of doing it, what is the more pythonic way of doing this? -- http://mail.python.org/mailman/listinfo/python-list
IDE on the level of Eclipse or DEVc++?
is there an IDE for python of the same quality as Eclipse or DEVC++? I am currently using the editor that coems iwth python and it is all fine but for bigger projects it would be nice to have some way to easier browse the projectfiles for example. -- http://mail.python.org/mailman/listinfo/python-list
installed 3.0, rebind winprompt to 2.5?
i installed python 3.0. now when im laucnhing from the dos prompt in win vista it searches in python3.0 i want to rebind it to 2.5, what do i need to change? -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE on the level of Eclipse or DEVc++?
i downloaded the extension for eclipse, nice. any opinions of netbeans vs eclipse for python? -- http://mail.python.org/mailman/listinfo/python-list
socket error: connection refused?
The first time i start the shell it always works. But often after closing it and restarting it I get: Two windows pops up and the shell, after clicking the windows the shell just closes by itself. socket error: connection refused IDLE's subprocess didnt make connection. im using python 2.5.1 and windows vista. -- http://mail.python.org/mailman/listinfo/python-list
Re: socket error: connection refused?
On 23 Juni, 20:55, [EMAIL PROTECTED] wrote: > It's a security conflict. You should be able to run it again and have > it work. Our company's cisco does the same thing (even after we > approve the app) doesnt work but i found out i should open the task manager and kill all the python processes, then it works. -- http://mail.python.org/mailman/listinfo/python-list
regexp: match only if previous matched?
I need to extract prices froma html-document. [0-9]*\$ matches 112$ 45$ etc but also just a $. why that shouldnt really matter and it is unlikely anyway to appear a $sign with no price attahced to it I still want to prevent it. How do I avoid matching "$"? It has to be "nbr$". -- http://mail.python.org/mailman/listinfo/python-list
NameError: name 'maketrans' is not defined, pythonchallenge
im doing the python challenge and well, i solved this problem with ruby :) phrase = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj." puts phrase .tr('A-XY-Za-xy-z','C-ZA-Bc-za-b') the answer says to use maketrans but i cant get it to work: >>> pat = maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b') Traceback (most recent call last): File "", line 1, in pat = maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b') NameError: name 'maketrans' is not defined >>> "hej tjena tjenixen".maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b') Traceback (most recent call last): File "", line 1, in "hej ditt fetto".maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b') AttributeError: 'str' object has no attribute 'maketrans' http://docs.python.org/lib/node41.html -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError: name 'maketrans' is not defined, pythonchallenge
from string import maketrans ok but how can i write: pattern = maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b') pattern = maketrans('A-Za-z', 'C-Bc-b') none works -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError: name 'maketrans' is not defined, pythonchallenge
import string text = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj." table = string.maketrans(string.ascii_lowercase, string.ascii_lowercase[2:]+string.ascii_lowercase[:2]) print string.translate(text,table) -- http://mail.python.org/mailman/listinfo/python-list
shorten this: if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz": cant i write something like: if char in "[A-Za-z]": ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Freeze problem with Regular Expression
On 25 Juni, 17:20, Kirk <[EMAIL PROTECTED]> wrote: > Hi All, > the following regular expression matching seems to enter in a infinite > loop: > > > import re > text = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA) > una ' > re.findall('[^A-Z|0-9]*((?:[0-9]*[A-Z]+[0-9|a-z|\-]*)+\s*[a-z]*\s*(?:[0-9] > *[A-Z]+[0-9|a-z|\-]*\s*)*)([^A-Z]*)$', text) > # > > No problem with perl with the same expression: > > # > $s = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA) una > '; > $s =~ /[^A-Z|0-9]*((?:[0-9]*[A-Z]+[0-9|a-z|\-]*)+\s*[a-z]*\s*(?:[0-9]*[A- > Z]+[0-9|a-z|\-]*\s*)*)([^A-Z]*)$/; > print $1; > # > > I've python 2.5.2 on Ubuntu 8.04. > any idea? > Thanks! > > -- > Kirk what are you trying to do? -- http://mail.python.org/mailman/listinfo/python-list