ANN: CherryPy-2.1.0-final released
Hello everyone, I am happy to announce the release of CherryPy-2.1.0 If is the result of 6 months of intense development since the last stable release and the work of a growing number of contributors. CherryPy has become increasingly popular these past few months (the mailing lists now have more than 500 people) and it is also used in other popular products such as Subway and Turbogears. This release is a major step forward for CherryPy. It is packed with new features and bug fixes. Here are the main improvements in this release: - New WSGI interface, which allow CherryPy sites to be deployed on any WSGI server. People are already running it on mod_python, FastCGI, SCGI, IIS or CherryPy's own built-in HTTP server. - New implementation for sessions, which supports multiple backends - Built-in list of convenient "filters" for things like gzip compression, XHTML validation, caching, unicode decoding/encoding, authentication, XML-RPC wrapper, etc ... These filters can easily be enabled/disabled through configuration. - New "development" mode which provides things like autoreload (no need to manually restart your server when you make a change), logging of page stats, etc ... - Better handling of file uploads - Internal implementation now uses generators everywhere (no more StringIO) - New built-in HTTP server implementation *** About CherryPy: CherryPy-2 is a pythonic, object-oriented web development framework. Here is a sample Hello, World in CherryPy-2: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() Main properties: - this code starts a multi-threaded HTTP server that dispatches requests to methods - requests like "http://domain/dir/page?arg1=va l1&arg2=val2" are mapped to "dir.page(arg1='val1', arg2='val2')" - CherryPy also supports "RESTful" URLs like http://domain/book/science/9 - requests are mapped to an object tree that is "mounted" on cherrypy.root (for instance: "cherrypy.root.user", "cherrypy.root.user.remi", ...) - method must be explicitly exposed with a decorator "@cherrypy.expose" (or "index.exposed = True" for Python-2.3) Remi. http://www.cherrypy.org -- http://mail.python.org/mailman/listinfo/python-list
Ann: CherryPy-2.0-beta released
Hello everyone, I am happy to announce the release of CherryPy-2.0-beta. CherryPy-2 is a pythonic, object-oriented web development framework. CherryPy-2 is a redesign of CherryPy-1 (the unpythonic features have been removed): no more compilation step, pure python source code (no more "CherryClass") Here is a sample Hello, World in CherryPy-2: # from cherrypy import cpg # class HelloWorld: # @cpg.expose # def index(self): # return "Hello world!" # cpg.root = HelloWorld() # cpg.server.start() Main properties: - this code starts a multi-threaded HTTP server that dispatches requests to methods - requests like "http://domain/dir/page?arg1=val1&arg2=val2"; are mapped to "dir.page(arg1='val1', arg2='val2')" - requests are mapped to an object tree that is "mounted" on cpg.root (for instance: "cpg.root.user", "cpg.root.user.remi", ...) - method must be explicitely exposed with a decorator "@cpg.expose" (or "index.exposed = True" for Python-2.3) - methods can return a generator instead of a string (useful when generating big pages) Here is a non-exhaustive list of CherryPy-2 features: multi-threaded HTTP server, XML-RPC server, sessions, form handling, authentication, unicode support, gzip-compression, virtual hosting, WSGI adapter (experimental) The design of CherryPy-2 allows to easily write/use pluggable "filters" or "modules": - filters perform operations on the request/response such as gzip-compression or string encoding - modules are web applications (like a blog or a web forum) than can be easily "mounted" anywhere you want in your website CherryPy-2 is already used in production by several sites and is supported by an active community. Remi. http://www.cherrypy.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Frameworks for "Non-Content Oriented Web Apps"
Have a look a the new CherryPy (http://www.cherrypy.org). It allows developers to build web applications in much the same way they would build any other object-oriented Python program. This might corespond to what you're looking for. Remi. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ann: CherryPy-2.0-beta released
> I'm a great believer that avoiding query strings in URL's is good > practise ( http://www.holloway.co.nz/book/9 for good arguments why). CherryPy also supports that out of the box: class Book: def default(self, categoryName, bookId): ... cpg.root.book = Book() If you go to "http://domain/book/science/9";, CherryPy will call book.default('science', '9') > Also how > much does it complicate matters to run cherryPy under an existing > webserver? Is any functionality lost? Well, you can easily run CherryPy behind Apache (see http://trac.cherrypy.org/cgi-bin/trac.cgi/wiki/BehindApache). Since CherryPy provides a WSGI interface (although it's still experimental), you can also run your CherryPy app with any WSGI-compatible HTTP server (although I don't really see any advantage to doing this). Remi -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.1.0-beta released
Hello everyone, I am happy to announce the first beta release of CherryPy-2.1 This release is a major step forward for CherryPy. It is packed with new features and bug fixes. Also, the CherryPy community is now growing quite fast and it is very active. Many people contributed to this release. Here are the main improvements in this release: - New WSGI interface, which allow CherryPy sites to be deployed on any WSGI server. People are already running it on mod_python, FastCGI, SCGI, IIS or CherryPy's own built-in HTTP server. - New implementation for sessions, which supports multiple backends - Built-in list of convenient "filters" for things like gzip compression, XHTML validation, caching, unicode decoding/encoding, authentication, XML-RPC wrapper, etc ... These filters can easily be enabled/disabled through configuration. - New "development" mode which provides things like autoreload (no need to manually restart your server when you make a change), logging of page stats, etc ... - Better handling of file uploads - Internal implementation now uses generators everywhere (no more StringIO) - New built-in HTTP server implementation *** About CherryPy: CherryPy-2 is a pythonic, object-oriented web development framework. Here is a sample Hello, World in CherryPy-2: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() Main properties: - this code starts a multi-threaded HTTP server that dispatches requests to methods - requests like "http://domain/dir/page?arg1=va l1&arg2=val2" are mapped to "dir.page(arg1='val1', arg2='val2')" - CherryPy also supports "RESTful" URLs like http://domain/book/science/9 - requests are mapped to an object tree that is "mounted" on cherrypy.root (for instance: "cherrypy.root.user", "cherrypy.root.user.remi", ...) - method must be explicitly exposed with a decorator "@cherrypy.expose" (or "index.exposed = True" for Python-2.3) Remi. http://www.cherrypy.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Seeking Python + Subversion hosting.
> Anyone know of a good hosting company that offers both server-side > Python and a subversion repository? > > I know of one: www.textdrive.com - they're a bit pricey, but I s'pose > you gets what you pays for - they look good. > > Just FYI - right now I'm with sapphiresoft.co.uk. They're cheap and in > my brief experience have been pretty good at responding to support > issues. They gave me a big 'no' to subversion though. (tip: if you use > these guys, be sure to tell them you want the server with the latest > Python goodies *before* you sign up!) Python-Hosting.com supports Subversion hosting as well. You can also get Trac hosting there if you need it. This is available as part of all the plans and you'll get all the other features included (backups, monitoring, DNS hosting, e-mail hosting, web hosting, DB hosting, ...) This is where http://www.cherrypy.org is hosted for instance. Regards, Remi. -- http://mail.python.org/mailman/listinfo/python-list
Re: Seeking Python + Subversion hosting.
> Anyone know of a good hosting company that offers both server-side > Python and a subversion repository? > > I know of one: www.textdrive.com - they're a bit pricey, but I s'pose > you gets what you pays for - they look good. > > Just FYI - right now I'm with sapphiresoft.co.uk. They're cheap and in > my brief experience have been pretty good at responding to support > issues. They gave me a big 'no' to subversion though. (tip: if you use > these guys, be sure to tell them you want the server with the latest > Python goodies *before* you sign up!) Python-Hosting.com supports Subversion hosting as well. You can also get Trac hosting there if you need it. This is available as part of all the plans and you'll get all the other features included (backups, monitoring, DNS hosting, e-mail hosting, web hosting, DB hosting, ...) This is where http://www.cherrypy.org is hosted for instance. Regards, Remi. -- http://mail.python.org/mailman/listinfo/python-list
numbering variables
Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-) Any ideas ? Thanks a lot. Rémi. -- http://mail.python.org/mailman/listinfo/python-list
Re: numbering variables
Patrick Useldinger a écrit : remi wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-) Any ideas ? Thanks a lot. Rémi. Use a dictionary: variable['s_1']= mylist.pop(), variable['s_2'] = mylist.pop() ... Ok thanks but is there a way to automate this variable numbering ? Such like : i = 0 for i <=len(mylist) s_i=mylist[i] i = i +1 or as you suggest : i = 0 while i<=len(mylist) variable['s_i']=mylist.pop() i = i+1 Thanks. Rémi. -- http://mail.python.org/mailman/listinfo/python-list
Re: numbering variables
Fredrik Lundh a écrit : "remi" <[EMAIL PROTECTED]> wrote: I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... why? I want to convert a very simple *.tex file into a very simple *.xml file mylist is made by : file_in = open('in.tex','r') file_string = file_in.read() corps = r"""\\begin{document}(?P.*)\\end{document}""" compile_obj = re.compile(corps, re.IGNORECASE| re.DOTALL) match_obj = compile_obj.search(file_string) contents = match_obj.group('contents') sect = r'\\section{(.*)}' motif1 = re.compile(sect) mylist = re.split(motif1,contents) I want to store each item of mylist in a variable (and after "xmlize" it little by little). The lengh of mylist isn't fixed it depends on the *.tex file. Thanks. Rémi. -- http://mail.python.org/mailman/listinfo/python-list
Re: numbering variables
Fredrik Lundh a écrit : "remi" <[EMAIL PROTECTED]> wrote: I want to store each item of mylist in a variable (and after "xmlize" it little by little). why not just process the items in the list? That's right. for item in mylist: print tex2xml(item) where tex2xml() is the main converting function i guess. So i should change "print tex2xml(item)" to a kind of "output.write(tex2xml(item))". Ok, i try this too but i think it will lead to a "line by line" processing of the file... I try. Thanks. Rémi. -- http://mail.python.org/mailman/listinfo/python-list
Re: numbering variables
Fredrik Lundh a écrit : variable['s_i']=mylist.pop() variable['s_' + str(i)]=mylist.pop() but that while and pop stuff is pretty weird; Why ? Because it destroys the list ? maybe you should read the sections on lists, for loops, and string formatting in the Python tutorial? here's a shorter way to create that dictionary: variable = {} for item in mylist: variable["s_%d" % len(variable)] = item maybe a dictionnary is more easely usable and reusable than a list... Thanks a lot for your help. and here's the obligatory one-liner: variable = dict(("s_" + str(k), v) for k, v in enumerate(mylist)) (shorter, but not exactly clearer, especially not if you're new to Python) As a beginner, I agree at 100% even if the latter is nicer ! Rémi. I send to people form clp a little sun from Toulouse (France) -- http://mail.python.org/mailman/listinfo/python-list
Re: (PHP or Python) Developing something like www.tribe.net
> CherryPy and Quixote are for programming in the small May I ask why you say that ? Just because a framework is light and easy doesn't mean it doesn't scale well ... > I have not idea how they scale in the large. Well, I do :-) Among many other sites, CherryPy powers the BackOffice system of a big cinema chain in the UK. The web app gets hammered all day long by hundreds of users whose work is completely dependent on this web app. It has 500 different web forms (everything is data driven) and the code is about 30K lines of python/cherrypy code (if the code wasn't data-driven it would be a *lot* more ...). If it gets accepted, there will be a talk about this system at EuroPython ... Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN (Screencast): Using python at WebFaction
Hello everyone, WebFaction (formerly Python-Hosting.com) have just released a screencast demo of their control panel. The 6 minute demo shows how you can setup some sites in a few clicks, using a variety of applications (including some Python ones such as Django and TurboGears). The one-click installer already supports all major tools, including Rails, WordPress, Django, TurboGears, Plone, Trac and Subversion, but also lightweight tools such as static HTML, CGI or PHP. The demo is available at: http://blog.webfaction.com/control-panel-demo Remi. http://www.webfaction.com - Hosting for an agile web -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python-2.5 available at WebFaction
Hello everyone, I'm happy to announce that WebFaction have now installed Python-2.5 on all their servers. WebFaction (formerly Python-Hosting.com) support all the major Python web frameworks (Django, TurboGears, CherryPy, mod_python, Pylons, web.py, ...) People using Python CGI or Python-2.5-compatible application servers will be able to use all the new features of Python-2.5 for their website. Remi http://www.webfaction.com - Hosting for an agile web -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-2.5 available at WebFaction
Paul McGuire wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hello everyone, > > > > I'm happy to announce that WebFaction have now installed Python-2.5 > > on all their servers. > > > > WebFaction (formerly Python-Hosting.com) support all the > > major Python web frameworks (Django, TurboGears, CherryPy, > > mod_python, Pylons, web.py, ...) > > > > People using Python CGI or Python-2.5-compatible application servers > > will be able to use all the new features of Python-2.5 for their > > website. > > > > Remi > > > > http://www.webfaction.com - Hosting for an agile web > > > > Is this available for all of your hosting plans, including your lowest cost > plan? Python CGI is. Web frameworks that require a long-running process (such as Django, TurboGears, ...) are available on our "Shared 2" plan and above. Remi. -- http://mail.python.org/mailman/listinfo/python-list
Re: python-hosting.com projects: dead?
> > I certainly hope so, but this is what I'm reacting to (from > > http://www.webfaction.com/freetrac): > > > > "We're sorry, we're not longer accepting applications for free trac/svn > > accounts. People have left their Trac sites unattended and as a result > > our server is being flooded with spam. We need to do some serious > > cleanup and when that's done we'll accept new applications again (that > > might take weeks, if not months though). " > > Um, that sounds to me like they're not accepting *new* > projects, not that they're shutting down existing ones. > Unless *my* reading comprehension skills have completely > abandoned me. Your reading comprehension skills are fine :) We're not accepting *new* projects anymore (for now), but we certainly continue to support existing ones. We would never take down the sites without at least a one month warning ... not that we have any plan to do so anyway... We had to do some serious cleanup and we disabled a lot of Trac sites that looked abandoned (people left their Trac sites open to spammers and our server was crawling under the load caused by these spammers). If your site got disabled by mistake just e-mail us and we'll re-enable it within minutes ... Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.2.0beta released
Hi everyone, I am please to announce the first beta release of CP-2.2.0 We've started to collect changes on this page: http://www.cherrypy.org/wiki/WhatsNewIn22 (there's many more items to come). Included in this release are: - Support for multiple applications within one CherryPy process - Lots of bug fixes and improvements (including a more stable session handling) - Switch to lowercase API (instead of camelCase). (old API is still supported but deprecated) Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.0-final released
Hello everyone, I am happy to announce the first stable release of CherryPy-2. CherryPy-2 is a pythonic, object-oriented web development framework. CherryPy-2 is a redesign of CherryPy-1 (the unpythonic features have been removed): no more compilation step, pure python source code (no more "CherryClass"). Here is a sample Hello, World in CherryPy-2: # from cherrypy import cpg # class HelloWorld: # @cpg.expose # def index(self): # return "Hello world!" # cpg.root = HelloWorld() # cpg.server.start() Main properties: - this code starts a multi-threaded HTTP server that dispatches requests to methods - requests like "http://domain/dir/page?arg1=val1&arg2=val2"; are mapped to "dir.page(arg1='val1', arg2='val2')" - CherryPy also supports "positional" arguments in URLs like http://domain/book/science/9 - requests are mapped to an object tree that is "mounted" on cpg.root (for instance: "cpg.root.user", "cpg.root.user.remi", ...) - method must be explicitely exposed with a decorator "@cpg.expose" (or "index.exposed = True" for Python-2.3) - methods can return a generator instead of a string (useful when generating big pages) Here is a non-exhaustive list of CherryPy-2 features: multi-threaded HTTP server, XML-RPC server, sessions, form handling, authentication, unicode support, gzip-compression, virtual hosting, WSGI adapter The design of CherryPy-2 allows to easily write/use pluggable "filters" or "modules": - filters perform operations on the request/response such as gzip-compression or string encoding - modules are web applications (like a blog or a web forum) than can be easily "mounted" anywhere you want in your website CherryPy-2 is already used in production by many sites and is supported by an active community. Remi. http://www.cherrypy.org -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.2.0-rc1 released
Hello everyone, I'm happy to announce that the first release candidate for CherryPy-2.2.0 is now available. This release includes various bugfixes, a new benchmarking tool and improved WSGI support. Check out this great post from Christian Wyglendowski to see how you can run multiple WSGI-CherryPy apps using other tools like wsgutils or Paste (or do the opposite: run a PyBloxsom or MoinMoin WSGI app within CherryPy): http://blog.dowski.com/2006/03/08/cherrypy-and-wsgi-can-play-nice/ Christian has also put together a great screencast showing how to run CherryPy and interact with it directly from the prompt: http://blog.dowski.com/2006/03/05/cherrypy-and-the-interactive-interpreter/ *** About CherryPy: CherryPy is a pythonic, lightweight and straightforward (no dependencies) web development framework. Here is a sample Hello, World in CherryPy: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() Details and downloads for the 2.2.0-rc1 release are available from the CherryPy website: http://www.cherrypy.org Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.2.0-rc1 released
Hello everyone, After six months of hard work and 300 changesets since the last stable release I'm happy to announce that CherryPy-2.2.0-final is out. The biggest changes are: - switch to a lowercase api (although the old camelCase API is still supported for backward compatibility) - support for multiple applications (new "cherrypy.tree" object) - better error handling - lots of bug fixes (especially in file-based sessions) - better test suite. Check out http://www.cherrypy.org/wiki/UpgradeTo2.2 for more details. *** About CherryPy: CherryPy is a simple (no dependencies), pythonic (doesn't get in your way) web development framework. Here is a sample Hello, World in CherryPy: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() The project has been growing strongly lately: cherrypy.org averaged 3000 visitors/day in March, up from 2000 visitors/day in January and February; and the cherrypy-users list just passed 700 users. Details and downloads are available from: http://www.cherrypy.org Remi. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: CherryPy-2.2.0 released
Oops ... The title should have been "CherryPy-2.2.0 released", not "CherryPy-2.2.0-rc1" ... [EMAIL PROTECTED] wrote: > Hello everyone, > > After six months of hard work and 300 changesets since the last stable > release I'm happy to announce that CherryPy-2.2.0-final is out. > > The biggest changes are: > > - switch to a lowercase api (although the old camelCase API is still > supported for backward compatibility) > > - support for multiple applications (new "cherrypy.tree" object) > > - better error handling > > - lots of bug fixes (especially in file-based sessions) > > - better test suite. > > Check out http://www.cherrypy.org/wiki/UpgradeTo2.2 for more details. > > *** > About CherryPy: > > CherryPy is a simple (no dependencies), pythonic (doesn't > get in your way) web development framework. > > Here is a sample Hello, World in CherryPy: > > # import cherrypy > # class HelloWorld: > # @cherrypy.expose > # def index(self): > # yield "" > # yield "Hello world!" > # yield "" > # cherrypy.root = HelloWorld() > # cherrypy.server.start() > > The project has been growing strongly lately: > cherrypy.org averaged 3000 visitors/day in March, > up from 2000 visitors/day in January and February; > and the cherrypy-users list just passed 700 users. > > > Details and downloads are available from: > > http://www.cherrypy.org > > > Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.2.0 released
(sorry for the double-post, the title of the previous one was wrong) Hello everyone, After six months of hard work and 300 changesets since the last stable release I'm happy to announce that CherryPy-2.2.0-final is out. The biggest changes are: - switch to a lowercase api (although the old camelCase API is still supported for backward compatibility) - support for multiple applications (new "cherrypy.tree" object) - better error handling - lots of bug fixes (especially in file-based sessions) - better test suite. Check out http://www.cherrypy.org/wiki/UpgradeTo2.2 for more details. *** About CherryPy: CherryPy is a simple (no dependencies), pythonic (doesn't get in your way) web development framework. Here is a sample Hello, World in CherryPy: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() The project has been growing strongly lately: cherrypy.org averaged 3000 visitors/day in March, up from 2000 visitors/day in January and February; and the cherrypy-users list just passed 700 users. Details and downloads are available from: http://www.cherrypy.org Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: CherryPy-2.2.0 released
(sorry for the double-post, the title of the previous one was wrong) Hello everyone, After six months of hard work and 300 changesets since the last stable release I'm happy to announce that CherryPy-2.2.0-final is out. The biggest changes are: - switch to a lowercase api (although the old camelCase API is still supported for backward compatibility) - support for multiple applications (new "cherrypy.tree" object) - better error handling - lots of bug fixes (especially in file-based sessions) - better test suite. Check out http://www.cherrypy.org/wiki/UpgradeTo2.2 for more details. *** About CherryPy: CherryPy is a simple (no dependencies), pythonic (doesn't get in your way) web development framework. Here is a sample Hello, World in CherryPy: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield "" # yield "Hello world!" # yield "" # cherrypy.root = HelloWorld() # cherrypy.server.start() The project has been growing strongly lately: cherrypy.org averaged 3000 visitors/day in March, up from 2000 visitors/day in January and February; and the cherrypy-users list just passed 700 users. Details and downloads are available from: http://www.cherrypy.org Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: Free Trac/Subversion hosting at Python-Hosting.com
Hello everyone, To celebrate its second anniversary, Python-Hosting.com is happy to announce that it is now offering free Trac/Subversion hosting. This offer is limited to open-source, python projects. Trac and Subversion make a great combination for project management. More information about Trac can be found here: http://www.edgewall.com/trac The free offer includes: - Your own Trac site with HTTP and HTTPS access - Your own Subversion repository with HTTP and HTTPS access - Access to trac-admin through a web interface - Access to Trac and Subversion user configuration through a web interface - Web usage statistics of your Trac site - Nightly backups of your data to external servers If you want to know more about this offer and find out how to sign up, check out the following page: http://www.python-hosting.com/freetrac Remi. -- http://mail.python.org/mailman/listinfo/python-list
Re: Loop until condition is true
Fredrik Lundh wrote: >>while True: >> some(code) >> if final_condition is True: >> break >> # >># > checking if a logical expression is true by comparing it to True is bad > style, and comparing values using "is" is also bad style. Erm... You totally missed the point. I wrote it this way because, first, it's perfectly valid Python code and, second and most important, it's also a valid english sentence. [CENSORED] I keep for myself how stupid I found your post. > the correct way to write that if-statement is: Don't try to teach your grandfather how to suck eggs. There is no "correct way" to code and "superfluous" isn't a synonym of "incorrect". > and yes, the "infinite" while loop is a standard Python pattern. get > used to it. Grandfathers and eggs. Now, excuse me but I have a group of savage AI written in bad style Python to tame. -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: Polling, Fifos, and Linux
Jeremy Moles wrote: > This is my first time working with some of the more lower-level python > "stuff." I was wondering if someone could tell me what I'm doing wrong > with my simple test here? > > Basically, what I need is an easy way for application in userspace to > simply echo values "down" to this fifo similar to the way proc files are > used. Is my understanding of fifo's and their capabilities just totally > off base? Funny coincidence... I was also trying some FIFO stuff today. I came to a very simple solution for just one writer and one listener. I make this stuff send text (strings) from one Konsole to another Konsole. The FIFO was created from Bash with: $ mkfifo -m 666 fifo listener.py -- #! /usr/bin/env python fifo = open("fifo","r") while True: print fifo.readline()[:-1] # [:-1] because of the newline added by print. # -- writer.py -- #! /usr/bin/env python fifo = open("fifo", "a")# Mode "a" or "w" try: fifo.write("This string goes down the pipe.\n") # Newline is important because the listener uses readline(). fifo.flush() # Output is buffered. except IOError: pass # -- If you kill the writer, the listener remains quiet until somebody writes into the pipe. The same happens if there is no writer. If you kill the listener, the writer reports a broken pipe when it tries to flush(). The writer can close and open the pipe to its liking, the listener doesn't care. The only problem is that the writer freezes when it opens the pipe until there is a listener at the other end. Any way, it's very simple and it uses 0% of the CPU. Just my 2 Euro cents, -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: [CherryPy]Serve dynamic binary file in cherrypy?
"mep" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Hi, > After lookup in cherrypy site and google for a while, I haven't > found any information about cherrypy how to serve dynamic binary > file(some generated charts).Is there any easy way to do this? > In cherrypy 2.0 & python 2.4 Yes, there is an easy way: have your handler method return the binary data, and set the Content-Type before returning the data, like this: # class Root: # def index(self): # ... Generate binary data in "data" ... # cpg.response.headerMap['Content-Type'] = 'image/gif' # return data Remi. -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python-2.4 available at Python-Hosting.com
Hello everyone, I'm happy to announce that Python-2.4 is already available on all of our servers. People using Python CGI or Python-2.4-compatible application servers will be able to use all the new features of Python-2.4 for their website. We've only installed a few third-party modules for it so far, but we'll install more as they become available and as people need them. About Python-Hosting.com: Python-Hosting.com is a hosting provider specialized in Python. Supported software includes Zope, Plone, Quixote, CherryPy, Webware, SkunkWeb, Twisted, Spyce, mod_python and others (in fact, pretty much everything you want that runs on Python). Remi PS: Python-Hosting.com will be 2 years old in a few weeks :-) -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python-2.4 available at Python-Hosting.com
Hello everyone, I'm happy to announce that Python-2.4 is already available on all of our servers. People using Python CGI or Python-2.4-compatible application servers will be able to use all the new features of Python-2.4 for their website. We've only installed a few third-party modules for it so far, but we'll install more as they become available and as people need them. About Python-Hosting.com: Python-Hosting.com is a hosting provider specialized in Python. Supported software includes Zope, Plone, Quixote, CherryPy, Webware, SkunkWeb, Twisted, Spyce, mod_python and others (in fact, pretty much everything you want that runs on Python). Remi PS: Python-Hosting.com will be 2 years old in a few weeks :-) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: python coding contest
André Malo wrote: >>is two lines and 347 characters ugly enough to win? > Nope. 3 lines / 179 chars here >:-> > Yes, it's quite unreadable. I'm in for the second place with 4 lines / 228 chars. > (The problem is that I need to find an internet cafe on 28/29th in order to > be able to submit) Do your best! I'd really like to see your code. Right now, 179 chars doesn't seem enough for me to write a "Hello world". ;-) -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: python coding contest
rbt wrote: > Does positioning matter? For example, say I give it '123' is it ok to > output this: > > 1 > 2 > 3 > > Or does it have to be 123 Download the test suite and you'll see that only 123 on one line passes the test. Sorry... -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: python coding contest
Tim Hochberg wrote: >> I am currently at 39 bytes following the requirements and the >> principle given above (my module passes the test). Anyone able to beat >> that? > Wow! It'll be interesting to see how to do that. The obvious way gives > 53 bytes. Hmmm, I'll have to see what can be done... 39 bytes... 53 bytes... It gives me the impression to follow a jet plane with a bike with my 179 bytes! There isn't a single superfluous byte. My code is so compressed that the syntactic colorizer can't cope any more. I definitively need a new algorythm. -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: python coding contest
Scott David Daniels wrote: [--CUT---] >> 39 bytes... 53 bytes... It gives me the impression to follow a jet >> plane with a bike with my 179 bytes! [--CUT--] > And I am sadly stuck at 169. Not even spitting distance from 149 (which > sounds like a non-cheat version). Try harder! ;-) I thought I was stuck at 179 but with a strict diet, I managed to loose some bones :-D and get down to a one-liner of 153 bytes. No cheating with import but it's so ugly that I'm not sure I will understand my own code next month. And this time I'm sure at 99% that I'm really stuck... -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: python coding contest
Christian Tismer wrote: >>> I feel that python is more beautiful and readable, even if you write >>> short programs. > Looking at what I produced the last days, I'm not convinced... Me neither. Especially since I've taken the one-liner road. Python can be very unreadable... sometimes. > And that's what puzzled me a bit about the approach and the intent > of this contest: Should this evolute into a language war about > goals (shortness, conciseness, brevity, whatnot) that Python > doesn't have as its main targets? Maybe to prove to the others that Python is a "real" language that can produce "uglinesses" too? > Sure, I see myself hacking this unfortunate little 7-seg code > until it becomes unreadable for me, the trap worked for me, > but why do I do this??? For the pleasure of twisting your mind in every possible way, for the challenge, for the luxury price if you win? Whatever... I'm trapped too and I can't give any reason off the top of my head. [---CUT---] > I think it is legal to use any standard pre-installed package you > like, if it belongs to the set of default batteries included. [---CUT---] If you use more than the built-ins, you've already lost. It costs you at least 9 bytes, well, 10 since I don't know any module with a single-letter name. "\t"+"import"+" "+name_of_module+"\n" And knowing how much I struggled to remove the last 10 bytes I removed from my code, the idea doesn't sound very attractive. > After all, I'd really love to set up another contest with > different measures and criteria. Go on! I don't think that "shortest code" is a very pythonic goal if you count in bytes. The same contest with the length of the code measured in "pythonic units" would be better. When I say "pythonic unit", I mean to count 1 unit for each variable, literal, operator or key-word. That would be more pythonic. ...but maybe less challenging. To try to do with Python things it wasn't meant to do is more "fun" for a contest. ;-) -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong in this HTML Source file of a Bank
[EMAIL PROTECTED] wrote: > Several times I logged-in successfully but after log-in I can't use > features/services which were shown prior to my login. Can anyone exoert > from this forum check , is it technical fault of Bank Web Site or this > problem pertaining to the user(me). This is definitively not the right newsgroup for HTML issues. Go to: http://validator.w3.org/ And I'm already too nice... -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is fun (useless social thread) ;-)
John Salerno wrote: [---CUT---] > So out of curiosity, I'm just wondering how everyone else came to learn > it. [---CUT---] I just needed it. I needed it to recode text files from my old Atari computer for my Linux box. I had already seen Python sources during some googling sessions and found them mostly understandable. I also knew it was already installed so I decided to give it a try. One night was all I needed to write my "recoder" with nothing more to help me than the (cryptic) included docs and the examples. Yes, 8 hours and I had learned arguments passing, files operations, strings manipulations and even module import with no prior knowledge. I fell in love with Python. I still have the source, it's very basic Python and I definitively could have used a dictionary... but it worked. From that moment, Python became my script language. Whenever I need to write more than 2 lines in Bash, I use Python. I learned the classes to play with some (rudimentary) artificial intelligence. I even took part in a contest where I learned 'lambda' and the generators. The only thing I haven't taken much care about is GUI in Python. For that, I learned C++... ;-) Any way, Python even helps me sometimes to write C++ since I use it to test my algorithms when it comes to data manipulation. I can feed my routines on the fly with whatever data I want to see how they react. So I use Python as a debugger before to even start writing things in C++. No need to compile or debug in Python. When something goes wrong: CTRL+C, correct and restart. Python is fun because it's easy to write, to understand and to use. -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Loop until condition is true
Hi there, There is always a "nice" way to do things in Python but this time I can't find one. What I'm trying to achieve is a conditionnal loop of which the condition test would be done at the end so the loop is executed at least once. It's some way the opposite of "while". So far, all I got is: while True: some(code) if final_condition is True: break # # What I don't find so "nice" is to have to build an infinite loop only to break it. Is there a better recipe? -- == Remi Villatel [EMAIL PROTECTED] == -- http://mail.python.org/mailman/listinfo/python-list
Re: Build unordered list in HTML from a python list
> Dear list members > > I have this python list that represets a sitemap: > > tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, > {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, > {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, > {'indent': 2, 'title':'Sub Item 1.1', 'hassubfolder':False}, > {'indent': 2, 'title':'Sub Item 1.2', 'hassubfolder':False}, > {'indent': 1, 'title':'Item 3', 'hassubfolder':False}, > {'indent': 1, 'title':'Folder 2', 'hassubfolder':True}, > {'indent': 2, 'title':'Sub Item 2.1', 'hassubfolder':False}, > {'indent': 2, 'title':'Folder 2.1', 'hassubfolder':True}, > {'indent': 3, 'title':'Sub Item 2.1.1', 'hassubfolder':False}, > {'indent': 3, 'title':'Sub Item 2.1.2', 'hassubfolder':False}, > > If an item of the list has 'True' for the 'hassubfolder' key than a new > "" must be created instead of "" after its title. (See > "Folder 2" node in the HTML code above. Or you can change your list to a dict with a tree structure and use recursion instead of a stack: tree = [ { 'title': 'Item 1', 'children': [] }, { 'title': 'Item 2', 'children': [] }, { 'title': 'Folder 1', 'children': [ { 'title': 'sub item 1.1', 'children' : [], }, { 'title': 'Folder 1.1', 'children' : [ .. ], }, ] }, ] and something like: def displayListItem(i): print '%s' % i['title'] if i['children']: print '' for c in i['children']: displayListItem(c) print '' print you might also use recursion with your existing list, by 'pop'ing the first item and passing the rest of the list. Remi -- http://mail.python.org/mailman/listinfo/python-list