Re: who moved reload?
harrismh777 wrote: You guys want one more...? ... we can't import tkconstants any longer nope. import tkinter.tkconstants oops... so upset I finger-checked... long day... This works: import tkinter from tkinter.constants import * This used to work: import Tkinter from Tkconstants import * ... not any more. regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: who moved reload?
On Wed, Apr 6, 2011 at 10:57 PM, harrismh777 harrismh...@charter.net wrote: harrismh777 wrote: You guys want one more...? ... we can't import tkconstants any longer nope. import tkinter.tkconstants oops... so upset I finger-checked... long day... This works: import tkinter from tkinter.constants import * This used to work: import Tkinter from Tkconstants import * ... not any more. Yep, things have moved. Glad you're finding your way around now! Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
Hello again, Philip, I really appreciate you sticking with me. Hopefully this will help someone else, too. I've done some more reading, and will offer some minimal code below. I've known about this page for a while, and it describes some of the unconventional things one needs to consider when subclassing numpy.ndarray: http://www.scipy.org/Subclasses Now, section 11.1 of the Python documentation says the following concerning pickling: Classes can further influence how their instances are pickled; if the class defines the method __getstate__(), it is called and the return state is pickled as the contents for the instance, instead of the contents of the instance’s dictionary. If there is no __getstate__() method, the instance’s __dict__ is pickled. http://docs.python.org/release/2.6.6/library/pickle.html That being said, I'm having problems there! I've found this minimal example of pickling with overridden __getstate__ and __setstate__ methods: http://stackoverflow.com/questions/1939058/please-give-me-a-simple-example-about-setstate-and-getstate-thanks I'll put all of the thoughts generated by these links together after responding to a few things you wrote. On Apr 5, 10:43 am, Philip Semanchuk phi...@semanchuk.com wrote: But as Dan Stromberg pointed out, there are some pickle-free ways to communicate between processes using multiprocessing. I only see your reply to Dan Stromberg in this thread, but not Dan Stromberg's original post. I am reading this through Google Groups. Perhaps Dan's post failed to make it through a gateway for some reason? As a side note, you should always use new style classes, particularly since you're exploring the details of Python class construction. New is a bit a of misnomer now, as new style classes were introduced in Python 2.2. They have been the status quo in Python 2.x for a while now and are the only choice in Python 3.x. Sorry, that was an oversight on my part. Normally I do remember that, but I've been doing a lot of subclassing rather than defining top- level classes, and therefore it slipped my mind. One can pickle user-defined classes: OK, I got that working, I'll show an example farther down. (I never tried to pickle a minimal class until now, I went straight for a hard one.) And as Robert Kern pointed out, numpy arrays are also pickle-able. OK, but SUBCLASSES of numpy.ndarray are not, in my hands, pickling as I would expect. I already have lots of code that is based on such subclasses, and they do everything I want EXCEPT pickle correctly. I may have to direct this line of questions to the numpy discussion group after all. This is going to be a longer exposition. So let me thank you in advance for your patience, and ask you to get comfortable. == begin code == from numpy import array, ndarray from pickle import dumps, loads ##=== class Foo(object): def __init__(self, contents): self.contents = contents def __str__(self): return str(type(self)) + \n + str(self.__dict__) ##=== class SuperFoo(Foo): def __getstate__(self): print __getstate__ duplicate = dict(self.__dict__) duplicate[bonus] = added during pickling return duplicate def __setstate__(self, d): print __setstate__ self.__dict__ = d self.finale = added during unpickling ##=== class ArraySubclass(ndarray): See http://www.scipy.org/Subclasses, this class is very similar. def __new__(subclass, data, extra=None, dtype=None, copy=False): print __new__ arr = array(data, dtype=dtype, copy=copy) arr = arr.view(subclass) if extra is not None: arr.extra = extra elif hasattr(data, extra): arr.extra = data.extra return arr def __array_finalize__(self, other): print __array_finalize__ self.__dict__ = getattr(other, __dict__, {}) def __str__(self): return str(type(self)) + \n + ndarray.__str__(self) + \ \n__dict__ : + str(self.__dict__) ##=== class PicklableArraySubclass(ArraySubclass): def __getstate__(self): print __getstate__ return self.__dict__ def __setstate__(self, d): print __setstate__ self.__dict__ = d ##=== print \n\n** Create a Foo object, then create a copy via pickling. original = Foo(pickle me please) print original clone = loads(dumps(original)) print clone print \n\n** Create a SuperFoo object, just to watch __setstate__ and __getstate__. original = SuperFoo(pickle me too, please) print original clone = loads(dumps(original)) print clone print \n\n** Create a numpy ndarray, then create a copy via pickling. original = array(((1,2,3),(4,5,6))) print original clone = loads(dumps(original)) print clone print \n\n** Create an ArraySubclass object, with meta-data... original = ArraySubclass(((9,8,7),(6,5,4)), extra = pickle me PLEASE!) print original print \n...now
Re: Python benefits over Cobra
On Thu, 07 Apr 2011 00:25:46 -0500, harrismh777 wrote: The gnu suite of tools and the linux kernel were the keys to unlocking Microsoft lock-in... brilliant technologies for innovation and freedom. I used to believe this too, but then I found I was relying on Linux and GNU software so much that I couldn't afford to move away from Linux and GNU. Damn lock-in. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: python 3 - instantiating class from user input
On Wed, 06 Apr 2011 21:04:44 -0700, Brad Bailey wrote: I dont understand why this is such a big deal. Nor do i understand why google can't find a reasonable answer. If one can't figure out from the title what I'm trying to do, then a look at code should firmly plant the intent. The general idea of the code is, in my opinion, very basic. I notice, that when you are coding a class instance, it's in the format of: newInstance = someClass() OK, so we are calling someClass as if it's a function. Is there a way to do something to the effect of: someClass(newInstance) I don't know. What effect do you expect? Please don't assume that just because you've spent hours searching for an answer, we know what the question is. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Hack SkyPe Account 2.1
Hi EveryBody This Program To Hack Sky Pe Account Just Paste A Email For Sky Pe And Click (Get Pass) Yeah Its True Try It Its Free From Here http://www.4shared.com/file/wFtoiI7z/Promar_Hack_Skype_21.html Download Now -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Thu, 07 Apr 2011 00:03:54 -0500, harrismh777 wrote: Ben Finney wrote: It's difficult to take a claim of “free” seriously for a technology (Mono) that knowingly implements techniques (the “C#” language, the “.NET” platform, etc.) covered by specific idea patents held by an entity that demonstrates every intention of wielding them to restrict the freedom of software recipients. Yes, precisely. In my view, Mono encourages .NET; and that's bad. Idea patents and particularly idea patents covering mathematics Do you have an example of a patent covering mathematics that applies to .NET? ( every known piece of software ever written can be described by lambda algebra ) And every piece of hardware can be described by a mathematical function, so does this mean you oppose *all* patents? are not truly patentable... which is why some of us are vigorously fighting software patents (as well at the corporations who wield them). What are you doing to fight software patents? Software must be free (as in freedom). Encouraging interoperability with known agendas against freedom is inconsistent with the fundamental proposal. I would have thought that if you really, truly believed in freedom, you would be happy to allow people the freedom to interoperate with non-free software. But perhaps you meant that software must be free, provided only the right sorts of freedom are supported. C# was an effort to lock-in commercial developers into the .NET framework (and it almost damn-well worked!). Got a source for that? News just in: 100% of all enterprises are using .NET or Java! http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=showixPost=162367 sarcasm And you can trust it because Forrester said so! /sarcasm As I see it, C# has never had more than an 8% market share. But perhaps you have some better data. At this point Microsoft has absolutely nothing to offer the computer science community at large except bzillions of euros ( or dollars ) of wasteful litigation and head-ache. Do you have an example of this wasteful litigation? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents (was: Python benefits over Cobra)
On Thu, 07 Apr 2011 07:50:56 +1000, Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Mono is free, open source software that is compatible with .NET […] It's difficult to take a claim of “free” seriously for a technology (Mono) that knowingly implements techniques (the “C#” language, the “.NET” platform, etc.) covered by specific idea patents held by an entity that demonstrates every intention of wielding them to restrict the freedom of software recipients. It's astonishing how anti-Mono FUD just won't die. (Something can be true, and still FUD. Oh no, people might *choke* on a peanut, or have an allergic reaction, we must label every piece of food May Contain Nuts just in case, because you never know!!!) Let's reword your concern slightly: It's difficult to take a claim of “free” seriously for technologies (including, but not limited to, HTML, CSS, C++, XML, Public Key Cryptography, packet-based multimedia, IPv6) that knowingly or unknowingly [the later not being a defence against infringement] implement techniques covered by specific idea patents held by an entity that allegedly demonstrates every intention, or at least some intention, of wielding them to restrict the freedom of software recipients. Perhaps every piece of software should be labeled May Infringe Patents. I've seen a lot of FUD about Mono, but nothing to suggest that it is at more risk than any other piece of non-trivial software. As far as I know, there is only one major piece of FOSS that *has* actually been sued for patent infringement, and it's not Mono. Software idea patents are incompatible with free software. Every non-trivial program likely violates countless such patents, but most of those patents are not yet enforced even in the unlucky jurisdictions where they are recognised by law. Right. So why single out Mono? Python likely violates countless such patents, so obviously we can't take the idea of Python being free seriously either. Same with Perl, and the Linux kernel, and the entire Gnu tool set. As you say, quite probably every piece of non-trivial software you have used, or ever will use, or write, infringes. By this logic, we can't take the idea of FOSS software seriously at all, since no software can be expected to be free from infringing some patent somewhere. But of course, the conclusion does not follow from the premise. Yes, Mono is at risk from patents, *possibly even from Microsoft*. So is everything else. So why single out Mono as non-serious? (Although it is in Microsoft's best interest to tolerate Mono. It's in their best interests to tolerate FOSS. And as their recent actions show: http://www.betanews.com/article/Microsoft-cozies-up-to-open-source-donates-10-to-Apache/1217018107 http://www.crunchgear.com/2009/07/24/linus-torvalds-speaks-out-on-the-microsoft-gpl-code-contribution/ at least parts of Microsoft have finally come to recognise this.) More here: http://www.jprl.com/Blog/archive/development/mono/2009/Jan-19.html Microsoft, though, is clearly a vigorous enforcer of software idea patents they hold. They have been very cagey about stating what they will and won't enforce about patents they hold on .NET – and none of those statements are binding. This is complete FUD. I suggest you start with this: http://www.microsoft.com/interop/cp/default.mspx Perhaps what you mean is, none of the licences granted are *irrevocable*. But the same applies to the GPL -- break the GPL's (generous) terms, and you too could find that your licence is revoked. Is it possible that there could be portions of .NET or Mono which are unclear patent-wise? Of course it is possible, it's even likely. Software patents are truly a mess. But there is zero evidence I have seen that Mono is more of a mess patent-wise, or more of a risk, than any other non-trivial piece of software. With large portions of Mono protected by the Microsoft Community Promise licence, it may even be that Mono is *safer* than most FOSS software. Microsoft is far less vigorous at enforcing patents than many other companies. (This is possibly a bad thing, when they darkly drop hints that there are secret patent infringements in Linux and some day there will be a reckoning...) Given the tens, or is it hundreds, of thousands of patents they hold, they've barely used them. Do you want to know who scares me? Google and Apple. Google, because they're turning software from something you run on your own computer to something you use on a distant server you have no control over. And Apple, because they're turning the computer from a general purpose computing device you control, to a locked-down, restricted, controlled specialist machine that only runs what they permit you to run. But I digress. The freedom of a software work isn't a matter of the copyright license alone; it's a matter of the freedoms each recipient has in
Re: Multiprocessing, shared memory vs. pickled copies
Following up to my own post... On Apr 6, 11:40 pm, John Ladasky lada...@my-deja.com wrote: What's up with that? Apparently, what's up is that I will need to implement a third method in my ndarray subclass -- namely, __reduce__. http://www.mail-archive.com/numpy-discussion@scipy.org/msg02446.html I'm burned out for tonight, I'll attempt to grasp what __reduce__ does tomorrow. Again, I'm going to point out that, given the extent that multiprocessing depends upon pickling, pickling should be made easier. This is Python, for goodness' sake! I'm still surprised at the hoops I've got to jump through. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sandboxed Python: memory limits?
Am 07.04.2011 02:06, schrieb Chris Angelico: On Thu, Apr 7, 2011 at 6:38 AM, Martin v. Loewis mar...@v.loewis.de wrote: You can adjust the implementations of PyMem_Malloc and PyObject_Malloc. This would catch many allocations, but not all of them. If you adjust PyMem_MALLOC instead of PyMem_Malloc, you catch even more allocations - but extensions modules which directly call malloc() still would bypass this accounting. I'm not too concerned about extensions, here; in any case, I lock most of them off. I just want to prevent stupid stuff like this: a='a' while True: a+=a That would certainly be caught by instrumenting PyObject_MALLOC. More generally, I believe that if you instrument the functions I mentioned, your use case is likely covered. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents (was: Python benefits over Cobra)
On Thu, Apr 7, 2011 at 5:39 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Do you want to know who scares me? Google and Apple. Google, because they're turning software from something you run on your own computer to something you use on a distant server you have no control over. And Apple, because they're turning the computer from a general purpose computing device you control, to a locked-down, restricted, controlled specialist machine that only runs what they permit you to run. But I digress. I agree about Apple, but Google are not turning software... into; they are providing an option that involves such things. They are not stopping you from running software on your own computer, and they never can. One of my hobbies is running (and, let's face it, playing) online games. The MUD system is similar to what Google does, only more so; the server has *everything* and the client is just basic TELNET. Yes, some clients have some nice features, but they don't need to, and some of my players use extremely basic terminals. But nobody complains that they're playing a game they have no control over (and the only complaints about a distant server relate to ping times). Having the option to cloud things is a Good Thing. Yes, you lose control if you put your data on someone else's cloud, but if you want the functionality, you pay the price. If you don't like that price, you stick with your desktop software. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
How to use optparse without the command line?
Hello, Is there support/idioms/suggestions for using optparse without a command line? I have a code which used to be called through subprocess. The whole flow of the code is based on what 'options' object from optparse contains. Now I want to call this code without subprocessing. What I did first was to build a fake command-line and use options, args = parser.parse_args(fake_cmdline) But I find it dumb to encode and decode a dictionary... So I would like to know how I if there is a good way of passing a dictionary to optparse and benefiting from its option management (check, error detection, etc). Thanks a lot! Marko -- http://mail.python.org/mailman/listinfo/python-list
Re: Trapping the segfault of a subprocess.Popen
On Apr 7, 1:58 am, Nobody nob...@nowhere.com wrote: On Wed, 06 Apr 2011 02:20:22 -0700, Pierre GM wrote: I need to run a third-party binary from a python script and retrieve its output (and its error messages). I use something like process = subprocess.Popen(options, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (info_out, info_err) = process.communicate() That works fine, except that the third-party binary in question doesn't behave very nicely and tend to segfaults without returning any error. In that case, `process.communicate` hangs for ever. Odd. The .communicate method should return once both stdout and stderr report EOF and the process is no longer running. Whether it terminates normally or on a signal makes no difference. The only thing I can think of which would cause the situation which you describe is if the child process spawns a child of its own before terminating. In that case, stdout/stderr won't report EOF until any processes which inherited them have terminated. I think you nailed it. Running the incriminating command line in a terminal doesn't return to the prompt. In fact, a ps shows that the process is sleeping in the foreground. Guess I should change the subject of this thread... I thought about calling a `threading.Timer` that would call `process.terminate` if `process.wait` doesn't return after a given time... But it's not really a solution: the process in question can sometimes take a long time to run, and I wouldn't want to kill a process still running. I also thought about polling every x s and stopping when the result of a subprocess.Popen([ps,-p,str(initialprocess.pid)], stdout=subprocess.PIPE) becomes only the header line, but my script needs to run on Windows as well (and no ps over there)... It should suffice to call .poll() on the process. In case that doesn't work, the usual alternative would be to send signal 0 to the process (this will fail with ESRCH if the process doesn't exist and do nothing otherwise), e.g.: import os import errno def exists(process): try: os.kill(process.pid, 0) except OSError, e: if e.errno == errno.ESRCH: return False raise return True OK, gonna try that, thx. You might need to take a different approach for Windows, but the above is preferable to trying to parse ps output. Note that this only tells you if /some/ process exists with the given PID, not whether the original process exists; that information can only be obtained from the Popen object. -- http://mail.python.org/mailman/listinfo/python-list
Re: Trapping the segfault of a subprocess.Popen
On Apr 7, 5:12 am, Terry Reedy tjre...@udel.edu wrote: On 4/6/2011 7:58 PM, Nobody wrote: On Wed, 06 Apr 2011 02:20:22 -0700, Pierre GM wrote: I need to run a third-party binary from a python script and retrieve its output (and its error messages). I use something like process = subprocess.Popen(options, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (info_out, info_err) = process.communicate() That works fine, except that the third-party binary in question doesn't behave very nicely and tend to segfaults without returning any error. In that case, `process.communicate` hangs for ever. I am not sure this will help you now, but Victor Stinner has added a new module to Python 3.3 that tries to catch segfaults and other fatal signals and produce a traceback before Python disappears. Unfortunately, I'm limited to Python 2.5.x for this project. But good to know, thanks... -- http://mail.python.org/mailman/listinfo/python-list
Spam on the mailing list
I don't know whether it's ironic or in some way Pythonesque, but this is the only mailing list that I've seen significant amounts of spam on... Maybe spam filters have trouble distinguishing between Monty Python and unsolicited commercial email? Chris Angelico Somewhat amused -- http://mail.python.org/mailman/listinfo/python-list
who moved reload?
All right... somebody is sacked (er, fired) ! Who moved reload()? This kinda stuff is driving me bonkers... there was no need to move reload() anyplace... ... so for those of you who haven't found out yet, if you want to reload a module in 3.x you have to import reload() first from module 'imp' ... now that is just plain wrong. :-} import mymod from imp import reload reload(mymod)= now reload() will work. Somebody out there thinks this is funny, right? reload(mymod) Traceback (most recent call last): File pyshell#1, line 1, in module reload(mymod) NameError: name 'reload' is not defined ??? regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents (was: Python benefits over Cobra)
On Apr 7, 7:17 pm, Chris Angelico ros...@gmail.com wrote: On Thu, Apr 7, 2011 at 5:39 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Do you want to know who scares me? Google and Apple. Google, because they're turning software from something you run on your own computer to something you use on a distant server you have no control over. And Apple, because they're turning the computer from a general purpose computing device you control, to a locked-down, restricted, controlled specialist machine that only runs what they permit you to run. But I digress. I agree about Apple, but Google are not turning software... into; they are providing an option that involves such things. They are not stopping you from running software on your own computer, and they never can. One of my hobbies is running (and, let's face it, playing) online games. The MUD system is similar to what Google does, only more so; the server has *everything* and the client is just basic TELNET. Yes, some clients have some nice features, but they don't need to, and some of my players use extremely basic terminals. But nobody complains that they're playing a game they have no control over (and the only complaints about a distant server relate to ping times). Having the option to cloud things is a Good Thing. Yes, you lose control if you put your data on someone else's cloud, but if you want the functionality, you pay the price. If you don't like that price, you stick with your desktop software. Chris Angelico Currently Oracle's actions seem far more concerning than anything microsoft could cook up. Look at the Openjdk http://www.theregister.co.uk/2011/02/04/openjdk_rules/ now thats a joke... As I see it, C# has never had more than an 8% market share. But perhaps you have some better data. Jobs posted in Sydeny in the last 3 days on our major search seek.com.au; Jobs% of total Jobs c# 134 17.1% java422 53.9% python 29 3.7% c++ 79 10.1% Ruby16 2.0% asp.net 103 13.2% scala 0 0.0% Total 783 -- http://mail.python.org/mailman/listinfo/python-list
Why is __root checked for in OrderedDict?
If you look at the code in http://hg.python.org/cpython/file/6adbf5f3dafb/Lib/collections/__init__.py#l49 the attribute __root is checked for, and only created if missing. Why? I ask because, from what I understand, the __init__ method will only be called when the object is first being created, so __root will always be missing. My only guess is that this allows subclasses to do strange things without breaking the code (and if so, is a nice defensive coding pattern). But I am worried I am missing something. Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: How to program in Python to run system commands in 1000s of servers
Roy Smith r...@panix.com writes: I'm not sure how to parse: We cannot use ssh as root remote connectivity as well. but with 1000's of servers, I really don't see any alternative to ssh, with key authentication. You don't really propose to type passwords at 1000's of machines, do you? I guess it might mean someone decided to config sshd with PermitRootLogin no... I believe this is common? I don't think it's a particularly good idea, especially for a large scale deployment. So I guess there may be some config needed for the machines before they can be remotely administrated in an automatic fashion. -- http://mail.python.org/mailman/listinfo/python-list
Re: Incompatible _sqlite3.so
Tim Johnson t...@johnsons-web.com writes: I have python 2.6.5 on my main workstation with ubuntu 10.04. I am attempting to set up a temporary test platform on an asus netbook with slax running from an SD card. I have installed a python 2.7 module on the slax OS. (I can't find a python 2.6.5 module for slax). I haven't used Slax in a while, but there is an easy way to convert Slackware packages to Slax modules with the script tgz2lzm. Documented at http://www.slax.org/documentation_create_modules.php So presumably you can find a suitable Slackware package for Python and convert it yourself. At a guess that would have sqlite3 included too. -- http://mail.python.org/mailman/listinfo/python-list
Re: Spam on the mailing list
On Wednesday, April 6, 2011 11:03:31 AM UTC-4, Chris Angelico wrote: I don't know whether it's ironic or in some way Pythonesque, but this is the only mailing list that I've seen significant amounts of spam on... My impression is that there is much more spam on comp.lang.python than on the archives of Python-list, so it seems the gateway is catching a lot of it: http://mail.python.org/pipermail/python-list/2011-April/date.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour of subprocess.Popen, ssh and nohup I don't understand
Thanks, that explains a lot. Adriaan Renting. On 4/6/2011 at 07:43 PM, Dan Stromberg drsali...@gmail.com wrote: On Wed, Apr 6, 2011 at 12:47 AM, Adriaan Renting rent...@astron.nl wrote: This solves the problem using stdin=open(os.devnull, 'rb') instead of stdin=None makes it run even if there is input from stdin in the foreground process. The operating system is Ubuntu 8.04 I understood what Suspended (tty input) means. I don't understand why it waits for input if stdin=None. Thank you for your help. Adriaan Renting. -- http://mail.python.org/mailman/listinfo/python-list http://docs.python.org/library/subprocess.html With None, no redirection will occur; the child*s file handles will be inherited from the parent. When a background process reads from a tty (which is most likely what its inherited stdin is connected to), it gets a SIGTTIN, suspending your background process. See also ssh -n. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On Apr 7, 2011, at 3:41 AM, John Ladasky wrote: Following up to my own post... On Apr 6, 11:40 pm, John Ladasky lada...@my-deja.com wrote: What's up with that? Apparently, what's up is that I will need to implement a third method in my ndarray subclass -- namely, __reduce__. http://www.mail-archive.com/numpy-discussion@scipy.org/msg02446.html I'm burned out for tonight, I'll attempt to grasp what __reduce__ does tomorrow. Again, I'm going to point out that, given the extent that multiprocessing depends upon pickling, pickling should be made easier. This is Python, for goodness' sake! I'm still surprised at the hoops I've got to jump through. Hi John, My own experience has been that when I reach a surprising level of hoop jumping, it usually means there's an easier path somewhere else that I'm neglecting. But if pickling subclasses of numpy.ndarray objects is what you really feel you need to do, then yes, I think asking on the numpy list is the best idea. Good luck Philip -- http://mail.python.org/mailman/listinfo/python-list
fighting game made with python
is there any fighting games(street fighter, mortal kombat, etc) made in python? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python benefits over Cobra
On Thursday, April 7, 2011 2:43:09 AM UTC-4, Steven D#39;Aprano wrote: On Thu, 07 Apr 2011 00:25:46 -0500, harrismh777 wrote: The gnu suite of tools and the linux kernel were the keys to unlocking Microsoft lock-in... brilliant technologies for innovation and freedom. I used to believe this too, but then I found I was relying on Linux and GNU software so much that I couldn't afford to move away from Linux and GNU. Damn lock-in. Once you commit yourself to a free and open community, there's nothing locking you in other than your personal level of commitment and loyalty, and how much you stand to lose by simply walking away. Free software doesn't eliminate the real constraints of the real world. -- http://mail.python.org/mailman/listinfo/python-list
Re: logging module usage
Thank you. This has been very helpful. Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: who moved reload?
On Thu, Apr 7, 2011 at 00:45, harrismh777 harrismh...@charter.net wrote: All right... somebody is sacked (er, fired) ! Who moved reload()? This kinda stuff is driving me bonkers... there was no need to move reload() anyplace... ... so for those of you who haven't found out yet, if you want to reload a module in 3.x you have to import reload() first from module 'imp' ... now that is just plain wrong. :-} import mymod from imp import reload reload(mymod)= now reload() will work. Somebody out there thinks this is funny, right? reload(mymod) Traceback (most recent call last): File pyshell#1, line 1, in module reload(mymod) NameError: name 'reload' is not defined ??? http://docs.pythonsprints.com/python3_porting/py-porting.html#organizational-changes might help you. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to program in Python to run system commands in 1000s of servers
On Thu, Apr 7, 2011 at 9:27 PM, Anssi Saari a...@sci.fi wrote: Roy Smith r...@panix.com writes: We cannot use ssh as root remote connectivity as well. but with 1000's of servers, I really don't see any alternative to ssh, with key authentication. You don't really propose to type passwords at 1000's of machines, do you? I guess it might mean someone decided to config sshd with PermitRootLogin no... I believe this is common? I don't think it's a particularly good idea, especially for a large scale deployment. So I guess there may be some config needed for the machines before they can be remotely administrated in an automatic fashion. Depending on what exactly is needed, it might be easier to run a separate daemon on the computers, one whose sole purpose is to do the task / get the statistics needed and return them. Then the Python script need only collect each program's returned response. Alternatively, if the program needs to be run periodically anyway, it might be easier to simply cron it on every computer it needs to run on, and then log the results to some central server (maybe a MySQL database, or something). Then whenever you want stats, you just query that server. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
neil harper wrote: is there any fighting games(street fighter, mortal kombat, etc) made in python? yep, if somebody moves one more thing. there's going to be a fight... :) -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
yep, if somebody moves one more thing. there's going to be a fight... bitch in your own thread, please? We've already heard you complain plenty, no need to take it to other threads too. On 4/7/2011 9:10 AM, harrismh777 wrote: neil harper wrote: is there any fighting games(street fighter, mortal kombat, etc) made in python? yep, if somebody moves one more thing. there's going to be a fight... :) -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
Steven D'Aprano wrote: Let's reword your concern slightly: It's difficult to take a claim of “free” seriously for technologies (including, but not limited to, HTML, CSS, C++, XML, Public Key Cryptography, packet-based multimedia, IPv6) that knowingly or unknowingly [the later not being a defence against infringement] implement techniques covered by specific idea patents held by an entity that allegedly demonstrates every intention, or at least some intention, of wielding them to restrict the freedom of software recipients. Steve, this is a straw man argument. Its not good argument to reword 'his' concern, nor to provide a non-related analogy, nor to build a straw man that you can easily knock down. In doing so, your argument loses merit (bad enough) but also you end up missing the other point. No one is 'singling out' Mono. Mono and .NET are just examples of evil proprietary frameworks|software designed to lock-in market share and usurp freedom. There are *many* other examples that we might talk about. But the main point is that if you value freedom, you will not support proprietary frameworks. So, if a software package, like just for example (Cobra), relies on .NET (or Mono) then Cobra is a bad thing for freedom in computer scinece. If Python is free software ( at least GPL compatible license ) then Python is a 'good thing' from the standpoint of freedom in computer science. That was the comparison. There is no FUD here... NO FEAR Absolutely CERTAIN NO DOUBT kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Thu, Apr 7, 2011 at 11:31 AM, harrismh777 harrismh...@charter.net wrote: Steven D'Aprano wrote: Let's reword your concern slightly: It's difficult to take a claim of “free” seriously for technologies (including, but not limited to, HTML, CSS, C++, XML, Public Key Cryptography, packet-based multimedia, IPv6) that knowingly or unknowingly [the later not being a defence against infringement] implement techniques covered by specific idea patents held by an entity that allegedly demonstrates every intention, or at least some intention, of wielding them to restrict the freedom of software recipients. Steve, this is a straw man argument. Its not good argument to reword 'his' concern, nor to provide a non-related analogy, nor to build a straw man that you can easily knock down. In doing so, your argument loses merit (bad enough) but also you end up missing the other point. No one is 'singling out' Mono. Mono and .NET are just examples of evil proprietary frameworks|software designed to lock-in market share and usurp freedom. There are *many* other examples that we might talk about. But the main point is that if you value freedom, you will not support proprietary frameworks. So, if a software package, like just for example (Cobra), relies on .NET (or Mono) then Cobra is a bad thing for freedom in computer scinece. If Python is free software ( at least GPL compatible license ) then Python is a 'good thing' from the standpoint of freedom in computer science. That was the comparison. Cobra does not rely on a proprietary framework. It runs on Mono, which is an open source implementation of the ECMA-334 and ECMA-335 standards. The only difference between it and Python is that Python was developed at a research institute while .NET was developed at a corporation. There is no FUD here... NO FEAR Absolutely CERTAIN NO DOUBT At this point Microsoft has absolutely nothing to offer the computer science community at large except bzillions of euros ( or dollars ) of wasteful litigation and head-ache. Looks like FUD and smells like FUD. Unless you happen to be on Microsoft's legal team and know that they're about to sue everyone who's using Mono. kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
Steven D'Aprano wrote: In my view, Mono encourages .NET; and that's bad. Idea patents and particularly idea patents covering mathematics Do you have an example of a patent covering mathematics that applies to .NET? Therein lies *the* problem. The point that gets missed over and over is that there CAN BE NO PATENT COVERING MATHEMATICS ... period. Yes, C# and .NET are covered by hundreds of software patents. Its an insane mess... which must be eliminated at all costs. All software can be expressed as lambda calculus. The point being, all software is mathematics. No software should have been able to be patented; and this is regardless of prior art, time-frames, wording, etc. Mathematics, processes in algorithm, and algorithm specifications should never have seen the light of day as patentable. Believe it or not, we're about to win that argument... the most recent Supreme Court decision regarding process and process algorithms was a serious victory in the right direction. ( every known piece of software ever written can be described by lambda algebra ) And every piece of hardware can be described by a mathematical function, so does this mean you oppose*all* patents? You have a serious misunderstanding regarding idea patents. An idea that can be constructed is patentable (like a nand chip, the SN7400N, for instance) but the mathematical concept of the 'nand gate' cannot be patented. In other words, if Texas Instruments designs a specif kind of hardware to implement the concept of 'nand gate' and builds the chip (the quad nand SN7400N) and that chip design ( TTL ) is patented, that in no way patents the mathematical concept idea for 'nand gate'. Someone else is perfectly free to develop their own hardware to implement the math concept 'nand gate' (like Motorola's CMOS 4011 quad two input positive nand gate) and then patent *thier* hardware chip. I am not apposed to patents... they are worded into the Constitution of the United States for which I am honor-bound and patriot bound to protect, with life if necessary. What I am apposed to is the illicit use of the U.S. patent office by corporations to patent mathematical ideas that constrain progress in computer science and usurp the common liberties of we the people, costing all of us billions of dollars in litigation expenses (only the damn lawyers win). Software patents are evil and must be eliminated. Further, every effort must be brought to the front in apposition to software patents around the globe. This sin is not just local to the U.S. Every free nation (ones that value freedom) must take a stand in this fight. are not truly patentable... which is why some of us are vigorously fighting software patents (as well at the corporations who wield them). What are you doing to fight software patents? For one thing, what I'm doing right now; talking to you. For another, I join and support the organizations who are formally fighting to eliminate software patents. There are many of these, but the ones I support are: http://endsoftpatents.org/home-page http://www.fsf.org/campaigns/ http://www.opensource.org/ Take a stand, if you value freedom, and if you value computer science. Its your responsibility, as well as mine. Software must be free (as in freedom). Encouraging interoperability with known agendas against freedom is inconsistent with the fundamental proposal. I would have thought that if you really, truly believed in freedom, you would be happy to allow people the freedom to interoperate with non-free software. But perhaps you meant that software must be free, provided only the right sorts of freedom are supported. I take no action to prevent you (nor anyone else) from inter-operating with non-free software nor the evil corporations who provide it. You are not free in doing so, but I will not in any way constrain you any further than your own choices. Again, you miss the point. Proprietary software and proprietary interoperability are at work to destroy my freedoms and the freedoms of computer science. At this point in time, I am not legally free to build *any* non-trivial software without requiring very expensive cross-licensing (which I cannot afford) with evil corporate empires because of software idea patents holding me by the nose whilst kicking my rear-end. This situation is intolerable, and must be eliminated... the quicker the sooner. C# was an effort to lock-in commercial developers into the .NET framework (and it almost damn-well worked!). Got a source for that? Another poster provided you with the numbers (which are conservative, by the way). If it had not been for SUN and Java, we would have been toast with Microsoft and C#. Fortunately .NET and C# turned out to be a Microsoft fad vision flop, like Visual BASIC. But that also misses the main point... which was and is--- proprietary software (and
Re: fighting game made with python
Littlefield, Tyler wrote: yep, if somebody moves one more thing. there's going to be a fight... bitch in your own thread, please? We've already heard you complain plenty, no need to take it to other threads too. uh, that was humor... like, get a sense of... lighten up... sometimes we're just trying to be funny. No, I doubt there are any blood and guts action fighting games written in Python... but I suppose you could google it, and if you find some, I'd like to know too I won't play them of course, ... just would be interesting to know that Python is so versatile. kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
job for python lead
Hi , There is a opening for the position of python lead in a company called TEK systems global services for bangalore location.Interested candidates can send in their profiles to snara...@teksystems.com. CHEERS CNA 9986229891 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and DDE
On Wednesday, April 6, 2011 3:37:34 PM UTC-4, Robert Upton wrote: Dear Pythoners, I am attempting to get the DDE module to import into Python and am having some trouble. I have downloaded and installed the pywin32 extensions for Python 2.6, which is the version of python I am running on Windows. When I attempt to import the DDE module, as follows, import win32ui import dde I get: Traceback (most recent call last): File string, in line 1, in fragment ImportError: This must be an MFC application - try loading with win32ui first For what it's worth, importing dde works from within the MFC demo application Pythonwin.exe, located in site-packages\pythonwin, which is where you'll also find the MFC DLLs and manifest, along with win32ui.pyd and dde.pyd. You'll probably find more help on the python-win32 mailing list: http://mail.python.org/mailman/listinfo/python-win32 Or file a bug report on the SourceForge bug tracker for pywin32: http://sourceforge.net/tracker/?group_id=78018atid=551954 -- http://mail.python.org/mailman/listinfo/python-list
feedparser vs. network errors - something remembers that net was down.
I have an application which uses feedparser (Python 2.6, of course), on a Linux laptop. If the network connection is up at startup, it works fine. If the network connection is down, feedparser reports a network error. That's fine. However, if the network is down, including access to DNS, when the application starts, but comes up later, the program continues to report a network error. So, somewhere in the stack, someone is probably caching something. My own code looks like this: def fetchitems(self) : # fetch more items from feed source try :# try fetching now = time.time()# timestamp # fetch from URL d = feedparser.parse(self.url,etag=self.etag, modified=self.modified) # if network failure if d is None or not hasattr(d,status) : raise IOError(of network or news source failure) if d.status == 304 :# if no new items self.logger.debug(Feed polled, no changes.) return # nothing to do self.logger.debug(Read feed: %d entries, status %s % (len(d.entries), d.status)) if d.status != 200 : # if bad status raise IOError(of connection error No. %d % (d.status,)) ... The exception at: IOError(of network or news source failure) is raised. Looking in feedeparser.py, parse calls _open_resource, which, after much fooling around, builds a urllib2 request, builds an opener via urllib2, and calls its open method. So I'm not seeing any state that should persist from call to call. What am I missing? John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
harrismh777 wrote: Steven D'Aprano wrote: At this point Microsoft has absolutely nothing to offer the computer science community at large except bzillions of euros ( or dollars ) of wasteful litigation and head-ache. Do you have an example of this wasteful litigation? You have to be kidding, right? Check *any* of the sites I listed above and read about it... software idea patent litigation is a business now worth billions of dollars per year. One of the premier sites: http://www.groklaw.net/ Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
On 2011-04-07, harrismh777 harrismh...@charter.net wrote: Littlefield, Tyler wrote: yep, if somebody moves one more thing. there's going to be a fight... bitch in your own thread, please? We've already heard you complain plenty, no need to take it to other threads too. uh, that was humor... like, get a sense of... lighten up... sometimes we're just trying to be funny. No, I doubt there are any blood and guts action fighting games written in Python... but I suppose you could google it, and if you find some, I'd like to know too I won't play them of course, ... just would be interesting to know that Python is so versatile. Python would b ea bad choice for most of any fighting game, but could see use as a configuration or internal scripting engine. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
Python would b ea bad choice for most of any fighting game, but could see use as a configuration or internal scripting engine. Python's objects are rather large, which sort of makes for some slow work. Maybe a configuration setup, but Lua and Angelscript are better suited to high-end games where scripting is required because of their smaller footprint. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 4/7/11 1:40 AM, John Ladasky wrote: On Apr 5, 10:43 am, Philip Semanchukphi...@semanchuk.com wrote: And as Robert Kern pointed out, numpy arrays are also pickle-able. OK, but SUBCLASSES of numpy.ndarray are not, in my hands, pickling as I would expect. I already have lots of code that is based on such subclasses, and they do everything I want EXCEPT pickle correctly. I may have to direct this line of questions to the numpy discussion group after all. Define the __reduce_ex__() method, not __getstate__(), __setstate__(). http://docs.python.org/release/2.6.6/library/pickle.html#pickling-and-unpickling-extension-types ndarrays are extension types, so they use that mechanism. -- 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: fighting game made with python
On Thu, Apr 7, 2011 at 10:41 AM, Littlefield, Tyler ty...@tysdomain.com wrote: Python would b ea bad choice for most of any fighting game, but could see use as a configuration or internal scripting engine. Python's objects are rather large, which sort of makes for some slow work. Maybe a configuration setup, but Lua and Angelscript are better suited to high-end games where scripting is required because of their smaller footprint. EVE online manages to do it. shrug. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Amazon Simple Queue Service Worker
I'm not sure about what you want to do, but you could check http://www.openstack.org/ web and look for ideas for using with Amazon. 2011/4/7 Joseph Ziegler j...@lounginghound.com Hi all, Little new to the python world, please excuse the Noobness. We are writing a server which will subscribe to the Amazon Simple Queue Service. I am looking for a good service container. I saw Twisted and Zope out there. It's going to be a server which polls on a queue via the Boto api. Do you have any suggestions for a framework to start? Best Regards, Joe -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Literate Programming
Has anyone found a good system for literate programming in python? I have been trying to use pylit/sphinx/pdflatex to generate technical documentation. The application is scientific/numerical programming, so discussing maths in maths syntax in between python syntax is important. While I like the style, there are several things which do not work as they should. One problem is that reST strips the indentation of code. When documentation intersperses nested blocks, it would look better if indentation was preserved so that the semantics of the code is clear in the documentation. Are there any tricks to achieve this in sphinx, or other systems which get it right? Another problem is the the syntax highlighting sometimes get confused. Most of the time, keywords are highlighted, but sometimes they don't. For instance, documentation between if and else in a conditional, seems to prevent sphinx from recognising else. I also have some problems with 'def´ not being recognised, where I have absolutely no clue as to why. Are there any solutions to this? Third problem, when I use automethod to get the docstring prettyprinted, it would be neat if the verbatim docstring definition did not appear as well. Any hints? I am not dead set on keeping pylit/sphinx, although it would be good to minimise the amount of doc code requiring rewriting. The most important thing is to get a working system where I could write a tutorial explaining both the python syntax and the maths of a problem completely unambiguously. TIA -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Spam on the mailing list
On Thu, 07 Apr 2011 01:03:31 +1000, Chris Angelico wrote: I don't know whether it's ironic or in some way Pythonesque, but this is the only mailing list that I've seen significant amounts of spam on... Bear in mind that the mailing list has a bidirectional gateway to the comp.lang.python newsgroup. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Thu, 2011-04-07 at 11:50 -0400, Benjamin Kaplan wrote: On Thu, Apr 7, 2011 at 11:31 AM, harrismh777 harrismh...@charter.net wrote: Steven D'Aprano wrote: ...n Mono, which is an open source implementation of the ECMA-334 and ECMA-335 standards. The only difference between it and Python is that Python was developed at a research institute while .NET was developed at a corporation. +1 Please read http://www.jprl.com/Blog/archive/development/mono/2009/Jan-19.html If you still do not understand why this is a bogus issue then just go away. Most important bit being: quote What I find even funnier is that Microsoft supposedly holds a number of patents in a number of areas frequently used by open-source projects, such as HTML, CSS, C++, XML, and others. So why don't we ever see any suggestions to avoid these technologies because the Big Bad Microsoft might sue? For that matter, (again) considering how vague software patents tend to be, wouldn't many Microsoft patents on .NET stand a chance at being applicable toward Java, Python, and other projects? (Again) Why just focus on Mono? /quote There is no FUD here... NO FEAR Absolutely CERTAIN NO DOUBT At this point Microsoft has absolutely nothing to offer the computer science community at large except bzillions of euros ( or dollars ) of wasteful litigation and head-ache. Looks like FUD and smells like FUD. Unless you happen to be on Microsoft's legal team and know that they're about to sue everyone who's using Mono. +1 Not to mention that they've collaborated with Mono on numerous occasions, and other projects [like Samba], so it suing them would pretty a change of precedent. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents (was: Python benefits over Cobra)
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Perhaps what you mean is, none of the licences granted are *irrevocable*. But the same applies to the GPL -- break the GPL's (generous) terms, and you too could find that your licence is revoked. Actually, you could argue since the GPL doesn't meet the legal definition of a contract, it can be revoked unilateraly (but not retroactively) by the copyright holder at any time for any reason. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rri...@csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: Sandboxed Python: memory limits?
Chris Angelico ros...@gmail.com writes: So I'm hoping to restrict the script's ability to consume all of memory, without (preferably) ulimit/rlimiting the entire process (which does other things as well). But if it can't be, it can't be. Just wondering, but rather than spending the energy to cap Python's allocations internally, could similar effort instead be directed at separating the other things the same process is doing? How tightly coupled is it? If you could split off just the piece you need to limit into its own process, then you get all the OS tools at your disposal to restrict the resources of that process. Depending on what the other things are, it might not be too hard to split apart, even if you have to utilize some IPC mechanism to coordinate among the two pieces. Certainly might be of the same order of magnitude of tweaking Python to limit memory internally. -- David -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On Apr 7, 10:44 am, Robert Kern robert.k...@gmail.com wrote: On 4/7/11 1:40 AM, John Ladasky wrote: On Apr 5, 10:43 am, Philip Semanchukphi...@semanchuk.com wrote: And as Robert Kern pointed out, numpy arrays are also pickle-able. OK, but SUBCLASSES of numpy.ndarray are not, in my hands, pickling as I would expect. I already have lots of code that is based on such subclasses, and they do everything I want EXCEPT pickle correctly. I may have to direct this line of questions to the numpy discussion group after all. Define the __reduce_ex__() method, not __getstate__(), __setstate__(). http://docs.python.org/release/2.6.6/library/pickle.html#pickling-and... ndarrays are extension types, so they use that mechanism. Thanks, Robert, as you can see, I got on that track shortly after I posted my code example. This is apparently NOT a numpy issue, it's an issue for pickling all C extension types. Is there a way to examine a Python object, and determine whether it's a C extension type or not? Or do you have to deduce that from the documentation and/or the source code? I started hunting through the numpy source code last night. It's complicated. I haven't found the ndarray object definition yet. Perhaps because I was looking through .py files, when I actually should have been looking through .c files? -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
On Thursday, April 7, 2011 9:51:05 AM UTC-4, neil harper wrote: is there any fighting games(street fighter, mortal kombat, etc) made in python? I found a 2D pygame (SDL) fighter called fighter framework, which is basically karate sparring. http://www.pygame.org/project-fighter+framework-1550-3173.html run.py loads the game. I had to copy a font from ./karate/Karate.ttf to ./lastninja.ttf in order to get past an error. The game only has basic graphics and sound, like something from an Atari 2600. The available moves for the fighter are low, medium, and high kicks, punch, block, and jump, plus combos for a roundhouse kick, jump kick, front flip, and back flip. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sandboxed Python: memory limits?
On Fri, Apr 8, 2011 at 4:36 AM, David Bolen db3l@gmail.com wrote: Just wondering, but rather than spending the energy to cap Python's allocations internally, could similar effort instead be directed at separating the other things the same process is doing? How tightly coupled is it? If you could split off just the piece you need to limit into its own process, then you get all the OS tools at your disposal to restrict the resources of that process. Well, what happens is roughly this: Process begins doing a lengthy operation. Python is called upon to generate data to use in that. C collects the data Python generated, reformats it, stores it in database (on another machine). C then proceeds to use the data, further manipulating it, lots of processing that culminates in another thing going into the database. The obvious way to split it would be to send it to the database twice, separately, as described above (the current code optimizes it down to a single INSERT at the bottom, keeping it in RAM until then). This would work, but it seems like a fair amount of extra effort (including extra load on our central database server) to achieve what I'd have thought would be fairly simple. I think it's going to be simplest to use a hardware solution - throw heaps of RAM at the boxes and then just let them do what they like. We already have measures to ensure that one client's code can't be evil repeatedly in a loop, so I'll just not worry too much about this check. (The project's already well past its deadlines - mainly not my fault!, and if I tell my boss We'd have to tinker with Python's internals to do this, he's going to put the kybosh on it in two seconds flat.) Thanks for the information, all! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
On Thu, Apr 7, 2011 at 11:51 PM, neil harper neilalt300...@gmail.com wrote: is there any fighting games(street fighter, mortal kombat, etc) made in python? I'd say there are some around. Depends how good you want them, though, because of the performance issues already mentioned. Someone has done, no kidding, Tetris written in sed. If you can do that, you can write a fighting game in Python! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: How to program in Python to run system commands in 1000s of servers
Chris Angelico ros...@gmail.com writes: Depending on what exactly is needed, it might be easier to run a separate daemon on the computers, one whose sole purpose is to do the task / get the statistics needed and return them. Then the Python script need only collect each program's returned response. Those would still need to be deployed somehow to the thousands of machines though. I realized after posting that something like pexpect might work for stuffing the keystrokes needed to root login via ssh to all machines and such... If that's what he needs to do, since it wasn't very clear. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is __root checked for in OrderedDict?
On Apr 7, 4:13 am, andrew cooke and...@acooke.org wrote: If you look at the code inhttp://hg.python.org/cpython/file/6adbf5f3dafb/Lib/collections/__init...the attribute __root is checked for, and only created if missing. Why? I ask because, from what I understand, the __init__ method will only be called when the object is first being created, so __root will always be missing. First of all, three cheers for reading the source code! A user can call __init__() even after the OrderedDict instance has already been created. If so, the __root attribute will already exist and the whole operation becomes equivalent to an update(). You can see the same behavior with regular dictionaries: d = dict(a=1, b=2) d.__init__(b=4, c=5) d {'a': 1, 'c': 5, 'b': 4} Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Literate Programming
Without fully answering your question ... I suggest you have a look at Leo http://webpages.charter.net/edreamleo/front.html and ask your question at the (google) groups page devoted to that editor. http://groups.google.com/group/leo-editor HTH J^n -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
Adam Tauno Williams wrote: Please read http://www.jprl.com/Blog/archive/development/mono/2009/Jan-19.html If you still do not understand why this is a bogus issue then just go away. Good blog--- off the point, but a nice rant none-the-less. = block quote With all this in mind, you can see why patent FUD is hard to fight, because there's no way to dismiss it. Software patents are a reality, they're ugly, but they can't be avoided. (Yet they must be ignored, to avoid increased liability.) = /block quote His primary error in thought, suggests that we must live with software patents forever... wrong. They must be eliminated. = block quote My problem is that the anti-Mono people only seem to focus on patents with respect to Mono and Microsoft, ignoring the rest of the software industry. They're ignoring the (gigantic) forest so that they can pay attention to a single tree, Microsoft. = /block quote Also, wrong. In fact, Mono is at the bottom of my list. Even though Mono encourages .NET C#, it at least is open source software... my primary targets (there are hundreds of them) are way more important than Mono... = block quote What I find even funnier is that Microsoft supposedly holds a number of patents in a number of areas frequently used by open-source projects, such as HTML, CSS, C++, XML, and others. So why don't we ever see any suggestions to avoid these technologies because the Big Bad Microsoft might sue? = /block quote This is because the patents are so obviously bogus (and vague) that even non-lawyers know that they wouldn't stand a chance in court. No, the dangers lie elsewhere. Microsoft is a bully... and how they choose their battles has been a mystery to many of us... like the BN case... who knew?... frankly, I'm not concerned about Mono... at the moment Microsoft needs them... for the moment... = block quote For that matter, (again) considering how vague software patents tend to be, wouldn't many Microsoft patents on .NET stand a chance at being applicable toward Java, Python, and other projects? (Again) Why just focus on Mono? Final note: I am a Software Engineer, not a patent lawyer. = /block quote At least he admits that he doesn't know what he is talking about. That is refreshing. No one is focusing on *just* Mono... nobody... its just one area of concern. The reason Mono gets hit (from others besides me) is that they are in partnership and collaboration with Microsoft, consciously and unconsciously. This must be punished. Microsoft is a corporate bully, a terrible citizen, and officially (district and federal) a criminal, guilty of breaking anti-trust laws. FOSS should not collaborate with Microsoft, in any way. We won our class action suit against Microsoft here in Minnesota... out of which I received a smallish payout... and that is a start. Microsoft must cease to exist (as a business interest if necessary) as a corporate bully, and FOSS should have nothing to do with aiding them. This is not just business... this is principle. If you give up principle (Mono, or anyone else) even if you win, you lose. kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Fri, Apr 8, 2011 at 2:33 AM, harrismh777 harrismh...@charter.net wrote: Therein lies *the* problem. The point that gets missed over and over is that there CAN BE NO PATENT COVERING MATHEMATICS ... period. Yes, C# and .NET are covered by hundreds of software patents. Its an insane mess... which must be eliminated at all costs. All software can be expressed as lambda calculus. The point being, all software is mathematics... With enough software, you can simulate anything. That means that the entire universe can be expressed as lambda calculus. Does that mean that nothing can ever be patented, because it's all just mathematics? At what point is there valid, patentable creativity to be found in combining known elements in previously unknown ways? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 4/7/11 1:39 PM, John Ladasky wrote: On Apr 7, 10:44 am, Robert Kernrobert.k...@gmail.com wrote: On 4/7/11 1:40 AM, John Ladasky wrote: On Apr 5, 10:43 am, Philip Semanchukphi...@semanchuk.comwrote: And as Robert Kern pointed out, numpy arrays are also pickle-able. OK, but SUBCLASSES of numpy.ndarray are not, in my hands, pickling as I would expect. I already have lots of code that is based on such subclasses, and they do everything I want EXCEPT pickle correctly. I may have to direct this line of questions to the numpy discussion group after all. Define the __reduce_ex__() method, not __getstate__(), __setstate__(). http://docs.python.org/release/2.6.6/library/pickle.html#pickling-and... ndarrays are extension types, so they use that mechanism. Thanks, Robert, as you can see, I got on that track shortly after I posted my code example. This is apparently NOT a numpy issue, it's an issue for pickling all C extension types. Yes, but seriously, you should ask on the numpy mailing list. You will probably run into more numpy-specific issues. At least, we'd have been able to tell you things like ndarray is an extension type, so look at that part of the documentation quicker. Is there a way to examine a Python object, and determine whether it's a C extension type or not? For sure? No, not really. Not at the Python level, at least. You may be able to do something at the C level, I don't know. Or do you have to deduce that from the documentation and/or the source code? I started hunting through the numpy source code last night. It's complicated. I haven't found the ndarray object definition yet. Perhaps because I was looking through .py files, when I actually should have been looking through .c files? Yes. The implementation for __reduce__ is in numpy/core/src/multiarray/methods.c as array_reduce(). You may want to look in numpy/ma/core.py for the definition of MaskedArray. It shows how you would define __reduce__, __getstate__ and __setstate__ for a subclass of ndarray. -- 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: Spam on the mailing list
On 2011-04-07, Nobody nob...@nowhere.com wrote: On Thu, 07 Apr 2011 01:03:31 +1000, Chris Angelico wrote: I don't know whether it's ironic or in some way Pythonesque, but this is the only mailing list that I've seen significant amounts of spam on... Bear in mind that the mailing list has a bidirectional gateway to the comp.lang.python newsgroup. Where google groups is a perennial source of garbage. Personally, I see almost zero spam in this group (reading it in comp.lang.python). That's attributable in part to my News provider filtering out stuff and in part to my .score file entry that automatically discards anything posted via groups.google.com. -- Grant Edwards grant.b.edwardsYow! Do you have exactly at what I want in a plaid gmail.compoindexter bar bat?? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to program in Python to run system commands in 1000s of servers
Am 07.04.2011 21:14, schrieb Anssi Saari: Chris Angelicoros...@gmail.com writes: Depending on what exactly is needed, it might be easier to run a separate daemon on the computers, one whose sole purpose is to do the task / get the statistics needed and return them. Then the Python script need only collect each program's returned response. Those would still need to be deployed somehow to the thousands of machines though. But only once... I realized after posting that something like pexpect might work for stuffing the keystrokes needed to root login via ssh to all machines and such... If that's what he needs to do, since it wasn't very clear. Maybe that works. But it is much, much worse than using keys... Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Literate Programming
On 4/7/11 1:09 PM, Hans Georg Schaathun wrote: Has anyone found a good system for literate programming in python? I have been trying to use pylit/sphinx/pdflatex to generate technical documentation. The application is scientific/numerical programming, so discussing maths in maths syntax in between python syntax is important. While I like the style, there are several things which do not work as they should. One problem is that reST strips the indentation of code. When documentation intersperses nested blocks, it would look better if indentation was preserved so that the semantics of the code is clear in the documentation. Are there any tricks to achieve this in sphinx, or other systems which get it right? http://sphinx.pocoo.org/markup/code.html As far as I can tell, it just works. See here for an example: http://ipython.scipy.org/doc/nightly/html/interactive/reference.html -- 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: Why is __root checked for in OrderedDict?
Is that normal? I mean, OK, it's possible (and yes I forgot it could be called directly), but is there any usual reason to do so? I guess what I'm asking is: if I'm writing library code should I be this careful? (I've written quite a lot of Python code without this ever biting me, but maybe I'm just lazy). For example, would you consider it a bug if someone complained that calling __init__() resulted in unexpected behaviour? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list
Confused about __prepare__
In the code below I use __prepare__ to change the class dictionary so that a tuple is stored in __setitem__(). Since __getitem__() removes the tuple I wasn't expecting any problems, but it seems that __init__ is being retrieved via some other mechanism. Why? Is a copy of the dict being made somewhere? If so, can I change that? Thanks, Andrew class TupleDict(dict): '''Stores additional info, but removes it on __getitem__().''' def __setitem__(self, key, value): print('setting', key, value) super(TupleDict, self).__setitem__(key, (value, 'secret')) def __getitem__(self, key): value = super(TupleDict, self).__getitem__(key) print('getting', key, value[0]) # drop secret return value[0] class TupleMeta(type): @classmethod def __prepare__(metacls, name, bases, **kargs): print('in prepare') return TupleDict() def __new__(cls, name, bases, classdict): print('in new') return type.__new__(cls, name, bases, classdict) class C(metaclass=TupleMeta): def __init__(self): self.a = 1 c = C() in prepare setting __module__ __main__ setting __init__ function __init__ at 0x7f37cbad40d8 in new Traceback (most recent call last): File ..., line 34, in module c = C() # TypeError: 'tuple' object is not callable TypeError: 'tuple' object is not callable -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about __prepare__
Sorry I should probably have made clear that this is Python 3.2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about __prepare__
On Thu, Apr 7, 2011 at 3:31 PM, andrew cooke and...@acooke.org wrote: In the code below I use __prepare__ to change the class dictionary so that a tuple is stored in __setitem__(). Since __getitem__() removes the tuple I wasn't expecting any problems, but it seems that __init__ is being retrieved via some other mechanism. Why? I suspect you're being bitten by http://docs.python.org/dev/reference/datamodel.html#special-method-lookup In particular: implicit special method lookup generally also bypasses the __getattribute__() method. __init__() is a special method. The default __getattribute__() implementation consults an object's __dict__. type.__new__() presumably does an implicit special method lookup for __init__() behind the scenes. Hence, your custom __dict__ is bypassed. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about __prepare__
Yes, I think you're right, thanks. Makes sense from an efficiency POV. Luckily, it turns out I don't need to do that anyway :o) Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 5 apr, 02:05, Robert Kern robert.k...@gmail.com wrote: PicklingError: Can't pickle class 'multiprocessing.sharedctypes.c_double_Array_10': attribute lookup multiprocessing.sharedctypes.c_double_Array_10 failed Hehe :D That is why programmers should not mess with code they don't understand! Gaël and I wrote shmem to avoid multiprocessing.sharedctypes, because they cannot be pickled (they are shared by handle inheritance)! To do this we used raw Windows API and Unix System V IPC instead of multiprocessing.Array, and the buffer is pickled by giving it a name in the file system. Please be informed that the code on bitbucked has been fixed by someone who don't understand my code. If it ain't broke don't fix it. http://folk.uio.no/sturlamo/python/sharedmem-feb13-2009.zip Known issues/bugs: 64-bit support is lacking, and os._exit in multiprocessing causes a memory leak on Linux. Maybe. If the __reduce_ex__() method is implemented properly (and multiprocessing bugs aren't getting in the way), you ought to be able to pass them to a Pool just fine. You just need to make sure that the shared arrays are allocated before the Pool is started. And this only works on UNIX machines. The shared memory objects that shmarray uses can only be inherited. I believe that's what Sturla was getting at. It's a C extension that gives a buffer to NumPy. Then YOU changed how NumPy pickles arrays referencing these buffers, using pickle.copy_reg :) Sturla -- http://mail.python.org/mailman/listinfo/python-list
Replacing *instance* dict
Related to the above, Is there anything wrong with the following code to replace the *instance* rather than the class dict? It seems very crude, but appears to work. Thanks, Andrew class TupleSuper: def __new__(cls): print('in new') instance = object.__new__(cls) instance.__dict__ = TupleDict(instance.__dict__) return instance class D(TupleSuper): def __init__(self): self.a = 1 if __name__ == '__main__': d = D() assert d.a == 1 d.a = 2 assert d.a == 2 d.a = 'three' assert d.a == 'three' print('woop') On Thursday, April 7, 2011 7:31:16 PM UTC-3, andrew cooke wrote: class TupleDict(dict): '''Stores additional info, but removes it on __getitem__().''' def __setitem__(self, key, value): print('setting', key, value) super(TupleDict, self).__setitem__(key, (value, 'secret')) def __getitem__(self, key): value = super(TupleDict, self).__getitem__(key) print('getting', key, value[0]) # drop secret return value[0] -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 4 apr, 22:20, John Ladasky lada...@my-deja.com wrote: https://bitbucket.org/cleemesser/numpy-sharedmem/src/3fa526d11578/shm... I've added a few lines to this code which allows subclassing the shared memory array, which I need (because my neural net objects are more than just the array, they also contain meta-data). But I've run into some trouble doing the actual sharing part. The shmarray class CANNOT be pickled. That is hilarious :-) I see that the bitbucket page has my and Gaëls name on it, but the code is changed and broken beyond repair! I don't want to be associated with that crap! Their shmarray.py will not work -- ever. It fails in two ways: 1. multiprocessing.Array cannot be pickled (as you noticed). It is shared by handle inheritance. Thus we (that is Gaël and I) made a shmem buffer object that could be pickled by giving it a name in the file system, instead of sharing it anonymously by inheriting the handle. Obviously those behind the bitbucket page don't understand the difference between named and anonymous shared memory (that is, System V IPC and BSD mmap, respectively.) 2. By subclassing numpy.ndarray a pickle dump would encode a copy of the buffer. But that is what we want to avoid! We want to share the buffer itself, not make a copy of it! So we changed how numpy pickles arrays pointing to shared memory, instead of subclassing ndarray. I did that by slightly modifying some code written by Robert Kern. http://folk.uio.no/sturlamo/python/sharedmem-feb13-2009.zip Known issues/bugs: 64-bit support is lacking, and os._exit in multiprocessing causes a memory leak on Linux. Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 8 apr, 02:03, sturlamolden sturlamol...@yahoo.no wrote: http://folk.uio.no/sturlamo/python/sharedmem-feb13-2009.zip Known issues/bugs: 64-bit support is lacking, and os._exit in multiprocessing causes a memory leak on Linux. I should probably fix it for 64-bit now. Just recompiliong with 64-bit integers will not work, because I intentionally hardcoded the higher 32 bits to 0. It doesn't help to represent the lower 32 bits with a 64 bit integer (which it seems someone actually have tried :-D) The memory leak on Linux is pesky. os._exit prevents clean-up code from executing, but unlike Windows the Linux kernel does no reference counting. I am worried we actually need to make a small kernel driver to make this work properly for Linux, since os._exit makes the current user-space reference counting fail on child process exit. Sturla -- http://mail.python.org/mailman/listinfo/python-list
RE: multiprocessing
Hi, thanks for your response. I checked out multiprocessing.value, however from what I can make out, it works with object of only a very limited type. Is there a way to do this for more complex objects? (In reality, my object is a large multi-dimensional numpy array). Thanks, Elsa. Date: Wed, 6 Apr 2011 22:20:06 -0700 Subject: Re: multiprocessing From: drsali...@gmail.com To: kerensael...@hotmail.com CC: python-list@python.org On Wed, Apr 6, 2011 at 9:06 PM, elsa kerensael...@hotmail.com wrote: Hi guys, I want to try out some pooling of processors, but I'm not sure if it is possible to do what I want to do. Basically, I want to have a global object, that is updated during the execution of a function, and I want to be able to run this function several times on parallel processors. The order in which the function runs doesn't matter, and the value of the object doesn't matter to the function, but I do want the processors to take turns 'nicely' when updating the object, so there are no collisions. Here is an extremely simplified and trivial example of what I have in mind: from multiprocessing import Pool import random p=Pool(4) myDict={} def update(value): global myDict index=random.random() myDict[index]+=value total=1000 p.map(update,range(total)) After, I would also like to be able to use several processors to access the global object (but not modify it). Again, order doesn't matter: p1=Pool(4) def getValues(index): global myDict print myDict[index] p1.map(getValues,keys.myDict) Is there a way to do this This should give you a synchronized wrapper around an object in shared memory: http://docs.python.org/library/multiprocessing.html#multiprocessing.Value -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing
On Apr 7, 2011, at 8:57 PM, Kerensa McElroy wrote: Hi, thanks for your response. I checked out multiprocessing.value, however from what I can make out, it works with object of only a very limited type. Is there a way to do this for more complex objects? (In reality, my object is a large multi-dimensional numpy array). Elsa, Are you following the current thread in this list which is talking about sharing numpy arrays via multiprocessing? http://mail.python.org/pipermail/python-list/2011-April/1269173.html Date: Wed, 6 Apr 2011 22:20:06 -0700 Subject: Re: multiprocessing From: drsali...@gmail.com To: kerensael...@hotmail.com CC: python-list@python.org On Wed, Apr 6, 2011 at 9:06 PM, elsa kerensael...@hotmail.com wrote: Hi guys, I want to try out some pooling of processors, but I'm not sure if it is possible to do what I want to do. Basically, I want to have a global object, that is updated during the execution of a function, and I want to be able to run this function several times on parallel processors. The order in which the function runs doesn't matter, and the value of the object doesn't matter to the function, but I do want the processors to take turns 'nicely' when updating the object, so there are no collisions. Here is an extremely simplified and trivial example of what I have in mind: from multiprocessing import Pool import random p=Pool(4) myDict={} def update(value): global myDict index=random.random() myDict[index]+=value total=1000 p.map(update,range(total)) After, I would also like to be able to use several processors to access the global object (but not modify it). Again, order doesn't matter: p1=Pool(4) def getValues(index): global myDict print myDict[index] p1.map(getValues,keys.myDict) Is there a way to do this This should give you a synchronized wrapper around an object in shared memory: http://docs.python.org/library/multiprocessing.html#multiprocessing.Value -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing, shared memory vs. pickled copies
On 8 apr, 02:38, sturlamolden sturlamol...@yahoo.no wrote: I should probably fix it for 64-bit now. Just recompiliong with 64-bit integers will not work, because I intentionally hardcoded the higher 32 bits to 0. That was easy, 64-bit support for Windows is done :-) Now I'll just have to fix the Linux code, and figure out what to do with os._exit preventing clean-up on exit... :-( Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing
I'm afraid I've not heard of a way of putting more complex objects into shared memory with multiprocessing. That is, not without using a queue along the lines of http://docs.python.org/library/multiprocessing.html#exchanging-objects-between-processes, which isn't quite the same thing. On Thu, Apr 7, 2011 at 5:57 PM, Kerensa McElroy kerensael...@hotmail.comwrote: Hi, thanks for your response. I checked out multiprocessing.value, however from what I can make out, it works with object of only a very limited type. Is there a way to do this for more complex objects? (In reality, my object is a large multi-dimensional numpy array). Thanks, Elsa. -- Date: Wed, 6 Apr 2011 22:20:06 -0700 Subject: Re: multiprocessing From: drsali...@gmail.com To: kerensael...@hotmail.com CC: python-list@python.org On Wed, Apr 6, 2011 at 9:06 PM, elsa kerensael...@hotmail.com wrote: Hi guys, I want to try out some pooling of processors, but I'm not sure if it is possible to do what I want to do. Basically, I want to have a global object, that is updated during the execution of a function, and I want to be able to run this function several times on parallel processors. The order in which the function runs doesn't matter, and the value of the object doesn't matter to the function, but I do want the processors to take turns 'nicely' when updating the object, so there are no collisions. Here is an extremely simplified and trivial example of what I have in mind: from multiprocessing import Pool import random p=Pool(4) myDict={} def update(value): global myDict index=random.random() myDict[index]+=value total=1000 p.map(update,range(total)) After, I would also like to be able to use several processors to access the global object (but not modify it). Again, order doesn't matter: p1=Pool(4) def getValues(index): global myDict print myDict[index] p1.map(getValues,keys.myDict) Is there a way to do this This should give you a synchronized wrapper around an object in shared memory: http://docs.python.org/library/multiprocessing.html#multiprocessing.Value -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Thu, 07 Apr 2011 14:37:27 -0500, harrismh777 wrote: The reason Mono gets hit (from others besides me) is that they are in partnership and collaboration with Microsoft, consciously and unconsciously. This must be punished. Just like Python, Apache, and the Linux kernel. What are you going to do to punish them? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is __root checked for in OrderedDict?
On Apr 7, 2:40 pm, andrew cooke and...@acooke.org wrote: Is that normal? I mean, OK, it's possible (and yes I forgot it could be called directly), but is there any usual reason to do so? It's common for subclasses to call their parent's __init__ method, so that should emulate dict as nearly as possible to help avoid surprises. For the most part, client code won't use __init__ directly because update() already provides equivalent functionality (but with a better name). For list.__init__(), the behavior is different. It clears the list, so someone may be using an __init__ call when it isn't practical to use the syntactic equivalents del a[:] or a[:] = []. Outside those cases, I don't it is normal, but who knows what future programmers will need to do? I guess what I'm asking is: if I'm writing library code should I be this careful? For the standard library, it pays to really think out the corner cases because you never know what people are going to rely on. The Liskov substitution principle asks us to make OrderedDict behave as much like dict as possible (so that OD's can be used a drop-in substitute when needed). Also subclassers tend to stress the API in ways that wouldn't be common for the base class. For standard library code, I think all the little things matter: * int(), bool(), list() etc all return a zero value when called with no arguments * the ordered dict code internally calls __update() instead of update() so that a subclass can override update() without breaking the constructor * eval(repr(obj)) should round-trip whereever possible * containers should behave reasonable well even if someone makes the container reference itself: a=[]; a.append(a) * classes should try to be pickable, copyable, and deepcopyable, etc ... Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: fighting game made with python
On Thu, Apr 7, 2011 at 6:51 AM, neil harper neilalt300...@gmail.com wrote: is there any fighting games(street fighter, mortal kombat, etc) made in python? http://mail.python.org/mailman/listinfo/python-list I talked to a guy from Blizzard about Python in their games once. He said that not only are most (all?) Blizzard games written in Python (all the heavy lifting is done in C via OpenGL anyway), but it's pretty common for things to be done this way. -- http://mail.python.org/mailman/listinfo/python-list
How to re import a module
Hello i want to know the best way to re import a module, because i have a web server with just one Apache session for all my domains and applications, and i if i need to make some changes on one application restart the server will affect the others, so i was thinking in 2 ways the first will be 're imported' the module, the second use subprocess. First the less unsecured that in this case i think is re import the module, give me your opinions please. --- Thanks in advance Diego Hidalgo -- http://mail.python.org/mailman/listinfo/python-list
Chances in Management careers.
Careers for fresher. Great earning in Management careers. http://topcareer.webs.com/index.htm http://jobshunter.webs.com/index.htm Government Vacancies for all graduates earn in salary. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
[issue11771] hashlib object cannot be pickled
Gregory P. Smith g...@krypto.org added the comment: heh yeah. while all hash functions do have internal state and someone could conceivably want to store such a state (it basically amounts to queued up partial block of input data if any and the current starting IV) there are not consistent APIs to expose that and I really don't see why it'd be worth trying to find them. remember, hashlib doesn't have to be openssl. there are non openssl libtomcrypt based versions and someone nice should write a libnss based version someday. i'd mark this won't fix. :) -Greg On Tue, Apr 5, 2011 at 7:02 AM, Antoine Pitrou rep...@bugs.python.org wrote: Antoine Pitrou pit...@free.fr added the comment: Why on Earth would you want to serialize a hashlib object? It makes as much sense as serializing, say, a JSONEncoder. -- nosy: +gregory.p.smith, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11771 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11771 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11771] hashlib object cannot be pickled
Raymond Hettinger raymond.hettin...@gmail.com added the comment: I also recommend closing this one. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11771 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11715] Building Python on multiarch Debian and Ubuntu
Stefan Krah stefan-use...@bytereef.org added the comment: The FreeBSD and Solaris bots are failing: dpkg-architecture: not found error: build/temp.freebsd-8.2-RELEASE-amd64-3.3-pydebug/multiarch: No such file or directory [62607 refs] *** Error code 1 find_executable.patch should solve the problem. -- Added file: http://bugs.python.org/file21558/find_executable.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11791] python -m doctest has a -v flag that it ignores
New submission from Devin Jeanpierre jeanpierr...@gmail.com: The usage string details a -v option, but python -m doctest doesn't use a -v option. The attached patch adds that. -- files: doctest_verbosity.diff keywords: patch messages: 133195 nosy: Devin Jeanpierre priority: normal severity: normal status: open title: python -m doctest has a -v flag that it ignores versions: Python 3.2 Added file: http://bugs.python.org/file21559/doctest_verbosity.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11791 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11777] Executor.map does not submit futures until iter.next() is called
ysj.ray ysj@gmail.com added the comment: Got it. Seems the behavior is not consist with the Executor.map() function: The returned iterator raises a TimeoutError if __next__() is called and the result isn't available after timeout seconds from ***the original call to map()*** -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11777 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11777] Executor.map does not submit futures until iter.next() is called
Brian Quinlan br...@sweetapp.com added the comment: Nice catch. I hadn't noticed that the docs are lying :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11777 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11771] hashlib object cannot be pickled
Changes by STINNER Victor victor.stin...@haypocalc.com: -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11771 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11792] asyncore module print to stdout
New submission from Samuele Kaplun samuele.kap...@cern.ch: The method log_info of the dispatcher class of the asyncore.py module, uses print statement to print to stdout. This lead to conflicts when asyncore is used within e.g. mod_wsgi, as writing to stdout is not supposed to be valid. -- components: Library (Lib) messages: 133198 nosy: kaplun priority: normal severity: normal status: open title: asyncore module print to stdout type: behavior versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11793] raw strings
New submission from chaos 846909...@qq.com: print(r'\') SyntaxError: EOL while scanning string literal print(r'\'') \' -- messages: 133199 nosy: chaos priority: normal severity: normal status: open title: raw strings type: compile error versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11793 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11794] Backport new logging docs to 2.7
New submission from Nick Coghlan ncogh...@gmail.com: Vinay did some great work on the logging documentation for 3.2 (http://docs.python.org/py3k/library/logging). However, a lot of people will currently miss it, since they land on the existing 2.7 documentation (http://docs.python.org/library/logging) instead. A backport would update the web site immediately, and then be incorporated in the bundled documentation when 2.7.2 is released (presumably later this year). Backporting should be relatively straightforward (since logging hasn't changed *that* much between 2.7 and 3.2), but isn't completely trivial (since details of the Python 3 only items will need to be removed and the changed in and added in notices will need to be updated to reflect the information in the existing 2.x series documentation) -- assignee: docs@python components: Documentation keywords: easy messages: 133200 nosy: docs@python, ncoghlan priority: normal severity: normal status: open title: Backport new logging docs to 2.7 versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11793] raw strings
chaos 846909...@qq.com added the comment: I think it should be print(r'\') \ print(r'\'') SyntaxError: EOL while scanning string literal -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11793 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1690608] email.utils.formataddr() should be rfc2047 aware
Torsten Becker torsten.bec...@gmail.com added the comment: Hi David, thank you for polishing up the patch and committing it. :) I am glad I could help and I was actually about to ask you if you knew any follow-up issues. I'll definitely continue contributing as time allows. I did not submit the agreement yet, but I'll look into that ASAP. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1690608 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11793] raw strings
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: This is by design and documented: http://docs.python.org/reference/lexical_analysis.html String quotes can be escaped with a backslash, but the backslash remains in the string; for example, r\ is a valid string literal consisting of two characters: a backslash and a double quote; r\ is not a valid string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw string cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the string, not as a line continuation. -- nosy: +amaury.forgeotdarc resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11793 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11762] Ast doc: warning and version number
Georg Brandl ge...@python.org added the comment: Sounds good to me, except for Use *ast.__version__* to work across versions. which is not quite clear. While talking about version numbers, we should probably also document *what changed* between those versions. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11762 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11789] Extend upon metaclass/type class documentation, here: zope.interface and usage of instances of classes as base classes
Georg Brandl ge...@python.org added the comment: This doesn't work as you show. What you probably meant was something like this: class InterfaceBase(type): ... Interface = InterfaceBase('Interface', (), {}) class IFoo(Interface): ... which you can just as well do by using normal metaclass syntax. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11789 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11792] asyncore module print to stdout
Changes by Antoine Pitrou pit...@free.fr: -- assignee: - giampaolo.rodola nosy: +giampaolo.rodola stage: - needs patch versions: +Python 3.2, Python 3.3 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11792] asyncore module print to stdout
Giampaolo Rodola' g.rod...@gmail.com added the comment: What change are you proposing exactly? Btw, overriding log_info() in such cases seems reasonable to me, without changing anything in asyncore. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2736] datetime needs an epoch method
Velko Ivanov viva...@ivanov-nest.com added the comment: On 04/05/2011 18:22, Alexander Belopolsky wrote: The datetime module intended to be an island of relative sanity. ... - Tim Peters Refusing to cooperate with the rest of the world is not sane by my books. On 04/05/2011 21:06, Alexander Belopolsky wrote: Converting datetime values to float is easy. If your dt is a naive instance representing UTC time: timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1) If your dt is an aware instance: timestamp = (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)) / timedelta(seconds=1) Please add these lines to the datetime module's documentation. In some central, well lit place. I believe that if nothing else, the whole discussion should have proved to you that there are many people looking for them. OTOH a sinceepoch(epoch=datetime(1970,1,1)) method of the datetime class should be equally easy. Would be especially useful if few of the more frequently used EPOCHs are provided as constants. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11792] asyncore module print to stdout
Samuele Kaplun samuele.kap...@cern.ch added the comment: Thanks for looking into it. Indeed that's the workaround I implemented in our application. On the other hand it would be nice if either: * the log_info method would print to stderr, * would use warning.warn() * would use the logging module to allow for fine grained configuration The 1st solution would be already enough for mod_wsgi usage (also see: http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Writing_To_Standard_Output) Cheers! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11792] asyncore module print to stdout
Giampaolo Rodola' g.rod...@gmail.com added the comment: asyncore is a minimalistic and generic framework; as such it should not privilege a specific application such as mod_wsgi or make any other assumption. I'd say it's fine to let user decide what to do in its own subclass. Furthermore, log_info() is used by asyncore only to warn about events which are supposed to be handled by user via method overriding (e.g. handle_read()). It's not something you want wsgi or any other application except yours to be aware of. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11793] raw strings
chaos 846909...@qq.com added the comment: Sorry for my poor english and thank you for the answer. Since I'm a perler, I think this is counterintuitive. (In perl: print '\'; #print \ print '\''; #error print \; #print print \; #error ) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11793 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com