Wing IDE 3.0 released
Hi, We're happy to announce the release of Wing IDE 3.0, an advanced development environment for the Python programming language. It is available from: http://wingware.com/ Wing IDE provides powerful debugging, editing, code intelligence, testing, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. New features added in Wing 3.0 include: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion and call tips in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*) * Introduction of Wing IDE 101, a free edition for beginning programmers * Available as a .deb package for Debian and Ubuntu * Support for Stackless Python * Support for 64 bit Python on Windows and Linux (*)'d items are available in Wing IDE Professional only. The CHANGELOG.txt file in the installation provides additional details. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Purchasing Upgrading -- Wing IDE Professional Wing IDE Personal are commercial software and require a license to run. To upgrade a 2.x license or purchase a new 3.x license: Upgradehttps://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. Thanks! The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
cx_Logging 1.4
What is cx_Logging? cx_Logging is a Python extension module which operates in a fashion similar to the logging module that ships with Python 2.3 and higher. It also has a C interface which allows applications to perform logging independently of or in tandem with Python. Where do I get it? http://cx-logging.sourceforge.net What's new? 1) On Windows, ensure that the log files are opened in such a way that they are not inherited by subprocesses; otherwise, the existence of a subprocess prevents log rotation. 2) Build an import library on Windows and change the shared object name of the module on other platforms so that other projects can use it directly at the C level. 3) Removed unnecessary dependency on the win32api package on Windows. 4) Tweaked setup script to build PKG-INFO and MANIFEST using metadata in the setup script instead of separate files. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Using fractions instead of floats
On Sep 30, 7:35 pm, andresj [EMAIL PROTECTED] wrote: I was doing some programming in Python, and the idea came to my mind: using fractions instead of floats when doing 2/5. The core problem with rationals (other than the inability to handle irrationals) is their tendency to require more and more memory as calculations progress. This means they get mysteriously slower and slower. http://mail.python.org/pipermail/python-list/2002-October/166630.html My own pet numeric type is fixed point. You get as much precision as you specify. Alas, 2/5 would likely result in 0. ;) -- Adam Olsen, aka Rhamphoryncus -- http://mail.python.org/mailman/listinfo/python-list
Re: Using fractions instead of floats
[EMAIL PROTECTED] wrote: On Oct 1, 8:17?pm, [EMAIL PROTECTED] wrote: On Oct 1, 9:03 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote: On Oct 1, 8:30 am, Nick Craig-Wood [EMAIL PROTECTED] wrote: mpq(1,3)+0.6 mpq(14,15) Golly! That's quite impressive. And more than a little bit magic as well, since 0.6 is definitely not the same as 3/5. It's not? Since when? The 0.6 above is a floating point number, mathematically very close to 0.6 but definitely not equal to it, since 0.6 can't be represented exactly as a float. Oh, you mean something like this, right? import gmpy a = 0.6 a 0.59998 So, the rational should have 59998 in the neumerator and 10 in the denominator? Actually (5404319552844595 / 2**53) would be best. But it doesn't b = gmpy.mpq(a) b mpq(3,5) Why do you suppose that is? For the same reason that str() does. See below. For that matter, why does str(a) '0.6' give me an EXACT representation? It doesn't. It just rounds at a lower number of decimal places than is necessary to faithfully represent the number. str() is intended to give friendly results, not strictly correct ones. In this case it happens that float(str(0.6)) == 0.6, but this is not guaranteed. For most numbers that a user or programmer might enter, there will only be a relatively small amount of precision necessary, and float(str(x)) == x will tend to hold. That's why it does this. Didn't you just say it couldn't be represented exactly? Yup. Which is correct, str(a) '0.6' or repr(a) '0.59998' ? The latter. How does gmpy make the conversion from float to rational? gmpy has a configurable transformation between floats and the internal representation. I believe the default goes through str(). -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: slice last 4 items from a list
Very pythoninc! On 10/1/07, John Machin [EMAIL PROTECTED] wrote: On Oct 2, 6:27 am, brad [EMAIL PROTECTED] wrote: Is this the correct way to slice the last 4 items from a list? x = [1,2,3,4,5,6,7,8,9] print x[-4:] It works, but is it Pythonic? It's Pythonic. It's also unambiguous, unlike your specification, which could be interpreted as 'chop off the last 4 items from a list' i.e. del x[-4:]. What you are actually doing is 'print the last 4 items of a list'. -- http://mail.python.org/mailman/listinfo/python-list -- http://search.goldwatches.com/search.aspx?Search=cufflinks http://www.jewelerslounge.com -- http://mail.python.org/mailman/listinfo/python-list
Re: module confusion
In message [EMAIL PROTECTED], Robert Kern wrote: Not all of the modules in a package are imported by importing the top-level package. You can't import packages, only modules. os.path is a particularly weird case because it is just an alias to the platform-specific path-handling module; os is not a package. os is a module, os.path is a variable within that module. That's all there is to it. -- http://mail.python.org/mailman/listinfo/python-list
RE: Wrapper functions and arguments
On Behalf Of Jeremy Sanders def a(x, y, z): print x, y, z def b(x, y, z='fruitbat') print x, y, z for func in a, b: def wrapper(func=func, *args, **argsk): # do something func(*args, **argsk) x.append(wrapper) x[0](1, 2, 3) x[1](1, 2) ... Is there any way to do this? Can you capture arguments in a tuple and dict, but still receive other keyword arguments? I think you're missing one level of wrapping. def a(x, y, z): print x, y, z def b(x, y, z='fruitbat'): print x, y, z x = [] for func in a, b: def wrapper(func): def wrapped(*args, **kwds): print wrapped! func(*args, **kwds) return wrapped x.append(wrapper(func)) x[0](1, 2, 3) wrapped! 1 2 3 x[1](1, 2) wrapped! 1 2 fruitbat --- Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list
Re: module confusion
On Tue, 02 Oct 2007 19:34:29 +1300, Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Robert Kern wrote: Not all of the modules in a package are imported by importing the top-level package. You can't import packages, only modules. Oh come on, this is unnecessary nitpicking. Importing the module `__init__` from a package using the name of the package is close enough to justify the phrase I import the package IMHO. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: LastWriteTime in windows registry
Peters, Matthew J. ET3 wrote: I'm looking for a way to read the lastwritetime property of a windows registry key. ... I found the function in perl So what does the Perl source say? It presumably hooks some kind of Windows API. Take that and, if it isn't already exposed via pywin32, use ctypes to get hold of it. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
Couldn't agree with you more. What would be fantastic is if I could drop into the Pypi (and/or use easy_install) and download automatically compiled versions of extension modules for different versions of python. I'm sure the community at large would be happy to chip in an annual fee to help build/maintain this infrastructure: I know my firm would. PS: IMHO The growth of Ruby is, to a large extent, due to easy installation of modules via its gem system... On Sep 28, 6:53 pm, John Nagle [EMAIL PROTECTED] wrote: Insofar as Python has an organization, it's not adequately managing extension modules. Each extension module has its own infrastructure, with its own build procedures, its own bug list, and its own maintainers. There's not even an archive. Unlike CPAN, Cheese Shop is just a directory of URLs. Take a look at how Perl does it. Here are the instructions on how to contribute to CPAN: http://www.cpan.org/modules/04pause.html There's a way to get your module into the system, a standardized format, build, and installation procedure, and an archive which is mirrored. There's a common bug reporting system. Modules abandoned by their original developers are not lost, and can be adopted by someone else. Python doesn't have any of this. And that's far more of a problem than Python 3.x. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: reliable unit test logging
Ben Finney wrote: Vyacheslav Maslov [EMAIL PROTECTED] writes: I have many many many python unit test, which are used for testing some remote web service. Part of your confusion comes from the fact that test a remote service isn't what a unit test does. A unit test is one that executes a very *limited* part of the code: it tests a code unit, not the whole system, and makes a simple set of assertions about the result. If there are accesses to remote services over the network, that's far beyond the scope of a unit test. I don't doubt that you may be using the Python standard library module 'unittest' to perform these tests. But they're not unit tests; they're integration tests, or system tests, or performance tests, or something else. Can someone explain my why so simple feature like logging of timestamps during test execution was not implemented in any extension? Probably because the most important thing to know for the purpose of a unit test is whether the yes/no assertions were violated. Knowing when the tests start and finish isn't interesting. If start and finish times *are* interesting for your tests, you're *not* doing unit testing, but some other form of testing like performance tests. I understand your opinion, you are right, i use unit tests for some other kind of work. But anyway it works and produce good results for project. Untested code, that should give you enough to try it out yourself: Thanks i will look into this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about quoting style.
Gabriel Genellina a écrit : En Mon, 01 Oct 2007 19:10:11 -0300, James Stroud [EMAIL PROTECTED] escribi�: Bruno Desthuilliers wrote: First point is that Python has no variable interpolation. If you squint, it kind of does*: print '%(language)s has %(#)03d quote types.' % \ {'language': Python, #: 2} Python has 002 quote types. You might think if the dict as a name space and the formatting operation as performing interpolation--but this take on formatting might be a stretch. Stretching more: py language=Python py number=4 py print '%(language)s has %(number)d quote types.' % locals() Python has 4 quote types. Or even more: py from string import Template py print Template('$language has $number quote types.').substitute(locals()) Python has 4 quote types. Answering to James, Carsten and Gabriel : sorry guys, but I definitively won't count string formatting as variable interpolation - even if, when used with locals(), it comes very close from a practical POV (and is IMHO way cleaner). -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about quoting style.
J. Cliff Dyer a écrit : (snip) You missed another dimension of python string types. I didn't missed - I choosed to skip the subject since it was not about quoting style. Not to say I necessarily made the best choice... -- http://mail.python.org/mailman/listinfo/python-list
Re: s.split() on multiple separators
On 2007-10-01, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 30 Sep 2007 16:16:30 -0300, [EMAIL PROTECTED] escribi?: From my POV, if I want sequence from here to there, it should include both here and there. I do understand the consequences of making high bound exclusive, which is more elegant code: xrange(len(c)). But it does seem a bit illogical... See this note from E.W.Dijkstra in 1982 where he says that the Python convention is the best choice. http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html It may be convincing if you only consider natural numbers in ascending order. Suppose you have the sequence a .. b and you want the reverse. If you work with included bounds the reverse is just b .. a. If you use the python convention, things become more complicated. Another problem is if you are working with floats. Suppose you have a set of floats. Now you want the subset of numbers that are between a and b included. If you want to follow the convention that means you have to find the smallest float that is bigger than b, not a trivial task. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Select as dictionary...
Abandoned [EMAIL PROTECTED] wrote: ( I don't want to use FOR and APPEND because the query have 2 million result and i want to speed) How many times do you plan on doing this? On my system I just timed adding 2 million elements to a dictionary: it took 0.35 seconds. Appending 2 million elements to a list took 0.43 seconds. Unless you really do need to repeat this operation many many many times then just write the obvious code instead of wasting your (and our) time trying to micro-optimise. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tapping into the access of an int instance
[EMAIL PROTECTED] (CM) wrote: CM On Sep 20, 1:21 pm, Tor Erik Sønvisen [EMAIL PROTECTED] wrote: Hi, Does anyone know how to interrupt the lookup of an integer value? I know I need to subclass int, since builtin types can't be altered directly... Below is how far I've come... What I want is to tap into the access of instance i's value 1... class Int(int): def __init__(self, *a, **k): super(Int, self).__init__(self, *a, **k) i = Int(1) i 1 Regards, Tor Erik CM While I'm not *totally* sure what you are asking, you can access the CM first parameter you passed in __init__ via args[0]. What args do you mean? -- Piet van Oostrum [EMAIL PROTECTED] URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: s.split() on multiple separators
Antoon Pardon [EMAIL PROTECTED] writes: It may be convincing if you only consider natural numbers in ascending order. Suppose you have the sequence a .. b and you want the reverse. If you work with included bounds the reverse is just b .. a. If you use the python convention, things become more complicated. It's a tradeoff. The convention used by Python (and Lisp, Java and others) is more convenient for other things. Length of the sequence x[a:b] is simply b-a. Empty sequence is denoted simply with x[a:a], where you would need to use the weird x[a:a-1] with inclusive bounds. Subsequences such as x[a:b] and x[b:c] merge smoothly into x[a:c], making it natural to iterate over subsequences without visiting an element twice. Another problem is if you are working with floats. Suppose you have a set of floats. Now you want the subset of numbers that are between a and b included. If you want to follow the convention that means you have to find the smallest float that is bigger than b, not a trivial task. The exact same argument can be used against the other convention: if you are working with inclusive bounds, and you need to represent the subset [a, b), you need to find the largest float that is smaller than b. -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
Maybe a better question is, how has Tk managed to keep beating up the newer, more modern, more featureful, better documented toolkits encroaching on his territory? What's Tk's secret weapon? There is no secret weapon. It's a question about dependencies, maintenance, stability and supported platforms. Using one of the other Toolkits would mean that an awful lot of libraries need to be included as well - even nowadays, people complain about the size of a python distribution. Then something in the core libraries has to be actively reliably maintained to not endanger the overall release cycles. Linked to that is the question of stability - not so much as it doesn't crash but more on the lines of it doesn't move so fast people cry for newer versions all the time And last but not least is Tk available on a wide range of platforms, larger than more or less every other toolkit. I know of a popular source control software which vendor chose Tk for the same reason. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Overriding Logging Config FileHandler Filename
Kenneth Love wrote: My (probably erroneous) speculation is that I can retrieve a handler specified in the INI file and dynamically change the filename argument to the desired value. So far, I have been unable to figure out how to do this. Here's a brute-force approach (tweaking the config file in memory before passing it on to the logging module) that might work. import logging.config import ConfigParser import StringIO HANDLER = handler LOGFILE = alternate.log instream = open(some.cfg) cp = ConfigParser.ConfigParser() cp.readfp(instream) section = handler_%s % HANDLER oldargs = eval(cp.get(section, args)) cp.set(section, args, (LOGFILE,) + oldargs[1:]) outstream = StringIO.StringIO() cp.write(outstream) outstream.seek(0) logging.config.fileConfig(outstream) logging.error(oops!) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On 2 Okt, 04:54, bramble [EMAIL PROTECTED] wrote: Maybe the key I'm missing is this: maybe GvR and company think that a language absolutely should come off-the-shelf with GUI toolkit bindings. So, given that, they feel they've gotta pick just one, and they've already got Tkinter and it works, so that's that. Is that it? Yes. Also, Tk isn't a particularly fast-moving target compared to some of the other toolkits, so it's possible to not spend too much time maintaining the bindings for it, I imagine. Otherwise, Tkinter might have fallen out of the standard library by now. Paul -- http://mail.python.org/mailman/listinfo/python-list
Using ImageGrab (PIL) to capture screen of remote computer
Hi, Is it possible to use ImageGrab of the Python Imaging Library to capture the screen of a remote computer? I'm running my python program on a computer that is connected directly via a ethernet crossover cable to another computer. Can I somehow get ImageGrab to grab the display of the remote computer by specifying the IP address ? Thanks a lot jorma -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
On Sun, Sep 30 2007, Klaus Schilling wrote: ... private property is unethical How I craved to read that! Viva la revolution! Ест человек - ест проблем, Нет человек - нет проблем! The End justify the means! Long live communism! -- Камен -- http://mail.python.org/mailman/listinfo/python-list
Re: reliable unit test logging
Vyacheslav Maslov [EMAIL PROTECTED] writes: I understand your opinion Hopefully you mean explanation, not opinion. I gave what appear to me to be facts, not opinion, about the definition of a unit test. you are right, i use unit tests for some other kind of work. More accurately: you use the Python 'unittest' framework for some tests that are not unit tests. But anyway it works and produce good results for project. Indeed, there's nothing wrong with using the module this way. The only trouble in this case is confused terminology, that has led you to believe the module is deficient, when actually it's doing the job it's meant to do. Thanks i will look into this. Glad to help. -- \ Holy uncanny photographic mental processes, Batman! -- Robin | `\ | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: s.split() on multiple separators
On 2007-10-02, Hrvoje Niksic [EMAIL PROTECTED] wrote: Antoon Pardon [EMAIL PROTECTED] writes: It may be convincing if you only consider natural numbers in ascending order. Suppose you have the sequence a .. b and you want the reverse. If you work with included bounds the reverse is just b .. a. If you use the python convention, things become more complicated. It's a tradeoff. The convention used by Python (and Lisp, Java and others) is more convenient for other things. Length of the sequence x[a:b] is simply b-a. Empty sequence is denoted simply with x[a:a], where you would need to use the weird x[a:a-1] with inclusive bounds. Subsequences such as x[a:b] and x[b:c] merge smoothly into x[a:c], making it natural to iterate over subsequences without visiting an element twice. Sure it is a tradeoff and the python choice may in the end still turn out the best. But that doesn't contradict that a number of considerations were simply not mentioned in the article refered to. Another problem is if you are working with floats. Suppose you have a set of floats. Now you want the subset of numbers that are between a and b included. If you want to follow the convention that means you have to find the smallest float that is bigger than b, not a trivial task. The exact same argument can be used against the other convention: if you are working with inclusive bounds, and you need to represent the subset [a, b), you need to find the largest float that is smaller than b. Which I think is a good argument against using any convention and having explict conditions for the boundaries to include or exclude them. So instead of writing xrange(2,6) you have to write something like xrange(2 = x 6) which explictly states 2 is included and 6 is excluded. If someone wants both boundaries include he can write xrange(2 = x = 5). A slice notation that would somehow indicate which boundaries are included and which are excluded would be usefull IMO. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
problem with special built-in method __contains__,
if i have a dictionary name number and i want toask the list whether a particular key already exists. print number {'octal': '1234567', 'binary': '10100101', 'decimal': '1234567890', 'hexadecimal': '1-9,a-f'} i got error..after execute number._contains_(test) Traceback (most recent call last): File pyshell#15, line 1, in module number._contains_(test) AttributeError: 'dict' object has no attribute '_contains_' -- http://mail.python.org/mailman/listinfo/python-list
readline() - problem
Hi! I'm a new user of python, and have problem. I have a plain ascii file: 11..1 12..1 11..1 I want to create a new file which contains only lines with '1' on 15th position. I've tried this: import string f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() if s[15]=='1' : o.write(s) o.close() f.close() Why it doesn't work ('s' contains ' ' )? piotr -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On Tue, 2007-10-02 at 03:04 +, bramble wrote: But Py3k is all about breaking compatibility That's a complete distortion of Python 3.0's mission. Python 3.0 breaks backwards compatibility only where there exist good reasons to do so. As Guido put it in a recent Python-3000 post, Python 3000 is boldly choosing to be backwards compatible, except in cases where a real benefit can be obtained by being incompatible. So, unless you can make a case that a real benefit can be obtained by removing Tkinter, it'll stay. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with special built-in method __contains__,
On Oct 2, 12:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: if i have a dictionary name number and i want toask the list whether a particular key already exists. print number {'octal': '1234567', 'binary': '10100101', 'decimal': '1234567890', 'hexadecimal': '1-9,a-f'} i got error..after execute number._contains_(test) It's __contains__ and not _contains_. But better is just: 'test' in number -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list
Re: readline() - problem
On Oct 2, 12:25 pm, [EMAIL PROTECTED] wrote: Hi! I'm a new user of python, and have problem. I have a plain ascii file: 11..1 12..1 11..1 I want to create a new file which contains only lines with '1' on 15th position. I've tried this: import string f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() if s[15]=='1' : o.write(s) o.close() f.close() Why it doesn't work ('s' contains ' ' )? You're iterating over the lines in f already, so no need to call readline. for line in f: if line[15] == '1': o.write(line) -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list
Re: readline() - problem
[EMAIL PROTECTED] writes: import string Why import 'string' if you're not using it? f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() Your line object is already bound to the 'line' name in each iteration. You need to use that, not attempt to read yet another line each time. That is, instead of:: for line in f: foo = f.readline() do_interesting_thing(foo) you should do this:: for line in f: do_interesting_thing(line) -- \ The cost of a thing is the amount of what I call life which is | `\ required to be exchanged for it, immediately or in the long | _o__)run. -- Henry David Thoreau | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Using fractions instead of floats
On 2007-10-01, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Oct 1, 6:26 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-01, Arnaud Delobelle [EMAIL PROTECTED] wrote: Finally, arithmetic would become very confusing if there were three distinct numeric types; it already causes enough confusion with two! Scheme says: It's not that bad. Scheme has prefix numeric operators, so that 1/2 is unambiguously (for the interpreter and the user) a litteral for 'the fraction 1/2'. You can't avoid the confusion in python, as binary operators are infix. Of course, we could create a new kind of litteral. Let's see, / and // are already operators, so why not use /// ? ;) But you wouldn't actually need a literal rational represention. But I'm just playing Devil's Advocate here; I like rationals in Scheme and Lisp, but I don't see a need for them in Python. On the other hand, Python has had complex numbers a long time, and it doesn't need those more than rationals, does it? My guess is that it got complex numbers but not rationals because rationals just aren't very efficient. But as a programmer, I'm mostly just a data-twiddler, and don't generally need either of those numeric type in my day-to-day work. So I'm not the guy to ask. ;) -- Neil Cerutti I'm tired of hearing about money, money, money, money, money. I just want to play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal -- http://mail.python.org/mailman/listinfo/python-list
Re: readline() - problem
Given a file: t.txt 1 2 1 1 3 1 ### end of file ### file = open('t.txt', 'r') for i, line in enumerate(file): print Line:, i, Text:, line would give the result: Line: 0 Text: 1 2 Line: 1 Text: 1 1 Line: 2 Text: 3 1 To check the third character in each line: for line in file: if (line != '') and (len(line) 2): if line[2] == '1': print Got line:, line Would give: Got line: 1 1 Got line: 3 1 Cheers, Wesley Brooks On 02/10/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi! I'm a new user of python, and have problem. I have a plain ascii file: 11..1 12..1 11..1 I want to create a new file which contains only lines with '1' on 15th position. I've tried this: import string f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() if s[15]=='1' : o.write(s) o.close() f.close() Why it doesn't work ('s' contains ' ' )? piotr -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: readline() - problem
On 2 Pa , 13:39, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: import string Why import 'string' if you're not using it? f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() Your line object is already bound to the 'line' name in each iteration. You need to use that, not attempt to read yet another line each time. Of course, it helped. Many thanks for all. piotr -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with special built-in method __contains__,
On Tue, Oct 02, 2007 at 11:14:38AM -, [EMAIL PROTECTED] wrote regarding problem with special built-in method __contains__,: if i have a dictionary name number and i want toask the list whether a particular key already exists. print number {'octal': '1234567', 'binary': '10100101', 'decimal': '1234567890', 'hexadecimal': '1-9,a-f'} i got error..after execute number._contains_(test) Traceback (most recent call last): File pyshell#15, line 1, in module number._contains_(test) AttributeError: 'dict' object has no attribute '_contains_' First of all, the special methods contain a *double* underscore before and after the name, so it's not _contains_, it's __contains__. Secondly, for most basic operations, you shouldn't have to use these special methods directly. They are bound to other funtionality in Python. So instead of: number.__contains('test') try the following: 'test' in number Cheers, Cliff -- http://mail.python.org/mailman/listinfo/python-list
file open dialog from within PythonWin
Hi, I want to open a file seach dialog from within my python script which I run from within PythonWin. I also have the wxPython package installed. How might I do this? Thanks, Aine -- http://mail.python.org/mailman/listinfo/python-list
Inheriting from int or long
I started creating a simple bits class, intended to act like a array of bits. This was my initial idea, basically just overriding the string representation to display the bitmask (so far): class bits(long): def __str__ (self): s = '' if self == 0L: s += '-' else: x = self while x = 1: if x 1L: s = '#' + s else: s = '-' + s x = 1 return s My thought was this will act like a Long, and so should act like an array of bits with arbitrary precision, supporting the standard bitwise operations, along with others I may add. import bits b = bits.bits(32) b 32L print b #- b = bits.bits(35) print b #---## b = bits.bits(36) print b #--#-- b = 1 print b 72 So obviously when I attempt a bitwise operation (ex. b = 1), b is being assigned the result of b 1, which is a Long. b = bits.bits(36) type(b) class 'bits.bits' type (b 1) type 'long' Is there any way around this without reimplementing all of the bitwise operators? It's not the biggest deal to reimplement the operators, but it kind of defeats the benefit of inheriting from an integer type. If there isn't a way around this, then I am curious in what situations it would be beneficial to inherit from an int or long. This issue seems more related to numeric types, since they are so centered around operations that involve assignment, as opposed to, say, a List, which has some operators (ex. +=), but does not depend on them (ex. use append() instead). -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a custom python python distribution
On Sep 30, 10:18 pm, shailesh [EMAIL PROTECTED] wrote: Hi, I wish to create a Python distribution includind Python and some other libraries (Zope 3, PyWin32, numpy, lxml, etc.) which are required for my applications. e.g. there are Enthough and ASPN distributions of Python. Unfortunately, I have not been able to find the right documentation for this purpose. Could some one give an overview of what needs to be done for this purpose? With regards, -Shailesh Are you wanting to create an executable or what? There are a few different ways to distribute your work. You can use py2exe, GUI2exe (a py2exe wrapper), PyInstaller, Distutils or Python Eggs. Here are some links: http://pyinstaller.python-hosting.com/ http://www.py2exe.org/ http://xoomer.alice.it/infinity77/main/GUI2Exe.html http://docs.python.org/dist/dist.html http://peak.telecommunity.com/DevCenter/PythonEggs That should get you started. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: setuptools without unexpected downloads
On Sep 27, 10:44 am, Fredrik Lundh [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: What would it entail to do this? Using py2exe + some installer (like Inno Setup) to create an installer that basically copies/installs the files into the site-packages folder or wherever the user chooses? if the setup.py file is properly built, python setup.py bdist_wininst builds an installer that does exactly that. ideally, someone doing this would: 1) build EXE installers and EGG:s for a reasonable number of Python versions (e.g. 2.3 and newer) for selected releases. if possible, using the same compilers as used for the python.org core distribution. 2) test the installers in some way (at least some kind of sanity checking is necessary; i.e. installing the kit and checking that the core modules can at least be imported). 3) if necessary, work with upstream providers to fix/improve setup.py and test code. /F Mr. Lundh, Holden indicates that VS2003 is the current compiler used for the official Python distribution. Do you know how to use that program to compile an exe? I'm assuming the line python setup.py bdist_wininst isn't sufficient since it was an answer to my somewhat naive question. Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: I earn $36800 a month with google adsense
On 2 okt, 03:41, panguohua [EMAIL PROTECTED] wrote: On 10 1 , 8 06 , panguohua [EMAIL PROTECTED] wrote: On 10 1 , 1 13 , panguohua [EMAIL PROTECTED] wrote: www.space666.com a good website for making money with your blog.more information there support! ! good Wow ! I have a question though. If you really make $38600 a month, how come you even bother to spam us? Alain -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheriting from int or long
[EMAIL PROTECTED] wrote: I started creating a simple bits class, intended to act like a array of bits. This was my initial idea, basically just overriding the string representation to display the bitmask (so far): class bits(long): def __str__ (self): s = '' if self == 0L: s += '-' else: x = self while x = 1: if x 1L: s = '#' + s else: s = '-' + s x = 1 return s My thought was this will act like a Long, and so should act like an array of bits with arbitrary precision, supporting the standard bitwise operations, along with others I may add. import bits b = bits.bits(32) b 32L print b #- b = bits.bits(35) print b #---## b = bits.bits(36) print b #--#-- b = 1 print b 72 So obviously when I attempt a bitwise operation (ex. b = 1), b is being assigned the result of b 1, which is a Long. b = bits.bits(36) type(b) class 'bits.bits' type (b 1) type 'long' Is there any way around this without reimplementing all of the bitwise operators? It's not the biggest deal to reimplement the operators, but it kind of defeats the benefit of inheriting from an integer type. No, there isn't. How is the existing operation of the operator going to know that you want an instance of bits instead of long? It can't possibly know that, even if it looked at the class of one or even both of it's operands: it could be that instantiating a bits-object needed a reference to TheCommonApplicationContextThingy or so If there isn't a way around this, then I am curious in what situations it would be beneficial to inherit from an int or long. This issue seems more related to numeric types, since they are so centered around operations that involve assignment, as opposed to, say, a List, which has some operators (ex. +=), but does not depend on them (ex. use append() instead). It's beneficial if you want special behavior - but I don't see how the requirement of overloading the methods to make thinks work affect the grade of beneficiality. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
bramble wrote: Maybe a better question is, how has Tk managed to keep beating up the newer, more modern, more featureful, better documented toolkits encroaching on his territory? What's Tk's secret weapon? Wouldn't license compatability be an issue? Tk's license is BSD-style, which means it plays nice with both proprietary and open-source software (as does Python's license). Aren't PyGtk and wxPython LGPL? And PyQt is either GPL or proprietary. -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
access __doc__ from within function without reference to function name
The subject of this message might be a little cryptic, so here's an example of what I mean: def foo(): doc string of foo print foo.__doc__ foo() doc string of foo What I want to know is whether it is possible to call __doc__ against some builtin method, like __func__ or something like that. So calling __doc__ without the functions name, something like this: def foo(): doc string of foo print __func__.__doc__ # pseudo code So basically, my question is: is there a way to access a function from within itself without using its name? Regards, Sander. -- http://mail.python.org/mailman/listinfo/python-list
Re: file open dialog from within PythonWin
On Oct 2, 7:56 am, [EMAIL PROTECTED] wrote: Hi, I want to open a file seach dialog from within my python script which I run from within PythonWin. I also have the wxPython package installed. How might I do this? Thanks, Aine Aine, I recommend downloading the wxPython Demo as it shows how to do most common tasks and a lot of other cool things as well. It includes code for common dialogs, such as the FileDialog, which is what I think you want. The man page for this widget is below: http://www.wxpython.org/docs/api/wx.FileDialog-class.html You can find the Demo here: http://www.wxpython.org/download.php Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: file open dialog from within PythonWin
On Oct 2, 7:56 am, [EMAIL PROTECTED] wrote: Hi, I want to open a file seach dialog from within my python script which I run from within PythonWin. I also have the wxPython package installed. How might I do this? Thanks, Aine Oh yeah. You might find this helpful too: http://wiki.wxpython.org/Getting_Started Mike -- http://mail.python.org/mailman/listinfo/python-list
random keypress bounce in a terminal
Hi all, I'm a novice in the world of Python and to begin with something useful I want to create a small tool for my microcontroller work. So I wrote a binary file compare (called bfc). It is just a few lines and put here with two sample files: http://www.evoran.hu/tmp I have found a keypress handler and built into my program. It works fine as long as I hit keys normally, but gives extra characterts if I keep pressing some key, e.g. up or down arrow keys. It runs on a Linux system. What's the wrong with it? Thanks for any help, István -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
neil wrote: I see python is not really there for 64 bit yet but most of the people I think you mean Windows is not really there for 64 bit yet. Python works well on real 64 bit operating system. Blender does too I presume. -- http://mail.python.org/mailman/listinfo/python-list
Re: access __doc__ from within function without reference to function name
SanPy [EMAIL PROTECTED] wrote: So basically, my question is: is there a way to access a function from within itself without using its name? Not really, no. Python is executing a code block, it has no idea which function referenced that code block. You can get the current code object quite easily (inspect.currentframe ().f_code), but the reference from function to code is one way: a single code object could be used by multiple functions. You can get the source code though, so if you are desperate enough you could try parsing the source code to extract the docstring: print inspect.getsource(inspect.currentframe()) Use the name of the function, that's the best way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python's robotparser like Wikipedia's robots.txt file?
On 02/10/2007, John Nagle [EMAIL PROTECTED] wrote: But there's something in there now that robotparser doesn't like. Any ideas? Wikipedia denies _all_ access for the standard urllib user agent, and when the robotparser gets a 401 or 403 response when trying to fetch robots.txt, it is equivalent to Disallow: *. http://infix.se/2006/05/17/robotparser It could also be worth mentioning that if you were planning on crawling a lot of Wikipedia pages, you may be better off downloading the whole thing instead: http://download.wikimedia.org/ (perhaps adding http://code.google.com/p/wikimarkup/ to convert the wiki markup to HTML). -- filip salomonsson -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
bramble [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | I don't know... As I meant to imply above, it's looking like Tkinter | will be playing its expected role in Py3k as the GUI toolkit of | choice. And from what I've seen of the Py3k effort, there's been | really excellent work on pulling out stuff that should be pulled out. | So, if it was *really* simply only first-mover advantage keeping it | there, I'd expect to see talk of removing it from the standard | library. First, the 3.0a1 release put off modification of the stdlib. Second, Guido wants to distribute a minimal development environment - Idle - and that is written in TKinter. Third, I have not seen a formal proposal from the authors of any other GUI toolkit that such replace TKinter or even supplement it. There are disadvantages as well as advantages to having one's work in the stdlib. -- http://mail.python.org/mailman/listinfo/python-list
Adding behaviour for managing task dependencies
Hi, I'm currently writing an animation pipeline in Python which is a system for controlling the flow of work and assets for a team of people working on a computer animated film. The system will be fairly large with a database backend. One particular problem that I'd like to address is the need for managing dependent tasks. Often you need to process one particular set of information before starting on another so when you batch them all together and send them off to a set of computers to process you need some way of formulating the dependencies. This preferably ends up looking a lot like a Makefile in the end with syntax a bit like: task task_name (dependencies): commands to complete the task ... Where the dependencies are a list of other tasks that need to be completed first. However I'd really like to do it in Python, but I'm thinking I'd might need to extend Python a bit in order to achieve the new syntax. I've seen attempts to do this within the Python syntax (Scons and buildIt) and I'm not a big fan of the way it ends up looking. I've worked at a place that has written it's own language to handle that sort of thing but then you end up with a language that is good for that but rubbish at everything else. Python seems like a good basis if I could tweak it slightly. One particular point that interests me is the idea of maintaining compatibility with Python modules so you still have all the functionality. This makes me think of the from __future__ import ... statements which, if I understand them correctly, can introduce new syntax like the with_statement, whilst still maintaining compatibility with older modules? Is this correct? Can anyone write a syntax changing module or is __future__ a hard coded special case? I realise I'll have to get into the C side of things for this. Are there other approaches to this that I really should be considering instead? Any thoughts would be most appreciated, though I would like to stress that I don't think Python should support the syntax I'm proposing I'd just like to know if I can extend a copy of it to do that. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: access __doc__ from within function without reference to function name
The subject of this message might be a little cryptic, so here's an example of what I mean: def foo(): doc string of foo print foo.__doc__ foo() doc string of foo What I want to know is whether it is possible to call __doc__ against some builtin method, like __func__ or something like that. So calling __doc__ without the functions name, something like this: def foo(): doc string of foo print __func__.__doc__ # pseudo code So basically, my question is: is there a way to access a function from within itself without using its name? Well, I don't know if it's the best way to do it, but the following code I just threw together does the trick for me: ### A module docstring import inspect def get_doc_string(): frame = inspect.stack()[1] funcname = frame[3] try: # for straight functions return eval(funcname).__doc__ except: locals = frame[0].f_locals try: # for object methods return getattr(locals[self], funcname).__doc__ except: try: # for class and module docstrings return locals[__doc__] except: print If you got here, there's something I missed import pdb; pdb.set_trace() return funcname if __name__ == __main__: def outer_function(): A function docstring s = get_doc_string() print s return s class Foo(object): A class docstring zip = get_doc_string() def bar(self): A method's docstring s = get_doc_string() print s return s def f1(func): this is f1 s = func() print s return s test = outer_function() assert test == A function docstring foo = Foo() assert foo.bar() == A method's docstring print Foo.zip assert Foo.zip == A class docstring module_docstring = get_doc_string() print module_docstring assert module_docstring == A module docstring assert f1(get_doc_string) == this is f1 ### I couldn't find a handy way to get the actual function-object/class-object/module/method object for the given context without the convoluted try/except block. Perhaps someone with more knowledge of the inspect module could reudce that do something far more simple. There may also be problems if this is imported across modules. But this might help point you in the right direction. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
Duncan Booth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Subclassing doesn't have to imply a common implementation, just a common | interface. True, but in Python, subclassing is usually done to reuse implementation. Interface subclassing is usually from a common abstract base class (which will be better supported in Py3).. -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On Monday 01 October 2007 21:04, bramble wrote: What is the backstory to why Python includes Tk bindings, as opposed to some other set of bindings? I've written a few little Tkinter-based apps, and it's nice and simple. I like it well enough. That said though, I keep feeling the gravitational pull toward GTK+. I've been meaning to get the whole glade+gtk+python thing happening with my own projects, as soon as time allows. Is there resistance in the upper Python echelons to GTK because of its LGPL licensing? Reading Alex's Nutshell book, right off the bat he comments that The most popular Python GUI toolkit today is probably wxPython. But then he goes on for 45 pages on Tkinter... Seems like he wanted to write that chapter on wx instead... WxWidgets, the last time I looked at it, seemed awfully like MS Window's MFC. The licensing seemed vague at the time, and it looks like wx contains an extra layer of GUI library, so I didn't spend any real time on it. But, regardless, it seems to get good press among python folk (I think I remember ESR noting how it was his GUI toolkit of choice). PyQt has had that issue (IIRC) about needing to pay for it for commercial apps, so I can see how there might be resistance to it being considered the standard Python GUI toolkit. So, it would seem to me that Tkinter *might* remain in Python proper, but that I probably wouldn't see much effort put into it. Well, the Python standard library docs tell a different story. There's stuff in there about Tix, ScrolledText, turtle, and then the other GUI packages doc page goes on about Python megawidgets (Tk-based) and Tkinter3000 Widget Construction Kit (WCK). Wow. Looks like Tkinter is still having serious support -- even though in that same doc at the bottom notes, PyGTK, PyQt, and wxPython, all have a modern look and feel and far more widgets and better documentation than Tkinter. So, that leaves me wondering, why is Tkinter still getting so much focus in the Python standard library? Maybe a better question is, how has Tk managed to keep beating up the newer, more modern, more featureful, better documented toolkits encroaching on his territory? What's Tk's secret weapon? Tkinter's secret weapon are pgmrs like me that would rather put pressure on the Tk people to improve what already is working. Update and improve Tk, change the look and feel of it, add features. Let me spend my time programming not trying to make existing programs compatible with the unknown. (Some change to who knows what.) On the other hand, questions like yours are exactly what keeps the pressure on the Tkinter people to upgrade. I think they got the message with the recent announcement of some long awaited changes. jim-on-linux http://inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Dictionary invalid token error
This works: area_group = {001:06, 002:04, 003:04, 006:9} This does not (one the end, 09 is used instead of 9) area_group = {001:06, 002:04, 003:04, 006:09} File stdin, line 1 area_group = {001:06, 002:04, 003:04, 006:09} SyntaxError: invalid token Why does 09 cause an invalid token while 9 does not? ### Python 2.4.4 (#2, Apr 5 2007, 18:43:10) [GCC 4.1.2 20061115 (prerelease) (Debian AMD64 4.1.1-21)] on linux2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary invalid token error
This works: area_group = {001:06, 002:04, 003:04, 006:9} This does not (one the end, 09 is used instead of 9) area_group = {001:06, 002:04, 003:04, 006:09} File stdin, line 1 area_group = {001:06, 002:04, 003:04, 006:09} SyntaxError: invalid token Why does 09 cause an invalid token while 9 does not? Numbers with leading zeros are parsed as octal. 8 and 9 are invalid digits in octal. Thus, it falls over. 00 through 07 will work fine, but 08 and 09 will go kaput. http://docs.python.org/ref/integers.html -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary invalid token error
brad [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Why does 09 cause an invalid token while 9 does not? 9 isn't a valid octal digit. You probably want to use strings for storing telephone number like codes, if leading zeroes are significant. -- http://mail.python.org/mailman/listinfo/python-list
Re: How popular is Django ?
Thomas Guettler [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: | comp.lang.python is a usenet group. which means that it is independently hosted on newsservers around the world. It is also a mailing list hosted by python.org and a gmane group. |django-users is a mailinglist hosted by google. |The number of django-users subscribers can be calculated by google. |But the number of comp.lang.python users can only be guessed. Unless Google claims otherwise, I would assume that '11000' is only the number of people who access c.l.p via Google. And if they did so claim, I would want to see the algorithm before giving it any credence. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary invalid token error
Tim Chase wrote: Numbers with leading zeros are parsed as octal. 8 and 9 are invalid digits in octal. Thus, it falls over. 00 through 07 will work fine, but 08 and 09 will go kaput. http://docs.python.org/ref/integers.html -tkc Thanks... that makes sense. I'll store them as strings. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python's robotparser like Wikipedia's robots.txt file?
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], John Nagle wrote: For some reason, Python's parser for robots.txt files doesn't like Wikipedia's robots.txt file: import robotparser url = 'http://wikipedia.org/robots.txt' chk = robotparser.RobotFileParser() chk.set_url(url) chk.read() testurl = 'http://wikipedia.org' chk.can_fetch('Mozilla', testurl) False chk.errcode 403 Significant? Helpful. Also an undocumented feature. See http://docs.python.org/lib/module-robotparser.html John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On 10/1/07, bramble [EMAIL PROTECTED] wrote: What is the backstory to why Python includes Tk bindings, as opposed to some other set of bindings? I've written a few little Tkinter-based apps, and it's nice and simple. I like it well enough. That said though, I keep feeling the gravitational pull toward GTK+. I've been meaning to get the whole glade+gtk+python thing happening with my own projects, as soon as time allows. Is there resistance in the upper Python echelons to GTK because of its LGPL licensing? Reading Alex's Nutshell book, right off the bat he comments that The most popular Python GUI toolkit today is probably wxPython. But then he goes on for 45 pages on Tkinter... Seems like he wanted to write that chapter on wx instead... WxWidgets, the last time I looked at it, seemed awfully like MS Window's MFC. The licensing seemed vague at the time, and it looks like wx contains an extra layer of GUI library, so I didn't spend any real time on it. But, regardless, it seems to get good press among python folk (I think I remember ESR noting how it was his GUI toolkit of choice). PyQt has had that issue (IIRC) about needing to pay for it for commercial apps, so I can see how there might be resistance to it being considered the standard Python GUI toolkit. So, it would seem to me that Tkinter *might* remain in Python proper, but that I probably wouldn't see much effort put into it. Well, the Python standard library docs tell a different story. There's stuff in there about Tix, ScrolledText, turtle, and then the other GUI packages doc page goes on about Python megawidgets (Tk-based) and Tkinter3000 Widget Construction Kit (WCK). Wow. Looks like Tkinter is still having serious support -- even though in that same doc at the bottom notes, PyGTK, PyQt, and wxPython, all have a modern look and feel and far more widgets and better documentation than Tkinter. So, that leaves me wondering, why is Tkinter still getting so much focus in the Python standard library? Maybe a better question is, how has Tk managed to keep beating up the newer, more modern, more featureful, better documented toolkits encroaching on his territory? What's Tk's secret weapon? Tk is stable, slow moving, highly portable, and liberally licensed. It's not very good except for that, but those are very important characteristics for something in the standard library. You'll note that Tix and the various other Tk expansion packs aren't in the stdlib. wxPython is LGPL with a binary linking exception - there's no license ambiguity there - but it develops far too fast to be in the stdlib. PyQt is GPL or commercial only and I wouldn't consider that suitable for a standard library package. PyGtk has poor cross platform support, a very large footprint (the largest of all these libraries) as well as a complicated runtime environment. It's probably the closest to suitable for standard library inclusion, but it doesn't have the binary linking exemption that wxPython does (theres some question as to how needed that is for Python code, though) and it's got no compelling API advantage over Tk. If you want to trade the large footprint for the more advanced toolkit, thats an option you have but I don't think it's a suitable standard library decision. -- http://mail.python.org/mailman/listinfo/python-list
Subprocesses on Windows
Hey Guys! Well before I explain my problem, let me tell you all that I am not a professional programmer and new to python too. I just write some scripts as and when required and this time it seems I am stuck somewhere in trying to create subprocesses. The problem is something like this. I am trying to run nmap scan on my network and for that I want to start multiple nmap instances (256 at once) togather and wait till those 256 are over before I start next lot of 256 instances. Well to test I have put in two nmap scans in my program and I have succeeded to start both of them simultaneously (in fact one after another) by using subprocess module and Popen. But the problem is when I run a loop to start both of these nmap instances, they do start BUT the script then exits to command prompt completing all the executions. But this is not what I want. I want to wait till both of these nmap processes are finished and then only exit from script (in fact exit from that function or loop). Then only I would be able to call next lot of IP Ranges to scan. I did try os.waitpid() but it gives following error while running the program: ### [10172, 'None']This is the variable where I am storing process IDs ### Traceback (most recent call last): File C:\python\inscan.py, line 121, in module clas_b() File C:\python\inscan.py, line 92, in clas_b wpid, sts = os.waitpid(retval[i], 0) and passing here to os.waitpid OSError: [Errno 10] No child processes I hope you guys understood! I am pasting my function here. Just have a look and suggest something for that. I heard fork() is not supported for windows and that's why I used 'subprocess module'. def clas_b(): i = 0 IP = ((10,50,89,0,24), (10,50,90,0,24)) retval = ['None', 'None'] for k in IP: b1 = k[0]; b2 = k[1]; b3 = k[2] b4 = k[3]; mkb = k[4] # Call the subprocess using convenience method #retval[i] = subprocess.call(clas_c(b1, b2, b3, b4, mkb), 0, None, None, \ # outptr[i], errptr[i], shell=True) # clas_c actually runs Nmap command and stores results in an output file retval[i] = int(subprocess.Popen(clas_c(b1, b2, b3, b4, mkb), \ shell=True).pid) print ### print retval print ### while 1: wpid, sts = os.waitpid(retval[i], 0) if os.WIFSTOPPED(sts): continue I don't know anything about this elif os.WIFSIGNALED(sts): I just found this somewhere and return -WTERMSIG(sts) pasted to my program for to test elif os.WIFEXITED(sts): return os.WEXITSTATUS(sts) else: raise error, Not stopped, signaled or exited??? i += 1 Thanks, Nachiket Joshi Yahoo! oneSearch: Finally, mobile search that gives answers, not web links. http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC-- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python's robotparser like Wikipedia's robots.txt file?
Filip Salomonsson wrote: On 02/10/2007, John Nagle [EMAIL PROTECTED] wrote: But there's something in there now that robotparser doesn't like. Any ideas? Wikipedia denies _all_ access for the standard urllib user agent, and when the robotparser gets a 401 or 403 response when trying to fetch robots.txt, it is equivalent to Disallow: *. http://infix.se/2006/05/17/robotparser That explains it. It's an undocumented feature of robotparser, as is the 'errcode' variable. The documentation of robotparser is silent on error handling (can it raise an exception?) and should be updated. It could also be worth mentioning that if you were planning on crawling a lot of Wikipedia pages, you may be better off downloading the whole thing instead: http://download.wikimedia.org/ (perhaps adding http://code.google.com/p/wikimarkup/ to convert the wiki markup to HTML). This is for SiteTruth, the site rating system (see sitetruth.com), and we never look at more than 21 pages per site. We're looking for the name and address of the business behind the web site, and if we can't find that after looking in 20 of the most obvious places to look, it's either not there or not prominently disclosed. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: win32com COMAdminCatalogObject Value method
Try objCOMAdminCatalogObject.SetValue(ID, AppID). Roger- Hide quoted text - - Show quoted text - When I try that I get exception: AttributeError: Add.SetValue I think the only valid methods are: Key(), Name(), Valid() and Value() The thing I'm most confused about is that it seems to be getting into the __getattr__ method, not the set, here's the whole error: Traceback (most recent call last): File C:\programming\python\dev\src\FullInstallScripts \COMObjectFullInstall.py, line 74, in module CreateApplication() File C:\programming\python\dev\src\FullInstallScripts \COMObjectFullInstall.py, line 21, in CreateApplication objCOMAdminCatalogObject.SetValue(ID, AppID) File C:\Python25\Lib\site-packages\win32com\client\dynamic.py, line 496, in __getattr__ raise AttributeError, %s.%s % (self._username_, attr) AttributeError: Add.SetValue -- http://mail.python.org/mailman/listinfo/python-list
Question on overriding implicit lookups
In Python we have a wonderful facility for customizing attribute access by defining __getattr__ or __getattribute__ in our classes. Unfortunately (or perhaps fortunately, for reasons I don't know), this facility only works for explicit attribute access, i.e. accessing foo.bar. What I am in need of, for reasons I'll keep out of the discussion for now, is a similar facility for implicit attribute access, such as the call to foo.__len__ when something like len(foo) is executed. I would like some way to customize access during these implicit lookups without having to define each one in the class myself. Essentially what I am looking for is a mechanism like __getattribute__, only one that will work for these implicit lookups to functions like __len__, __str__, __getitem__, and so on. Hopefully my question makes sense. -- http://mail.python.org/mailman/listinfo/python-list
Re: access __doc__ from within function without reference to function name
Tim Chase [EMAIL PROTECTED] wrote: So basically, my question is: is there a way to access a function from within itself without using its name? Well, I don't know if it's the best way to do it, but the following code I just threw together does the trick for me: The original request was to do it without using the function's name, but you are depending on that name so your code is easy enough to break. e.g. change the definition of f1 to: def f2(func): this is f1 s = func() print s return s f1 = f2 del f2 and the output is: A function docstring A method's docstring A class docstring A module docstring If you got here, there's something I missed c:\temp\docstring.py(18)get_doc_string() - return funcname (Pdb) -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyPE 2.8.7
On Sep 26, 12:50 am, stef [EMAIL PROTECTED] wrote: thebjorn wrote: On Sep 25, 12:37 pm, stef [EMAIL PROTECTED] wrote: Josiah Carlson wrote: === What isPyPE? === PyPE(Python Programmers' Editor) was written in order to offer a lightweight but powerful editor for those who think emacs is too much and idle is too little. Syntax highlighting is included out of the box, as is multiple open documents via tabs. sounds very good, so now I want to try it ... ... the windows ansi zip file is corrupted :-( ... the unicode version crashes :-( This is what the log file tells: Traceback (most recent call last): File pype.py, line 110, in ? File zipextimporter.pyc, line 78, in load_module File configuration.pyc, line 149, in ? Exception: Unable to create config directory: 'G:\\.pype' I don't have a G-drive ;-) cheers, Stef Mientki You must be doing it wrong. Of course ;-) but what am I doing wrong ? cheers, Stef Works flawlessly for me (no g: drive here either) -- well, except that it doesn't have Emacs keybindings wink. -- bjorn We ended up emailing directly. His problems were related to less-than- correct HOME, USERPROFILE, HOMEDRIVE, and/or HOMEPATH values. When such things happen, users can either fix their profile paths, or run PyPE with --standalone, which will force the profile path to be the same path as the path that PyPE is running out of. Also, the original PyPE 2.8.7 ansi upload was incomplete, which I remedied shortly thereafter (and later replaced with PyPE 2.8.8). -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheriting from int or long
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] |I started creating a simple bits class, intended to act like a array | of bits. This was my initial idea, basically just overriding the | string representation to display the bitmask (so far): For this purpose, for the reason you discovered, simply writing a bit_rep function would likely be better ;-) [discovery of need to override possibly all of long's special methods] || Is there any way around this without reimplementing all of the bitwise | operators? It's not the biggest deal to reimplement the operators, but | it kind of defeats the benefit of inheriting from an integer type. Since the code needed is mostly boilerplate, I think the standard Python distribution could and should contain builtin type subclass template files, at least for int/long/float for the reasons you give below. | If there isn't a way around this, then I am curious in what situations | it would be beneficial to inherit from an int or long. As I already said, if you only want to change __str__, consider a standalone function. If you want to change the behavior of any of the operations and still tie into the syntax, then the alternative, wrapping the builtin, may be worse. class mysub(int): ... def __add__(self, other): return mysub(self,other) versus class mywrap(): def __init__(self,dat): self._int = dat # should test type def __add__(self, other): return mywrap(self._int + other._int) | This issue | seems more related to numeric types, since they are so centered around | operations that involve assignment, as opposed to, say, a List, which | has some operators (ex. +=), but does not depend on them (ex. use | append() instead). Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: I earn $36800 a month with google adsense
I am only a publisher!!! really it is useful -- http://mail.python.org/mailman/listinfo/python-list
Re: random keypress bounce in a terminal
István wrote: It works fine as long as I hit keys normally, but gives extra characterts if I keep pressing some key, e.g. up or down arrow keys. It runs on a Linux system. What's the wrong with it? Nothing. Linux VTs will generate multiple characters for special keys. Regards, Björn -- BOFH excuse #258: That's easy to fix, but I can't be bothered. -- http://mail.python.org/mailman/listinfo/python-list
Re: I earn $36800 a month with google adsense
Wow ! I have a question though. If you really make $38600 a month, how come you even bother to spam us? Please, don't reply - and especially, don't reply quoting the spammer's site, so his page-rank inncreases... diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Can you please give me some advice?
* Bruno Desthuilliers (Sat, 29 Sep 2007 19:17:43 +0200) [EMAIL PROTECTED] a écrit : (snip) I know nothing of Ruby, but just the fact that in Ruby the Hello World program is puts 'Hello, World!' whereas the Python Hello World program is print 'Hello, World!' suggests to me that Python is more intuitive because the word print has a meaning in English that makes sense given what you want to do, but puts just doesn't. Hem Sorry, but it reminds me of the most clueless comments on Python I've seen on c.l.ruby. I really don't think Python is more or less intuitive than Ruby, and making a judgement on such a pointless detail is not even worth the bandswith IMHO. FWIW, 'puts' means 'put string' (implied : on stdout), which is certainly much more semantically correct than what 'print' implies. You missed the point. puts for printing something to stdout is definitely a bad name for this operation. I mean put string (even abbreviated) what does that mean? On the other hand it does not mean that Python ist more intuitive than Ruby - only the printing to stdout is more intuitive. -- http://mail.python.org/mailman/listinfo/python-list
toprettyxml messes up with whitespaces
Hi all, I parse an XML file, replace a node with a new one (like updating cache) and write it back. Every write, new spaces are added. For example, first read - update - write cycle; var name=APPNAME status=undefined My First App /var Second cycle: var name=APPNAME status=undefined My First App /var Third cycle: var name=APPNAME status=undefined My First App /var And this goes on. The node is one that is not touched in the XML, it is simply written back after reading. I have the same with void spaces in between the nodes, I managed to compensate that by stripping the lines. I would like to use toprettyxml to make it user editable and viewable. But this is really weird. How can I circumvent this behaviour? regards, - Jorgen -- http://mail.python.org/mailman/listinfo/python-list
Re: Using fractions instead of floats
On Oct 2, 12:42 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-01, Arnaud Delobelle [EMAIL PROTECTED] wrote: Scheme has prefix numeric operators, so that 1/2 is unambiguously (for the interpreter and the user) a litteral for 'the fraction 1/2'. You can't avoid the confusion in python, as binary operators are infix. Of course, we could create a new kind of litteral. Let's see, / and // are already operators, so why not use /// ? ;) But you wouldn't actually need a literal rational represention. In which case rationals are better off in a module than in the language! But I'm just playing Devil's Advocate here; I like rationals in Scheme and Lisp, but I don't see a need for them in Python. On the other hand, Python has had complex numbers a long time, and it doesn't need those more than rationals, does it? My guess is that it got complex numbers but not rationals because rationals just aren't very efficient. Another guess could be that real numbers being closed under the four arithmetic operations, there is no danger to accidentally step into complex numbers. OTOH floats and rationals are two (conflicting) ways of extending integers. But as a programmer, I'm mostly just a data-twiddler, and don't generally need either of those numeric type in my day-to-day work. So I'm not the guy to ask. ;) I use rationals a lot, and I don't want them in the language :) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
On 2007-10-01 23:37:28 +0200, Wildemar Wildenburger [EMAIL PROTECTED] said: Frank Goenninger wrote: On 2007-09-29 01:27:04 +0200, Damien Kick [EMAIL PROTECTED] said: If you were referring to the free in free Mumia Abu Jamal, I would agree with you. I don't think anyone would imagine that this phrase meant that someone was going to get Mumia Abu Jamal gratis. Like it or not, free software referring to free as in beer is probably the most common interpretation of the phrase for a native English speaker. Admittedly, I do not have a scientific survey handy. However, I just asked my wife--who has absolutely no interest in anything related to programming, has never heard of the FSF, Eric Raymond, nor the disagreement between those two camps, nor probably will she ever have an interest--what she thinks I mean when I say free software. After getting over the why are you asking such a stupid question phase, the first thing that jumped to her mind was free as in beer. You can stamp, growl, swagger, spit, curse, and bluster all you want on this point, but millions of English speakers are going to ignore you anyway. Lucky for most of them, they do not have to suffer the lectures of sociopolitically motivated language mavens trying to correct them from the error of mistaking the meaning of a phrase to be the normal meaning of that phrase. Fully true for non-native English speakers as well. Just did the wife test also - she is a pure software user - and yes, free is no money, do what you want and that's it. I *never* use the term free if I don't want to imply free beer (which is a Good Thing and as such highly valuated - ask any Bavarian). Using free as by FSF or any other lawyer-style 6 pixel font printed phrasing is pure perfidiousness. I appearantly missed a lot of that conversation, but what is your point? While I agree that the word free implies free of monetary cost to many people societies, that is by no means set in stone (talk to native americans, blacks, jews, palestinians, etc. about the word free, see what they have to say). But that aside: The word free with respect to the FSF and GPL have a perfectly well defined meaning. People may misunderstand that from not knowing the definition but that doesnt make it any less well defined. Again, why this discussion? /W Well, I didn't start the discussion. So you should ask the OP about the why. I jumped in when I came across the so often mentioned hey, it's all well defined statement was brought in. I simply said that if that well-definedness is against common understanding then I don't give a damn about that clever definitions. Because I have to know that there are such definitions - always also knowing that free is not really free. It is such a good subject to discuss over and over and over without ever reaching any conclusion or resolution because neither FSF nor GNU nor the FREE as in FREE BEER defenders will change their mind. So, wasting bandwith is the only real effect ... And hey, it's Usenet, so wasting time and bandwith is part of the game. Again, why this discussion - ah - I don't really know... ;-) -- Frank Goenninger frgo(at)goenninger(dot)net Don't ask me! I haven't been reading comp.lang.lisp long enough to really know ... -- http://mail.python.org/mailman/listinfo/python-list
Re: access __doc__ from within function without reference to function name
The original request was to do it without using the function's name, but you are depending on that name so your code is easy enough to break. e.g. change the definition of f1 to: def f2(func): this is f1 s = func() print s return s f1 = f2 del f2 Even Python-proper seems to get confused by this (though I would contend it's correct behavior): === def f1(): raise Exception f2 = f1 del(f1) f2() === The traceback references f1() instead of f2. (other printing than the calling line of code from the python file itself) === Traceback (most recent call last): File x.py, line 5, in ? f2() File x.py, line 2, in f1 raise Exception Exception === pdb suffers the same problem: === def f1(): import pdb; pdb.set_trace() print 'hello' f2 = f1 del(f1) f2() === then, when run, use where to ask where Python thinks you are: === c:\temp\z.py(3)f1() - print 'hello' (Pdb) where c:\temp\z.py(7)?() - f2() c:\temp\z.py(3)f1() - print 'hello' === It thinks we're in f1 as well even though f1 no longer exists. My understanding was that the OP wanted a way to refrain from hard-coding the function-name into the body of the function, rather than to completely avoid the name of the function ever being used anywhere. Unless there's a mapping that I couldn't find (that would take the current frame and map it to the calling function/method/module object) the only way to completely avoid this (AFAICT) would be to take the location information returned by the stack frame, parse the file, and extract the doc-string from the resulting line(s). It gets hairier when the python is poorly written as one could have pessimal cases of valid python docstrings that look like def f(x): docstring; return x*2 or def f(x): docstring; return x*2 or common multiline items like def f(x): docstring1 docstring2 pass or even worse, def f(x): this is a \docstring\ with \\\and\ mutliple lines pass def f(x): this is\ a docstring pass The parser also has to accomodate raw and unicode string prefixes, as they're valid too: def f(x): rraw! pass def f(x): uUnicode pass in addition. Okay...in most of these cases, the pathological coder should be taken out back and beaten, but it's a non-trivial problem :) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding behaviour for managing task dependencies
On Tue, 02 Oct 2007 14:28:35 +, m.pricejones wrote: Hi, I'm currently writing an animation pipeline in Python which is a system for controlling the flow of work and assets for a team of people working on a computer animated film. The system will be fairly large with a database backend. One particular problem that I'd like to address is the need for managing dependent tasks. Often you need to process one particular set of information before starting on another so when you batch them all together and send them off to a set of computers to process you need some way of formulating the dependencies. This preferably ends up looking a lot like a Makefile in the end with syntax a bit like: task task_name (dependencies): commands to complete the task ... Where the dependencies are a list of other tasks that need to be completed first. However I'd really like to do it in Python, but I'm thinking I'd might need to extend Python a bit in order to achieve the new syntax. I've seen attempts to do this within the Python syntax (Scons and buildIt) and I'm not a big fan of the way it ends up looking. I've worked at a place that has written it's own language to handle that sort of thing but then you end up with a language that is good for that but rubbish at everything else. Doesn't seem too bad if you just want to write down dependencies. Better have one tool/language doing it's job perfectly than having a big monster tool doing lots of jobs pretty bad. This is also sometimes called domain-specific languages or `language oriented programming http://www.onboard.jetbrains.com/is1/articles/04/10/ lop/`_. Python seems like a good basis if I could tweak it slightly. One particular point that interests me is the idea of maintaining compatibility with Python modules so you still have all the functionality. If you disagreed with my statements above, that's a good point. Would make deserialization of those nearly-Makefiles easier, too. This makes me think of the from __future__ import ... statements which, if I understand them correctly, can introduce new syntax like the with_statement, whilst still maintaining compatibility with older modules? I might be wrong here but AFAIK those `__future__` imports just set some 'compiler' flags. The documentation isn't saying much about the treatment of those statements but I guess they're handled internally (since __future__.py doesn't seem to do anything at all). See the `module documentation http://docs.python.org/lib/module-future.html`_ for details. Is this correct? Can anyone write a syntax changing module or is __future__ a hard coded special case? I realise I'll have to get into the C side of things for this. Are there other approaches to this that I really should be considering instead? Syntax (as in: grammar) is compiled into the python binary. You can change the python source (as it's free) and recompile but, FWIW, I would not suggest this. You're _forking_ CPython then and well, this would be an additional project to maintain (merging all updates, fixes, releases into your fork etc.). `PyPy http://codespeak.net/pypy/`_ could be slightly easier to adjust but still: extra project. Another approach could be `Logix http://livelogix.net/logix/`_. It's an alternate front-end for Python with the ability to change its syntax on- the-fly. I don't know how actively maintained it is, though. Any thoughts would be most appreciated, though I would like to stress that I don't think Python should support the syntax I'm proposing I'd just like to know if I can extend a copy of it to do that. As stated above, there are several ways to change Python to support the syntax you want but hey, why do you need this? As far as I understood you, you want to use *normal* python functions and add dependencies to them. First thing popping into my mind is a simple function eg. ``depends (source, target)`` or ``depends(target)(source)``. The second example would have the advantage of adapting neatly into the decorator syntax:: def early_task(): foo() @depends(early_task) def late_task(): bar() The wrapping `depends` function could decide whether `early_task` is done already or not (and invoke it, if neccessary) and finally pass through the call to `late_task`. This is just an example how you could use existing syntax to modelize dependencies, there are other ways I guess. HTH, Stargaming -- http://mail.python.org/mailman/listinfo/python-list
Re: module confusion
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Robert Kern wrote: Not all of the modules in a package are imported by importing the top-level package. You can't import packages, only modules. os.path is a particularly weird case because it is just an alias to the platform-specific path-handling module; os is not a package. os is a module, os.path is a variable within that module. That's all there is to it. Yes, but os.path is also module. That's why I said it was a weird case. In [1]: import os In [2]: type(os.path) Out[2]: type 'module' -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Using fractions instead of floats
On 2007-10-02, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Oct 2, 12:42 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-01, Arnaud Delobelle [EMAIL PROTECTED] wrote: Scheme has prefix numeric operators, so that 1/2 is unambiguously (for the interpreter and the user) a litteral for 'the fraction 1/2'. You can't avoid the confusion in python, as binary operators are infix. Of course, we could create a new kind of litteral. Let's see, / and // are already operators, so why not use /// ? ;) But you wouldn't actually need a literal rational represention. In which case rationals are better off in a module than in the language! I was supposing that 1/2 would result in a rational number, which would require language support, whether it's a literal rational number or a division of two integer constants. But I'm just playing Devil's Advocate here; I like rationals in Scheme and Lisp, but I don't see a need for them in Python. On the other hand, Python has had complex numbers a long time, and it doesn't need those more than rationals, does it? My guess is that it got complex numbers but not rationals because rationals just aren't very efficient. Another guess could be that real numbers being closed under the four arithmetic operations, there is no danger to accidentally step into complex numbers. OTOH floats and rationals are two (conflicting) ways of extending integers. You would have to adopt a few simple conversion rules, a la Scheme. Inexact numbers are contagious, for example. It was pretty shocking for a Scheme programmer to see the gmpy package break that rule. ;) I use rationals a lot, and I don't want them in the language :) Fair enough. -- Neil Cerutti The pastor will preach his farewell message, after which the choir will sing, Break Forth Into Joy. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list
Air Conditioners
http://freeaircon.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Mysqldb printing sql and params no matter what I do
I had some code originally that printed the sql and params when I called the .execute method. I removed it but it still prints. I rebooted and renamed files and still it prints. I am totally stumped; I tried google but perhaps didn't use the right search; got a lot of hits but no clues. I'm using MySQLdb 1.2.2 and python 2.4.4 on XP here is a snipppet that shows problem. import MySQLdb from datetime import * DBSERVER='localhost' DBSCHEMA='mds81' sql = '''SELECT aid from assessments WHERE xmitdate between %s AND %s LIMIT 9''' class _record: def __init__(self, adict):self.__dict__=adict class CaptainQuery: def __init__(self, host, schema): self.Connection = MySQLdb.connect (host=host, db=schema) self.dictcursor = self.Connection.cursor(cursorclass=MySQLdb.cursors.DictCursor) print '--before execute' self.dictcursor.execute(sql, (20070201, 20070630) ) print 'after execute---' records = self.dictcursor.fetchall() for r in records: print r Q = CaptainQuery(DBSERVER, DBSCHEMA ) - the output is below- --before execute SELECT aid from assessments WHERE xmitdate between %s AND %s LIMIT 9 (20070201, 20070630) after execute--- {'aid': 16711L} {'aid': 16712L} {'aid': 16713L} {'aid': 16715L} {'aid': 16845L} {'aid': 16849L} {'aid': 16850L} {'aid': 16851L} {'aid': 16852L} --- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding behaviour for managing task dependencies
Stargaming: Thanks, that's given me plenty to think about. Some wise words. I guess I should appreciate that with my particular goal there aren't going to be easy solutions but I definitely don't want to dive down the wrong track if it can be avoided. Cheers, Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: access __doc__ from within function without reference to function name
Tim Chase [EMAIL PROTECTED] wrote: The parser also has to accomodate raw and unicode string prefixes, as they're valid too: def f(x): rraw! pass def f(x): uUnicode pass in addition. Okay...in most of these cases, the pathological coder should be taken out back and beaten, but it's a non-trivial problem :) Fortunately someone already wrote a parser for Python code, so it is pretty trivial: import compiler class Visitor(compiler.visitor.ASTVisitor): def visitFunction(self, node): print node.doc def showdoc(source): compiler.walk(compiler.parse(source), Visitor()) showdoc(r'''def f(x): this is a \docstring\ with \\\and\ mutliple lines pass ''') this is a docstring with \and mutliple lines showdoc(r'''def f(x): uUnicode with concatenation pass ''') Unicode with concatenation -- http://mail.python.org/mailman/listinfo/python-list
Corrupted C Runtime on app exit via Dispatch
I'm new to Python, but I am trying to support a product at work. We're running under Win XP, using Python 2.4. We're using Python to run optimizations, generating a bunch of test conditions and having existing products evaluate the solutions. The programs we're running are MFC apps, built with VS 2003. (Although they are really old MFC apps). I can run the apps by hand and NEVER have a problem, only when they are invoked via Python Dispatch. We invoke a program via Dispatch, run some tests, save the output file, then tell the program to exit. I've tried various ways to shut the program down, they don't seem to matter. They all shut down properly as far as I can tell The main process has indicated it has exited. The process still exists in Task Manager for a short while. After running successfully a few times, the exiting process will finally crash in HeapFree in free.c. Dissecting the remains, the heap looks like it's already been freed, or it's subtlely corrupted (only the Blink and Flink pointers are trashed - memory contents look good). The crashing code can be almost anything - boost libraries, core code, CStrings, etc. It appears this is C Runtime cleanup on exit, it ALWAYS crashes in crt0dat.c, in the __onexitbegin cleanup loop. I trying to get a handle on what's happening. Is this a mismatch library problem? I've gone through and made everything consistent, using msvcr71.dll. Is this a Python threading incompatibility with Windows? My Python exit code looks (at the moment) like this; app.ExitApplication() app=None collect() pythoncom.CoUninitialize() I've imported gc, I was hoping forcing a garbage collection would help this problem - nothing substantial has come out of that. At this point, app.ExitApplication closes all documents and processes a SendMessage(WM_CLOSE,0,0). Nothing fancy. And, or course, this never happens in Debug mode. Only in release builds. I've got debug symbols in the main code and in the libraries we build, but 3rd party DLLs / libs don't have symbols. Can someone with more Python experience point me in a general direction? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Combine two dictionary...
On Oct 1, 2:01 pm, Abandoned [EMAIL PROTECTED] wrote: I want to total score.. For example dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and 3 millions element result should be dict3={1:4, 3:8, 8:6} Unless you have some prior knowledge about the dicts (e.g. len(intersection(d1,d2))), it's hard to beat the following, in pure Python at least: def sumdicts(d1,d2): if len(d1) len(d2): d1,d2 = d2,d1 dsum = dict(d1) for key,value in d2.iteritems(): if key not in dsum: dsum[key] = value else: dsum[key] += value return dsum Surprisingly (?), this turns out to be faster than using dict.get(key, 0) instead of the explicit if/else. George -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Kamen TOMOV wrote: On Sun, Sep 30 2007, Klaus Schilling wrote: ... private property is unethical How I craved to read that! Viva la revolution! Ест человек - ест проблем, Нет человек - нет проблем! The End justify the means! Long live communism! ENDUT! HOCH HECH! - Крусти Отменен, Сфир Ет. Ѕеqонж /W -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a custom python python distribution
shailesh wrote: Hi, I wish to create a Python distribution includind Python and some other libraries (Zope 3, PyWin32, numpy, lxml, etc.) which are required for my applications. e.g. there are Enthough and ASPN distributions of Python. Unfortunately, I have not been able to find the right documentation for this purpose. Could some one give an overview of what needs to be done for this purpose? I can guess, nothing more. You could use Inno Setup (windows guy?) URL:http://www.jrsoftware.org/isinfo.php to install python and then automatically all additional libs. And that is a general idea ... just automate the installing of all libs. It may even boil down to just copying the additional files to the site-packages directory. I don't know, but some experimentation should get you long way. It shouldn't be very hard. /W -- http://mail.python.org/mailman/listinfo/python-list
Re: I earn $36800 a month with google adsense
panguohua wrote: I am only a publisher!!! really it is useful Wow! That has got to be the first response by a spammer with some form of meaningful remark. I'm impressed. Dude, you, even as a spammer, can learn a lot from this group. As Diez pointed out, you will want to quote the site that you're spamvertising (Bastard!), so your pagerank rises. Pretty new to the biz, ain't ya? /W -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding behaviour for managing task dependencies
On Oct 2, 3:28 pm, [EMAIL PROTECTED] wrote: Hi, I'm currently writing an animation pipeline in Python which is a system for controlling the flow of work and assets for a team of people working on a computer animated film. The system will be fairly large with a database backend. One particular problem that I'd like to address is the need for managing dependent tasks. Often you need to process one particular set of information before starting on another so when you batch them all together and send them off to a set of computers to process you need some way of formulating the dependencies. This preferably ends up looking a lot like a Makefile in the end with syntax a bit like: task task_name (dependencies): commands to complete the task ... Where the dependencies are a list of other tasks that need to be completed first. However I'd really like to do it in Python, but I'm thinking I'd might need to extend Python a bit in order to achieve the new syntax. I've seen attempts to do this within the Python syntax (Scons and buildIt) and I'm not a big fan of the way it ends up looking. I've worked at a place that has written it's own language to handle that sort of thing but then you end up with a language that is good for that but rubbish at everything else. Python seems like a good basis if I could tweak it slightly. One particular point that interests me is the idea of maintaining compatibility with Python modules so you still have all the functionality. This makes me think of the from __future__ import ... statements which, if I understand them correctly, can introduce new syntax like the with_statement, whilst still maintaining compatibility with older modules? Is this correct? Can anyone write a syntax changing module or is __future__ a hard coded special case? I realise I'll have to get into the C side of things for this. Are there other approaches to this that I really should be considering instead? Any thoughts would be most appreciated, though I would like to stress that I don't think Python should support the syntax I'm proposing I'd just like to know if I can extend a copy of it to do that. Mike You could use a professional Job scheduling system such as LSF or Suns Grid Engine that both support job dependencies (and a whole lot more). For example, search for 'Job Dependencies' on this page: http://docs.sun.com/app/docs/doc/820-0699/6nce0ht7s?a=view - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
wana watch latest hindi hot videos?
wana watch latest hindi hot videos? than www.yedil.com is the site you are looking for have a nice time with www.yedil.com .Log on now -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on overriding implicit lookups
David Ells a écrit : In Python we have a wonderful facility for customizing attribute access by defining __getattr__ or __getattribute__ in our classes. Unfortunately (or perhaps fortunately, for reasons I don't know), this facility only works for explicit attribute access, i.e. accessing foo.bar. What I am in need of, for reasons I'll keep out of the discussion for now, is a similar facility for implicit attribute access, such as the call to foo.__len__ when something like len(foo) is executed. I would like some way to customize access during these implicit lookups without having to define each one in the class myself. Essentially what I am looking for is a mechanism like __getattribute__, only one that will work for these implicit lookups to functions like __len__, __str__, __getitem__, and so on. Hopefully my question makes sense. An obvious solution would be to define each one of these magic methods in a mixin class. Else, here's a QD but working solution : class Test(object): def _get_magic_attribute(self, name): return YADDA YADDA for _name in ('__len__', '__str__', '__repr__'): exec %s = lambda self, _name='%s' : \ self._get_magic_attribute(_name) % (_name, _name) del _name For a cleaner version, you may want to use a custom metaclass, but that seems a bit overkill to me. -- http://mail.python.org/mailman/listinfo/python-list
WCCM8 ECCOMAS 2008 - Mini-Symposium on Computational Bioimaging and Visualization - Announce Call for Contributions
___ Mini-Symposium on Computational Bioimaging and Visualization Within the WCCM8 ECCOMAS 2008 International Conference (http://www.iacm-eccomascongress2008.org ) Venice, Italy, 30 June - 5 July 2008 ___ Dear Colleague, The use of computational procedures based on medical images to model and visualize represented objects requires a high level of research investment, due mainly to the strong demands of clinical partners. These procedures can have different goals, such as shape reconstruction and visualization, segmentation, motion and deformation analyses, registration, simulation, etc. The main goal of this Mini- symposium is to promote the debate between researchers involved in the related fields (Bio-medical Image Acquisition, Analysis and Processing; Multi-scale Shape and Motion Reconstruction; Multi-scale Modeling and Analysis; Scientific Visualization, Bio-medical Software Libraries, Environments; etc.), in order to set the major lines of developments for the near future. Mini-symposium Organizers: João Manuel R.S. Tavares ([EMAIL PROTECTED], FEUP, Porto Portugal) Renato Natal Jorge ([EMAIL PROTECTED], FEUP, Porto, Portugal) Thomas J.R. Hughes ([EMAIL PROTECTED], ICES, University of Texas at Austin, USA) Chandrajit Bajaj ([EMAIL PROTECTED], ICES, University of Texas at Austin, USA) IMPORTANT DATES Deadline for presenting a one page abstract: December 15th., 2007 Acceptance of the contributions: January 31th., 2008 Deadline for submitting the final abstract: February 28th., 2008 -- http://mail.python.org/mailman/listinfo/python-list
Re: Can you please give me some advice?
Thorsten Kampe a écrit : * Bruno Desthuilliers (Sat, 29 Sep 2007 19:17:43 +0200) [EMAIL PROTECTED] a écrit : (snip) I know nothing of Ruby, but just the fact that in Ruby the Hello World program is puts 'Hello, World!' whereas the Python Hello World program is print 'Hello, World!' suggests to me that Python is more intuitive because the word print has a meaning in English that makes sense given what you want to do, but puts just doesn't. Hem Sorry, but it reminds me of the most clueless comments on Python I've seen on c.l.ruby. I really don't think Python is more or less intuitive than Ruby, and making a judgement on such a pointless detail is not even worth the bandswith IMHO. FWIW, 'puts' means 'put string' (implied : on stdout), which is certainly much more semantically correct than what 'print' implies. You missed the point. Your opinion. puts for printing something to stdout MHO It's not printing. To me, printing implies a printer and a piece of paper (or other appropriate support). It's sending bytes to some kind of cs abstraction known as a stream. /MHO But anyway... This is certainly enough to prove that intuitive is a *very* subjective qualifier. -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a custom python python distribution
Maybe you should check the Slax distro. Go to www.slax.org. There is one special slax distro caled Frodo. I think that it includes nearly nothing but the core. There are also several packages for the distro that you can put inside the distro and create your own distribution. There are also detailed instructions. This way you can create a Live distro, but there are also instruction on how to install it on the HDD. If I understood your question then I guess that this should be the answer. best regards -- http://mail.python.org/mailman/listinfo/python-list
RE: Mysqldb printing sql and params ... NEVER MIND
el stupido here accidently put a couple of print statements into a mysqldb module when eclipse opened it from the link in the stacktrace; -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On Oct 2, 5:29 am, Paul Boddie [EMAIL PROTECTED] wrote: On 2 Okt, 04:54, bramble [EMAIL PROTECTED] wrote: Maybe the key I'm missing is this: maybe GvR and company think that a language absolutely should come off-the-shelf with GUI toolkit bindings. So, given that, they feel they've gotta pick just one, and they've already got Tkinter and it works, so that's that. Is that it? Yes. Ahh... Ok. Thanks, that explains it. At first, it hadn't ocurred to me that anyone would want to provide a GUI toolkit binding along with a popular general purpose programming language implementation. Moreover, it *really* wouldn't occur to me that they'd also want to provide an IDE (as Terry mentions in another reply). But then, I'm looking at Python today, in 2007, at a time when Python has multiple high-quality GUI toolkit bindings available, and when most editors and IDE's have excellent Python support built-in. Given that line of reasoning though, it seems odd to me that GvR and Co. would still regard shipping those as part of Python proper as a requirement for Py3k. -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On Oct 2, 7:33 am, Carsten Haese [EMAIL PROTECTED] wrote: On Tue, 2007-10-02 at 03:04 +, bramble wrote: But Py3k is all about breaking compatibility That's a complete distortion of Python 3.0's mission. Python 3.0 breaks backwards compatibility only where there exist good reasons to do so. As Guido put it in a recent Python-3000 post, Python 3000 is boldly choosing to be backwards compatible, except in cases where a real benefit can be obtained by being incompatible. So, unless you can make a case that a real benefit can be obtained by removing Tkinter, it'll stay. Well, it of course wouldn't break backward compatibility by simply removing it from the standard library and providing it as an optional extra set of modules. -- http://mail.python.org/mailman/listinfo/python-list
Re: Algebraic Modules For Python
On 10/1/07, Brandon McGinty [EMAIL PROTECTED] wrote: Hi All, I know that there is probably a great deal of literature on this on the net, but I don't have any time to go searching. snip -- Brandon McGinty McGinty Soft Ltd. Website design, configuration, and maintenance Python and PHP coder snip So let me get this straight: You label yourself as a coder for hire in Python, but you don't have time to search the Internet for an answer to your own Python question? Remind me to avoid McGinty Soft for any and all needs which might require someone useful. -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
bramble wrote: Maybe a better question is, how has Tk managed to keep beating up the newer, more modern, more featureful, better documented toolkits encroaching on his territory? What's Tk's secret weapon? On the OS vendor level, it may not be beating Tkinter. OSX 10.4 comes out of the box (no action by the user required to install it) with python 2.3.5 + wx 2.5.3.1: mbi136-54 25% /usr/bin/python Python 2.3.5 (#1, Aug 19 2006, 21:31:42) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type help, copyright, credits or license for more information. py import wx py wx.__version__ '2.5.3.1' py ^D mbi136-54 27% uname -v Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 Consider also that a similar setup with ubuntu is only an apt-get away. And, if you know the proper incantations, is probably just as easy with fedora. Window$ of course...cousucksgh...Excuse me...doesn't get support for anything like that from micr$oft, but I think its very easy with enthought. So in some ways, Tkinter appears to be simply vestigial. James -- http://mail.python.org/mailman/listinfo/python-list
Re: toprettyxml messes up with whitespaces
On Oct 2, 11:43 am, Jorgen Bodde [EMAIL PROTECTED] wrote: Hi all, I parse an XML file, replace a node with a new one (like updating cache) and write it back. Every write, new spaces are added. For example, first read - update - write cycle; var name=APPNAME status=undefined My First App /var Second cycle: var name=APPNAME status=undefined My First App /var Third cycle: var name=APPNAME status=undefined My First App /var And this goes on. The node is one that is not touched in the XML, it is simply written back after reading. I have the same with void spaces in between the nodes, I managed to compensate that by stripping the lines. I would like to use toprettyxml to make it user editable and viewable. But this is really weird. How can I circumvent this behaviour? regards, - Jorgen I had similar problems and ended up switching to the lxml package to solve the issue. I think you can do it with ElementTree too. Maybe somebody with more experience with the xml / minidom modules will show up soon. Mike -- http://mail.python.org/mailman/listinfo/python-list
List Question
How is this expressed in Python? If x is in y more than three times: print x y is a Python list. -- http://mail.python.org/mailman/listinfo/python-list