Karrigell version 2.2.5 - licence changes to BSD
A new version of the web framework Karrigell (http://www.karrigell.com) has been released The main changes in this version are : - the Open Source licence changes from GPL to BSD - logging management (written by Radavan Garabik) : new options loggingFile and loggingParameters - new options in configuration file : debug manages the Debug button when exceptions occur in scripts ; reloadModules specifies if modules must be reloaded at each request Bug fixes - option encodeFormData was not managed correctly (bug report by Helmut Jarausch) - cookies attributes (path, expiry date...) was erased at each request. 2 variables now manage cookies : COOKIE is the cookies received from the browser ; SET_COOKIE is used by a script to set a cookie in the browser. Bug report by Joe Correia - for security reasons, mask modules k_session and KarrigellRequestHandler for virtual hosts Download page : http://sourceforge.net/project/showfiles.php?group_id=67940 Tutorial : http://quentel.python-hosting.com/wiki -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Updated Cygwin Package: python-2.4.3-1
New News: === I have updated the version of Python to 2.4.3-1. The tarballs should be available on a Cygwin mirror near you shortly. The following are the notable changes since the previous release: o upgrade to Python 2.4.3 o apply SourceForge patch #1490224 to fix the time.altzone DST offset problem Old News: === Python is an interpreted, interactive, object-oriented programming language. If interested, see the Python web site for more details: http://www.python.org/ Please read the README file: /usr/share/doc/Cygwin/python-2.4.3.README since it covers requirements, installation, known issues, etc. Standard News: To update your installation, click on the Install Cygwin now link on the http://cygwin.com/ web page. This downloads setup.exe to your system. Then, run setup and answer all of the questions. If you have questions or comments, please send them to the Cygwin mailing list at: cygwin@cygwin.com . *** CYGWIN-ANNOUNCE UNSUBSCRIBE INFO *** If you want to unsubscribe from the cygwin-announce mailing list, look at the List-Unsubscribe: tag in the email header of this message. Send email to the address specified there. It will be in the format: [EMAIL PROTECTED] If you need more information on unsubscribing, start reading here: http://sources.redhat.com/lists.html#unsubscribe-simple Please read *all* of the information on unsubscribing that is available starting at this URL. Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Large Dictionaries
Claudio Grondi wrote: Chris Foote wrote: Klaas wrote: 22.2s 20m25s[3] 20m to insert 1m keys? You are doing something wrong. I've put together some simplified test code, but the bsddb module gives 11m for 1M keys: I have run your code for the bsddb on my P4 2.8 GHz and have got: Number generator test for 100 number ranges with a maximum of 3 wildcard digits. Wed May 17 16:34:06 2006 dictionary population started Wed May 17 16:34:14 2006 dictionary population stopped, duration 8.4s Wed May 17 16:34:14 2006 StorageBerkeleyDB population started Wed May 17 16:35:59 2006 StorageBerkeleyDB population stopped, duration 104.3s Surprising here, that the dictionary population gives the same time, but the BerkeleyDB inserts the records 6 times faster on my computer than on yours. I am running Python 2.4.2 on Windows XP SP2, and you? Fedora core 5 with ext3 filesystem. The difference will be due to the way that Windows buffers writes for the filesystem you're using (it sounds like you're using a FAT-based file system). Number generator test for 100 number ranges with a maximum of 3 wildcard digits. Wed May 17 22:18:17 2006 dictionary population started Wed May 17 22:18:26 2006 dictionary population stopped, duration 8.6s Wed May 17 22:18:27 2006 StorageBerkeleyDB population started Wed May 17 22:29:32 2006 StorageBerkeleyDB population stopped, duration 665.6s Wed May 17 22:29:33 2006 StorageSQLite population started Wed May 17 22:30:38 2006 StorageSQLite population stopped, duration 65.5s As I don't have SQLite installed, it is interesting to see if the factor 10 in the speed difference between BerkeleyDB and SQLite can be confirmed by someone else. Why is SQLite faster here? I suppose, that SQLite first adds all the records and builds the index afterwards with all the records there (with db.commit()). SQLite is way faster because BerkeleyDB always uses a disk file, and SQLite is in RAM only. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Reference Counts
Hi All, I am a new user of Python and am having a bit of problem understanding the Reference counting and memory leakage issues. Requesting help from experienced users I wrote the following simple program. #!/usr/bin/python import sys global a print Total Reference count at the start =,sys.gettotalrefcount() a=1 print a ref count =,sys.getrefcount(a) b=a print a ref count =,sys.getrefcount(a) del a del b print Total Reference count at the end =,sys.gettotalrefcount() I executed it. I am seeing the following. Total Reference count at the start = 16538 a ref count = 49 a ref count = 50 Total Reference count at the end = 16540 [6416 refs] There are a few questions that I am having on this. (1) Why should 'a' reference count be 49 before I even made an assignment ? (2) The Total Reference count at the end has increased by 2 . Why ? Am I leaking memory ? (3) I have read somewhere that an increase in sys.gettotalrefcount() is indicative of a memory leak ? Aint that correct ? Thanks for the help. Bye, raghavan V -- http://mail.python.org/mailman/listinfo/python-list
Re: Reference Counts
Am Donnerstag 18 Mai 2006 08:28 schrieb raghu: #!/usr/bin/python import sys global a print Total Reference count at the start =,sys.gettotalrefcount() a=1 print a ref count =,sys.getrefcount(a) b=a print a ref count =,sys.getrefcount(a) del a del b print Total Reference count at the end =,sys.gettotalrefcount() ... Total Reference count at the start = 16538 a ref count = 49 a ref count = 50 Total Reference count at the end = 16540 [6416 refs] There are a few questions that I am having on this. (1) Why should 'a' reference count be 49 before I even made an assignment ? Because 1 is a special integer. Small integers (-1..100, but this depends on the Python version) are interned, similar to strings, so there are already references to the integer object before you assign it to a (at least one; 1 is such a magic constant that you can guess that there are already other references to it in other places of the stdlib, which has loaded when your script runs, so it's not hard to imagine that 1 already has 48 references outside of your program). (2) The Total Reference count at the end has increased by 2 . Why ? Am I leaking memory ? No. I'd guess that the names a and b were interned as strings (as they are used as dict lookup keys in the globals() dict), and you have one reference to each interned object. (3) I have read somewhere that an increase in sys.gettotalrefcount() is indicative of a memory leak ? Aint that correct ? Yes. It is correct if consecutive runs of your algorithm always yield a higher sys.gettotalrefcount() for each run. In this case (where you run your algorithm only once), it isn't. It just shows you some of the innards of the Python runtime machinery. Execute the following script to see the result of a memory leak: import sys x = {} i = 0 def test(): global x, i x[i] = test i += 1 # Forget to clean up x... LEAK a reference to test! for j in xrange(1): print Before, j, :, sys.gettotalrefcount() test() print After, j, :, sys.gettotalrefcount() And, the following (slightly altered) program doesn't exhibit this memory leak: import sys x = {} i = 0 def test(): global x, i x[i] = test i += 1 del x[i-1] # Properly clean up x. for j in xrange(1): print Before, j, :, sys.gettotalrefcount() test() print After, j, :, sys.gettotalrefcount() I don't have a debug build of Python at hand, so I can't run them now. But, if you're interested in the results, you'll certainly do that yourself. ;-) --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
There are some difference which are quite essential. First of all I dont se how you set attributes with that and then I dont see how you can mix python code with the creation. So how do you do this: root = ET.Element(html) *!*root: *!*head(head): *!*title(title): for i in sections: !*! section(): *=*Text = section[i] -- http://mail.python.org/mailman/listinfo/python-list
Python - Web Display Technology
I am trying to figure out why so little web development in Python uses Flash as a display technology. It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a far more powerful and elegant display technology. On the other hand, HTML/JS seems clunky and antiquated. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. Anyways, what are the technical reasons for this? http://SamFeltus.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
Am Donnerstag 18 Mai 2006 08:51 schrieb SamFeltus: I am trying to figure out why so little web development in Python uses Flash as a display technology. It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a far more powerful and elegant display technology. On the other hand, HTML/JS seems clunky and antiquated. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. Anyways, what are the technical reasons for this? There no Python specific reason, but I refrain from using Flash because it requires more than just the usual browser (which is available everywhere). Using HTML/CSS/JS, I can make it so that the information I want to give to the user displays right on pretty much every computer that's available out there (think PS3), when I resort to techniques such as Flash or Java, I limit the number of people I can reach. Take me for example: I'm running Linux on AMD64, and there's no proper Flash implementation yet which I can plug into my Firefox. So, I'm out on any Flash page. If you want to exclude me from viewing the information you want to present, fine, use Flash. If you don't, don't use it. And: the web is a platform to offer _information_. Not to offer shiny graphics/sound, which is the only benefit Flash has to offer. To sum it up: Flash/Java considered evil here. But that's just my 5 cents. --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
But you cant mix python code in there when creating the nodes. That is when it gets quite ugly an unreadable according to me. But I also relly do think that this: # build a tree structure root = ET.Element(html) *!*root: *!*head(head): *!*title(title): *=*text = Page Title *!*body(body): *=*bgcolor = #ff *=*text = Hello, World! Especially if you start having deeper hierachies like. But the big other plus is that you can have any python code in beetween. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
Actually we did start of with YAML, but realised that we need to have the power of a programming language aswell. But I wanted to come up with something that looked very clos to YAML since I find it quite readable. I have implemented the syntax, but as a preprocessor for python and it works quite nice. Cheers, T -- http://mail.python.org/mailman/listinfo/python-list
Re: Any pointers/advice to help learn CPython source?
[EMAIL PROTECTED] wrote: Anyone have any good advice to someone interested in learning about innards of Python implementation? e.g. What is best place to start? Where can I get a 10,000 ft. overview of general structure? Anyone written docs on helping do this? How did other people successfully make it through? Depends on what you want to get out of it. There are only a handful of top level directories that are interesting: Include - include files Objects - all Python objects (list, dict, int, float, functions, and many others) Python - core interpreter and other support facilities Lib - Python stdlib (Lib/test is the test suite) Modules - C extension modules Parser - simple parser/tokenizer The last three probably aren't interesting. However, if you are interested in the GC (or SRE) implementation, then you should look under Modules as gcmodule.c and _sre.c are there. So are a bunch of others. Include/ isn't particularly interesting. Objects/ isn't too interesting either from the standpoint of learning about the interpreter. Although the object implementations may be interesting in their own right. Each object is in an unsurprising file named something like: listobject.c or intobject.c. That leaves Python/ which is where the real innards are. If you are interested in the interpreter, then Python/ceval.c is pretty much it. The compiler is primarly in Python/compile.c, but also see Python/ast.c (2.5 only) and Python/symtable.c. All the global builtin functions are in Python/bltinmodule.c. Import support is in Python/import.c. Most of the other files in Python/ are small and/or platform specific. They probably aren't as interesting in general. n -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
Heiko Wundram enlightened us with: And: the web is a platform to offer _information_. Not to offer shiny graphics/sound [...] Many would disagree... Not me, but I know a lot of people that would. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
SamFeltus enlightened us with: I am trying to figure out why so little web development in Python uses Flash as a display technology. There are a couple of reasons: - Flash is bad for websites that are 100% done inside the Flash movie. In such a case the back-button doesn't work anymore, which is a major usability issue. - In the above case, bookmarking a page doesn't work either. - You need an extra plugin. Even though it's available for the major OSses and hardware systems, it's not available for every platform that can run a browser. - The plugin is closed-source. - The format that is the source for the SWF files is a closed, proprietary format. - Many user-interface widgets are generally badly implemented in Flash. For instance, on many scrolling thingies, the scrollwheel doesn't work. Or, the regular scrollwheel works, but for scrolling horizontally the tilt wheel isn't supported. Another example: sometimes it's only clear what a link points to when you hover over it (revealing a text behind an image, for instance), which is impossible on some devices (think handhelds with a touch-screen). - Search engines don't understand Flash movies. They are also unable to link directly to relevant pages. - Many more reasons... It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a far more powerful and elegant display technology. Flash is indeed more powerful, but not elegant at all. On the other hand, HTML/JS seems clunky and antiquated. It's getting a lot better. Try using XHTML 1.1 and only up to date, platform/browser-independent JavaScript, it'll be much better. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. It's absolute crap when it comes to coding. ActionScript stands almost perpendicular to Python when it comes to the Python way of thinking. In ActionScript there are many ways of doing the same thing, none of which are obvious. Another thing is that when you call a function that doesn't exist, that call is silently ignored. The same holds for getting the value of a non-existing variable. This makes debugging very difficult. http://SamFeltus.com Your site looks quite unstyled without flash... And I don't have Flash player 8... Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Job Offer (Herzelia, Israel)
Job Title: Python Application Expert Company: Logia (http://www.logiamobile.com) Contact: Lior Rudnik ([EMAIL PROTECTED]) Job Description: * Design Development of our leading product's PC client application * Development in Python Job Requirements: * At least 4 years of experience developing client applications * Extensive knowledge and experience in Object Oriented and design methodologies * Fast learner, able to study the impact of new technologies and adapt accordingly * Excellent communication skills, ability to handle multiple interfaces * High problem analysis and solving skills * Ability to work in a very challenging dynamic environment Advantage (nice to have) * Experience developing python * Experience with wxPython and/or wxWidgets * Experience with open source * Experience with content - Video, Audio * Experience with VoIP -- http://mail.python.org/mailman/listinfo/python-list
Re: Reference Counts
Heiko, Thanks for the explanation. I understood the idea of 1 being interned. Also I understood the globals vars having a reference in the internal dict. I ran the leaky version of the program and yes...it showed a progressively increasing totalrefcount as below. Before 0 : 16579 After 0 : 16581 Before 1 : 16581 After 1 : 16583 Before 2 : 16583 After 2 : 16585 Before 3 : 16585 After 3 : 16587 Before 4 : 16587 After 4 : 16589 Before 5 : 16589 After 5 : 16591 Before 6 : 16591 After 6 : 16593 Before 7 : 16593 After 7 : 16595 Before 8 : 16595 After 8 : 16597 Before 9 : 16597 After 9 : 16599 Before 10 : 16599 After 10 : 16601 Before 11 : 16601 After 11 : 16603 Before 12 : 16603 After 12 : 16605 Before 13 : 16605 After 13 : 16607 Before 14 : 16607 After 14 : 16609 Before 15 : 16609 However, the 'non-leaky' one showed a funny trend ...it kept increasing the totalrefcount for five iterations (see 1 thru 5) and then dropped down by 5 ( See Before 5 : 16584 After 5 : 16580 ) suddenly and again increase as shown below. However, at the time when the script finsished execution, we were not too far from the starting totalrefcount (16584 from 16579), Before 0 : 16579 After 0 : 16580 Before 1 : 16580 After 1 : 16581 Before 2 : 16581 After 2 : 16582 Before 3 : 16582 After 3 : 16583 Before 4 : 16583 After 4 : 16584 Before 5 : 16584 After 5 : 16580 Before 6 : 16580 After 6 : 16581 Before 7 : 16581 After 7 : 16582 Before 8 : 16582 After 8 : 16583 Before 9 : 16583 After 9 : 16584 Before 10 : 16584 After 10 : 16580 Before 11 : 16580 After 11 : 16581 Before 12 : 16581 After 12 : 16582 Before 13 : 16582 After 13 : 16583 Before 14 : 16583 After 14 : 16584 Before 15 : 16584 What is the Mystery behind the increase and the subsequent drop ? Thanks. Raghavan V -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)
On Wed, 17 May 2006 21:37:14 +0800, Andy Sy wrote: If tabs are easily misunderstood, then they are a MISfeature and they need to be removed. From the Zen of Python: Explicit is better than implicit... In the face of ambiguity, refuse the temptation to guess... Special cases aren't special enough to break the rules... Exactly. How many levels of indentation does 12 spaces indicate? It could be 1,2,3,4,6 or 12. If you say it's 3 then you are _implying_ that each level is represented by 4 spaces. How many levels of indentation is 3 tabs? 3 levels in any code that you will find in the wild. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reference Counts
Am Donnerstag 18 Mai 2006 09:33 schrieb raghu: However, the 'non-leaky' one showed a funny trend ...it kept increasing the totalrefcount for five iterations (see 1 thru 5) and then dropped down by 5 ( See Before 5 : 16584 After 5 : 16580 ) suddenly and again increase as shown below. However, at the time when the script finsished execution, we were not too far from the starting totalrefcount (16584 from 16579), The cyclic garbage collector isn't run after every byte-code instruction, but only after several have executed (because of performance issues). That's why you see an increase in reference counts, until the interpreter calls the garbage collector, which frees the object cycles, and so forth. I don't exactly know what the magic constant (i.E. number of byte-code instructions between subsequent runs of the garbage collector) is, but I presume it's somewhere in the order of 100 bytecode instructions. Why you need the cyclic gc to clean up the data structures my sample creates is beyond be, but I'd guess it has something to do with the internal structure of dicts. Anyway, you can easily test this hypothesis by calling gc.collect() explicitly in the main loop after test() has run (remember to import gc... ;-)). This forces a run of the cyclic gc. If funny pattern still remains I wouldn't know of any other explanation... ;-) But, as long as references aren't being leaked (you don't see the drop in references after every x instructions), there's nothing to worry about. --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: getting the value of an attribute from pdb
Hello Gary, (Pdb) p root.title bound method Tk.wm_title of Tkinter.Tk instance at 0xb717c16c (Pdb) p root.title[Tk.wm_title] Looks like title is a function, try p root.title() HTH, Miki http://pythonwise.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make the program notify me explicitly
Hello hankssong, You can alert yourself in many methods: * Open a message dialog - Use Tkinter or other GUI toolkit (such as wxPython) * Write yourself an email - Use email + smtplib library modules * Provide an RSS feed and read it - Use HTTPServer library * Write yourself an instant message - see msnpy and other libraries HTH, Miki http://pythonwise.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to couple pyunit with GUI?
Hello volcano, http://pyunit.sourceforge.net/ has unittestgui.py (bit old though) HTH, Miki http://pythonwise.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python for a CAD program
baalbek wrote: CAD systems available today (Autocad, Archicad, Architectural Desktop, etc) have one huge flaw: they don't store data to a SQL database, but to binary files. There's a reason for this. Most CAD data is not in a form (First Normal Form) suitable for a relational database. In addition, the sheer number of objects involved in each operation brings performance to its knees. Finally, most RDBMS provide (and are optimized for) transactional semantics -- for a CAD system, this is wasted overhead. People dabbled in this years back but quickly discovered just how different they are. If you have access to it, you should take a peek at the source for the OpenAccess database. Although this is for chips, I suspect some of the same design principles would go into designing a CAD database. -- http://mail.python.org/mailman/listinfo/python-list
Re: using wxPython events inside a loop
Hello BigSmoke, You can process one at a time in an OnIdle handler, this way you'll work only when the application is doing nothing. HTH, Miki, http://pythonwise.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Terry Reedy a écrit : Christophe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there a good reason why when you try to take an element from an already exausted iterator, it throws StopIteration instead of some other exception ? Yes. . . To distinguish the control message I am done yielding values, as per the code specification (so don't bother calling me again). from error messages that say Something is wrong, I cannot yield values and give up. In other words, to distinguish expected correct behavior from unexpected incorrect behavior. This is essential for the normal and correct use of iterators. You talk about expected behaviour and my expected behaviour is that an iterator should not be usable once it has raised StopIteration once. def f(i): ... print list(i) ... print list(i) ... f(iter(range(2))) [0, 1] [] As per specification. Specifications sometimes have bugs too. I am guessing that you want the first list() call to terminate normally and return a list, which requires exhausted i to raise StopIteration, while you want the second list() to not terminate but raise an exception, which requires exhausted i to raise something other than StopIteration. Tough. Exactly. This would be a sane way to handle it. One solution is call list(i) exactly once: def f(i): li = list(i) print li print li Ok, call me stupid if you want but I know perfectly well the solution to that problem ! Come on, I was showing example code of an horrible gotcha on using iterators. Instead of saying that all works as intended could you be a little helpful and tell me why it was intended in such an obviously broken way instead ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python for a CAD program
Paddy wrote: Unfortunately, Cadence got their first with their DFII environment for Schematic based design and their Lisp based language SKILL Well, SKILL (a Franz Lisp derivative) is very old and has some peculiar design quirks. Interfacing with anything not written by Cadence or not written in SKILL is painful, at best. Interestingly, Python is being used as an extension language for the OpenAccess database. LSI Logic had a Python wrapper for 2.0 (it looked like they used SWIG). I had written one for 2.1, but never was able to release it before my company was acquired by Cadence (and that project quashed). There is some interest... just not quite critical mass. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell if function was passed a list or a string?
import types type() is types.ListType False type() is types.StringType True type([]) is types.StringType False type([]) is types.ListType True This is even worse than an 'isinstance' check; it refuses even subclasses of the types you accept, breaking polymorphism *and* inheritance. And also note the following comment in the types module of the standard library that was imported above: # StringTypes is already outdated. Instead of writing type(x) in # types.StringTypes, you should use isinstance(x, basestring). But # we keep around for compatibility with Python 2.2. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code ('semantic' vs. arbitrary indentation)
Carl J. Van Arsdall a écrit : glomde wrote: But If you work in a team it is kind of hard to make sure that everybody use tabs and not spaces. And it is not very easy to spot either. The converse can also be said, it's difficult to make sure everyone uses spaces and not tabs. I think we've just about beat this discussion to death... nice work everyone! No, it's really easy : a simple precoomit hook which will refuse any .py file with the \t char in it and it's done ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)
PoD wrote: How many levels of indentation does 12 spaces indicate? It could be 1,2,3,4,6 or 12. If you say it's 3 then you are _implying_ that each level is represented by 4 spaces. By reading the code I can see how many levels of indentation it represents. How many levels of indentation is 3 tabs? 3 levels in any code that you will find in the wild. No. That is precisely the problem: there is code in the wild which contains mixed space and tab indentation, and any time that happens 3 tabs could mean any number of indentations. Now, I just know someone is going to challenge me over my assertion that there really could be code with mixed spaces and tabs out there, so here are a few examples found by grepping a Plone Products folder. All the projects below use spaces almost everywhere for indentation, but it looks like a few tabs slipped through. http://svn.plone.org/view/archetypes/Archetypes/trunk/BaseUnit.py?rev=5111view=auto contains tabs at the start of two lines. Fortunately these are continuation lines so it doesn't really matter how you display them. I think they are intended to be displayed with tab-size=8. http://svn.plone.org/view/archetypes/Archetypes/trunk/Storage/__init__.py?rev=4970view=auto One tab used for indentation. The block is only one line long so the code doesn't break whatever tabsize you use, but visually it would appear the intended tabsize is 0. http://svn.plone.org/view/plone/CMFPlone/trunk/skins/plone_scripts/computeRelatedItems.py?rev=9836view=auto A tab is used for two levels of indentation. Anything other than tabsize=8 would cause a syntax error. http://svn.plone.org/view/plone/CMFPlone/trunk/skins/plone_scripts/computeRoleMap.py?rev=9836view=auto Lots of tabs, most but not all on continuation lines. The two which aren't are on single line blocks with a single tab representing two indents. CMFPlone\tests\testInterfaces.py CMFPlone\tests\testTranslationServiceTool.py ExternalEditor (various files) kupu (spellcheck.py) and finally, at the end of my Plone Products directory I found this beauty where I've replaced the tab characters with tab to make them visible: svn://svn.zope.org/repos/main/Zelenium/trunk/scripts/tinyWebServer.py if __name__ == '__main__': tabport = PORT tabif len(sys.argv) 1: tabport = int(sys.argv[1]) tab server_address = ('', port) tabhttpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler) tabprint serving at port, port tabprint To run the entire JsUnit test suite, open tabprint http://localhost:8000/jsunit/testRunner.html?testPage=http://localhost:8000/tests/JsUnitSuite.htmlautoRun=true; tabprint To run the acceptance test suite, open tabprint http://localhost:8000/TestRunner.html; tabwhile not HTTPHandler.quitRequestReceived : tabhttpd.handle_request()tab tab This is a genuine example of code in the wild which will look like syntactically valid Python at either tab-size=4 or tab-size=8, but if you view it at tab-size=4 you will see different block indentation than the Python interpreter uses at tab-size=8. At tab-size=4 it reads: if __name__ == '__main__': port = PORT if len(sys.argv) 1: port = int(sys.argv[1]) server_address = ('', port) httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler) print serving at port, port print To run the entire JsUnit test suite, open print http://localhost:8000/jsunit/testRunner.html?testPage=http://localhost:8000/tests/JsUnitSuite.htmlautoRun=true; print To run the acceptance test suite, open print http://localhost:8000/TestRunner.html; while not HTTPHandler.quitRequestReceived : httpd.handle_request() but at tab-size=8 it reads: if __name__ == '__main__': port = PORT if len(sys.argv) 1: port = int(sys.argv[1]) server_address = ('', port) httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler) print serving at port, port print To run the entire JsUnit test suite, open print http://localhost:8000/jsunit/testRunner.html?testPage=http://localhost:8000/tests/JsUnitSuite.htmlautoRun=true; print To run the acceptance test suite, open print http://localhost:8000/TestRunner.html; while not HTTPHandler.quitRequestReceived : httpd.handle_request() I wouldn't have a problem with tabs if Python rejected mixed indentation by default, because then none of the code above would execute. But it doesn't. :( Anyone got a subversion checkin hook to reject mixed indentation? I think that big repositories like Zope and Plone could benefit from it. I just ran the same grep on the Python source tree. Not a tab in sight. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: There are some difference which are quite essential. First of all I dont se how you set attributes with that and Use dicts as childs. then I dont see how you can mix python code with the creation. You can put any python expression in there, and in the Node class you can do what you want. Seems that you are after a templating-system. Well, there are plenty of them available, including yours. A preprocessor is nothing but a template system - see TurboGears-utilized KID (http://kid.lesscode.org/) for example, it generates python files. And way more readable, because you are working in the domain of your application (HTML) instead of some crude syntax that is neither fish or flesh. Counterquestion: how do you create this: ?xml version='1.0' encoding='utf-8'? ?python from urllib import urlopen from elementtree.ElementTree import parse, tostring feed = 'http://naeblis.cx/rtomayko/weblog/index.atom' root = parse(urlopen(feed)).getroot() ns = '{http://purl.org/atom/ns#}' title = root.findtext(ns + 'title') ? html xmlns=http://www.w3.org/1999/xhtml; xmlns:py=http://purl.org/kid/ns#; head title py:content=title / /head body bgcolor=blue text=yellow h1 py:content=title / table cellpadding=4 cellspacing=4 tr py:for=i, entry in enumerate(root) py:if=entry.tag == ns + 'entry' td py:attrs=bgcolor=('white', 'yellow')[i % 2] a py:attrs=href=entry.find(ns + 'link').attrib['href'] py:content=entry.findtext(ns + 'title') / /td /tr /table /body /html Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)
PoD a écrit : On Wed, 17 May 2006 21:37:14 +0800, Andy Sy wrote: If tabs are easily misunderstood, then they are a MISfeature and they need to be removed. From the Zen of Python: Explicit is better than implicit... In the face of ambiguity, refuse the temptation to guess... Special cases aren't special enough to break the rules... Exactly. How many levels of indentation does 12 spaces indicate? It could be 1,2,3,4,6 or 12. If you say it's 3 then you are _implying_ that each level is represented by 4 spaces. Actually, who said you had to always use the same number of spaces to indent ? 12 = 6 + 6 = 4 + 4 + 4 but also 12 = 2 + 10 = 1 + 1 + 3 + 3 + 4 :D How many levels of indentation is 3 tabs? 3 levels in any code that you will find in the wild. No, it could be 3 levels or 3 tabs per level or 2 tabs for the first level and 1 tab for the second ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code ('semantic' vs. arbitrary indentation)
Edward Elliott wrote: What really should happen is that every time an editor reads in source code, the code is reformatted for display according to the user's settings. The editor becomes a parser, breaking the code down into tokens and emitting it in a personally preferred format. I completely agree, and I guess that is what I was groping towards in my remarks about using modern editing tools. At the same time I would be resist any move towards making source files less huiman-readable. There will still be times when those tools aren't available (e.g. for people working on embedded s/w or legacy systems), and that's when having ASCII source with tabbed indentation would be so useful. But it looks, sadly, like we're fighting a rearguard action on that one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: i I would like to extend python so that you could create hiercical [...] # build a tree structure root = ET.Element(html) *!*root: *!*head(head): *!*title(title): *=*text = Page Title *!*body(body): *=*bgcolor = #ff *=*text = Hello, World! I think that with the added syntax you get better view of the html page. Repeating things dissapears and you get indentation that corresponds to the tree. I think it is very pythonic IMHO. It could be done quite generic. If the variable, object after '*!*' must support append method and if you use '*=*' it must support __setitem__ Any comments? I personally dislike the nested-indented-brackets type of code given in other replies, and i think your suggestion has a certain appeal - 'What you see is what you mean' . But it's not Python. You also repeat yourself: head(head), title(title), body(body) What about this: # build a tree structure root = ET.Element(html) !root !head !title if A is True: text = Page A else: text = Page B !body bgcolor = #ff text = Hello, World! mmm...yamlthon? yython...:-) All the best Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make the program notify me explicitly
Ben Finney , Miki ,thanks a lot! may be message dialog is the best way to let me be informed! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make the program notify me explicitly
Ben Finney , Miki ,thanks a lot! may be message dialog is the best way to let me be informed! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to customize getattr(obj, prop) function ?
Pierre wrote: Hi, Sorry in advance, english is not my main language :/ I'd like to customize the result obtained by getattr on an object : if the object has the requested property then return it BUT if the object doesn't has actually this property return something else. So implement __getattr__(self, name). In my case, I can't use getattr(object, property, default_value). Why so ? I tried to write a class with a __getattr__ method and even a __getattribute__ method but this doesn't do what I want Warning: __getattribute__ will take over normal attribute lookup. It can be really tricky. Anyway, you don't need it for your use case - just stick with __getattr__() and you'll be ok. Maybe I didn't correctly understand this : http://docs.python.org/ref/attribute-access.html Here is a piece of my code : = class myclass: Make this : class MyClass(object): docstring a = 'aa' b = 'bb' a and b are class attributes, not instance attributes. If you want per-instance attributes (which is the most usual case...), you need to define them in a method - usually the __init__() method: def __init__(self): self.a = 'aa' self.b = 'bb' def __getattr___(self, ppt): getattr if hasattr(self, ppt): return self.ppt __getattr__() will be called only if the normal attribute lookup fails. So calling hasattr(self, ...) in __getattr__ is useless. More than this: the fact that __getattr__() has benn called means that normal lookup has already failed, so hasattr() will end up calling __getattr__()... else: return my custom computed result (snip) if __name__ == __main__: d = myclass() p1 = getattr(d, a) You do understand that getattr(d, a) is the same as d.a, don't you ? print p1 p2 = getattr(d, b) print p2 p3 = getattr(d, c) print p3 I get an AttributeError when accessing to the property named c. Any explanation/solution to my problem ? 1/ use new-style classes 2/ only implement __getattr__() here's a minimal working example: class MyClass(object): def __init__(self, default='default'): self.a = 'aa' self.b = 'bb' self._default = default def __getattr__(self, name): return self._default m = MyClass() m.a m.b m.toto HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
SamFeltus wrote: I am trying to figure out why so little web development in Python uses Flash as a display technology. It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a far more powerful and elegant display technology. On the other hand, HTML/JS seems clunky and antiquated. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. Anyways, what are the technical reasons for this? - Flash is a proprietary technology requiring a proprietary plugin. - There aint actually no working Flash plugin for Mozilla on a 64bit processor - I just *can't* read Flash anims on my computer - Flash is meant to display animations, not web content - Flash content is not indexed by search engines - Flash content cannot be manipulated by normal text/HTML/XML tools (x)html/css/js is neither 'clunky' nor 'antiquated' (and FWIW, Flash is based on ActionScript, which is mostly javascript...). -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: i I would like to extend python so that you could create hiercical tree structures (XML, HTML etc) easier and that resulting code would be more readable than how you write today with packages like elementtree and xist. I dont want to replace the packages but the packages could be used with the new operators and the resulting IMHO is much more readable. The syntax i would like is something like the below: # Example creating html tree '*!*' is an operator that creates an new node, '*=*' is an operator that sets an attribute. (snip) With syntactical sugar: # build a tree structure root = ET.Element(html) *!*root: *!*head(head): *!*title(title): *=*text = Page Title *!*body(body): *=*bgcolor = #ff *=*text = Hello, World! What about using XXXdata/XXX for nodes and '=' for attributes ? Would look like: html head titlePage Title/title /head body bgcolor='#ff' Hello World /body /html I think that with the added syntax you get better view of the html page. indeed !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to customize getattr(obj, prop) function ?
I don't want to use getattr(object, property, default_value) because I'm using external code and I don't want to modify or patch it. In this code, the call is getattr(object, property). On my objects, I must provide default values depending on the property that was requested, the default value is not always the same. And Yes I understand that obj.a is equivalent to getattr(obj, 'a') BUT the difference between class attribute and instance attribute... :S -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
[glomde] i I would like to extend python so that you could create hiercical tree structures (XML, HTML etc) easier and that resulting code would be more readable than how you write today with packages like elementtree and xist. Any comments? Yes: it's ugly and unnecessary. Why would you want to change the language syntax just to make it easier to express markup directly in program code? Javascript just made that mistake with E4X: IMHO, it makes for some of the ugliest code. E4X reminds me of that Microsoft b*stardisation, XML Data Islands. http://www.w3schools.com/e4x/e4x_howto.asp http://en.wikipedia.org/wiki/E4X For a nice pythonic solution to representing markup directly in python code, you should check out stan. http://divmod.org/users/exarkun/nevow-api/public/nevow.stan-module.html Here's a nice stan example, taken from Kieran Holland's tutorial http://www.kieranholland.com/code/documentation/nevow-stan/ aDocument = tags.html[ tags.head[ tags.title[Hello, world!] ], tags.body[ tags.h1[ This is a complete XHTML document modeled in Stan. ], tags.p[ This text is inside a paragraph tag. ], tags.div(style=color: blue; width: 200px; background-color: yellow;) [ And this is a coloured div. ] ] ] That looks nice and simple, and no need to destroy the elegance of python to do it. regards, -- alan kennedy -- email alan: http://xhaus.com/contact/alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Process forking on Windows
Andrew Robert wrote: bruno at modulix wrote: Andrew Robert wrote: Hi everyone, I have a python program that will need to interact with an MQSeries trigger monitor. It does this fine but it hogs the trigger monitor while it executes. I'd like to fork the program off and terminate the parent process so that the trigger monitor frees up. just-asking Is this really the solution ? /just-asking Does anyone how this can be accomplished on a Windows platform? AFAIK, there's no fork in Windows - you might want to give a try with CreateProcess. http://www.byte.com/art/9410/sec14/art3.htm http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch01.asp Unfortunately there is a real need for this. The MQSeries trigger monitor is single threaded. Because of this, my program would absorb it until it completes. The way to get around this would be to fork off and terminate the parent. Unfortunately, Windows appears to be somewhat stubborn about it. Creating a subprocess does not alleviate the need to get the originating process out of the trigger monitor. Have you *really* read the material pointed by the above links ? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Process forking on Windows - or what is MQSeries
Andrew Robert wrote: Gary Herron wrote: Andrew Robert wrote: snip The windows CreateProcess call has many of the same semantics as the Unix fork, i.e., a new process is created sharing all the resources of the original process. The subprocess modules uses CreateProcess, but if that does not give you sufficient control over the process creation, you can call CreateProcess directly via the win32process module in the win32all package. However, I still don't understand *what* the MQSeries trigger monitor is or *how* it would create the need for such a solution. Gary Herron MQSeries is a rather interesting piece of middle-ware offered by IBM that allows you to link disparate hosts/applications together via XML messaging and application specific queues. In the broadest sense, think of MQSeries like a large switchboard connecting everything together. Message queues can be programmed to do something via a mq application process such as a rule to take action when first, 5th, etc message arrives. The state of queues and their linked processes are controlled by the trigger monitor. The trigger monitor can only deal with one running process at a time. In this situation, it is possible for a process(my python program) to monopolize and block other processes from being triggered. Ideally, this needs to be avoided through the use of a fork. Since there's no fork() on Windows, how do other programs working with MQSeries deal with this situation ? How does it comes that your program 'monopolize' the monitor, while other don't ? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
Bill Pursell [EMAIL PROTECTED] writes: In my experience, the people who complain about the use of tabs for indentation are the people who don't know how to use their editor, and those people tend to use emacs. HA HA HA HA HA HA HA HA HA HA HA HA Tee, hee heee snif! Phew. Better now. That was funny! Thanks! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
SamFeltus [EMAIL PROTECTED] writes: It seems most Python applications choose HTML/CSS/JS as the display technology, These are open, freely-implementable, non-proprietary standards controlled by standards bodies. yet Flash is a far more powerful and elegant display technology. This is a proprietary, closed format controlled by a single corporation. -- \ He who allows oppression, shares the crime. -- Erasmus | `\ Darwin, grandfather of Charles Darwin | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
You can put any python expression in there, and in the Node class you can do what you want. But the main advantage is any python code not only expressions. In addition to that you get nice flow style. Can set variables which you later use as want. Seems that you are after a templating-system. Well, there are plenty of them available, including yours. A preprocessor is nothing but a template system - see TurboGears-utilized KID (http://kid.lesscode.org/) for example, it generates python files. And way more readable, because you are working in the domain of your application (HTML) instead of some crude syntax that is neither fish or flesh. What I propose is for all data that is hierarcical. Not only HTML. I dont use it for creating html. Templating systems have the drawback IMO that the more code you get the more undreadable it gets. If the code part is small they are very nice. The other part is that indentation, syntax highlighting and so on works not so well when working with such code. I would translate your example to the below. Which I think is much more readable, since you see the python code flow much easier. I realised that you realy should do Element(html) and not html(html) when adding nodes in my syntax and using elementtree. from urllib import urlopen from elementtree.ElementTree import parse, tostring feed = 'http://naeblis.cx/rtomayko/weblog/index.atom' root = parse(urlopen(feed)).getroot() ns = '{http://purl.org/atom/ns#}' title = root.findtext(ns + 'title') root = ET.Element(html) *+* root: *+* Element(head): *+* Element(title) *+* Element(body): *=* bgcolor = blue *=* text = yellow *+* Element(table): *=* cellpadding=4 *=* cellspacing=4 for i, entry in enumerate(root): *+* Element(tr): if entry.tag==ns + 'entry': *+* Element(td): *=* bgcolor = ('white', 'yellow')[i % 2] *+* Element(a): *=* href = entry.find(ns + 'link').attrib['href'] *=* text = entry.findtext(ns + 'title') With the above you can use your favorite editor to do the coding and get indentation, syntax highlightning and so on. Which I find can be quite a burden with a templating system especially the more code that is in there. It is also easier to debug in comparison when using a templating system. -- http://mail.python.org/mailman/listinfo/python-list
Re: Large Dictionaries
Chris Foote wrote: Claudio Grondi wrote: Chris Foote wrote: Klaas wrote: 22.2s 20m25s[3] 20m to insert 1m keys? You are doing something wrong. I've put together some simplified test code, but the bsddb module gives 11m for 1M keys: I have run your code for the bsddb on my P4 2.8 GHz and have got: Number generator test for 100 number ranges with a maximum of 3 wildcard digits. Wed May 17 16:34:06 2006 dictionary population started Wed May 17 16:34:14 2006 dictionary population stopped, duration 8.4s Wed May 17 16:34:14 2006 StorageBerkeleyDB population started Wed May 17 16:35:59 2006 StorageBerkeleyDB population stopped, duration 104.3s Surprising here, that the dictionary population gives the same time, but the BerkeleyDB inserts the records 6 times faster on my computer than on yours. I am running Python 2.4.2 on Windows XP SP2, and you? Fedora core 5 with ext3 filesystem. The difference will be due to the way that Windows buffers writes for the filesystem you're using (it sounds like you're using a FAT-based file system). Ok, according to the Windows task manager the Python process reads/writes to the file system during the run of BerkeleyDB test around 7 GByte(!) of data and the hard drive is continuously busy, where the size of file I found in the Temp directory is always below 20 MByte. The hard drive access is probably the main reason for loosing time - here a question to BerkeleyDB experts: Can the BerkeleyDB via Python bsddb3 interface be tuned to use only RAM or as BerkeleyDB can scale to larger data amount it makes not much sense to tweak it into RAM? Chris, is maybe a RAM-disk the right way to go here to save time lost for accessing the file stored in the file system on the hard drive? The RAM requirements, according to Windows XP task manager, are below 100 MByte. I am using the NTFS file system (yes, I know, that FAT is in some configurations faster than NTFS) and XP Professional SP2 without any tuning of file system caching. The CPU is 100% busy. What CPU and RAM (SIMM, DDR, DDR2) do you have? I have 2GByte fast DDR PC400/3200 dual line RAM. It seems, that you are still not getting results within the range others experience running your code, so I suppose, it has something to do with the hardware you are using. Number generator test for 100 number ranges with a maximum of 3 wildcard digits. Wed May 17 22:18:17 2006 dictionary population started Wed May 17 22:18:26 2006 dictionary population stopped, duration 8.6s Wed May 17 22:18:27 2006 StorageBerkeleyDB population started Wed May 17 22:29:32 2006 StorageBerkeleyDB population stopped, duration 665.6s Wed May 17 22:29:33 2006 StorageSQLite population started Wed May 17 22:30:38 2006 StorageSQLite population stopped, duration 65.5s As I don't have SQLite installed, it is interesting to see if the factor 10 in the speed difference between BerkeleyDB and SQLite can be confirmed by someone else. Why is SQLite faster here? I suppose, that SQLite first adds all the records and builds the index afterwards with all the records there (with db.commit()). SQLite is way faster because BerkeleyDB always uses a disk file, and SQLite is in RAM only. One of the reasons I put an eye on BerkeleyDB is that it pretends to scale to a huge amount (Terrabyte) of data and don't need as much RAM as Python dictionary and it is not necessary to save/load pickled version of the data (i.e. here the dictionary) from/to RAM in order to work with it. I guess, that in your case BerkeleyDB is for the named reasons probably the right way to go, except your data will stay small and the Python dictionary with them will always fit into RAM. Now I am curious to know which path you have decided to go and why? Claudio Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
You also repeat yourself: head(head), title(title), body(body) What about this: # build a tree structure root = ET.Element(html) !root !head !title if A is True: text = Page A else: text = Page B !body bgcolor = #ff text = Hello, World! Yes this is how it should be. But It depends on which package would be used. If you used xist it would look like that since they have one class for each html tag. I really propose a generic solution that any package that support the method append and __settiem__ could use the new syntax. But minor isssues but it would look something like this with xist: !root !head(): !title(): if A is True: text = Page A else: text = Page B !body() bgcolor = #ff text = Hello, World! mmm...yamlthon? yython...:-) Guess what I have for suffix on the files before preprocessing? pyml ofcourse. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make the program notify me explicitly
hankssong wrote: may be message dialog is the best way to let me be informed! EasyGui is possibly the simplest and fastest way to get message dialogue boxes in Python: http://www.ferg.org/easygui/ - alex23 -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
What about using XXXdata/XXX for nodes and '=' for attributes ? Would look like: html head titlePage Title/title /head body bgcolor='#ff' Hello World /body /html I think that with the added syntax you get better view of the html page. indeed !-) I dont think it is very pythonic :-). You dont use endtags and then you dont use ':' to mark that you nest a level. :-) And I dont see where it is allowed to put real python code. So could you show an example with a for loop? :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
Here's a nice stan example, taken from Kieran Holland's tutorial http://www.kieranholland.com/code/documentation/nevow-stan/ I took a quick look and it looks nice as long as your page is static. But I couldnt se how you could mix in python code seamlessy when creating your tree. But I might be wrong if you could write: tags.body[ for i in range(10): tags.h1[ Heading %s. %(i) ], tags.p[ This text is inside a paragraph tag. ], ] I think that this is close enough to my syntax. But I dont think you can do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Process forking on Windows
Andrew Robert wrote: bruno at modulix wrote: [...] just-asking Is this really the solution ? /just-asking [...] Unfortunately there is a real need for this. The MQSeries trigger monitor is single threaded. Because of this, my program would absorb it until it completes. The way to get around this would be to fork off and terminate the parent. Unfortunately, Windows appears to be somewhat stubborn about it. Creating a subprocess does not alleviate the need to get the originating process out of the trigger monitor. I have my doubts that this will solve the problem. You have a process that communicates with another, single-threaded, piece of software. If you fork of a sub-process, then you have another process communicating (and hogging up) this single-threaded piece of software. Well, if your original program is long-running, your sub-process is short-running, and you cannot 'disconnect' from the MQ Monitor other than by terminating a process, yes then I can see how using a subprocess could solve your problem... But I don't know why the SubProcess module doesn't do what you want. Cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: How to customize getattr(obj, prop) function ?
Pierre wrote: I don't want to use getattr(object, property, default_value) because I'm using external code and I don't want to modify or patch it. In this code, the call is getattr(object, property). Seems like a perfectly valid reason !-) On my objects, I must provide default values depending on the property that was requested, the default value is not always the same. On what does it depends ? Attribute name ? Class ? Phase of the moon ? And Yes I understand that obj.a is equivalent to getattr(obj, 'a') BUT the difference between class attribute and instance attribute... :S If you mean you don't understand the difference between a class attribute and an instance attribute, then it would be time to learn Python's OO 101 - else you're in for trouble. For short, an instance attribute has a per-instance value and is (usually) stored in the object's __dict__, while a class attribute is shared by all instances of the class and is (usually) stored in the class's __dict__. class Parrot(object): cls_attr = 'class attribute' def __init__(self): self.instance_attr = 'instance attribute' import pprint pprint.pprint(Parrot.__dict__.items()) p = Parrot() pprint.pprint(p.__dict__.items()) print Parrot.cls_attr try: print Parrot.instance_attr except AttributeError, e: print e # will lookup 'cls_attr' in p, then in Parrot print p.cls_attr print p.instance_attr # will create an instance attribute 'cls_attr' in # object p, shadowing Parrot.cls_attr p.cls_attr = 'WTF ?' print p.cls_attr print Parrot.cls_attr del p.cls_attr print p.cls_attr print Parrot.cls_attr HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Best active community website
Hi I have been looking for a active Python community website. Something like www.codeproject.com (contains code articles and guide, by developers, for developers) for Python users. Does something like this exist? /Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Large Dictionaries
Chris Foote wrote: Richie Hindle wrote: [Chris] Has anyone written a fast hash module which is more optimal for large datasets ? PyJudy might be what you're looking for, though I've never used it: http://www.dalkescientific.com/Python/PyJudy.html Judy's key benefits are scalability, high performance, and memory efficiency. A Judy array is extensible and can scale up to a very large number of elements, bounded only by machine memory. ... PyJudy arrays are similar to Python dictionaries and sets. Thanks for the suggestion Richie. PyJudy works brilliantly :-) Cheers, Chris It seems, that there is no Microsoft Windows version of Judy available, so for this reason PyJudy won't work on Windows - am I right? Claudio -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)
Duncan Booth wrote: No. That is precisely the problem: there is code in the wild which contains mixed space and tab indentation... followed by some good examples of mixed tab and space indentation I wouldn't have a problem with tabs if Python rejected mixed indentation by default, because then none of the code above would execute. I think it's great that at least we're all agreed that mixed indentation is a bad idea in any code, and particularly in Python. How would people feel about having the -t (or even -tt) behaviour become the default in future Python releases? A legacy option would obviously need to be provided for the old default behaviour. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to couple pyunit with GUI?
Miki, toda, but it did not work for me. BTW, I have forgotten to mention - the implementation I develop should be multi-platform.If anything else comes to you mind - I'll be more than gateful to hear. Regards, Mark -- http://mail.python.org/mailman/listinfo/python-list
Europython 2006 call for proposals
Hello, I am writing this supporting the Python in Business Track. We are looking for talks proposals concerning the usage of Python in doing business. So, if you have a story to tell... Maybe you have written a webcrawler in Python and founded a search engine? Or you are using Python to organize all those HTTPS-certificates, selling your company and flying to space, all with programming Python? Or are you up to more challenging aspects of daily life, like using Python to organize the ticket sales for a cinema-chain? Or even to do Point-Of-Sale stuff with some retailers? Or you have done something else interesting with Python in your Business? Please, come to EuroPython 2006 and tell others how you got prosperous programming in Python! (Just to remind you: Switzerland is one of the most well known places to take care of your money matters) Did Python give you inspiration to make Javascript suck less? Did you write a famous Python book, got hired by a company and live happily ever after? Cone to CERN, Switzerland, from 3. to 5. July 2006 - tell your story! Learn about Web 2.5 and up at the place Web 0.1-1.0 were developed! Be at the place famous for creating the antimatter to blow up Vatican! Have food in THE cafeteria with the highest likelyhood to queue together with a future or past Nobel Prize winner. Go to www.europython.org - and don't miss the talk submission deadline on 2006-05-31 [on a special note to Italians who are only allowed to travel to conferences with the possibility of recruitment: there will be some highly qualified PyPys at the conference; and just have a look at the timescale of PyPy founding by the European Union] Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
Edmond Dantes [EMAIL PROTECTED] writes: It all depends on your editor of choice. Emacs editing of Lisp (and a few other languages, such as Python) makes the issue more or less moot. I personally would recommend choosing one editor to use with all your projects, and Emacs is wonderful in that it has been ported to just about every platform imaginable. The real issue is, of course, that ASCII is showing its age and we should probably supplant it with something better. But I know that will never fly, given the torrents of code, configuration files, and everything else in ASCII. Even Unicode couldn't put a dent in it, despite the obvious growing global development efforts. Not sure how many compilers would be able to handle Unicode source anyway. I suspect the large majority of them would would choke big time. All right unicode support is not 100% perfect already, but my main compilers support it perfectly well, only 1/5 don't support it, and 1/5 support it partially: --(unicode-script.lisp)- (defun clisp (file) (ext:run-program /usr/local/bin/clisp :arguments (list -ansi -norc -on-error exit -E utf-8 -i file -x (ext:quit)) :input nil :output :terminal :wait t)) (defun gcl (file) (ext:run-program /usr/local/bin/gcl :arguments (list -batch -load file -eval (lisp:quit)) :input nil :output :terminal :wait t)) (defun ecl (file) (ext:run-program /usr/local/bin/ecl :arguments (list -norc -load file -eval (si:quit)) :input nil :output :terminal :wait t)) (defun sbcl (file) (ext:run-program /usr/local/bin/sbcl :arguments (list --userinit /dev/null --load file --eval (sb-ext:quit)) :input nil :output :terminal :wait t)) (defun cmucl (file) (ext:run-program /usr/local/bin/cmucl :arguments (list -noinit -load file -eval (extensions:quit)) :input nil :output :terminal :wait t)) (dolist (implementation '(clisp gcl ecl sbcl cmucl)) (sleep 3) (terpri) (print implementation) (terpri) (funcall implementation unicode-source.lisp)) --(unicode-source.lisp)- ;; -*- coding: utf-8 -*- (eval-when (:compile-toplevel :load-toplevel :execute) (format t ~2%~A ~A~2% (lisp-implementation-type) (lisp-implementation-version)) (finish-output)) (defun ιοτα (key (номер 10) (단계 1) (בכוכ 0)) (loop :for i :from בכוכ :to номер :by 단계 :collect i)) (defun test () (format t ~%Calling ~S -- ~A~% '(ιοτα :номер 10 :단계 2 :בכוכ 2) (ιοτα :номер 10 :단계 2 :בכוכ 2))) (test) (loadunicode-script.lisp) ;; Loading file unicode-script.lisp ... CLISP i i i i i i i ooooo o o I I I I I I I 8 8 8 8 8 o 88 I \ `+' / I 8 8 8 888 \ `-+-' / 8 8 8 o 8 `-__|__-'8 8 8 8 8 |8 o 8 8 o 8 8 --+-- o8oo ooo8ooo o 8 Copyright (c) Bruno Haible, Michael Stoll 1992, 1993 Copyright (c) Bruno Haible, Marcus Daniels 1994-1997 Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998 Copyright (c) Bruno Haible, Sam Steingold 1999-2000 Copyright (c) Sam Steingold, Bruno Haible 2001-2006 ;; Loading file unicode-source.lisp ... CLISP 2.38 (2006-01-24) (built 3347193361) (memory 3347193794) Calling (ΙΟΤΑ :НОМЕР 10 :단계 2 :בכוכ 2) -- (2 4 6 8 10) ;; Loaded file unicode-source.lisp Bye. GCL GNU Common Lisp (GCL) GCL 2.6.7 Calling (ιοτα :номер 10 :단계 2 :בכוכ 2) -- (2 4 6 8 10) ECL ;;; Loading unicode-source.lisp ECL 0.9g Calling (ιοτα :номер 10 :단계 2 :בכוכ 2) -- (2 4 6 8 10) SBCL This is SBCL 0.9.12, an implementation of ANSI Common Lisp. More information about SBCL is available at http://www.sbcl.org/. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. SBCL 0.9.12 Calling (|ιοτα| :|номер| 10 :|ˋ¨ʳÂ| 2 :|בכוכ| 2) -- (2 4 6 8 10) CMUCL ; Loading #P/local/users/pjb/src/lisp/encours/unicode-source.lisp. CMU Common Lisp 19c (19C) Reader error at 214 on #Stream for file /local/users/pjb/src/lisp/encours/unicode-source.lisp: Undefined read-macro character #\à [Condition of type READER-ERROR] Restarts: 0: [CONTINUE] Return NIL from load of unicode-source.lisp. 1: [ABORT ] Skip remaining initializations. Debug (type H for help) (LISP::%READER-ERROR #Stream for file
Re: Question about exausted iterators
Christophe wrote: Ok, call me stupid if you want but I know perfectly well the solution to that problem ! Come on, I was showing example code of an horrible gotcha on using iterators. OK, your are stupid ;-) Why asking questions when you don't want to listen answers ? Instead of saying that all works as intended could you be a little helpful and tell me why it was intended in such an obviously broken way instead ? Why an exausted iterator must return an Exception (other than StopIteration of course) ? Well an exausted iterator could be seen like an empty string or an empty list (or tons of others things), so you expect the code for car in : print car to return an Exception because it's empty ??? It's your job to check the iterator when it need to be. Regards. Dom -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: What about using XXXdata/XXX for nodes and '=' for attributes ? Would look like: html head titlePage Title/title /head body bgcolor='#ff' Hello World /body /html I think that with the added syntax you get better view of the html page. indeed !-) I dont think it is very pythonic :-). Adding ugly and unintuitive operators to try to turn a general purpose programming language into a half-backed unusable HTML templating language is of course *much* more pythonic... I think you would have much more success trying to get this added to Perl !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Best active community website
[EMAIL PROTECTED] wrote: Hi I have been looking for a active Python community website. Something like www.codeproject.com (contains code articles and guide, by developers, for developers) for Python users. Does something like this exist? - this newsgroup - which is very active, friendly and helpful -, - the Python Cookbook: http://aspn.activestate.com/ASPN/Python/Cookbook/ -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
Am Donnerstag 18 Mai 2006 13:27 schrieb bruno at modulix: Adding ugly and unintuitive operators to try to turn a general purpose programming language into a half-backed unusable HTML templating language is of course *much* more pythonic... What about writing a mini-language that gets translated to Python? Think of Cheetah, which does exactly this (albeit not being limited to templating HTML data). Adding these kind of operators to Python is an absolute NoNo, because it's nothing general the OP is trying to achieve here. Creating a small wrapper language: why not? (it's not that we have enough templating languages already ;-)) By the way: the language you (the OP) are trying to implement here goes strictly against the MVC model of application programming. You know that, right? --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to couple pyunit with GUI?
Hi Mark,On 5/18/06, Mark Geyzer [EMAIL PROTECTED] wrote: Fabio, thank you for your response, but I'm afraid that you misunderstood me - probably, I was not too clear. I do no test GUI - on the contrary, I am testing a HW interface. What I do need is a GUI equivalent of the TextTestRunner method. Any ideas? My fault, I did just a 'fast-read'. Well, I use pydev (http://pydev.sf.net), which allows me to select a folder and then recursively run all the unit-tests below that folder. Pydev is the gui, but the underlying module that actually runs the tests does not actually need a gui (I'm sending it attached). Just send it the dir you want and it will recursively inspect the modules, get the unit-tests and run them. You can probably easily extend it to run the files you want and not get things recursively if you don't want it... But with all that, It is still a command-line utility -- if you stilll want a gui to it, try pydev, which will allow you to right-click a folder and run all the unit-tests below it. Cheers, Fabio On 5/17/06, Fabio Zadrozny [EMAIL PROTECTED] wrote: On 17 May 2006 08:24:40 -0700, volcano [EMAIL PROTECTED] wrote: I am desperately looking for an info how to combine a testingapplication with decent GUI interface - the way most xUnits do. Ibelieve I have seen something about using Tkinter, but I do notremember - where. I am working on a complex testing application built over unittestmodule, and I need GUI interface that will alllow me to select tests atdifferent levels of test hierarchy tree.I am new to python, so say everything slow and repeat it twice:) --http://mail.python.org/mailman/listinfo/python-list Have you checked http://pyguiunit.sourceforge.net/ -- it is for PyQt, but can probably be adapted for other GUIs. -- Fabio -- Mark GeyzerSoftware Engineer,tel: +972-52-6782603 ''' Usage: runfiles.py dir [dir...] Run all unit tests found in the current path. An unit test is a file with TestCase-derived classes. ''' import sys import unittest import optparse import fnmatch import os import os.path import re def MatchMasks( p_FileName, p_Filters ): for filter in p_Filters: if fnmatch.fnmatch( p_FileName, filter ): return 1 return 0 def NotDir( p_FileName ): return not os.path.isdir( p_FileName ) def _FindFiles( p_Path, p_InFilters, p_OutFilters, p_Recursive = True ): import os import fnmatch if not p_Path: p_Path = '.' def AddFile( o_Result, p_DirName, p_FileNames ): p_FileNames = filter( lambda x: MatchMasks( x, p_InFilters ), p_FileNames ) p_FileNames = filter( lambda x: not MatchMasks( x, p_OutFilters ), p_FileNames ) p_FileNames = filter( NotDir, p_FileNames ) p_FileNames = [os.path.join( p_DirName, x ) for x in p_FileNames] o_Result.extend( p_FileNames ) result = [] if (p_Recursive): os.path.walk( p_Path, AddFile, result ) else: result = os.listdir( p_Path ) result = filter( lambda x: MatchMasks( x, p_InFilters ), result ) result = filter( lambda x: not MatchMasks( x, p_OutFilters ), result ) result = filter( NotDir, result ) result = [os.path.join( p_Path, x ) for x in result] return result; def make_list( p_element ): ''' Returns p_element as a list. ''' if isinstance( p_element, list ): return p_element else: return [p_element,] def FindFiles( p_Pathes, p_InFilters=None, p_OutFilters=None, p_Recursive = True ): ''' Find files recursivelly, in one or more directories, matching the given IN and OUT filters. @param p_Patches: One or a list of patches to search. @param p_InFilters: A list of filters (DIR format) to match. Defaults to ['*.*']. @param p_OutFilters A list of filters (DIR format) to ignore. Defaults to []. @param p_Recursive Recursive search? ''' if p_InFilters is None: p_InFilters = ['*.*'] if p_OutFilters is None: p_OutFilters = [] p_Pathes = make_list( p_Pathes ) result = [] for i_path in p_Pathes: files = _FindFiles( i_path, p_InFilters, p_OutFilters, p_Recursive ) result.extend( files ) return result def parse_cmdline(): usage='usage: %prog directory [other_directory ...]' parser = optparse.OptionParser(usage=usage) options, args = parser.parse_args() if not args: parser.print_help() sys.exit(1) return args #= #IMPORTING #= def FormatAsModuleName( filename): result = filename result = result.replace( '\\', '/' ) result = result.split( '/' ) result = '.'.join( result ) return result def SystemPath(
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
Adding ugly and unintuitive operators to try to turn a general purpose programming language into a half-backed unusable HTML templating language is of course *much* more pythonic... IT is not only for HTML. I do think html and xml are the biggest creators of hierarcical treestructures. But it would work for any package that manipulates, creates hierarchical data. I used HTML as example since it is a good example and most people would understand the intention. But could you elaborate on your comment that it is unusable. Do you think all template systems are unusable or what is the specific reason you think what i propose is unusable? IMO it is a mix between yml and python. Yml has the advantage that it can be read by many programming languages but the disadvantage is that it is static. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter Dialog Management problems:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that? 2) Pressing the Done button in the Settings Panel, just erases the Done button (and any other widgets in the Panel). It does not dismiss the Panel. Pressing the X button does work. What callback is that? Can I make the Done button call that instead? How? 3) Pressing the Done button from the Main Panel has no effect? Why not? It used to work (self.quit()). Again, I would like to call whatever is called when the X button (top Right corner) is pressed. Thanks in advance: TkInter Test #** Imports * import os import sys import Tkinter from Tkinter import Tk, Frame, Button, Label, Entry, Scrollbar from Tkinter import Text, Checkbutton, IntVar import tkFileDialog from tkMessageBox import askyesno, showerror # *** runScript() * def runScript (strFilename): Executes Python script file if (VERBOSE): print strFilename, is being imported fileText = try: fptr = open (strFilename, 'r') fileText = fptr.read() fptr.close() except Exception, (errno): print Exception in import of file:, strFilename, - Errno = , errno print (sys.exc_info()) showerror ('Error', 'Problem importing file - see console for details') else: fname = [strFilename[:-3].split('/')[-1]] for f in fname: __import__(f) # *** getGUIFilename *** def getGUIFilename(): returns a tkInter File Selection Dialog strFilename = tkFileDialog.askopenfilename(initialdir='.', filetypes=[('Python files','*.py'), ('All Files','*.*')]) return strFilename # *** ScenarioPlayerDialog class * class ScriptDialog(Frame): Script Dialog GUI class def __init__(self, parent=None): Script GUI class constructor Frame.__init__(self, parent) self.pack() self.commandRow = Frame(self) self.commandLabel = Label(self.commandRow, width=14, text=Python Command:) self.commandEnt = Entry(self.commandRow) self.commandRow.pack(side=Tkinter.TOP, fill=Tkinter.X) self.commandLabel.pack(side=Tkinter.LEFT) self.commandEnt.pack(side=Tkinter.RIGHT, expand=Tkinter.YES, fill=Tkinter.X) self.commandEnt.delete('0', Tkinter.END) self.commandEnt.pack(side=Tkinter.TOP, fill=Tkinter.X) buttonRow3 = Frame(self) doneBtn = Button(buttonRow3, text='Done', command=self.done) doneBtn.pack(side=Tkinter.RIGHT) buttonRow3.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES, fill=Tkinter.X) buttonRow2 = Frame(self) runBtn = Button(buttonRow2, text='Run Script', command=self.playScript) runBtn.pack(side=Tkinter.LEFT) buttonRow2.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES, fill=Tkinter.X) buttonRow1 = Frame(self) executeBtn = Button(buttonRow1, text='Execute Command') executeBtn.pack(side=Tkinter.LEFT) settingsBtn = Button(buttonRow1, text='Settings...', command=self.editSettings) settingsBtn.pack(side=Tkinter.LEFT) self.verbose = Tkinter.IntVar() Checkbutton(self,text=Verbose,variable=self.verbose, command=self.setVerbosity).pack(side=Tkinter.RIGHT) buttonRow1.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES, fill=Tkinter.X) self.pack(expand=Tkinter.YES, fill=Tkinter.BOTH) self.theParent = parent def setVerbosity(self): Callback called when the 'Verbose' RadioButton is pressed global VERBOSE VERBOSE = self.verbose.get() def playScript(self): Callback called when the 'Run Script' button is pressed sFilename = getGUIFilename() if (VERBOSE): print Running script file: , sFilename runScript (sFilename) def editScript(self): Callback called when the 'Edit Script' button is pressed sFilename = getGUIFilename() editScript (sFilename) def executeCommand(self): Callback called when the 'Execute Command' button is pressed strCommand = self.commandEnt.get() if (VERBOSE): print strCommand, is being executed exec (strCommand) def editSettings(self): Callback called
Which is More Efficient?
I have a program that uses up a lot of CPU and want to make it is efficient as possible with what I have to work with it. So which of the following would be more efficient, knowing that l is a list and size is a number? l=l[:size] del l[size:] If it makes a difference, everything in the list is mutable. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to customize getattr(obj, prop) function ?
[Please provide some context in your reply, so we know what questions or comments you're replying to.] Pierre [EMAIL PROTECTED] writes: I don't want to use getattr(object, property, default_value) because I'm using external code and I don't want to modify or patch it. You can subclass the class you want to modify, and override its behaviour. class ScaryExternalThing(object): The external class we don't want to modify. class OurModifiedFriendlyThing(ScaryExternalThing): Class for use by our code. attr_defaults = { 'foo': eggs, 'bar': beans, } def __getattr__(self, name): Method invoked when getting an unknown attribute value = attr_defaults.get(name, spam) return value -- \ Welchen Teil von 'Gestalt' verstehen Sie nicht? [What part of | `\ 'gestalt' don't you understand?] -- Karsten M. Self | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is More Efficient?
Measure it and find out. Sounds like a little investment in your time learning how to measure performance may pay dividends for you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
looping a écrit : Christophe wrote: Ok, call me stupid if you want but I know perfectly well the solution to that problem ! Come on, I was showing example code of an horrible gotcha on using iterators. OK, your are stupid ;-) Why asking questions when you don't want to listen answers ? Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. Instead of saying that all works as intended could you be a little helpful and tell me why it was intended in such an obviously broken way instead ? Why an exausted iterator must return an Exception (other than StopIteration of course) ? Because it's exausted. Because it has been for me a frequent cause of bugs and because I have yet to see a valid use case for such behaviour. Well an exausted iterator could be seen like an empty string or an empty list (or tons of others things), so you expect the code for car in : print car to return an Exception because it's empty ??? Of course not. It's your job to check the iterator when it need to be. It's my job to avoid coding bugs, it's the language job to avoid placing pitfalls everywhere I go. I must confess I have a strong opinion on that point. Not long ago I started working on some fresh code where I decided to use a lot of iterators and set instead of list if possible. That behaviour has caused me to lose quite some time tracking bugs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is More Efficient?
Dustan [EMAIL PROTECTED] writes: I have a program that uses up a lot of CPU and want to make it is efficient as possible with what I have to work with it. Profile your program and find the precise parts that are the slowest. Attempting to optimise before that is a waste of your time. So which of the following would be more efficient, knowing that l is a list and size is a number? l=l[:size] del l[size:] Which one is more efficient in your program, when you profile its performance? URL:http://docs.python.org/lib/profile.html -- \ Working out the social politics of who you can trust and why | `\ is, quite literally, what a very large part of our brain has | _o__)evolved to do. -- Douglas Adams | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
What about writing a mini-language that gets translated to Python? Think of Cheetah, which does exactly this (albeit not being limited to templating HTML data). I have implemented my proposal as preprocessor. And it works fine. But my proposal in not only for HTML it can be used for all hieracical data. Example: myList = [] *+* myList: *+* []: for i in range(10): *+* i *+* {}: for i in range(10): *=* i = i Which should create myList = [[0..9], {0:0, ... 9:9}] So it adds the power of for loops etc when creating data structures. ANY datastructure. nothing general the OP is trying to achieve here Define general :-). I do think I solve something and make it more readable. You could also argue that list comprehension doesnt solve anything general. By the way: the language you (the OP) are trying to implement here goes strictly against the MVC model of application programming. You know that, right? ???. I cant see how this breaks MVC. MVC depends on how you parition your application this doesnt put any constraint on how you should do your application. -- http://mail.python.org/mailman/listinfo/python-list
Conversion of perl unpack code to python - something odd
Hey everyone, Maybe you can see something I don't. I need to convert a working piece of perl code to python. The perl code is: sub ParseTrig { # unpack the ibm struct that triggers messages. my $struct = shift; my %data; @data{qw/StructID Version QName ProcessName TriggerData ApplType ApplId EnvData UserData QMgrName/} = unpack(A4A4A48A48A64A4A256A128A128A48, $struct); return undef unless $data{StructID} eq 'TMC'; return \%data; Taking away the fact that it is a function, the base code sets a 732 element structure with the ascii pattern derived above. I wrote a simple test script that accepts the command argument at position 1. #!C:\Python24\python import sys, string, struct # From the language declarations in manual, the following format was derived format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' size=struct.calcsize(format) # Extract list item out for convenience/readability data=sys.argv[1] # Calculated size of the struct format is 732 # Length of data string is 732 print len(data) print size d1,d2=struct.unpack(format,data) print d1 sys.exit(0) When I run it, it says there are too many values to unpack. Traceback ( most recent call last) File m:\mq\mq\scripts\format.py, line 32, in ? d1, d2 = struct.unpack(format,data) ValueError: too many values to unpack Error starting triggered application I checked the manual on the structure used to pack the code and it appears correct. # # MQTMC2 Language declarations as defined chapt 22 of programmers ref # http://publibfp.boulder.ibm.com/epubs/pdf/csqzak09.pdf # # CHAR4 Struct ID # CHAR4 Version # CHAR48 QName # CHAR48 ProcessName # CHAR64 TriggerData # CHAR4 ApplType # CHAR256 ApplID # CHAR128 EnvData # CHAR128 UserData # CHAR48 QMgrName Any help you can provide on this would be greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: Adding ugly and unintuitive operators to try to turn a general purpose programming language into a half-backed unusable HTML templating language is of course *much* more pythonic... IT is not only for HTML. I do think html and xml are the biggest creators of hierarcical treestructures. What is a 'non-hierarchical treestructure' ? A list ?-) But it would work for any package that manipulates, creates hierarchical data. FWIW, filesystems are trees, most RDBMS use BTrees, and almost any OO program is a graph of objects - trees being a subset of graphs.. Strange enough, working with trees is nothing new, and it seems that almost anyone managed to get by without cryptic 'operators' stuff. I used HTML as example since it is a good example and most people would understand the intention. Sorry for being dumb. But could you elaborate on your comment that it is unusable. Ask all the coders that switched from Perl to Python why they did so... Do you think all template systems are unusable Nope - I use template systems everyday. Please don't take it wrong: there's surely something to do to ease declarative XML-like (including JSON, Yaml etc...) datastructure construction. But I think the pythonic way to go would rely on metaprogramming - not on ugly perlish syntax. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is More Efficient?
Dustan wrote: I have a program that uses up a lot of CPU and want to make it is efficient as possible with what I have to work with it. So which of the following would be more efficient, knowing that l is a list and size is a number? l=l[:size] del l[size:] since you have the program, it shouldn't that hard to test the two alternatives, should it ? (in theory, del should be faster in most cases, since it avoids creating another object. but the only way to tell for sure is to try it out). If it makes a difference, everything in the list is mutable. the only difference between mutable and immutable objects in Python is that mutable objects have methods that let you modify the object contents, while immutable objects don't have such methods. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ /F -- http://mail.python.org/mailman/listinfo/python-list
If you were given a mall would you take it?
http://www.telebay.com/esolutions/opp.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.
glomde wrote: What about writing a mini-language that gets translated to Python? Think of Cheetah, which does exactly this (albeit not being limited to templating HTML data). I have implemented my proposal as preprocessor. And it works fine. But my proposal in not only for HTML Nor is Cheetah. Nor is Django's templating system. Nor are some other Python templating systems. it can be used for all hieracical data. Example: myList = [] *+* myList: *+* []: for i in range(10): *+* i *+* {}: for i in range(10): *=* i = i Sweet Lord, have mercy ! Which should create myList = [[0..9], {0:0, ... 9:9}] myList = [ range(10), dict((i, i) for i in range(10)) ] Let's talk about readability I do think I solve something and make it more readable. Lol. Any Perl coder around ? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Conversion of perl unpack code to python - something odd
Andrew Robert wrote: # From the language declarations in manual, the following format was derived format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' that's 10 specifiers. d1,d2=struct.unpack(format,data) that's two variables. print d1 sys.exit(0) When I run it, it says there are too many values to unpack. Traceback ( most recent call last) File m:\mq\mq\scripts\format.py, line 32, in ? d1, d2 = struct.unpack(format,data) ValueError: too many values to unpack Error starting triggered application I checked the manual on the structure used to pack the code and it appears correct. try printing the return value from struct.unpack, and see if you can figure out what's wrong with your code: print struct.unpack(format,data) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Conversion of perl unpack code to python - something odd
Andrew Robert wrote: format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' You are trying to squeeze 10 items into just d1,d2=struct.unpack(format,data) two variables (d1 and d2) ValueError: too many values to unpack and Python is quite explicit that it doesn't like that once you realize that 'unpack' doesn't refer to struct.unpack() but to tuple unpacking like a, b = ab a, b = abc Traceback (most recent call last): File stdin, line 1, in ? ValueError: too many values to unpack Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell if function was passed a list or a string?
rh0dium [EMAIL PROTECTED] wrote: [ ... ] Since you have lots of answers to your real question: an.append(re.sub(,,, str(a))) an.append(str(a).replace(,, )) -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Fredrik Lundh a écrit : Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
BartlebyScrivener wrote: I was hoping you'd find this earlier when I suggested that you type: creating a new database with MySQL into google. It's the number one hit: http://coronet.iicm.edu/mysql/create.html If you send the commands listed there via the commandline or through MySQLdb you should be in business. I saw this one, but it seems to use a lot of the command line, and I didn't know how all that translates into a Python script. My goal was to do it all using just mysqldb, but maybe it's just easier (or more normal) to create a database in another way, and *then* use mysqldb to manipulate it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
I guess there isn't much to understand. If you are satisfied with a text based, static image web, that is light on artistic possabilities, all that HTML stuff is acceptable. Perhaps the HTML/JS group will even get off their rear ends and bring some decent cross platform graphics capabilities to the web one decade? Perhaps even bring some 90's style graphics to the browser one decade? WC3 at Work - Beware Falling Luddites -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
I guess there isn't much to understand. If you are satisfied with a text based, static image web, that is light on artistic possabilities, all that HTML stuff is acceptable. Perhaps the HTML/JS group will even get off their rear ends and bring some decent cross platform graphics capabilities to the web one decade? Perhaps even bring some 90's style graphics to the browser one decade? WC3 at Work - Beware Falling Luddites -- http://mail.python.org/mailman/listinfo/python-list
module webbrowser - open link in same window - osx
hi, i'm using the webbrowser module to open url's in safari or firefox. specifically i'm using the webbrowser.open('http://...', new=0) command. however, even though i say new=0 my url is always opened in a new browser window. what can i do, so my link is opened in an already open browser window? thank you for your help, robin -- http://mail.python.org/mailman/listinfo/python-list
Strange error
I have encountered a very strange error and I'm hoping that some Python hackers here could give me insight on this. searchview.py file contains two functions: def mysearch(indexname, request, c, page = 0, searchdburl = INDEX_URL, query_add = {}, queries = [], form = True, limit = DEFAULT_LIMIT, tags = {}, order = ''): and def search(findquery, path = None, page=0, tags = {}, order='', limit = DEFAULT_LIMIT, queries=[], searchdburl = INDEX_URL): I import and call both from various places. Now recently I discovered that when I call: mysearch('pubcomm', request, vars, page = page, query_add = query_add) from one place, then inside mysearch() (I test it at the start of the function) the tags argument *has* a value leftover from apparently from a previous call. When investigating I have also found that it sometimes has the value of the search() function's tags parameter from, apparently, some previous call. After I changed the call to this: mysearch('pubcomm', request, vars, page = page, query_add = query_add, tags = {}) the error stopped occurring, so it seems that what I'm suspecting is right. The searchview.py file does not contain any global 'tags' variable, but the search() function does process it's own tags argument like so: tags = dict([(k, listify(v)) for k, v in tags.iteritems()]) The whole thing is happening on Python 2.4.2 on Linux (I tried it on Fedora and Gentoo). It's under a heavy load (the whole thing happens inside a Flup based FCGI backend), but I'm not using threads so there is no concurrency involved - only sequential processing of requests. I haven't isolated a test case yet, hoping that someone could give me a hint on this. Maybe I'm making some stupid mistake or maybe it's some namespace bug (or 'feature'). Any ideas? Thanks, Wojtek -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. so what is a valid answer? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange error
[EMAIL PROTECTED] wrote: I have encountered a very strange error and I'm hoping that some Python hackers here could give me insight on this. searchview.py file contains two functions: def mysearch(indexname, request, c, page = 0, searchdburl = INDEX_URL, query_add = {}, queries = [], form = True, limit = DEFAULT_LIMIT, tags = {}, order = ''): and def search(findquery, path = None, page=0, tags = {}, order='', limit = DEFAULT_LIMIT, queries=[], searchdburl = INDEX_URL): default values are evaluated once, when the function object is created. this is explained in the tutorial, in the language reference, and in the FAQ: http://pyfaq.infogami.com/why-are-default-values-shared-between-objects /F -- http://mail.python.org/mailman/listinfo/python-list
Python Install
I'm sure this is an easy question for most here, but it's throwing me for a loop at the moment - I need to upgrade RHEL 3 with the latest version of Python. I downloaded the source and installed, but we're still having problems (i.e. some Python apps don't work, Add/Remove Applications console errors out and doesn't open, etc.). My guess is that it's using old libraries or otherwise conflicting with the old Python version, but I'm not sure how to remove the original version. Any help would be greatly appreciated! -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Christophe wrote: Fredrik Lundh a écrit : Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. The important thing is: it _is_ specified. And what about code like this: iterable = produce_some_iterable() for item in iterable: if some_condition(item) break do_something() for item in iterable: do_something_with_the_rest() If it weren't for StopIteration raised if the iterable was exhausted, you'd have to clutter that code with something like try: for item in iterable: do_something_with_the_rest() except IteratorExhausted: pass What makes you say that this is better than the above? Just because _you_ had some cornercases that others seems not to have (at least that frequently, I personally can't remember I've ever bitten by it) isn't a valid reason to _not_ do it as python does. Besides that: it would be a major change of semantics of iterators that I seriously doubt it would make it into anything before P3K. So - somewhat a moot point to discuss here I'd say. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange error
Evaluation of default values seems to have nothing to do with the case I described. The default values are both tags = {}, and still inside mysearch() I sometimes get some value from previous call inside tags, when the tags keyword argument is not specified. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Fredrik Lundh a écrit : Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. so what is a valid answer? Some valid use case for that behaviour, some example of why what I ask could cause problems, some implementation difficulties etc ... Saying it's like that because someone said so isn't exactly what I was expecting as an answer :) People sometimes can be wrong you know. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Fredrik Lundh schreef: Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. so what is a valid answer? I think he wants to know why the spec has been written that way. The rationale mentions exhausted iterators: Once a particular iterator object has raised StopIteration, will it also raise StopIteration on all subsequent next() calls? Some say that it would be useful to require this, others say that it is useful to leave this open to individual iterators. Note that this may require an additional state bit for some iterator implementations (e.g. function-wrapping iterators). Resolution: once StopIteration is raised, calling it.next() continues to raise StopIteration. This doesn't, however, completey answer the OP's question, I think. It is about raising or not raising StopIteration on subsequent next() calls but doesn't say anything on possible alternatives, such as raising another exception (I believe that's what the OP would like). Not that I know of use cases for other exceptions after StopIteration; just clarifying what I think the OP means. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python for a CAD program
David Cuthbert wrote: baalbek wrote: CAD systems available today (Autocad, Archicad, Architectural Desktop, etc) have one huge flaw: they don't store data to a SQL database, but to binary files. There's a reason for this. Most CAD data is not in a form (First Normal Form) suitable for a relational database. In addition, the sheer number of objects involved in each operation brings performance to its knees. Finally, most RDBMS provide (and are optimized for) transactional semantics -- for a CAD system, this is wasted overhead. Object database systems (ODBMS) like ZODB are probably a much better fit for CAD data than RDBMS. The hierarchical structure in an object database is a natural fit to the way CAD drawings are created and manipulated, and most CAD systems internally represent drawings as some kind of object tree. Of course, ZODB *can* serialize its data to an SQL backend, among several other possibilities. One of the more intriguing possibilities would be using a CVS or Subversion based back-end to provide more complete version control help. I disagree that transactions are bad for CAD -- they may have a different semantic role and the needed granularity may be different, but the need to roll data back to an earlier revision is just as present in drawings as it is for code or financial transactions. Cheers, Terry -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Diez B. Roggisch a écrit : Christophe wrote: Fredrik Lundh a écrit : Christophe wrote: Because I'm still waiting for a valid answer to my question. The answer Because it has been coded like that or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ I didn't though I had to mention that Because the spec has been writen like that wasn't a valid answer either. The important thing is: it _is_ specified. And what about code like this: iterable = produce_some_iterable() for item in iterable: if some_condition(item) break do_something() for item in iterable: do_something_with_the_rest() If it weren't for StopIteration raised if the iterable was exhausted, you'd have to clutter that code with something like try: for item in iterable: do_something_with_the_rest() except IteratorExhausted: pass It would be ugly but you could do that instead : iterable = produce_some_iterable() for item in iterable: if some_condition(item) break do_something() else: iterable = [] for item in iterable: do_something_with_the_rest() I'll admit that the else clause in for/while loops isn't the most common and so some people might be a little troubled by that. There's also that : iterable = produce_some_iterable() for item in iterable: if some_condition(item) for item in iterable: do_something_with_the_rest() break do_something() What makes you say that this is better than the above? Just because _you_ had some cornercases that others seems not to have (at least that frequently, I personally can't remember I've ever bitten by it) isn't a valid reason to _not_ do it as python does. Maybe I've used more iterables than most of you. Maybe I've been doing that wrong. But I'd like to think that if I've made those mistakes, others will make it too and would benefit for some help in debugging that from the interpreter :) Besides that: it would be a major change of semantics of iterators that I seriously doubt it would make it into anything before P3K. So - somewhat a moot point to discuss here I'd say. It wouldn't be such a big semantic change I think. You could add that easily[1] as deprecation warning at first and later on switch to a full blown error. [1] Easily provided you can easily code what I ask itself ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - Web Display Technology
SamFeltus wrote: I guess there isn't much to understand. If you are satisfied with a text based, static image web, that is light on artistic possabilities, all that HTML stuff is acceptable. 1. artistic != animated. 2. the web has mostly been designed for text-based content. Perhaps the HTML/JS group will even get off their rear ends and bring some decent cross platform graphics capabilities to the web one decade? Perhaps even bring some 90's style graphics to the browser one decade? Ever heard of SVG ? FWIW, your site is maybe very artistic, but it's content doesn't show up much in google : http://www.google.com/search?q=site:samfeltus.com Compare with: http://www.google.com/search?q=site:python.org -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange error
[EMAIL PROTECTED] wrote: The default values are both tags = {}, and still inside mysearch() I sometimes get some value from previous call inside tags, when the tags keyword argument is not specified. which is exactly what happens if you *update* the default argument. did you even bother to read the FAQ entry? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Dialog Management problems:
On Thu, 18 May 2006 08:41:20 -0400, Michael Yanowitz [EMAIL PROTECTED] wrote: Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that? In fact, the two windows you created are not dialogs; they're just windows. To turn a window into an actual dialog, i.e basically to make it modal, you have to do the following operations (supposing your dialog window is named dlg and your main window in named root): ## Ensure only window can receive user events dlg.grab_set() ## Force Dialog to stay on top of main window dlg.transient(root) ## Wait for dialog to be destroyed root.wait_window(dlg) 2) Pressing the Done button in the Settings Panel, just erases the Done button (and any other widgets in the Panel). It does not dismiss the Panel. Pressing the X button does work. What callback is that? Can I make the Done button call that instead? How? This is not the way it works. In fact, what you did wrong is something that has been around for years in some Tkinter tutorial(s): you made your classes inherit from Frame. This is a Bad Idea: a Frame is not a window, but only a generic container. There are 2 classes for windows: Tk for the main window and Toplevel for all others. They both also act as containers, so you can do in them everything you do in Frames. So make your ScriptDialog inherit from Tk, your SettingsDialog inherit from Toplevel, remove all explicit creations of Tkinter.Tk or Tkinter.Toplevel and instantiate your classes instead. Then calling destroy on either on the dialogs will actually close the window. 3) Pressing the Done button from the Main Panel has no effect? Why not? It used to work (self.quit()). Again, I would like to call whatever is called when the X button (top Right corner) is pressed. This should work. BTW, your done method is not needed: creating the Button with command=self.quit works without problem. HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Roel Schroeven a écrit : Fredrik Lundh schreef: so what is a valid answer? I think he wants to know why the spec has been written that way. The rationale mentions exhausted iterators: Once a particular iterator object has raised StopIteration, will it also raise StopIteration on all subsequent next() calls? Some say that it would be useful to require this, others say that it is useful to leave this open to individual iterators. Note that this may require an additional state bit for some iterator implementations (e.g. function-wrapping iterators). Resolution: once StopIteration is raised, calling it.next() continues to raise StopIteration. This doesn't, however, completey answer the OP's question, I think. It is about raising or not raising StopIteration on subsequent next() calls but doesn't say anything on possible alternatives, such as raising another exception (I believe that's what the OP would like). Exactly ! Not that I know of use cases for other exceptions after StopIteration; just clarifying what I think the OP means. There are no use cases yet for me. I want those exceptions as an hard error for debuging purposes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about exausted iterators
Christophe wrote: Maybe I've used more iterables than most of you. Maybe I've been doing that wrong. your problem is that you're confusing iterables with sequences. they're two different things. /F -- http://mail.python.org/mailman/listinfo/python-list
Windows Registry Dump
Hi! Does someone know how I can make a Text-Dump-File of a remote Windows-Computer's Registry (not the whole registry - only a part of it)? Thanks a lot for some code or a helpful link! regards Dirk -- http://mail.python.org/mailman/listinfo/python-list
Re: [silly] Does the python mascot have a name ?
John Bokma [EMAIL PROTECTED] wrote in news:Xns97C6ADE23FCAcastleamber@ 130.133.1.4: John D Salt jdsalt_AT_gotadsl.co.uk wrote: Andy Sy [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: http://mail.python.org/pipermail/python-list/2003-September/185612.html Odi must be the Dutch for Monty. Nope. If it was Dutch it would probably be Odie Damn. All the best, John. -- http://mail.python.org/mailman/listinfo/python-list