Re: [Tutor] server used in python
On Mon, Mar 28, 2011 at 3:27 AM, ema francis wrote: > I am learnning python for 3 months from now. I wanted to know how and what > server is used in python web development?Looking for your help When you're developing a Python Web application, most people use a development server that automatically detects when you update a file and reloads it for you so you don't have to restart the Web server each time. When you're ready to take your site live, you have several options. If you design your Web application as a WSGI app (http://www.wsgi.org/wsgi/), you can hook into any WSGI server. Many people use Apache with mod_wsgi, but you can also proxy back to your Web app. Look at using the Flask Web Framework (http://flask.pocoo.org/docs/). Flask is a modern, lightweight, and well-documented Python Web framework so you won't have to spend much time learning it or fighting with it so you won't find yourself asking, "Will I be able to do what I want in the framework without hacking it?" Flask let's you program in Python rather than writing to the framework like you typically have to in larger, opinionated framework's like Django and Rails. It comes with a development server, and its documentation (http://flask.pocoo.org/docs/) explains several different types of deployment options for when you're ready to go live (http://flask.pocoo.org/docs/deploying/). - James -- Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] super() with Multiple Inheritance
Why does user.params() not return all the params up the inheritance chain? -- It's not including the params defined in Person() -- notice Vertex() does not have a params() method. class Element(object): def __init__(self,element_type): self.oid = None self.uuid = uuid.uuid4() self.key = None self.element_type = element_type def params(self): return dict(uuid=self.uuid, key=self.key) class Vertex(Element): def __init__(self): super(Vertex,self).__init__("vertex") class Person(Vertex): def __init__(self,name=None,uri=None,email=None): self.s = super(Person,self) self.s.__init__() self.name=name self.uri=uri self.email = email def params(self): params = dict(name=self.name,uri=self.uri,email=self.email) params.update(self.s.params()) return params class User(Person): def __init__(self, name=None, uri=None, email=None, first_name=None, last_name=None, facebook_id=None, facebook_link=None, facebook_username=None, gender=None, locale=None): self.s = super(User,self) self.s.__init__(name,uri,email) self.first_name = first_name self.last_name = last_name self.facebook_id = facebook_id self.facebook_link = facebook_link self.facebook_username = facebook_username self.gender = gender self.locale = locale def params(self): params = dict(first_name=self.first_name, last_name=self.last_name, facebook_id=self.facebook_id, facebook_link=self.facebook_link, facebook_username=self.facebook_username, gender=self.gender, locale=self.locale) print self.s.params() params.update(self.s.params()) return params ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] super() with Multiple Inheritance
I found this issue -- I was setting setting self.s to the return value of super() and trying to use self.s in params(): self.s = super(User,self) self.s.__init__(name,uri,email) def params(self): params = dict(name=self.name) params.update(self.s.params()) ...but this won't work. You have to use super each time you want to make a call to a parent's function. It returns an object with an internal queue. If you use this object twice, you will only call the method of the top class (in this case, Element). super does not return an object from the parent class. It is a mechanism from managing multiple inheritance On Thu, Apr 14, 2011 at 12:25 PM, Alan Gauld wrote: > > "James Thornton" wrote > >> Why does user.params() not return all the params up the inheritance >> chain? -- It's not including the params defined in Person() -- notice >> Vertex() does not have a params() method. > >> class Element(object): >> def params(self): >> return dict(uuid=self.uuid, key=self.key) >> >> class Vertex(Element): >> >> class Person(Vertex): >> def params(self): >> params = dict(name=self.name,uri=self.uri,email=self.email) >> params.update(self.s.params()) >> return params >> >> class User(Person): >> def params(self): >> params = dict(first_name=self.first_name, >> locale=self.locale) >> print self.s.params() >> params.update(self.s.params()) >> return params > > Where does User.params call Person.params? > Or for that matter Person.params call its super class? > It doesn't happen automatically(thank goodness) you > have to do it explicitly. > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] NLP
http://scikit-learn.sourceforge.net/ On Fri, Apr 8, 2011 at 6:52 AM, Ranjith Kumar wrote: > Hi all, > Can anyone suggest me any best Natural Language Processing in > python other than nltk. > -- > Cheers, > Ranjith Kumar K, > Chennai. > http://ranjithtenz.wordpress.com > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Programmatically Post to Pastebin
Pocoo (the creators of Flask) have a Python API for a pastebin they developed called LodgeIt. You can use the hosted version, or the download the source code and host your own (http://www.pocoo.org/projects/lodgeit/). http://paste.pocoo.org/ http://paste.pocoo.org/about/ http://paste.pocoo.org/help/api/ - James On Tue, May 10, 2011 at 6:57 PM, Lan Rogers wrote: > I realize this may not be entirely within the domain of a python > mailing list, but I'm having trouble finding anything helpful > elsewhere. > > I want to post files stored on a machine to Pastebin (or any similar > service for that matter) using a python script, and then store a link > to that post. Also, I would strongly prefer to avoid doing something > that requires an API key. > > Sorry if this isn't really the right place to ask about this, if > that's the case can someone show me a more appropriate forum? > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How do I learn python for web development
On Sun, Jul 31, 2011 at 3:22 PM, abdulhakim haliru wrote: > Hi guys, > > I am really interested in switching from PHP to python but there don't appear > to be a book for such. Hi - Start off by becoming familiar with Python -- here are some good online tutorials, in order from introductory to more advanced: http://www.quora.com/How-can-I-learn-to-program-in-Python/answer/James-Thornton And then do the Flask Quickstart and Tutorial (http://flask.pocoo.org/docs/). Flask is an elegantly-designed Python Web microframework so it's great for beginners because you don't have too spend much time learning it -- it let's you program in Python rather than writing to the framework. Ironically, this also makes Flask an ideal choice for advanced Python programmers because it gives you flexibility rather than always wondering "will the framework allow me to easily do...?" - James -- Bulbflow: A Python framework for graph databases (http://bulbflow.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file fetcher class object through http
> Essentially, I want to write a class that finds, and downloads a file from a > web server. mostly, I am looking for a smart class implementation that has > well-considered API and method choices. httplib2 (http://code.google.com/p/httplib2) by Joe Gregorio of Google is what I use. It has an intuitive interface that's easy to use. $ pip install httplib2 >>> import httplib2 >>> http = httplib2.Http() >>> resp, content = http.request("http://example.org/";, "GET") Here are more examples: http://code.google.com/p/httplib2/wiki/Examples - James -- Bulbflow: A Python framework for graph databases (http://bulbflow.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can't find error :-(
If you copied and pasted the line, it's possible the quote marks are of the wrong encoding -- try deleting the quote marks and adding them back. On Sun, Aug 28, 2011 at 6:34 AM, Lisi wrote: > Here is the error message: > /usr/local/bin/AddressBook: line 6: syntax error near unexpected token `(' > /usr/local/bin/AddressBook: line 6: `name = raw_input("Type the Name - leave > blank to finish")' > > (sorry KMail wrapped it.) > > Here is what I typed: > name = raw_input("Type the Name - leave blank to finish") > > Here is what I was copying: > name = raw_input("Type the Name - leave blank to finish") > > Help!! All three are copied and pasted from their relevant places to > eliminate mis-copying at this stage. What have I miscopied?? The original > and my copy look to me *exactly* the same. > > Lisi > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Bulbflow: A Python framework for graph databases (http://bulbflow.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor