From ylj798 at gmail.com Wed Nov 12 11:30:10 2008 From: ylj798 at gmail.com (yao) Date: Wed, 12 Nov 2008 18:30:10 +0800 Subject: [python-advocacy] help me~!!!'tuple' object has no attribute 'compile' Message-ID: <491AB032.2010507@gmial.com> my code ------------------------------------------------------------------------------------------- # -*- coding: utf8 -*- #!/usr/bin/python import urllib import urllib2 import re import MySQLdb conn=MySQLdb.connect (host="localhost",user="root",passwd="ylj",db="net", charset="utf8") cur = conn.cursor() sql='select net_site.downline_re,net_site.down_re,net_cha.id,net_cha.urlid,net_cha.source_url from net_site,net_cha where net_site.id=net_cha.urlid' cur.execute(sql) re=cur.fetchall() if len(re)!=0: for i in re: down_re="%s"%(i[1]) source_url="%s"%(i[4]) data= urllib2.urlopen(source_url).read() res=re.compile(down, re_DOTALL).findall(data) print str -------------------------------------------------------------------------------------------------------- when it's run,the eric give error ------------- The debugged program raised the exception unhandled AttributeError "'tuple' object has no attribute 'compile'" File: /var/www/py/down.py, Line: 27 ------------ the line:27 -------> res=re.compile(down, re_DOTALL).findall(data) From l.oluyede at gmail.com Wed Nov 12 12:16:51 2008 From: l.oluyede at gmail.com (Lawrence Oluyede) Date: Wed, 12 Nov 2008 12:16:51 +0100 Subject: [python-advocacy] help me~!!!'tuple' object has no attribute 'compile' In-Reply-To: <491AB032.2010507@gmial.com> References: <491AB032.2010507@gmial.com> Message-ID: <9eebf5740811120316x3baa4390h3cbea33e611dae76@mail.gmail.com> On Wed, Nov 12, 2008 at 11:30 AM, yao wrote: > my code > ------------------------------------------------------------------------------------------- > > # -*- coding: utf8 -*- > #!/usr/bin/python > > import urllib > import urllib2 > import re > import MySQLdb > > conn=MySQLdb.connect > (host="localhost",user="root",passwd="ylj",db="net", charset="utf8") > cur = conn.cursor() > sql='select > net_site.downline_re,net_site.down_re,net_cha.id,net_cha.urlid,net_cha.source_url > > from net_site,net_cha where net_site.id=net_cha.urlid' > cur.execute(sql) > re=cur.fetchall() here "re" it's a tuple resulted from the fetching of data from the database, so you hide the name of the 're' module. Just change name for this variable and you'll be fine. > if len(re)!=0: > for i in re: > down_re="%s"%(i[1]) > source_url="%s"%(i[4]) > data= urllib2.urlopen(source_url).read() > res=re.compile(down, re_DOTALL).findall(data) > print str > -------------------------------------------------------------------------------------------------------- > > when it's run,the eric give error > ------------- > The debugged program raised the exception unhandled AttributeError > "'tuple' object has no attribute 'compile'" > File: /var/www/py/down.py, Line: 27 > ------------ > the line:27 -------> res=re.compile(down, re_DOTALL).findall(data) By the way, I'm pretty sure this kind of questions should be addressed in comp.lang.python or some python newbie mailing list, not on this mailing list -- Lawrence, neropercaso.it - oluyede.org "It is difficult to get a man to understand something when his salary depends on not understanding it" - Upton Sinclair From carl at personnelware.com Tue Nov 25 19:50:43 2008 From: carl at personnelware.com (Carl Karsten) Date: Tue, 25 Nov 2008 12:50:43 -0600 Subject: [python-advocacy] intro to python intro, Implementation list Message-ID: <492C4903.5060205@personnelware.com> I am doing a talk: Intro to Python, or Everything you need to know about Python, or something. I did the talk at a linux user group, and it went pretty good - I plan on doing it more, so fleshing out some parts. In the intro, I want to point out 'this' (and I am not going to speak it all, so wordynes applies to written, not spoken.) Implementations: CPython - Mac, Unix (Linux, Solaris, AIX, etc), Windows, HPUX, BeOS, iPod, OS2, Palm, PS2, xBox and more. Jython - runs in Java Iron Python, Python.net ? runs in the .net clr (so Mono too) PyPy ? Python written in Python, complies Reduced Python to C code. PyS60 - Python for S60 mobile phones. Open Office, Gimp, InkScape, Pidgin, xChat, vim, emacs ? all have python embedded in them (I think it is typically CPython, not sure the details.) There are about 40 platforms listed: http://en.wikipedia.org/wiki/CPython#Supported_platforms Wich I think is a bit too much for the intro. unless I do a slide dedicated to that, or do a Slide2.0 Tag Cloud looking thing so that they are all up there but don't take up much space. Does my list seem accurate enough? Carl K From fuzzyman at voidspace.org.uk Tue Nov 25 20:18:58 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 25 Nov 2008 19:18:58 +0000 Subject: [python-advocacy] intro to python intro, Implementation list In-Reply-To: <492C4903.5060205@personnelware.com> References: <492C4903.5060205@personnelware.com> Message-ID: <492C4FA2.90009@voidspace.org.uk> Carl Karsten wrote: > I am doing a talk: Intro to Python, or Everything you need to know about Python, > or something. I did the talk at a linux user group, and it went pretty good - I > plan on doing it more, so fleshing out some parts. > > In the intro, I want to point out 'this' (and I am not going to speak it all, so > wordynes applies to written, not spoken.) > > Implementations: > CPython - Mac, Unix (Linux, Solaris, AIX, etc), Windows, HPUX, BeOS, iPod, OS2, > Palm, PS2, xBox and more. > Jython - runs in Java > Iron Python, Python.net ? runs in the .net clr (so Mono too) > PyPy ? Python written in Python, complies Reduced Python to C code. > PyS60 - Python for S60 mobile phones. > Open Office, Gimp, InkScape, Pidgin, xChat, vim, emacs ? all have python > embedded in them (I think it is typically CPython, not sure the details.) > > I think Python for S60 is a port of CPython rather than a fresh implementation. There is also CLPython, although I think it might be abandonware now: http://common-lisp.net/project/clpython/ IronPython should not have a space in the name. Maybe list Stackless under implementations? Michael Foord > There are about 40 platforms listed: > http://en.wikipedia.org/wiki/CPython#Supported_platforms > Wich I think is a bit too much for the intro. unless I do a slide dedicated to > that, or do a Slide2.0 Tag Cloud looking thing so that they are all up there but > don't take up much space. > > Does my list seem accurate enough? > > Carl K > _______________________________________________ > Advocacy mailing list > Advocacy at python.org > http://mail.python.org/mailman/listinfo/advocacy > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From Cameron at phaseit.net Tue Nov 25 20:21:12 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 25 Nov 2008 19:21:12 +0000 Subject: [python-advocacy] intro to python intro, Implementation list In-Reply-To: <492C4FA2.90009@voidspace.org.uk> References: <492C4903.5060205@personnelware.com> <492C4FA2.90009@voidspace.org.uk> Message-ID: <20081125192112.GA20304@lairds.us> On Tue, Nov 25, 2008 at 07:18:58PM +0000, Michael Foord wrote: . . . > >Implementations: > >CPython - Mac, Unix (Linux, Solaris, AIX, etc), Windows, HPUX, BeOS, iPod, > >OS2, > >Palm, PS2, xBox and more. > >Jython - runs in Java > >Iron Python, Python.net ? runs in the .net clr (so Mono too) > >PyPy ? Python written in Python, complies Reduced Python to C code. > >PyS60 - Python for S60 mobile phones. > >Open Office, Gimp, InkScape, Pidgin, xChat, vim, emacs ? all have python > >embedded in them (I think it is typically CPython, not sure the details.) > > > > > > I think Python for S60 is a port of CPython rather than a fresh > implementation. > > There is also CLPython, although I think it might be abandonware now: > > http://common-lisp.net/project/clpython/ > > IronPython should not have a space in the name. > > Maybe list Stackless under implementations? > > Michael Foord > > >There are about 40 platforms listed: > >http://en.wikipedia.org/wiki/CPython#Supported_platforms > >Wich I think is a bit too much for the intro. unless I do a slide > >dedicated to > >that, or do a Slide2.0 Tag Cloud looking thing so that they are all up > >there but > >don't take up much space. > > > >Does my list seem accurate enough? . . .