Wing IDE 3.2.2 released
Hi, Wingware has released version 3.2.2 of Wing IDE, our integrated development environment for the Python programming language. This bug fix release includes the following: * Added Toggle Bookmark for unnamed bookmarks, visual indicator of bookmarks, and bookmark traversal menu in editor * Improved syntax highlighting for Mako templates (*.mako) * Show number of replacements for Replace All operations * Several performance improvements for large projects and for editor responsiveness * Added toolbar to OS Commands tool and option to auto-save before executing a command * Fix for hanging up the editor on certain Python files * Several other bug fixes and minor features. See the change log for details: http://wingware.com/pub/wingide/3.2.2/CHANGELOG.txt *Wing 3.2 Highlights* Version 3.2 of Wing IDE includes the following new features not present in Wing IDE 3.1: * Support for Python 3.0 and 3.1 * Rewritten version control integration with support for Subversion, CVS, Bazaar, git, Mercurial, and Perforce (*) * Added 64-bit Debian, RPM, and tar file installers for Linux * File management in Project view (**) * Auto-completion in the editor obtains completion data from live runtime when the debugger is active (**) * Perspectives: Create and save named GUI layouts and optionally automatically transition when debugging is started (*) * Improved support for Cython and Pyrex (*.pyx files) * Added key binding documentation to the manual * Added Restart Debugging item in Debug menu and tool bar (**) * Improved OS Commands and Bookmarks tools (*) (*)'d items are available in Wing IDE Professional only. (**)'d items are available in Wing IDE Personal and Professional only. The release also contains many other minor features and bug fixes; see the change log for details: http://wingware.com/pub/wingide/3.2.2/CHANGELOG.txt *Downloads* Wing IDE Professional and Wing IDE Personal are commercial software and require a license to run. A free trial license can be obtained directly from the product when launched. Wing IDE 101 can be used free of charge. Wing IDE Pro 3.2.2http://wingware.com/downloads/wingide/3.2 Wing IDE Personal 3.2.2 http://wingware.com/downloads/wingide-personal/3.2 Wing IDE 101 3.2.2http://wingware.com/downloads/wingide-101/3.2 *About Wing IDE* Wing IDE is an integrated development environment for the Python programming language. It provides powerful debugging, editing, code intelligence, testing, version control, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free simplified version designed for teaching entry level programming courses with Python. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Wing IDE 3.2 supports Python versions 2.0.x through 3.1.x. *Purchasing and Upgrading* Wing 3.2 is a free upgrade for all Wing IDE 3.0 and 3.1 users. Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. Upgrade a 2.x license: https://wingware.com/store/upgrade Purchase a 3.x license:https://wingware.com/store/purchase -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Bazaar 2.0.1 and 2.1.0b1 released
Our first post-2.0 releases of Bazaar have finally become official. Now that we are at 2.0, we decided to split a stable releases series and a development series. As such, 2.0.1 has only bugfixes relative to the 2.0 release, while new features and potential compatibility changes are contained only within 2.1.0b1. All of the changes in 2.0.1 are available in 2.1.0b1. Thanks to everyone who has helped polish the 2.0.1 release, and ensure that our next 2.1 stable release will have lots of interesting changes to come. To get your own copy, please visit http://bazaar-vcs.org/Download. Packages for many popular platforms are available. The short summaries of changes are: bzr 2.0.1 # :Codename: Stability First :2.0.1: 2009-10-14 The first of our new ongoing bugfix-only stable releases has arrived. It includes a collection of 12 bugfixes applied to bzr 2.0.0, but does not include any of the feature development in the 2.1.0 series. bzr 2.1.0b1 ### :Codename: While the cat is away :2.1.0b1: 2009-10-14 This is the first development release in the new split stable and development series. As such, the release is a snapshot of bzr.dev without creating a release candidate first. This release includes a fair amount of internal changes, with deprecated code being removed, and several new feature developments. People looking for a stable code base with only bugfixes should focus on the 2.0.1 release. All bugfixes present in 2.0.1 are present in 2.1.0b1. Highlights include support for ``bzr+ssh://host/~/homedir`` style urls, finer control over the plugin search path via extended BZR_PLUGIN_PATH syntax, visible warnings when extension modules fail to load, and improved error handling during unlocking. John =:- This is the full NEWS entry about all bugs/features fixed and released relative to 2.0.0: bzr 2.1.0b1 ### :Codename: While the cat is away :2.1.0b1: 2009-10-14 This is the first development release in the new split stable and development series. As such, the release is a snapshot of bzr.dev without creating a release candidate first. This release includes a fair amount of internal changes, with deprecated code being removed, and several new feature developments. People looking for a stable code base with only bugfixes should focus on the 2.0.1 release. All bugfixes present in 2.0.1 are present in 2.1.0b1. Highlights include support for ``bzr+ssh://host/~/homedir`` style urls, finer control over the plugin search path via extended BZR_PLUGIN_PATH syntax, visible warnings when extension modules fail to load, and improved error handling during unlocking. New Features * Bazaar can now send mail through Apple OS X Mail.app. (Brian de Alwis) * ``bzr+ssh`` and ``bzr`` paths can now be relative to home directories specified in the URL. Paths starting with a path segment of ``~`` are relative to the home directory of the user running the server, and paths starting with ``~user`` are relative to the home directory of the named user. For example, for a user bob with a home directory of ``/home/bob``, these URLs are all equivalent: * ``bzr+ssh://b...@host/~/repo`` * ``bzr+ssh://b...@host/~bob/repo`` * ``bzr+ssh://b...@host/home/bob/repo`` If ``bzr serve`` was invoked with a ``--directory`` argument, then no home directories outside that directory will be accessible via this method. This is a feature of ``bzr serve``, so pre-2.1 clients will automatically benefit from this feature when ``bzr`` on the server is upgraded. (Andrew Bennetts, #109143) * Extensions can now be compiled if either Cython or Pyrex is available. Currently Pyrex is preferred, but that may change in the future. (Arkanes) * Give more control on BZR_PLUGIN_PATH by providing a way to refer to or disable the user, site and core plugin directories. (Vincent Ladeuil, #412930, #316192, #145612) Bug Fixes * * Bazaar's native protocol code now correctly handles EINTR, which most noticeably occurs if you break in to the debugger while connected to a bzr+ssh server. You can now can continue from the debugger (by typing 'c') and the process continues. However, note that pressing C-\ in the shell may still kill the SSH process, which is bug 162509, so you must sent a signal to the bzr process specifically, for example by typing ``kill -QUIT PID`` in another shell. (Martin Pool, #341535) * ``bzr add`` in a tree that has files with ``\r`` or ``\n`` in the filename will issue a warning and skip over those files. (Robert Collins, #3918) * ``bzr dpush`` now aborts if uncommitted changes (including pending merges) are present in the working tree. The configuration option ``dpush_strict`` can be used to set the default for this behavior. (Vincent Ladeuil, #438158) * ``bzr merge`` and ``bzr remove-tree`` now requires --force if pending merges are present in the working tree. (Vincent Ladeuil, #426344) * Clearer message when Bazaar runs
CodeInvestigator 0.18.0
CodeInvestigator 0.18.0 was released on October 29. It mainly deals with bug fixes: - Simple statements all on the one line separated by a semicolon. - Generators and yield. It has one enhancement: - An Entry Point filter was added. It allows you the leave out the entry points you're not interested in. You need Python 2.6 and Firefox for CodeInvestigator. CodeInvestigator is a tracing tool for Python programs. Running a program through CodeInvestigator creates a recording. Program flow, function calls, variable values and conditions are all stored for every line the program executes. The recording is then viewed with an interface consisting of the code. The code can be clicked: A clicked variable displays its value, a clicked loop displays its iterations. You read code, and have at your disposal all the run time details of that code. A computerized desk check tool and another way to learn about your program. http://sourceforge.net/project/showfiles.php?group_id=183942 -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Bug(s) in Python 3.1.1 Windows installation
En Wed, 28 Oct 2009 21:06:03 -0300, Alf P. Steinbach al...@start.no escribió: The installer did manage to do the rest of that part correctly: file associations and PATHEXT variable. The Python installer from python.org does NOT add .py and .pyw to PATHEXT; the ActivePython one does. (3) Tkinter not bundled, misleading incomplete documentation. However, running Tkinter based programs does *not* work: import Tkinter I suggest you read the documentation for the Python version you're using, not any other at random... http://docs.python.org/3.1/library/tkinter.html#a-simple-hello-world-program clearly says tkinter instead of Tkinter Checking I find that while there is a Tkinter folder there is no file [Tkinter.py] in this installation, i.e. the Tkinter module is not bundled with this distribution. Read in the tutorial the section about packages. tkinter is a package, not a module. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Copying a ZipExtFile
On Oct 28, 8:33 pm, ryles ryle...@gmail.com wrote: As for why the bytesToRead calculation in ZipExtFile.read() results in a long, I've not yet looked at it closely. Simple, actually: In ZipExtFile.__init__(): self.bytes_read = 0L In ZipExitFile.read(): bytesToRead = self.compress_size - self.bytes_read 13 - 0L == 13L -- http://mail.python.org/mailman/listinfo/python-list
Python newbie data structures question
Hi all! I am trying to choose the right data structure to do a value lookup with multiple keys. I want to lookup data by: key, key,{ values } My final product should be able to reference this datastructure from within a django template. Because my lookup needs only 80 values and will never change, it seems that I could just build some type of data structure or object. My rudamentary approach is to do lots of looping, but there must be a better way to do this. A dictionary object only has (key, value). The same pair of keys could return multiple values. Tuples might work, but I just don't understand them enough. the simple exampe is a quick lookup index the available sport by season that returns one or many value. The values would be data structures and contain more than just the name, but also things like uniform color, team size. indoors outdoors --- winter | bball | skiing | | | sledding | |-- | | baseball | summer| raquetball | soccer| | | | | |-- Advice? What data structure should I use? And a simple newbie example please.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug(s) in Python 3.1.1 Windows installation
* Gabriel Genellina: En Wed, 28 Oct 2009 21:06:03 -0300, Alf P. Steinbach al...@start.no escribió: The installer did manage to do the rest of that part correctly: file associations and PATHEXT variable. The Python installer from python.org does NOT add .py and .pyw to PATHEXT; the ActivePython one does. That's possible. Or possibly it's a bug in Windows Explorer, caching the registry entry; I discovered after writing the above that the change was not in the registry entry itself but only in the environments of new processes, no matter how started. It's difficult to say what the causes are, this program or that, when two programs that both demonstrably have some bugs interact. ;-) (3) Tkinter not bundled, misleading incomplete documentation. However, running Tkinter based programs does *not* work: import Tkinter I suggest you read the documentation for the Python version you're using, not any other at random... http://docs.python.org/3.1/library/tkinter.html#a-simple-hello-world-program clearly says tkinter instead of Tkinter Checking I find that while there is a Tkinter folder there is no file [Tkinter.py] in this installation, i.e. the Tkinter module is not bundled with this distribution. Read in the tutorial the section about packages. tkinter is a package, not a module. Thanks for trying to help. But this has already been discussed else/up-thread. Anyways, the main problem with the installation is that it fails when asked to compile (it seems to be a double bug: that some of the source code files to compile have syntax errors, and that the installation program isn't smart enough to go on with things after that), and the main problem with using Tkinter is the name change, with the documentation that one would use (referenced from the main 3.1.1 documentation which only provides a little kick-off starter intro) still using the old name and with, of course, no hint about version dependence. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie advice
CSharpner csharp...@gmail.com wrote: Here's what I /want/ to do, but don't know where to begin: Welcome to the fun :) - Write web services in Python (I've done plenty of this in .NET, BTW). I'm a big fan of CherryPy: http://www.cherrypy.org/ It's very straightforward and easy to get into. - Write plain DLLs (is that even an option in Python (I told you I was a newb to Python, didn't I? :)) I'd recommend Cython: http://www.cython.org/ It allows you to write dlls in (a subset of) Python that are converted to and compiled in C. - Write a web app (HTML front end, Python web services called from JavaScript). - Write a plain old web app with Python (no web services or Ajax, just plain HTML Python). Again, CherryPy, or depending on your needs one of the many, many web frameworks; I'm partial to Turbogears, but Django seems to be the most popular. For a good overview of what's out there: http://wiki.python.org/moin/WebFrameworks - Is it possible to create a Windows client desktop GUI app with Python? How? How 'bout a Linux GUI app? Python includes a wrapper around Tcl/Tk, which many consider to be kinda ugly by modern standards, but is cross platform and part of the stdlib (it's not always included with *nix distros by default but then it's a lot easier to make that happen during install under most package managers). PyQT, PyGtk and wxPython all have their active proponents. There are plenty of GUI libs out there: http://wiki.python.org/moin/GuiProgramming However, if you're already comfortable with HTML/CSS, I'd recommend taking a look at Pyjamas, which started as a port of the Google Web Toolkit, taking Python code and compiling it into javascript. The associated project, Pyjamas-Desktop, is a webkit-based desktop client/ widget set; so ideally you only have to write one UI and it'll run both on the web the desktop. Pyjamas: http://pyjs.org/ Pyjamas-Desktop: http://pyjd.sourceforge.net/ And finally, I'm not completely committed to using Windows to host my development either. I'm willing to use Linux too (but would prefer Windows... at least to get started, until I'm comfortable enough with Python). Google App Engine allows you to host our app on Google servers, with a very generous free quota: http://code.google.com/appengine/ It supports Django and several other of the web frameworks. It's worth noting that it uses the non-relational BigTable at the backend, which seems to cause a lot of grief to relationally-trained minds :) Hopefully something in here is enlightening :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python newbie data structures question
On Oct 29, 4:31 pm, codingJoe tracy.monte...@gmail.com wrote: I am trying to choose the right data structure to do a value lookup with multiple keys. Hey Joe, Is something like this what you're after? from collections import defaultdict sports = defaultdict(list) sports['winter','indoors'].append('bball') sports['winter','outdoors'].append('skiing') sports['winter','outdoors'].append('sledding') sports['summer','indoors'].append('raquetball') sports['summer','outdoors'].append('baseball') sports['winter','outdoors'] ['skiing', 'sledding'] sports['outdoors','winter'] # note that the order of the items is important [] (defaultdict is available in Python 2.5+) Tuples are immutable (unmodifiable) objects, which allows you to use them as dictionary keys. They're really not scary at all ;) Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem embedding Python.
On Oct 27, 7:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 27 Oct 2009 06:36:18 -0300, Brandon Keown keown.bran...@gmail.com escribió: On Oct 27, 2:47 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: You didn't test for the fopen result; are you sure test.py exists in the current directory at the time you run it? Ok, so I assumed that the file, if supplied without a path, would use current working directory, which was evidently a false assumption. Now that you've solved your problem, revise your conclusion. A file without a path *is* searched in the current working directory - but that directory may not be the one you think it is. -- Gabriel Genellina I'm not sure what you mean. I executed the program from the directory the file was in, they were in the same directory. And when a program executes from a path in CMD in windows, that is supposed to be the CWD. I'm not sure what it would be set to if not that... -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
I think you're misunderstanding how Python and the web work together. Python is not PHP -- it was not designed to replace HTML, and it is in itself not a templating language. If you would like to use Python code embedded in HTML, the way PHP is typically used, you may want to look at Python Server Pages (http://www.modpython.org/live/current/doc-html/pyapi-psp.html) which are provided by mod_python. I see, thank you! This is what has been bothering and confusing me. I started with HTML and added PHP later, and the PHP fit in nicely embedded in the HTML, and even though it's now HTML embedded in PHP the principals are the same. Python doesn't seem to work that way, and I have been having a hard time wrapping my head around just why. Just so you know (as I think this is what is causing much of the misunderstanding here), most Python web frameworks *do not* subscribe to the traditional model of the web, where URLs represent files on a server. (In the case of PHP, Python Server Pages, or CGI scripts, these are augmented files which are executed by the server, but it's the same concept). Instead, they typically map URLs to arbitrary code. I don't think that I like that idea. I will give it a fair chance, though, now that it problem has been identified. Thank you very much for helping me understand this important distinction. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
2009/10/29 Albert Hopkins mar...@letterboxes.org: On Wed, 2009-10-28 at 16:38 +0200, Dotan Cohen wrote: return HttpResponse(unmaintanable_html % data) That's fine for single variables, but if I need to output a table of unknown rows? I assume that return means the end of the script. Therefore I should shove the whole table into a variable and then copy that variable to the array data? No, if you use a templating system like Django's then basically you pass a QuerySet to your template. A QuerySet is basically a pointer to a SQL query, for example. The templating system just knows to expect an iterable, it can be a list of rows or it can be a QuerySet which does a fetch from a database. No need to shove an entire table into a variable. Sounds like the system is trying to outsmart the programmer here. Another advantage if templates for many is that it allows programmers to do what they do best (write code) while letting web designers do what they do best (designing web pages) without them walking over each other (that much). I do see that advantage. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list
Re: problems on installing PyGTK in Windows XP
Hi Yang, Did you modify the path environment variable to point to your gtk lib? This might be the problem. Below the steps, that I followed. General instructions are under http://www.pygtk.org/downloads.html In detail: Install the GTK+ bundle * Download the bundle http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.16/gtk+-bundle_2.16.6-20091013_win32.zip * unpack it and copy the directory for example to C:\ * Now append C:\gtk+-bundle_2.16.6-20091013_win32\bin to the path environment variable of windows You can change it under: My_Computer-Properties-Advanced-Environment_Variables-System_Variables-Path Test it: Open a new cmd window and type gtk-demo A window should pop up. if not your installation failed Now install PyCairo, PyGObject and PyGTK (please select the binary corresponding to your python version) The links are currently: * http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.4/ * http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.14/ * http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.12/ bye N Yang wrote: Python 2.6.3 is installed on my Windows XP throught the binary file provided by Python.org. Then I followed the steps described here: http://faq.pygtk.org/index.py?req=showfile=faq21.001.htp to install PyGTK. However, I still get the following error: import pygtk pygtk.require('2.0') import gtk Traceback (most recent call last): File stdin, line 1, in module File C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py, line 48, in mod ule from gtk import _gtk ImportError: DLL load failed: The specified module could not be found. I googled this problem and noticed that there are quite a few people having the same problem. But I am unable to find anything which helps me solve this problem. Could you please give me some suggestions? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie advice
CSharpner schrieb: Alright, I'm not new to programming, but I'm diving in head first into Python for the first time. I'm running on Windows 7, just installed Eclipse Java EE IDE for Web Developers and installed PyDev in it and installed Python 2.6. I've written my first Hello World program, which simply displays Hello World! in the console output. Here's what I /want/ to do, but don't know where to begin: - Write web services in Python (I've done plenty of this in .NET, BTW). This depends. If by web services you mean generally HTTP-based RPC, such as JSON or XMLRPC - yes. If you talk about offering a SOAP-server, then Python is rather painful in that respect. Which partially is his (or his 3rd-party-libs) fault, but IMHO mostly because that whole standard is as crappy as it can get, and my personal experience told me to not expect interoperability from it anyway. - Write plain DLLs (is that even an option in Python (I told you I was a newb to Python, didn't I? :)) There is elmer: http://elmer.sourceforge.net/ And you can create COM servers with win32-extensions, and AFAIK IronPython allows you to create something like DLLs also. - Write a web app (HTML front end, Python web services called from JavaScript). Plenty of options here, popular choices of frameworks include Django, TurboGears 1 2, Pylons, werkzeug, web.py and some more. - Write a plain old web app with Python (no web services or Ajax, just plain HTML Python). See above, just don't use AJAX - Is it possible to create a Windows client desktop GUI app with Python? How? How 'bout a Linux GUI app? Both, with various toolkits such as Tk, Wx, Qt, GTK. I don't know how to create and write a Python project with Eclipse to tell it to be a web service or a web app, or if what I need to do in the code to make as such, no run it from Eclipse to launch the app in a web server and launch a browser automatically. Can I debug after doing this? In other words, can I put break points in my web services or web apps and go back into the IDE to step through the code for web services and web apps? First of all: in python, you don't code like in VisualStudio, with an application template wizard. You simply start coding. Some of the frameworks such as TurboGears and Django actually do have such wizards, but they aren't integrated into the IDE, and once you started, you don't automate anything further. And usually, this is a good thing - the wizard-stuff is for languages that need a lot of boilerplate. Python is quite successful in not needing that. Debugging is certainly possible the way you want it, or at least close to that. I personally am satisfied with the built-in debugger, pdb. But PyDev comes with one that's supposed to be quite good as well, and winpdb is also deemed excellent. Also, I'm not tied to Eclipse. I'm totally open to other IDEs as well. SharpDevelop with the Python plugin looks interesting too. And finally, I'm not completely committed to using Windows to host my development either. I'm willing to use Linux too (but would prefer Windows... at least to get started, until I'm comfortable enough with Python). Cross-platform, especially within the web-world, is usually a no-brainer in python. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : Clearly. I was referring to stdout being send to the browser as the http response. s/browser/web server/ - it's the web server that reads your app's stdout and send it (as is or not FWIW) back to the client. As is, in my case. Actually, what use case is there for having Apache reprocess the HTML output of the script? compression, cache, whatever... And this output to stdout thingie is just the ipc scheme used for CGI - there are other possible interfaces between the application code and the web server. Other possible interfaces between the application code and the web server? Depends on the web server, obviously. With Apache you have things like mod_python, mod_wsgi, or mod_php if you go that route. FWIW, while I would not necessarily advise using mod_python (unless of course you really need deep Apache integration instead of independance from the frontal web server), reading the mod_python's manual might teach you a lot about the processing of a HTTP request and what you can do... I think I mentioned that, but I apologize for being unclear. It's not that it was unclear, but that it's innaccurate. outputting to stdout is an implementation detail, and should not be exposed at the applicative code level. Dealing with appropriate abstraction - here, an HttpResponse object - is far better (well, IMHO of course... - standard disclaimers, YMMV etc). I see. I believe that is called Dotan's Razor: a slight inaccuracy saves a lengthy explanation. but also impacts your mental map of what's going on... You're thinking in terms of streams and stdout, which, while not that far from actual implementation (in the end it always boils down to bits sent over the wires...), might not be the right level of abstraction when it comes to application programming. Sorry, but all I can replace here are the header and footer - if I want to generate a different markup for the content here part, I have to modify your applicative code. I've written web apps that way myself (some 7 years ago), and still have to maintain some web apps written that way, you know... Quite so, I though that is what you wanted. Yes, the HTML is hard-coded into the script. I am learning to abstract and even use object-oriented approaches, though. You can have efficient abstraction and decoupling without resorting to OO. Also, remember that PHP is first a templating language... I google, but cannot find any exapmles of this online. Well, no one in it's own mind would still use CGI (except perhaps for very trivial stuff) when you have way better solutions. What I am doing _is_ trivial. What I saw is already complex enough to justify using better tools IMHO. Or to make better use of the one you have. I understand that your goal is to help me. I am a hard learner: I recognize that you are teaching me the better way, but I need convincing as to why it is better. Bruno said so is good, It isn't. but saves you coding time down the line is a lot more convincing! Well, my POV is obviously biased - I've been doing mostly web programming for 6 or 7 years now, and not as a hobby. When you have several new projects to ship within a short timeline while still maintaining older projects, you really start thinking hard about readability, maintainability, and possible reuse. But wrt/ hard-coded embedded HTML vs templating (even in it's simpler form), it's not a matter of bruno said so - it's a well-known antipattern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : (snip) Yes, I like to separate HTML from code. However, often I need to output something in the middle of the page. How could I do that with a template? Perhaps learning to use some templating system could help ?-) I'd personnaly suggest either Mako (possibly one of the best Python templating systems) or Django's (well documented and beginner-friendly). -- http://mail.python.org/mailman/listinfo/python-list
Win XP: How to hide command window for sub processes?
Hi, I have a Python script which wants to start a subprocess and wait for it to finish. However I would like to have NO command window popping up during execution. My main Python script is started with the .pyw suffix, thus I got rid of the main console and I just see my GUI. So far I tried os.system() and subprocess.call() with os.system() the command window pops up and I see my commands output. with the subprocess.call() and stdin ./ stdout / stderr redirection I manage to get rid of stdout/stderr ( redirecting to the file 'NUL:' ) but the window stays. the subprocess is a call to a .exe file with multiple parameters. I would appreciate any hints bye Klaus -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
As is, in my case. Actually, what use case is there for having Apache reprocess the HTML output of the script? compression, cache, whatever... Thanks. I actually did think of compression. It's not that it was unclear, but that it's innaccurate. outputting to stdout is an implementation detail, and should not be exposed at the applicative code level. Dealing with appropriate abstraction - here, an HttpResponse object - is far better (well, IMHO of course... - standard disclaimers, YMMV etc). I see. I believe that is called Dotan's Razor: a slight inaccuracy saves a lengthy explanation. but also impacts your mental map of what's going on... You're thinking in terms of streams and stdout, which, while not that far from actual implementation (in the end it always boils down to bits sent over the wires...), might not be the right level of abstraction when it comes to application programming. Seeing how the templating engines work, I now know why my choice of words bothered you. In fact, I was thinking in terms of PHP's linear progress through the code which is not quite valid here. Thank you for taking the time to set me straight. What I saw is already complex enough to justify using better tools IMHO. Or to make better use of the one you have. I am beginning to see how true that is. I'd personnaly suggest either Mako (possibly one of the best Python templating systems) or Django's (well documented and beginner-friendly). I will examine them both this weekend. Thanks! -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : What do you mean by in the middle of the page? Do you mean, for instance, the behavior of middle.php in the following PHP example: ?php include_once(beginning.inc.php); include_once(middle.php); include_once(end.inc.php); ? Is that what you are after? Yes, that is what I am after. Django's templating system has an include statement, but also something you don't have in PHP : an extends statement. Yes, template inheritance. This means that you can define the general basic layout for all your site in one base template, and make your other templates just fill the blanks you defined in the base template. FWIW, I'm using Django has an example but quite a few other templating systems have this template inheritance feature one way or another... For instance, if one were to look at the source code of http://dotancohen.com they would see !-- / HEADER --. All the HTML up to that point was output by bigginin.inc.php. Similarly, near the end exists div class=bottomfiller, all the code from there is generated by end.inc.php. These two files are included in every page of the site. And ? Do you really thing we'd all be wasting time using templating systems too dumb to do even such a simple thing ??? Perhaps this might better answer your questions: http://docs.djangoproject.com/en/dev/topics/templates/#id1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
What would be good is if there was a balancing book eg. one specifically targeting ubuntu, which is gaining popularity as we mail. Agreed 100%. I opened this thread as I am learning Python, but my platform is Kubuntu. Of the students in my faculty, about one third have already moved to Ubuntu or some other Linux distribution. Windows-only tutorials just look outdated, even if their principles apply to other OSs as well. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list
Re: Building Python on Solaris 10?
Judy Booth wrote: Can anyone point me towards some instructions for building Python on Solaris 10? We need this for some of our test scripts and so far we cannot get this to build. We have tried both Python 2.6.4 and 3.1.1 and both fail with messages like this: Include/pyport.h:685:2: #error LONG_BIT definition appears wrong for platform (bad gcc/glibc config?). *** Error code 1 make: Fatal error: Command failed for target `Modules/python.o' The configure command used is: ./configure --with-universal-archs=64-bit --enable-universalsdk LDFLAGS=-s -L/usr/local/lib -L/opt/ssl/lib -lgcc --prefix=/opt/python --prefix=${PREFIX} and the compiler version is gcc 3.4.3. Why are you building with --with-universal-archs=64-bit --enable-universalsdk on Solaris ? Those options should only be used for Mac OS X. Python currently does not support building universal binaries on Solaris. If you're still having problems, you might want to look at this patch: http://bugs.python.org/issue1628484 If it works for you, please add a comment. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 29 2009) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try our new mxODBC.Connect Python Database Interface for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Perhaps this might better answer your questions: http://docs.djangoproject.com/en/dev/topics/templates/#id1 Actually, that example just proves my point! Look at this templating code: {% for entry in blog_entries %} h2{{ entry.title }}/h2 p{{ entry.body }}/p {% endfor %} Why would I want to learn that when Python already has a real for loop? I know HTML, and I have a goal of learning Python for it's reusability (desktop apps, for instance). I don't want to learn some templating language that duplicates what Python already has built in! I think that I will use the HTTP-abstraction features of Django, but disregard the templates. My code might be uglier, but the knowledge will be transferable to other projects. My ultimate goal is not to make the latest greatest website. My ultimate goal is to port my perfectly functional website to a language that will benefit me by knowing it. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : Ok, here's a Django example without a template: # views.py def index(request): torvalds = request.GET.get(torvalds, No torvalds here) return HttpResponse(htmlbody%s/body/html % torvalds) Allright, but what if I need to output in the middle of the page? Say, one row of a table that is neither the end nor beginning of the code? I ask because the construct return makes me believe that this is not good for this purpose. A django view function returns a full HttpResponse. It's nothing like PHP's server page scheme - here you first build your full response, then pass it back to the framework (which will deal with the frontal webserver). and here's an exemple using a template: (snip) Again, how could I output something in the middle of the page with the templates? Already answered elsewhere in this post. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 Global Variables
Ronn Ross a écrit : (please don't top-post - fixed) On Oct 28, 2009, at 20:50, mattofak matto...@gmail.com wrote: Hi All; I'm new to Python and moving from C, which is probably a big source of my confusion. I'm struggling with something right now though and I hope you all can help. I have a global configuration that I would like all my classes and modules to be able to access. What is the correct way to do this? Inside the method that you want to use the var prefix the first instance with global. For example: global my_var. Then you can use the var like normal in the method. Good luck Wrong, and wrong again. 1/ you don't have to use the global statement to access a global name - only if you plan on rebinding it (which is more often than not a bad idea but that's another problem) 2/ in Python, global really means module-level - there's nothing like a true global namespace. -- http://mail.python.org/mailman/listinfo/python-list
Trying to contact Nathaniel Wilson
Hi, Nathaniel, if you are there, you emailed me privately regarding sorting in Python. I have tried to reply, but your mail server has bounced my email due to policy reasons. Do you have another email address I can send to? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: logging from several independent classes
All named loggers (including A, B etc.) inherit from the root logger, obtained by doing root_logger = logging.getLogger() or root_logger = logging.getLogger() Somehow I missed this in the docs. Thanks Vinay. -- http://mail.python.org/mailman/listinfo/python-list
RE: Python 2.6 Global Variables
Dear all How do I write a code that gets executed 'every x' minutes? I know how to do it 'after x' minutes, I do the following: def doAtTimerFire(): The things I want to do 'after x' minutes go here. And then from main code, I do this: tmr = threading.Timer(timeInSeconds, doAtTimerFire) tmr.start() Please help. Regards, Ashish Vyas -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
klausfpga schrieb: Hi, I have a Python script which wants to start a subprocess and wait for it to finish. However I would like to have NO command window popping up during execution. You need to specify the hide parameter for windows. import subprocess kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su process = subprocess.Popen( (r'c:\python25\python.exe', r'd:\projekte\bar.py'), **kwargs ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 Global Variables
On Thu, Oct 29, 2009 at 3:25 AM, VYAS ASHISH M-NTB837 ashish.v...@motorola.com wrote: Dear all How do I write a code that gets executed 'every x' minutes? I know how to do it 'after x' minutes, I do the following: def doAtTimerFire(): The things I want to do 'after x' minutes go here. And then from main code, I do this: tmr = threading.Timer(timeInSeconds, doAtTimerFire) tmr.start() Please help. Regards, Ashish Vyas Please exercise some basic mailinglist etiquette and start a new thread, don't hijack an existing one with a completely unrelated question. New threads are started by emailing your post to python-list@python.org rather than replying to a message on an existing topic. Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list
ANN: Jump 0.9.5.1 released!
I am proud to announce that Jump 0.9.5.1 is released! You can find the Jump project at http://gitorious.org/jump, and its documentation at http://gitorious.org/jump/pages/Home. Jump is a build tool for distributing Jython applications in a really easy step. Features: * Distributing Jython applications into a single, independent JAR file. * Distributing Jython libraries into a single JAR file. **[New in v0.9.5]** * Distributing native Mac OS X application bundles, Windows .exe executables, WAR files for Python WSGI applications. **[New in v0.9.5] ** * Supporting Java source code and third-party JAR files. * Supporting Java Native Interface files for distributing JAR files. ** [New in v0.9.5]** * Starting the created distribution from either Jython or Java code. * Packaging **only required** Python modules into the final distribution **automatically**, which means you don't have to worry about using Python third-party libraries as long as they can be found in your `sys.path`. * Importing specified Python packages explicitly. **[New in v0.9.5]** * All Python modules (except Python's standard library) packaged into the final distribution are compiled to `$py.class` files, which means your source code is not public. If you have any question or bug report, please post it to our mailing list at http://groups.google.com/group/ollix-jump, contributions are always welcome as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft _r...@web.de wrote: klausfpga schrieb: Hi, I have a Python script which wants to start a subprocess and wait for it to finish. However I would like to have NO command window popping up during execution. You need to specify the hide parameter for windows. import subprocess kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su process = subprocess.Popen( (r'c:\python25\python.exe', r'd:\projekte\bar.py'), **kwargs ) Interestingly, none of that appears to be documented. I smell a docs bug waiting to be reported. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Another (simple) unicode question
Construct http://construct.wikispaces.com/ is a kick-ass binary file structurer (written by a 21 year old!) I thought of trying to port it to python3 but it barfs on some unicode related stuff (after running 2to3) which I am unable to wrap my head around. Can anyone direct me to what I should read to try to understand this? -- http://mail.python.org/mailman/listinfo/python-list
How to run a repeating timer every n minutes?
Dear All How do I write a code that gets executed 'every x' minutes? I know how to do it 'after x' minutes, I do the following: def doAtTimerFire(): The things I want to do 'after x' minutes go here. And then from main code, I do this: tmr = threading.Timer(timeInSeconds, doAtTimerFire) tmr.start() Sorry about the earlier post with wrong subject line. Please help. Regards, Ashish Vyas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run a repeating timer every n minutes?
I use the wx.Timer for this: import wx timer = wx.Timer(self, -1) # update gui every 1/4 second (250ms) timer.Start(250) Bind(wx.EVT_TIMER, OnUpdateValues) In the above I'm running the OnUpdateValues function every 250ms. Regards, Wesley Brooks 2009/10/29 VYAS ASHISH M-NTB837 ashish.v...@motorola.com Dear All How do I write a code that gets executed 'every x' minutes? I know how to do it 'after x' minutes, I do the following: def doAtTimerFire(): The things I want to do 'after x' minutes go here. And then from main code, I do this: tmr = threading.Timer(timeInSeconds, doAtTimerFire) tmr.start() Sorry about the earlier post with wrong subject line. Please help. Regards, Ashish Vyas -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run a repeating timer every n minutes?
VYAS ASHISH M-NTB837 wrote: cut You might want to start a thread with a continues loop that primarily sleeps (time.sleep) but wakes up at regular intervals and executes what needs to be. -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
Chris Rebert wrote: On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft _r...@web.de wrote: klausfpga schrieb: Hi, I have a Python script which wants to start a subprocess and wait for it to finish. However I would like to have NO command window popping up during execution. You need to specify the hide parameter for windows. import subprocess kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su process = subprocess.Popen( (r'c:\python25\python.exe', r'd:\projekte\bar.py'), **kwargs ) Interestingly, none of that appears to be documented. Except for here: http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx I smell a docs bug waiting to be reported. Cheers, Chris -- http://blog.rebertia.com -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
On Thu, Oct 29, 2009 at 4:37 AM, Martin P. Hellwig martin.hell...@dcuktec.org wrote: Chris Rebert wrote: On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft _r...@web.de wrote: klausfpga schrieb: Hi, I have a Python script which wants to start a subprocess and wait for it to finish. However I would like to have NO command window popping up during execution. You need to specify the hide parameter for windows. import subprocess kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su process = subprocess.Popen( (r'c:\python25\python.exe', r'd:\projekte\bar.py'), **kwargs ) Interestingly, none of that appears to be documented. Except for here: http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx I was referring to the following bits of the subprocess module used in the above code: subprocess.mswindows subprocess.STARTUPINFO() subprocess.STARTF_USESHOWWINDOW subprocess.SW_HIDE none of which are mentioned in the module's docs: http://docs.python.org/dev/py3k/library/subprocess.html Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run a repeating timer every n minutes?
Ashish Vyas wrote: Dear All How do I write a code that gets executed 'every x' minutes? [...] Regards, Ashish Vyas Here is one way - import threading class Timer(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.event = threading.Event() def run(self): while not self.event.is_set(): The things I want to do go here. self.event.wait(number_of_seconds_to_wait) def stop(self): self.event.set() In your main program - - to start the timer tmr = Timer() tmr.start() - to stop the timer tmr.stop() It is easy to extend this by passing the number_of_seconds_to_wait, or a function name to be executed, as arguments to the Timer. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: cool-compiling python 3
Rustom Mody wrote: I guess this is a bit OT but anyhow. I just finished compiling compiling python 3 on ubuntu and discovered that my laptop has a builtin toaster :-; Yeah I know this is not a python issue and probably modern laptops are meant to run wondrous beautiful elephantaneous things like eclipse cool-ly but heat up on a few gccs! Still does anyone know how/what/where I can tell ubuntu to run slow and cool? Thanks I guess if you have said that your laptop is overheating, more people would take you more seriously. Well, you might want to check CPUFreq. You can set the CPU to run at lower frequency or use the powersave governor before doing heavy compilation. The CPUFreq tool is command line (cpufreq-set, cpufreq-info, and cpufreq-selector), but I think one of the toolbar applet can switch your CPU frequency as well. If you compiled your own kernel (instead of using Ubuntu's generic kernel), there is a kernel option that you might need to change. -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
Chris Rebert wrote: cut Except for here: http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx I was referring to the following bits of the subprocess module used in the above code: Me too actually :-) subprocess.mswindows subprocess.STARTUPINFO() subprocess.STARTF_USESHOWWINDOW subprocess.SW_HIDE none of which are mentioned in the module's docs: http://docs.python.org/dev/py3k/library/subprocess.html Since this is platform specific stuff I would argue that it has no business being repeated, although a link to where it is documented elsewhere would have been nice. -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' -- http://mail.python.org/mailman/listinfo/python-list
Re: Win XP: How to hide command window for sub processes?
On Thu, Oct 29, 2009 at 4:57 AM, Martin P. Hellwig martin.hell...@dcuktec.org wrote: Chris Rebert wrote: cut Except for here: http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx I was referring to the following bits of the subprocess module used in the above code: Me too actually :-) subprocess.mswindows subprocess.STARTUPINFO() subprocess.STARTF_USESHOWWINDOW subprocess.SW_HIDE none of which are mentioned in the module's docs: http://docs.python.org/dev/py3k/library/subprocess.html Since this is platform specific stuff I would argue that it has no business being repeated, although a link to where it is documented elsewhere would have been nice. True, the Windows APIs are documented but it's not mentioned at all that they're accessible in a certain form from subprocess. Many other stdlib modules (e.g. `os` - http://docs.python.org/library/os.html) include and list platform-specific functions, I don't see why subprocess should be different. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
RE: How to run a repeating timer every n minutes?
Thanks a lot, this helps. -Original Message- From: python-list-bounces+ntb837=motorola@python.org [mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of Frank Millman Sent: Thursday, October 29, 2009 5:19 PM To: python-list@python.org Subject: Re: How to run a repeating timer every n minutes? Ashish Vyas wrote: Dear All How do I write a code that gets executed 'every x' minutes? [...] Regards, Ashish Vyas Here is one way - import threading class Timer(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.event = threading.Event() def run(self): while not self.event.is_set(): The things I want to do go here. self.event.wait(number_of_seconds_to_wait) def stop(self): self.event.set() In your main program - - to start the timer tmr = Timer() tmr.start() - to stop the timer tmr.stop() It is easy to extend this by passing the number_of_seconds_to_wait, or a function name to be executed, as arguments to the Timer. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Another (simple) unicode question
On Oct 29, 10:02 pm, Rustom Mody rustompm...@gmail.com wrote: Constructhttp://construct.wikispaces.com/is a kick-ass binary file structurer (written by a 21 year old!) I thought of trying to port it to python3 but it barfs on some unicode related stuff (after running 2to3) which I am unable to wrap my head around. Can anyone direct me to what I should read to try to understand this? unicode related stuff is rather vague. Have you read the Python Unicode HOWTO? Joel Spolsky's article? http://www.amk.ca/python/howto/unicode http://www.joelonsoftware.com/articles/Unicode.html In any case, it's a debugging problem, isn't it? Could you possibly consider telling us the error message, the traceback, a few lines of the 3.x code around where the problem is, and the corresponding 2.x lines? Are you using 3.1.1 and 2.6.4? Does your test work in 2.6? -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : 2009/10/29 Albert Hopkins mar...@letterboxes.org: On Wed, 2009-10-28 at 16:38 +0200, Dotan Cohen wrote: return HttpResponse(unmaintanable_html % data) That's fine for single variables, but if I need to output a table of unknown rows? I assume that return means the end of the script. Therefore I should shove the whole table into a variable and then copy that variable to the array data? No, if you use a templating system like Django's then basically you pass a QuerySet to your template. A QuerySet is basically a pointer to a SQL query, for example. The templating system just knows to expect an iterable, it can be a list of rows or it can be a QuerySet which does a fetch from a database. No need to shove an entire table into a variable. Sounds like the system is trying to outsmart the programmer here. Why so ??? -- http://mail.python.org/mailman/listinfo/python-list
RE: Copying a ZipExtFile
On October 28, 2009 8:33 PM, ryles wrote: snip with io.BytesIO() as memio: shutil.copyfileobj(f, memio) zip = zipfile.ZipFile(file=memio) # Can't use zip.extract(), because I want to ignore paths # within archive. src = zip.open('unknowndir/src.txt') with open('dst.txt', mode='wb') as dst: shutil.copyfileobj(src, dst) The last line throws an Error: Traceback (most recent call last): File test.py, line 25, in module shutil.copyfileobj(src, dst) File C:\Python26\lib\shutil.py, line 27, in copyfileobj buf = fsrc.read(length) File C:\Python26\lib\zipfile.py, line 594, in read bytes = self.fileobj.read(bytesToRead) TypeError: integer argument expected, got 'long' It should hopefully work if you use cStringIO/StringIO instead of BytesIO. It does! Excellent! You've saved me the trouble of a weekend debug session. --Matt -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie advice
On Oct 29, 3:00 am, alex23 wuwe...@gmail.com wrote: CSharpner csharp...@gmail.com wrote: Here's what I /want/ to do, but don't know where to begin: Welcome to the fun :) - Write web services in Python (I've done plenty of this in .NET, BTW). I'm a big fan of CherryPy:http://www.cherrypy.org/ It's very straightforward and easy to get into. - Write plain DLLs (is that even an option in Python (I told you I was a newb to Python, didn't I? :)) I'd recommend Cython:http://www.cython.org/ It allows you to write dlls in (a subset of) Python that are converted to and compiled in C. - Write a web app (HTML front end, Python web services called from JavaScript). - Write a plain old web app with Python (no web services or Ajax, just plain HTML Python). Again, CherryPy, or depending on your needs one of the many, many web frameworks; I'm partial to Turbogears, but Django seems to be the most popular. For a good overview of what's out there:http://wiki.python.org/moin/WebFrameworks - Is it possible to create a Windows client desktop GUI app with Python? How? How 'bout a Linux GUI app? Python includes a wrapper around Tcl/Tk, which many consider to be kinda ugly by modern standards, but is cross platform and part of the stdlib (it's not always included with *nix distros by default but then it's a lot easier to make that happen during install under most package managers). PyQT, PyGtk and wxPython all have their active proponents. There are plenty of GUI libs out there:http://wiki.python.org/moin/GuiProgramming However, if you're already comfortable with HTML/CSS, I'd recommend taking a look at Pyjamas, which started as a port of the Google Web Toolkit, taking Python code and compiling it into javascript. The associated project, Pyjamas-Desktop, is a webkit-based desktop client/ widget set; so ideally you only have to write one UI and it'll run both on the web the desktop. Pyjamas:http://pyjs.org/ Pyjamas-Desktop:http://pyjd.sourceforge.net/ And finally, I'm not completely committed to using Windows to host my development either. I'm willing to use Linux too (but would prefer Windows... at least to get started, until I'm comfortable enough with Python). Google App Engine allows you to host our app on Google servers, with a very generous free quota:http://code.google.com/appengine/ It supports Django and several other of the web frameworks. It's worth noting that it uses the non-relational BigTable at the backend, which seems to cause a lot of grief to relationally-trained minds :) Hopefully something in here is enlightening :) Thanks! Lots of good stuff in there. I think that's plenty to get me started. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie advice
On Oct 29, 4:25 am, Diez B. Roggisch de...@nospam.web.de wrote: CSharpner schrieb: Alright, I'm not new to programming, but I'm diving in head first into Python for the first time. I'm running on Windows 7, just installed Eclipse Java EE IDE for Web Developers and installed PyDev in it and installed Python 2.6. I've written my first Hello World program, which simply displays Hello World! in the console output. Here's what I /want/ to do, but don't know where to begin: - Write web services in Python (I've done plenty of this in .NET, BTW). This depends. If by web services you mean generally HTTP-based RPC, such as JSON or XMLRPC - yes. If you talk about offering a SOAP-server, then Python is rather painful in that respect. Which partially is his (or his 3rd-party-libs) fault, but IMHO mostly because that whole standard is as crappy as it can get, and my personal experience told me to not expect interoperability from it anyway. - Write plain DLLs (is that even an option in Python (I told you I was a newb to Python, didn't I? :)) There is elmer:http://elmer.sourceforge.net/ And you can create COM servers with win32-extensions, and AFAIK IronPython allows you to create something like DLLs also. - Write a web app (HTML front end, Python web services called from JavaScript). Plenty of options here, popular choices of frameworks include Django, TurboGears 1 2, Pylons, werkzeug, web.py and some more. - Write a plain old web app with Python (no web services or Ajax, just plain HTML Python). See above, just don't use AJAX - Is it possible to create a Windows client desktop GUI app with Python? How? How 'bout a Linux GUI app? Both, with various toolkits such as Tk, Wx, Qt, GTK. I don't know how to create and write a Python project with Eclipse to tell it to be a web service or a web app, or if what I need to do in the code to make as such, no run it from Eclipse to launch the app in a web server and launch a browser automatically. Can I debug after doing this? In other words, can I put break points in my web services or web apps and go back into the IDE to step through the code for web services and web apps? First of all: in python, you don't code like in VisualStudio, with an application template wizard. You simply start coding. Some of the frameworks such as TurboGears and Django actually do have such wizards, but they aren't integrated into the IDE, and once you started, you don't automate anything further. And usually, this is a good thing - the wizard-stuff is for languages that need a lot of boilerplate. Python is quite successful in not needing that. Debugging is certainly possible the way you want it, or at least close to that. I personally am satisfied with the built-in debugger, pdb. But PyDev comes with one that's supposed to be quite good as well, and winpdb is also deemed excellent. Also, I'm not tied to Eclipse. I'm totally open to other IDEs as well. SharpDevelop with the Python plugin looks interesting too. And finally, I'm not completely committed to using Windows to host my development either. I'm willing to use Linux too (but would prefer Windows... at least to get started, until I'm comfortable enough with Python). Cross-platform, especially within the web-world, is usually a no-brainer in python. Diez Thanks Diez! Both your and Alex's advice are a great help! -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen a écrit : Perhaps this might better answer your questions: http://docs.djangoproject.com/en/dev/topics/templates/#id1 Actually, that example just proves my point! Which one ? Look at this templating code: {% for entry in blog_entries %} h2{{ entry.title }}/h2 p{{ entry.body }}/p {% endfor %} What's the problem ? Simple, clear and obvious. Why would I want to learn that when Python already has a real for loop ? If you know even 101 Python, understanding the above code shouldn't be such a great challenge !-) I know HTML, and I have a goal of learning Python for it's reusability (desktop apps, for instance). Using templates instead of harcoding HTML in the applicative code actually plays a big part when it comes to reusability. Telling Django's template loader where to look for templates is just a matter of configuration, so using templates you can segment your whole project in small, possibly reusable apps - then in another project where you need the same features but with a totally different presentation, it's just a matter of writing project-specific templates. Quite a few django apps work that way, and they really save you a LOT of time. This wouldn't be possible using your beloved antipattern... I don't want to learn some templating language that duplicates what Python already has built in! Then use Mako - it uses plain Python to manage the presentation logic. And if you go for Mako, then you might as well switch to Pylons. Great framework too (better than Django on some parts FWIW), but you'll probably need much more time to be fully productive with it (power and flexibility come with a price...). Now wrt/ why having a distinct templating language, there are pros and cons. On the pros side, having a language that is clearly restricted to presentation logic prevents you (and anyone else working on the project - and sometimes you have to deal with well-below-average guys in your team) to put anything else than presentation logic in the templates. Bless me for I have sinned - sometimes, when you're tired and under pressure to deliver in time, it's tempting to add a QD hack in the presentation part instead of DoingTheRightThing(tm). This can save you some precious minutes now. The problem is that usually your boss won't give you the resources to clean up this mess once you delivered, and next time you have to work on this project - fix or evolution - you have to deal with this hack. Then with another, yet another, until your code is nothing more than an unmaintainable heap of junk. Been here, done that, bought the T-shirt :( Also remember that most of the time, a web app is a team effort, and even if *you* don't fail to temptation, others may do so. And finally, the team usually involve HTML coders - who, despite what the name seems to imply, are usually skilled enough to handle the presentation logic by themselves, so you the application programmer can concentrate on applicative code. From experience, they usually prefer a simple straightforward - even if somehow restricted - templating language. Now, as far as I'm concerned, having Mako instead of Django's templates wouldn't bother me at all. But Django has it's own template system, which from experience get the job done (believe me, there are way worse alternatives), and the overall qualities and features of the whole framework are IMHO enough to justify learning it's templating language. I think that I will use the HTTP-abstraction features of Django, but disregard the templates. My code might be uglier, but the knowledge will be transferable to other projects. My ultimate goal is not to make the latest greatest website. My ultimate goal is to port my perfectly functional website to a language that will benefit me by knowing it. Given the restricted and rather unintersting nature of pure presentation logic, you won't learn much from this part of the project anyway. You'd probably learn way more using Django's templates and learning how to write your own template tags. Or if you prefer Mako / Pylons, learning to make proper use of Mako's advanced features. But one thing is clear - if you persist on applying your favorite antipattern, you'll just waste more of your time. Your choice, as usual... My 2 cents... -- http://mail.python.org/mailman/listinfo/python-list
Re: Another (simple) unicode question
On Oct 29, 4:02 am, Rustom Mody rustompm...@gmail.com wrote: Constructhttp://construct.wikispaces.com/is a kick-ass binary file structurer (written by a 21 year old!) I thought of trying to port it to python3 but it barfs on some unicode related stuff (after running 2to3) which I am unable to wrap my head around. 2to3 isn't a general Python 2 to Python 3 translator. You can't pass any old Python 2.x code through 2to3 and expect it to work. Rather, you have to write the Python 2.x code in a subset of Python that I call transitional dialect. In order to port to Python 3 using 2to3, you first have to port it to this transitional dialect. If Unicode is the issue, one thing you should do to explicitly classify all strings as binary or text in Python 2.x. This means to change str() to unicode() or bytes(), whichever is appropriate, and to change to u or b. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Another (simple) unicode question
John Machin wrote: On Oct 29, 10:02 pm, Rustom Mody rustompm...@gmail.com wrote:... I thought of trying to port it to python3 but it barfs on some unicode related stuff (after running 2to3) which I am unable to wrap my head around. Can anyone direct me to what I should read to try to understand this? to which Jon replied with some good links to start, and then: In any case, it's a debugging problem, isn't it? Could you possibly consider telling us the error message, the traceback, a few lines of the 3.x code around where the problem is, and the corresponding 2.x lines? Are you using 3.1.1 and 2.6.4? Does your test work in 2.6? Also consider how 2to3 translates the problem section(s). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named _md5 - please help
Hi, I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. Many thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
annotate a traceback
I want to annotate a traceback in routine A which is raised in B. Useful information in A is not available in B I propose to use something like def A(info): try: B() except: t,v,b=sys.exc_info() v.args = (' '.join(map(str,v.args))+', info=%r' % info,) raise is this a reasonable approach? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named _md5 - Please help
Hi, I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. Many thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
mk wrote: Hello everyone, print hosts hosts = [ s.strip() for s in hosts if s is not '' and s is not None and s is not '\n' ] print hosts ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34', ''] Why does the hosts list after list comprehension still contain '' in last position? I checked that: print hosts hosts = [ s.strip() for s in hosts if s != '' and s != None and s != '\n' ] print hosts ..works as expected: ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34'] Are there two '\n' strings in the interpreter's memory or smth so the identity check s is not '\n' does not work as expected? This is weird. I expected that at all times there is only one '\n' string in Python's cache or whatever that all labels meant by the programmer as '\n' string actually point to. Is that wrong assumption? Clearly. And even if you do figure out what the internals really are doing, it is foolish to write a program that depends on them -- there is no guarantee that such implementation specific behavior will be consistent over other implementations. Conclusion: Don't use is for comparison when you mean to check for equality. And you do want an equality check here. Gary Herron Regards, mk -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - Please help
Hi, please don't post this to comp.lang.python *and* the python mailinglist. Both are synchronized, so your post shows up twice on both. I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 I've never seen this import. Normally, it should be import md5 So you might try to alter the import statement to import md5 as _md5 and see if things work. It might be of course that the author of your script provided a home-grown implementation of md5 which has a different interface, and called this _md5 to prevent name-clashes. Then you need to modify your whole script to make it work. Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. I don't understand this - you are talking about ports which is a Mac-thing, but run on centos? However that may be, this *should* be part of core python anyway. If not, you might look in yum for some python-dependency-packages, no idea how to do that though (debian user here) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: annotate a traceback
Robin Becker wrote: I want to annotate a traceback in routine A which is raised in B. Useful information in A is not available in B I propose to use something like def A(info): try: B() except: t,v,b=sys.exc_info() v.args = (' '.join(map(str,v.args))+', info=%r' % info,) raise is this a reasonable approach? I think a custom exception that takes the old sys.exc_info() and encapsulates it would be better. Java has this, and it allows you to convey different information without losing the original traceback. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
mk wrote: Hello everyone, print hosts hosts = [ s.strip() for s in hosts if s is not '' and s is not None and s is not '\n' ] print hosts ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34', ''] Why does the hosts list after list comprehension still contain '' in last position? I checked that: print hosts hosts = [ s.strip() for s in hosts if s != '' and s != None and s != '\n' ] print hosts ..works as expected: ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34'] Are there two '\n' strings in the interpreter's memory or smth so the identity check s is not '\n' does not work as expected? This is weird. I expected that at all times there is only one '\n' string in Python's cache or whatever that all labels meant by the programmer as '\n' string actually point to. Is that wrong assumption? Yes. Never use is unless you know 100% that you are talking about the same object, not just equality. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Bruno Desthuilliers wrote: Dotan Cohen a écrit : I don't want to learn some templating language that duplicates what Python already has built in! Then use Mako - it uses plain Python to manage the presentation logic. And if you go for Mako, then you might as well switch to Pylons. Great framework too (better than Django on some parts FWIW), but you'll probably need much more time to be fully productive with it (power and flexibility come with a price...). Good to know about Mako -- I don't want to have to learn yet another language, either. Not, at least, until I have achieved Python Mastery! :) Guess I better find some time to read through my Pylons book... ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - Please help
I can't alter the import statement as the error log is pointing to one of the installed python files 'hashlib.py' /python/2.6.2/lib/python2.6/hashlib.py and I don't have the right permissions to alter the python installation. Any idea? On 10/29/09, Diez B. Roggisch de...@nospam.web.de wrote: Hi, please don't post this to comp.lang.python *and* the python mailinglist. Both are synchronized, so your post shows up twice on both. I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 I've never seen this import. Normally, it should be import md5 So you might try to alter the import statement to import md5 as _md5 and see if things work. It might be of course that the author of your script provided a home-grown implementation of md5 which has a different interface, and called this _md5 to prevent name-clashes. Then you need to modify your whole script to make it work. Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. I don't understand this - you are talking about ports which is a Mac-thing, but run on centos? However that may be, this *should* be part of core python anyway. If not, you might look in yum for some python-dependency-packages, no idea how to do that though (debian user here) Diez -- http://mail.python.org/mailman/listinfo/python-list -- Wadienil. -- http://mail.python.org/mailman/listinfo/python-list
Recommended number of threads? (in CPython)
Hello everyone, I wrote run-of-the-mill program for concurrent execution of ssh command over a large number of hosts. (someone may ask why reinvent the wheel when there's pssh and shmux around -- I'm not happy with working details and lack of some options in either program) The program has a working queue of threads so that no more than maxthreads number are created and working at particular time. But this begs the question: what is the recommended number of threads working concurrently? If it's dependent on task, the task is: open ssh connection, execute command (then the main thread loops over the queue and if the thread is finished, it closes ssh connection and does .join() on the thread) I found that when using more than several hundred threads causes weird exceptions to be thrown *sometimes* (rarely actually, but it happens from time to time). Although that might be dependent on modules used in threads (I'm using paramiko, which is claimed to be thread safe). -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - please help
On Oct 29, 9:13 am, user7304 wadie...@gmail.com wrote: Hi, I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. Many thanks for your help. Try using hashlib.md5. From the docs: import hashlib m = hashlib.md5() m.update(Nobody inspects) m.update( the spammish repetition) m.digest() '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' http://www.python.org/doc/2.5.2/lib/module-hashlib.html Garrick -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run a repeating timer every n minutes?
Frank Millman wrote: class Timer(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.event = threading.Event() def run(self): while not self.event.is_set(): The things I want to do go here. self.event.wait(number_of_seconds_to_wait) def stop(self): self.event.set() In your main program - - to start the timer tmr = Timer() tmr.start() - to stop the timer tmr.stop() It is easy to extend this by passing the number_of_seconds_to_wait, or a function name to be executed, as arguments to the Timer. I'm newbie at threading, so I'm actually asking: should not method like stop() be surrounded with acquire() and release() of some threading.lock? I mean, is this safe to update running thread's data from the main thread without lock? Regards, mk -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
Richard Heathfield wrote: A man who cannot express what he needs to express /without/ resorting to .pdf format is computer-illiterate. What format do you suggest? I have some ideas on what I would have used, but you seem to love these veiled references that there is a better way, if the OP had just been smarter. Did it ever occur to you that this is not very helpful and might even be annoying? -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommended number of threads? (in CPython)
On Oct 29, 9:56 am, mk mrk...@gmail.com wrote: Hello everyone, I wrote run-of-the-mill program for concurrent execution of ssh command over a large number of hosts. (someone may ask why reinvent the wheel when there's pssh and shmux around -- I'm not happy with working details and lack of some options in either program) The program has a working queue of threads so that no more than maxthreads number are created and working at particular time. But this begs the question: what is the recommended number of threads working concurrently? If it's dependent on task, the task is: open ssh connection, execute command (then the main thread loops over the queue and if the thread is finished, it closes ssh connection and does .join() on the thread) I found that when using more than several hundred threads causes weird exceptions to be thrown *sometimes* (rarely actually, but it happens from time to time). Although that might be dependent on modules used in threads (I'm using paramiko, which is claimed to be thread safe). Since you're creating OS threads when doing this, your issue is probably more related to your OS' implementation of threads than Python. That said, several hundred threads, regardless of them being blocked by the GIL, sounds like a recipe for trouble on most machines, but as usual YMMV. If you're running into problems with a large number of connections (not related to a socket limit), you might look into doing it asynchronously - loop over a list of connections and do non-blocking reads to see if your command has completed. I've done this successfully with pexpect, and didn't run into any issues with the underlying OS. Garrick -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
Diez B. Roggisch wrote: mk wrote: Hello everyone, print hosts hosts = [ s.strip() for s in hosts if s is not '' and s is not None and s is not '\n' ] print hosts ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34', ''] Why does the hosts list after list comprehension still contain '' in last position? I checked that: print hosts hosts = [ s.strip() for s in hosts if s != '' and s != None and s != '\n' ] print hosts ..works as expected: ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34'] Are there two '\n' strings in the interpreter's memory or smth so the identity check s is not '\n' does not work as expected? This is weird. I expected that at all times there is only one '\n' string in Python's cache or whatever that all labels meant by the programmer as '\n' string actually point to. Is that wrong assumption? Yes. Never use is unless you know 100% that you are talking about the same object, not just equality. Some objects are singletons, ie there's only ever one of them. The most common singleton is None. In virtually every other case you should be using == and !=. -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
On Oct 29, 9:31 am, Diez B. Roggisch de...@nospam.web.de wrote: mk wrote: Hello everyone, print hosts hosts = [ s.strip() for s in hosts if s is not '' and s is not None and s is not '\n' ] print hosts ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34', ''] Why does the hosts list after list comprehension still contain '' in last position? I checked that: print hosts hosts = [ s.strip() for s in hosts if s != '' and s != None and s != '\n' ] print hosts ..works as expected: ['9.156.44.227\n', '9.156.46.34 \n', '\n'] ['9.156.44.227', '9.156.46.34'] Are there two '\n' strings in the interpreter's memory or smth so the identity check s is not '\n' does not work as expected? This is weird. I expected that at all times there is only one '\n' string in Python's cache or whatever that all labels meant by the programmer as '\n' string actually point to. Is that wrong assumption? Yes. Never use is unless you know 100% that you are talking about the same object, not just equality. Diez I'd also recommend trying the following filter, since it is identical to what you're trying to do, and will probably catch some additional edge cases without any additional effort from you. [s.strip() for s in hosts if s.strip()] This will check the results of s.strip(), and since empty strings are considered false, they will not make it into your results. Garrick -- http://mail.python.org/mailman/listinfo/python-list
PyQT4 user group
Hi! I'm starting to learn and use PyQT4 at work. Is there a good user group or forum out there that I should know about? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug(s) in Python 3.1.1 Windows installation
Mark Hammond wrote: On 29/10/2009 11:06 AM, Alf P. Steinbach wrote: So I suggest switching to some other more light-weight installer technology. Thanks for the suggestion, but I expect we will stick with MSI even with its shortcomings. Using MSI files has significant other advantages, particularly in managed environments. (2) Failure to set up PATH. This is by design. If you really care passionately about this, you should be able to find a number of discussions here, in python-dev and in the python bug tracker. One example of why the current behaviour is useful is that many people install multiple Python versions side-by-side and a last installed wins strategy isn't a great option. Even after setting up a correct PATH Tkinter does not work: I suspect this will be a Python 3.x issue - you probably want to stick with 2.x. HTH, Mark Looks like in 3.x the name was changed to tkinter. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - Please help
wadi wadi wrote: I can't alter the import statement as the error log is pointing to one of the installed python files 'hashlib.py' /python/2.6.2/lib/python2.6/hashlib.py and I don't have the right permissions to alter the python installation. Any idea? Which is something different from what you communicated. I'd say your python installation is botched, given the proprietary path I'd say whoever build it locally should start from scratch. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: ftpilb.FTP.stor...() freeze mystery
Gabriel Genellina wrote: En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell anthra.nor...@bluewin.ch escribió: Gabriel Genellina wrote: En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell anthra.nor...@bluewin.ch escribió: I am trying to upload a bunch of web pages to a hosting service.[...] I wrote a loop that iterates through the file names and calls either of the stor... () methods as appropriate. The loop successfully uploads eight of some twenty files and then freezes. Ctrl-C doesn't unlock the freeze. I have to kill the IDLE window freezes are less predictable than it seemed in the beginning. On one occasion it occurred after the transfer of a single file from the IDLE command line (my_ftp_object.storlines (STOR file_name, f). The file did upload. So the freezes seem to occur after a successful transfer. In this thread from last month, Sean DiZazzo shows how to add a timeout parameter to storbinary: http://comments.gmane.org/gmane.comp.python.general/639258 Do the same with storlines and see whether it helps. Thanks a million! Here's a way out by the look of it. As the devil is in the details I get an error that indicates an inconsistency in my ftplib library (2.4) (*** marks my comments): Traceback (most recent call last): File pyshell#65, line 1, in -toplevel- d2jm = upload.run (1) File I:/DOK/projects/WEB/JM\upload.py, line 369, in run D2JM.copy_1_2 (do) File I:/DOK/projects/WEB/JM\upload.py, line 342, in copy_1_2 try: self.FS2.storbinary ('STOR %s' % name, f, timeout = timeout) *** Here's the call to the overwritten method with the timeout. File I:/DOK/projects/WEB/JM\upload.py, line 440, in storbinary self.connection = self.transfercmd (command) *** command is 'STOR (target file name)'. Control passes to ftplib File C:\PYTHON24\lib\ftplib.py, line 345, in transfercmd return self.ntransfercmd(cmd, rest)[0] File C:\PYTHON24\lib\ftplib.py, line 321, in ntransfercmd host, port = self.makepasv() File C:\PYTHON24\lib\ftplib.py, line 299, in makepasv host, port = parse227(self.sendcmd('PASV')) File C:\PYTHON24\lib\ftplib.py, line 566, in parse227 raise error_reply, resp error_reply: 200 TYPE is now 8-bit binary *** 'is now' indicates something has changed resulting in an inconsistency Line 566 in PYTHON24/lib/ftplib.py: def parse227(resp): '''Parse the '227' response for a PASV request. Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] != '227': raise error_reply, resp *** Line 566 global _227_re Is 'resp' supposed to be an int (227) rather than a string ('227')? Probably a wrong conclusion. In version 2.5 it is still a string. Anyway, I can't start editing the library trial-and-error style. So, I do thank you for the push. Mores pushes will be greatly appreciated, but I hesitate to invite travel companions for a stroll into this wilderness. Frederic -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run a repeating timer every n minutes?
mk wrote: Frank Millman wrote: class Timer(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.event = threading.Event() def run(self): while not self.event.is_set(): The things I want to do go here. self.event.wait(number_of_seconds_to_wait) def stop(self): self.event.set() In your main program - - to start the timer tmr = Timer() tmr.start() - to stop the timer tmr.stop() It is easy to extend this by passing the number_of_seconds_to_wait, or a function name to be executed, as arguments to the Timer. I'm newbie at threading, so I'm actually asking: should not method like stop() be surrounded with acquire() and release() of some threading.lock? I mean, is this safe to update running thread's data from the main thread without lock? stop() is part of the Timer-interface, and tas it's not mentioned to be unsafe in the docs you can just call it. It might be that it internally calls some threadsafe means of communication (Event, Lock). In general you are right, however many of those considerations don't apply to (C)Python due to the GIL (global interpreter lock), which ensures that a lot of operations are atomic. For example, in current CPython it's perfectly safe to simply set a boolean instance variable to False to stop an running loop. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT4 user group
Chris wrote: Hi! I'm starting to learn and use PyQT4 at work. Is there a good user group or forum out there that I should know about? The PyQt Mailinglist. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
Falcolas a écrit : (snip) I'd also recommend trying the following filter, since it is identical to what you're trying to do, and will probably catch some additional edge cases without any additional effort from you. [s.strip() for s in hosts if s.strip()] The problem with this expression is that it calls str.strip two times... Sometimes, a more lispish approach is better: whatever = filter(None, map(str.strip, hosts)) or just a plain procedural loop: whatever = [] for s in hosts: s = s.strip() if s: whatever.append(s) As far as I'm concerned, I have a clear preference for the first version, but well, YMMV... -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
mk a écrit : Hello everyone, print hosts ['9.156.44.227\n', '9.156.46.34 \n', '\n'] Just for the record, where did you get this hosts list from ? (hint : depending on the answer, there might be a way to avoid having to filter out the list) -- http://mail.python.org/mailman/listinfo/python-list
Re: PSP problem showing images
Anybody of you have any idea? Alfons Nonell-Canals wrote: Hi Lawrence, Yes, I've tried it! I've saw the code, copyed the src path ans pasted into the browser and it works. I think it not works only unther a psp hostname/directory, for this reason I thought the problem is in the apache2 (site) configuration pasted in my mail... Thanks! Alfons. Lawrence D'Oliveiro wrote: In message mailman.2101.1256636602.2807.python-l...@python.org, Alfons Nonell-Canals wrote: I developed a script which generates some images (is a work about Chemistry) and returns a page with some results and these images. When I run the script from the web browser, all works fine: the images are created, some other staff is calculated and the final page with the results is fine except the images. It does not print the images! I chech the paths and all is fine. Did you view source to check the URLs in the “IMG SRC=...” directives? Did you try copying and pasting the image URLs directly into new windows/tabs, to see if they came up or you got an error page instead? -- Alfons Nonell-Canals, PhD Chemogenomics Lab Research Group on Biomedical Informatics (GRIB) - IMIM/UPF Barcelona Biomedical Research Park (PRBB) C/ Doctor Aiguader, 88 - 08003 Barcelona alfons.non...@upf.edu - http://cgl.imim.es Tel. +34933160528 http://alfons.elmeuportal.cat http://www.selenocisteina.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Dotan Cohen wrote: Perhaps this might better answer your questions: http://docs.djangoproject.com/en/dev/topics/templates/#id1 Actually, that example just proves my point! Look at this templating code: {% for entry in blog_entries %} h2{{ entry.title }}/h2 p{{ entry.body }}/p {% endfor %} Why would I want to learn that when Python already has a real for loop? I know HTML, and I have a goal of learning Python for it's reusability (desktop apps, for instance). I don't want to learn some templating language that duplicates what Python already has built in! The point is that using templates allows you to express your rendering-logic in terms of the desired output language (HTML in this case). This becomes even more apparent in genshi/KID, which use XML-namespaces inside normal XHTML-documents to express their logic. And thus you can - use a decent XML/HTML-editor to work with them, syntax-hilighting and everthing included. - communicate better with people who are only used to work with HTML - aren't a slave to Python's whitespace rules which are fine for Python, but not for HTML. - validate the HTML and be sure you don't f*ck it up with forgotten print-statements And the overall separation of rendering from programming is a *great* thing for maintainability. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT4 user group
For detailed questions, try http://stackoverflow.com/questions/tagged/pyqt or pyqt4 (the or may have to be escaped as %20or%20 in some browsers.) -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - Please help
On Oct 29, 8:49 am, wadi wadi wadie...@gmail.com wrote: I can't alter the import statement as the error log is pointing to one of the installed python files 'hashlib.py' /python/2.6.2/lib/python2.6/hashlib.py and I don't have the right permissions to alter the python installation. Any idea? On 10/29/09, Diez B. Roggisch de...@nospam.web.de wrote: Hi, please don't post this to comp.lang.python *and* the python mailinglist. Both are synchronized, so your post shows up twice on both. I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 I've never seen this import. Normally, it should be import md5 So you might try to alter the import statement to import md5 as _md5 and see if things work. It might be of course that the author of your script provided a home-grown implementation of md5 which has a different interface, and called this _md5 to prevent name-clashes. Then you need to modify your whole script to make it work. Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. I don't understand this - you are talking about ports which is a Mac-thing, but run on centos? However that may be, this *should* be part of core python anyway. If not, you might look in yum for some python-dependency-packages, no idea how to do that though (debian user here) Diez -- http://mail.python.org/mailman/listinfo/python-list -- Wadienil. You are being vague and confusing. There is no default _md5 python library in the standard library. You should be either using import md5 (deprecated) or import hashlib. Unless perhaps the code you show is from inside one of those libraries, and there is a _md5.so that it uses but cant find. Not sure about that. Did you write the code above? Or did you find it inside another file? If you found it inside another file what is the file? If you still have questions, I have another approach. Please cover your palm and fingers with a thick layer of black ink (making sure to cover your entire hand). Press your hand down firmly on a piece of bright white paper. Allow the ink to dry. Finally, scan the page and post it here. I will attempt to read your palm to find the answer. ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - please help
Hi Garrick, My python script depends on another framework that is implemented in python. The error is originating from the framework code note my script and I cannot change the framework. Also, it works on other machines. So my guess is that I have no choice I need to install the 'py25-hashlib' on my current box. Any idea? On Thu, Oct 29, 2009 at 3:59 PM, Falcolas garri...@gmail.com wrote: On Oct 29, 9:13 am, user7304 wadie...@gmail.com wrote: Hi, I am trying to run a python script and got this error. import _md5 ImportError: No module named _md5 Googling the problem suggested that I install the 'py25-hashlib'. the following does not work for me 'sudo port install py25-hashlib' , trying to install MacPorts raised many problems. My question is: any idea on how to install it using yum? I am running python 2.6.2 on a centos machine. Many thanks for your help. Try using hashlib.md5. From the docs: import hashlib m = hashlib.md5() m.update(Nobody inspects) m.update( the spammish repetition) m.digest() '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' http://www.python.org/doc/2.5.2/lib/module-hashlib.html Garrick -- http://mail.python.org/mailman/listinfo/python-list -- Wadienil. -- http://mail.python.org/mailman/listinfo/python-list
Are *.pyd's universal?
Can I use a pyd compiled on linux in a Windows distribution? Or must I recompile it for windows users? -- http://mail.python.org/mailman/listinfo/python-list
Re: Web development with Python 3.1
Diez B. Roggisch a écrit : The point is that using templates allows you to express your rendering-logic in terms of the desired output language (HTML in this case). Well, for Django, Mako, Cheetah and quite a few others, this might not be _that_ true - you can use any of the templating systems to generate almost any kind of text, not just HTML, and the templating logic itself is _not_ expressed in terms of the desired output language (ie: the template langage elements are not valid HTML). And the overall separation of rendering from programming is a *great* thing for maintainability. +1 on this - even if some may argue that this shouldn't prevent you from using Python to handle the presentation logic (whitespace problems set aside, and cf Mako and Cheetah). -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
* Martin P. Hellwig: Alf P. Steinbach wrote: * tm: On 28 Okt., 07:52, Alf P. Steinbach al...@start.no wrote: [Cross-posted comp.programming and comp.lang.python] Looking at your topic '(Python in Windows)', without taking a glimpse at your actual introduction, I have the following to say: I think it is not a good idea to teach programming with a focus on a specific operating system. Programming should IMHO be taught without reference to an operating system. Otherwise you just teach how to write unportable programs. I think you're trolling a little. :-) Without reference to an OS you can't address any of the issues that a beginner has to grapple with, including most importantly tool usage, without which it's not even possible to get started, but also, very importantly, a file system. Learning programming without tools and without using files (or only using the common denominator for file systems in OSes X, Y and Z) is sort of vacuous... In addition there's the motivational factor. I conclude from this that your assumption is that the reader might not be competent enough to have basic portable knowledge of using a computer. Which is fair enough, however I would suggest writing an introduction to solve this fundamental absence of knowledge first before introducing concepts like programming in python for which already are a number of freely available/modifiable resources online. You're right that I assume no knowledge of the command interpreter, and just the most cursory knowledge of folder structure etc. However I would not phrase that in terms of competence :-). Writing an introduction to solve that knowledge gap problem is generally a good idea and I've done that a number of times. But having done that I know very well what it entails when it includes What The Student Should Know instead of just recipes. In an environment with other folks that the student can seek help from it works well, but in a book it's rather off-putting: hey, it's page 90!, when are we getting to do real programming?. And I'm not taking that page 90 from thin air. There's rather a lot to know about the environment that a program executes in if one is going to create robust, dependable, generally usable programs, not just toy examples. Unfortunately even most professional programs do not handle the requirements of their environs very well, and I think that educators, even such as I, have a responsibility to now start teaching students to do things right. To take but one example that you may or may not be aware of, Microsoft's own Windows Explorer, the main GUI shell for Windows, which presumably was made by the best programmers available with the best knowledge of the program's environment, is unable to handle (such as delete) files or folders with paths greater than some 260 characters, is unable to handle filenames that differ only in case and are in the same directory, and is unable to e.g. delete a folder called con -- although such files folders can very easily be created. In addition to such things impacting on the design and functionality of programs even just the tool usage is very complex and runs to a great many pages. For example, for general tool usage in Windows the student needs to know about levels of environment variable specifications and file associations, which in turn requires knowledge of processes and the Windows registry database and various commands. And there's stuff you don't find in most textbooks that, in an introduction for that knowledge gap, IMO needs to be there. For example, the student should ideally know that it's not a good idea to write MZ as the first two characters in a Windows text file, or to let a program do that. But instead of collecting all this stuff in a very long-winded introduction, my idea now is to just/mostly introduce it by way of programming examples, and then the student also gets the connection to how this functionality is from a programming perspective. I don't think it is a virtue to help adding to the pool of programmers unaware of the command line, whatever platform that might be. This comment baffles me. But ignoring the above (I assumed and assumption you made, so it is likely I've got it totally wrong :-) ), I think that creating such a document provides a unique opportunity to document things that the more experienced developers take for granted but is a complete enigma for beginners in programming and using computers in general. This comment also baffles me. :-) Good luck with your effort! Thanks! Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie advice
On Oct 28, 9:53 pm, CSharpner csharp...@gmail.com wrote: Alright, I'm not new to programming, but I'm diving in head first into Python for the first time. I'm running on Windows 7, just installed Eclipse Java EE IDE for Web Developers and installed PyDev in it and installed Python 2.6. I've written my first Hello World program, which simply displays Hello World! in the console output. Here's what I /want/ to do, but don't know where to begin: - Write web services in Python (I've done plenty of this in .NET, BTW). - Write plain DLLs (is that even an option in Python (I told you I was a newb to Python, didn't I? :)) - Write a web app (HTML front end, Python web services called from JavaScript). - Write a plain old web app with Python (no web services or Ajax, just plain HTML Python). - Is it possible to create a Windows client desktop GUI app with Python? How? How 'bout a Linux GUI app? I don't know how to create and write a Python project with Eclipse to tell it to be a web service or a web app, or if what I need to do in the code to make as such, no run it from Eclipse to launch the app in a web server and launch a browser automatically. Can I debug after doing this? In other words, can I put break points in my web services or web apps and go back into the IDE to step through the code for web services and web apps? Also, I'm not tied to Eclipse. I'm totally open to other IDEs as well. SharpDevelop with the Python plugin looks interesting too. And finally, I'm not completely committed to using Windows to host my development either. I'm willing to use Linux too (but would prefer Windows... at least to get started, until I'm comfortable enough with Python). TIA I first started coding using Visual Studio + VB.net in college (not a CS major). I have now sworn off all that jazz for python+vim+*nix. Your thinking reminds me very much of how I used to think about solving problems with software. I thought in terms of the tools I had, which was basically which VS templates were available, which GUI widget library I could buy, which MS application framework I could use etc. At some point I decided to start all over. I started reading *basic* computer programming books, teaching myself C, and doing all coding in a simple text editor. It was a tough period but I'm glad I went through it because I think about programming completely differently now. Now a programming language is mostly an implementation detail. I design the solution without even thinking about programming languages or tools. I choose to implement most solutions in python because its syntax describes what I want to do the cleanest, its not tied to a corporate strategy, it has tons of useful libraries bla bla bla. This post describes the IDS vs language divide that I crossed over: http://osteele.com/archives/2004/11/ides Python can do everything you ask in your post, and their are many resources to help you do those things. I just wanted to give you some advice for the bigger picture. Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - please help
On 2009-10-29 11:39 AM, wadi wadi wrote: Hi Garrick, My python script depends on another framework that is implemented in python. The error is originating from the framework code note my script and I cannot change the framework. Also, it works on other machines. So my guess is that I have no choice I need to install the 'py25-hashlib' on my current box. Any idea? py25-hashlib is the name of a MacPorts package. That's for Macs, not Centos. hashlib is part of the standard library. You have a broken Python installation. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
* James Harris: On 28 Oct, 08:58, Alf P. Steinbach al...@start.no wrote: * tm: On 28 Okt., 07:52, Alf P. Steinbach al...@start.no wrote: [Cross-posted comp.programming and comp.lang.python] Looking at your topic '(Python in Windows)', without taking a glimpse at your actual introduction, I have the following to say: I think it is not a good idea to teach programming with a focus on a specific operating system. Programming should IMHO be taught without reference to an operating system. Otherwise you just teach how to write unportable programs. I think you're trolling a little. :-) Whether tm is promoting his own language or not I agree with some of his comments. I was going to avoid giving any feedback because most of my thoughts are, I'm afraid, negative but seeing your response to tm here I changed my mind. You asked for feedback. Hopefully you are looking for genuine criticism and honest opinions rather than flattery 'cause I'm not going to flatter. If you want to teach programming then target programming concepts (albeit using Python as a means to express them) and as tm says, avoid teaching either a particular OS or a particular set of bundled tools. If you want to teach programming under Windows then change the title to say so. The working title says in Windows. But you have a misconception, a false dichotomy. Learning programming in some concrete environment, which is a practical necessity, is not to learn programming for that environment. Sorry but I find the overall tone too patronising. Phrases like send your browser galloping in the direction of are offputting. With this and other phrases it sounds like you are either 1) writing this for young children, or 2) having more fun writing it than your readers will have reading it or, 3) being self-indulgent and not planning to help others at all. I know you don't mean any of these. Hopefully you can change the approach to suit. There are many of these jocular phrases and they appear in both chapters. Ah, don't be so stuffed-up! :-) Given that this is a Windows-based course it's good that you include teaching on Notepad rather than just the IDE. No, I don't intend to teach Notepad or any editor or IDE. The x squared graph is a good example to show that some fun can be had in a small space. Thanks. I wouldn't condemn but I would query the use of Activestate's distribution. A vanilla Python may have been better if you want to teach transportable skills. Teaching Activestate reminds me of how Compuserve bundled their own stuff with Internet access so people thought the Internet was what they saw on Compuserve. ActiveState is simplest to install. However, given what I've now learned about the current situation wrt. versions of Python, where Python 3.x is effectively a new language, and where apparently ActiveState has no installer for that, I'm rewriting to use the official distribution. It has some bugs in the installer and is in many respects incompatible with the information the student can find and will most easily stumble on on the net, even the sites that the 3.1.1 documentation links to (e.g. now tkinter instead of Tkinter, now / does not perform integer division and there goes my example of that, so on), but it's a more clean language. You get way too deep into Python in places (for a beginner's course in programming). For example, from now on I’ll always use from __future__ in any program that uses print. Sorry, but I think that hiding such concerns is a real disservice. Nobody learns to swim by reading. They can at best learn something /about/ swimming, but not swimming. The MIT course that you mention takes a more apt approach for teaching *programming*. For example, it explains some things like floating point numbers in Python not being able to express 0.1 perfectly in binary but that's appropriate as other languages have the same issue. I believe in mostly going from the concrete to the abstract. Sometimes theory has to precede the concrete examples. Sometimes, and most often, theory is best served after having seen what it's all about. As you say, you are an experienced programmer who is learning Python and the chapters read that way. They rush in to all kinds of gotchas and mechanisms. Perhaps you should either change it to be a book on learning Python for experienced programmers (this seems the best option) or start again and take a different approach. I'm sorry but the above is not meaningful to me. What gotchas? What mechanisms? With what you have written so far your audience seems to be youself (or someone in your position). Without reference to an OS you can't address any of the issues that a beginner has to grapple with, including most importantly tool usage, without which it's not even possible to get started, but also, very importantly, a file system. There's a difference between referring to an OS and tieing it in throughout the text which is what I
Re: Python 2.6 Global Variables
2/ in Python, global really means module-level - there's nothing like a true global namespace. Isn't that __main__? import __main__ __main__.foo = asdfasdf print foo # asdfasdf Not advocating, but it does serve the purpose. -- http://mail.python.org/mailman/listinfo/python-list
Re: Are *.pyd's universal?
On Thu, Oct 29, 2009 at 12:44 PM, Bakes ba...@ymail.com wrote: Can I use a pyd compiled on linux in a Windows distribution? No. Or must I recompile it for windows users? Yes. -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _md5 - Please help
wadi wadi wrote: Sorry for the confusion. In summary I have the same issue shown here with its solution. It seems to be a common problem. http://recurser.com/articles/2009/06/06/python-25-importerror-no-module-named-_md5-on-os-x/ However, their solution does not work with me as I am using a linux machine and they are suggesting the use of the 'port' command. I am looking for an equivalent command or workaround to install the missing library 'py25-hashlib' using 'yum' for example. googling python 2.6 rpm hashlib suggests that there is an explicit python hashlib package, named something like python-hashlib. So install it. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, from now on I’ll always use from __future__ in any program that uses print. Sorry, but I think that hiding such concerns is a real disservice. The disservice is in teaching folks to use non-standard elements, which is (sort-of) what __future__ is. Changes to the language are experimented with in __future__ and can change from one release to the next. If memory serves, the with statement is an example of having different behavior when it was moved out of __future__ and made a standard part of the language. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
In 7ktsj6f3bciq...@mid.individual.net, osmium wrote: Richard Heathfield wrote: A man who cannot express what he needs to express /without/ resorting to .pdf format is computer-illiterate. What format do you suggest? Firstly, I want to make clear that I'm not objecting to the OP's use of .pdf format - and even if I were (which I'm not), why should he care? He should be choosing a format to suit his readers, not me! My comment was more general. If .pdf is the right choice, fine, use .pdf - but be aware that there will be some subset of potential readers who are unable to use that format. I wrote a little freebie program that is quite popular round here (Physical World here, not Usenet here), which uses a PDF reader (you get to choose which one - Adobe, Foxit, whatever) for output. I don't like that situation, but I had bitten the bullet and decided to live with it. Two evenings ago, I was asked for Yet Another Copy (perhaps I should charge for it), so I cheerfully installed it on the user's desktop machine (Windows ME, would you believe), and then set about configuring the reader, when... ouch! No PDF reader on the machine. Not even an ancient Adobe version. Oh dear. Program suddenly rendered completely useless for that person. An Internet connection was available, but in the very limited time available I did not have time to download and install a reader. I'll do what I can to fix that over the next week or so, but it drove home the lesson that I need to rewrite the program to use bitmaps instead. So - what format do I suggest? That's easy - the simplest possible format that will do the job. If unmarked text will do it, use text. If that doesn't cut it, use HTML or some other markup language. If that won't do, okay, use PDF or Word or WordPro or WordPerfect or whatever your users have. Personally, for stuff I want to display over the Web, I have always found HTML/CSS, together with common graphics formats, to be perfectly adequate. I have some ideas on what I would have used, but you seem to love these veiled references that there is a better way, The best way is the simplest technology that will do the job properly. If that truly is PDF, okay, use PDF. But it is hard for me to envisage circumstances where Web content is best presented in that way. if the OP had just been smarter. Er, no, I didn't have that in mind at all. Did it ever occur to you that this is not very helpful and might even be annoying? Judging by the tone of your replies to me, I'm perfectly sure that you frequently (but not always) find my articles annoying. I also frequently (but not always) find your articles annoying. Did that ever occur to you? (I ask only for information - I'm really truly not trying to get on your case here, although I recognise that it might sound like it, hence this disclaimer.) -- Richard Heathfield http://www.cpax.org.uk Email: -http://www. +rjh@ Usenet is a strange place - dmr 29 July 1999 Sig line vacant - apply within -- http://mail.python.org/mailman/listinfo/python-list
Re: Are *.pyd's universal?
Bakes wrote: Can I use a pyd compiled on linux in a Windows distribution? Or must I recompile it for windows users? On Linux and several other Unices the suffix is .so and not .pyd. The compiled extensions depend on the Python version, operating system as well as platform and architecture. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug(s) in Python 3.1.1 Windows installation
Alf P. Steinbach wrote: * Ethan Furman: Mark Hammond wrote: On 29/10/2009 11:06 AM, Alf P. Steinbach wrote: So I suggest switching to some other more light-weight installer technology. Thanks for the suggestion, but I expect we will stick with MSI even with its shortcomings. Using MSI files has significant other advantages, particularly in managed environments. (2) Failure to set up PATH. This is by design. If you really care passionately about this, you should be able to find a number of discussions here, in python-dev and in the python bug tracker. One example of why the current behaviour is useful is that many people install multiple Python versions side-by-side and a last installed wins strategy isn't a great option. Even after setting up a correct PATH Tkinter does not work: I suspect this will be a Python 3.x issue - you probably want to stick with 2.x. HTH, Mark Looks like in 3.x the name was changed to tkinter. ~Ethan~ That works! g Thanks. But, where I can find information about how import now works? I mean there's no *file* named [tkinter.*] anywhere, so I suspect it looks in the [tkinter] directory or perhaps uses some setup file's name association or? Alf, apologies for e-mailing you directly: I hit Reply instead of Reply-to-all. Try searching the archives -- there have been many discussions about import, and a few about import in 3.x. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Checking if a function invocation will throw a TypeError?
Is there a standard function that will check whether certain *args, and **kwargs satisfy a argspec of a function (s.t. it does not throw a TypeError). Say: def foo(a,b=1): pass check(foo, 1,2) # True check(foo, 1) # True check(foo) # False check(foo, 1, a=2) # False Cheers, Andrey -- http://mail.python.org/mailman/listinfo/python-list
disutils, project structure developing - n00b question
So I have my project partitioned like so: ./setup.py ./pymlb/ ./pymlb/fetcher.py ./demos ./demos/demo.py In demo.py I have: from pymlb import fetcher However, it fails b/c pymlb is up a folder. It's also NOT installed as a module in my module directory because it's a development effort and I don't want to run setup.py to install them. See what I mean? What's the work around here? -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
Richard Heathfield wrote: if the OP had just been smarter. Er, no, I didn't have that in mind at all. In some cultures, implying that someone is illiterate suggests not smart. There is a formal disconnect there but possibly you can see how someone might infer that. At least I found out what your choice was, HTML, same as mine. -- http://mail.python.org/mailman/listinfo/python-list
Python2.6 + win32com crashes with unicode bug
I have automated image generation with Python, win32com and Visio5.0. This works well upto Python2.5 but fails with Python 2.6. Short term solution is to return to 2.5 :-(. I have reproduced the bug below with a minimum of Python lines. Below the problem the working example from 2.5 kind regards, Gerrit ---minimal session reproducing the bug--- Python 2.6.3 (r263:75183, Oct 5 2009, 14:41:55) [MSC v.1500 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. IDLE 2.6.3 from win32com.client.dynamic import Dispatch v = Dispatch(Visio.Application) d = v.Documents.OpenEx(D:/temp/test.vsd,8) Traceback (most recent call last): File pyshell#2, line 1, in module d = v.Documents.OpenEx(D:/temp/test.vsd,8) File C:\Python26\lib\site-packages\win32com\client\dynamic.py, line 467, in __getattr__ if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr) File C:\Python26\lib\site-packages\win32com\client\dynamic.py, line 295, in _make_method_ methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) File C:\Python26\lib\site-packages\win32com\client\build.py, line 297, in MakeFuncMethod return self.MakeDispatchFuncMethod(entry, name, bMakeClass) File C:\Python26\lib\site-packages\win32com\client\build.py, line 318, in MakeDispatchFuncMethod s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):' File C:\Python26\lib\site-packages\win32com\client\build.py, line 604, in BuildCallList argName = MakePublicAttributeName(argName) File C:\Python26\lib\site-packages\win32com\client\build.py, line 542, in MakePublicAttributeName return filter( lambda char: char in valid_identifier_chars, className) File C:\Python26\lib\site-packages\win32com\client\build.py, line 542, in lambda return filter( lambda char: char in valid_identifier_chars, className) UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 52: ordinal not in range(128) ---no problem with 2.5--- Python 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. IDLE 1.2 from win32com.client.dynamic import Dispatch v = Dispatch(Visio.Application) d = v.Documents.OpenEx(D:/temp/test.vsd,8) ---configuration data--- Windows XP SP3 ASUS 1106HA (11.6 EEE PC) Visio 5.0 -- http://mail.python.org/mailman/listinfo/python-list
Re: disutils, project structure developing - n00b question
On Thu, Oct 29, 2009 at 2:42 PM, Wells we...@submute.net wrote: So I have my project partitioned like so: ./setup.py ./pymlb/ ./pymlb/fetcher.py ./demos ./demos/demo.py In demo.py I have: from pymlb import fetcher However, it fails b/c pymlb is up a folder. It's also NOT installed as a module in my module directory because it's a development effort and I don't want to run setup.py to install them. See what I mean? What's the work around here? In order for from pymlb import fetcher no work you must make the './pymlb' directory into a package by adding a file called __init__.py (it can be empty.) Then make sure the top directory (i.e. '.' in your example) is in the python PATH. There are a couple of ways to do that: 1.) Hack it in demo.py before importing fetcher (i.e. import sys; sys.path.append(string absolute path of '.')) 2.) Use the PYTHONPATH environment variable. 3.) Use a .pth file (See http://docs.python.org/library/site.html) You'll have to figure out what directory to put it in (on my system '/usr/lib/python2.5/site-packages' works) Note, although it's not mentioned in the site module docs you can include an absolute path and it will be added to sys.path. There is additional good information about .pth files on Bob Ippolito's blog: http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/ Be sure to read the comments too. 4.) Probably some other method(s) that someone else will tell you... ;] HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: disutils, project structure developing - n00b question
On Thu, Oct 29, 2009 at 3:45 PM, Simon Forman sajmik...@gmail.com wrote: In order for from pymlb import fetcher no work you must make the s/no/to/ D'oh! -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
* Ethan Furman: Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, from now on I’ll always use from __future__ in any program that uses print. Sorry, but I think that hiding such concerns is a real disservice. The disservice is in teaching folks to use non-standard elements, which is (sort-of) what __future__ is. Changes to the language are experimented with in __future__ and can change from one release to the next. If memory serves, the with statement is an example of having different behavior when it was moved out of __future__ and made a standard part of the language. That's a bit of a straw man argument. I used from __future__ to write forward-compatible calls of print, so that those examples would not mysteriously work or not depending on the Python version. I did not use it to access experimental features. However, I didn't know then that the language has changed so much in 3.x that it isn't practical to aim at general forward compatibility or version independence. And I didn't know until your comment above that some features, apparently, only exist in __future__ but are not part of the language, subject to change. Is there a current example? And, just a suggestion, would it not be better to have a different name for such experimental (as opposed to future language version) features, e.g. from __experimental__, differentiating between forward compatibility in e.g. production code, and trying out experimental subject-to-change features? Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedback wanted on programming introduction (Python in Windows)
* Richard Heathfield: The best way is the simplest technology that will do the job properly. If that truly is PDF, okay, use PDF. But it is hard for me to envisage circumstances where Web content is best presented in that way. Google docs sharing. It made a mess of my *Word* documents. g Cheers hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list