Re: Q: sort's key and cmp parameters

2009-10-06 Thread Paul Rubin
Bearophile writes: > sorting, and something that's surely not bug-prone. In such situation > having a 'key' argument is *better*. Such sort can be stable. Nothing stops comparison sorting from being stable. Since the rest of your post seems premised on the opposite, I hope that clears things up

Re: Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread Roger Binns
tcumming...@gmail.com wrote: > The problem, is that I need the python app and the > sqlite db file to exist in the same disk file. This way the app to > access the data and the data are in the same file. For binaries this is possible with a little hackery. Firstly you need make the app be a zip f

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread catafest
I think the basically you need to write one python script name it __init__.py If you want this script may include functions to reading yours scripts from folder. Put this script in each folder and you use Margie solution . This allow you to use import from each folder . -- http://mail.python.org/m

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: I'm surprised to see you missed this. A module doesn't generally import itself, but it's an easy mistake for a circular dependency to develop among modules. Circular imports are always a difficulty. That has

Graphical nodes

2009-10-06 Thread Dylan Palmboom
Hi everyone Please could someone tell me of any libraries that you could use to make use of graphical nodes in python. Each node would hold data and properties. I am trying to achieve a similar effect, as in the application spoken about below. If you have seen an application called Nuke, by the f

ANN: python-gnupg v0.2.2 released

2009-10-06 Thread Vinay Sajip
A new version of the Python module which wraps GnuPG has been released. What Changed? = This is a minor bug-fix release. See the project website ( http://code.google.com/p/python-gnupg/ ) for more information. The changes were to the name of the distribution archive (now prefixed with

Re: Internationalized To:'s and Cc:'s

2009-10-06 Thread Nobody
On Tue, 06 Oct 2009 06:33:37 -0700, Maxim Kuleshov wrote: > How should I correctly construct internationalized base64'ed MIME > header? > The problem is that 'real name' _should_ be encoded, but the email > address - should not. > For example, ?utf-8?bla-bla=?= should be the correct > format, and

ANN: M2Crypto 0.20.2

2009-10-06 Thread Heikki Toivonen
M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web sessi

Re: Skeletal animation

2009-10-06 Thread Nobody
On Mon, 05 Oct 2009 15:25:17 -0700, Carl Banks wrote: > There are two ways to do what you want. The first way is to represent > bones as OpenGL transformations. Basically a joint deformation you'd > represent as a translation + rotation. To rotate a bone you'd simply > update the rotation of th

Re: Need feedback on subprocess-using function

2009-10-06 Thread Nobody
On Mon, 05 Oct 2009 02:29:38 -0700, ryles wrote: >> If you want a "double-ended" slave process, you need to use polling or >> non-blocking I/O or asynchronous I/O or multiple threads. I'm not aware of >> any single solution which works on all platforms. >> >> The easiest way around this problem is

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: > I'm surprised to see you missed this. A module doesn't generally import > itself, but it's an easy mistake for a circular dependency to develop > among modules. Circular imports are always a difficulty. That has nothing to do with making m

Multiprocessing.Queue deadlock

2009-10-06 Thread Felix
Hello, I keep running into a deadlock in a fairly simple parallel script using Multiprocessing.Queue for sending tasks and receiving results. >From the documentation I cannot figure out what is happening and none of the examples seem to cover quite what I am doing. The main code is results = mp.Q

Re: bug with itertools.groupby?

2009-10-06 Thread Dave Angel
Kitlbast wrote: On Oct 7, 3:04 am, Raymond Hettinger wrote: On Oct 6, 4:06 pm, Kitlbast wrote: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile'

Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available

2009-10-06 Thread Robert H
On Oct 6, 8:16 pm, "Sridhar Ratnakumar" wrote: > I'm happy to announce that ActivePython 2.6.3.7 is now available for > download from: > >      http://www.activestate.com/activepython/ > > This is a patch-level release that updates ActivePython to core Python > 2.6.3 along with the fixes for a cou

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: The most common problem is that a file is used as module and as executable at the same time. Like this: --- test.py --- class Foo(object): pass if __name__ == "__main__": import test assert Foo

Re: Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread Philip Semanchuk
On Oct 6, 2009, at 7:28 PM, tcumming...@gmail.com wrote: Ya, I thought of that... However... - It would be nice to be able to execute it directly (i.e,. click on it). You can't, "execute" a directory. - It would be more work to send as an email attachment. - I thought it was a cool

Re: Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread tcumming123
Ya, I thought of that... However... - It would be nice to be able to execute it directly (i.e,. click on it). You can't, "execute" a directory. - It would be more work to send as an email attachment. - I thought it was a cool idea, and had hoped someone else had figured out how to d

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 17:01:41 -0700, Carl Banks wrote: >> Why would a module need to import itself? Surely that's a very rare >> occurrence -- I think I've used it twice, in 12 years or so. I don't >> see why you need to disparage the idea of combining modules and scripts >> in the one file because

Re: bug with itertools.groupby?

2009-10-06 Thread Kitlbast
On Oct 7, 3:04 am, Raymond Hettinger wrote: > On Oct 6, 4:06 pm, Kitlbast wrote: > > > > > > > Hi there, > > > the code below on Python 2.5.2: > > > from itertools import groupby > > > info_list = [ > >     {'profile': 'http://somesite.com/profile1', 'account': 61L}, > >     {'profile': 'http://s

Re: del an imported Class at EOF... why?

2009-10-06 Thread alex23
Steven D'Aprano wrote: > import alienmodule > > class MyClass(alienmodule.AlienClass): >     do_stuff() > > rather than: > > from alienmodule import AlienClass > > class MyClass(AlienClass): >     do_stuff() > > del AlienClass The original developer may also have been unaware of the ability to li

Re: Is there a way to specify a superclass at runtime?

2009-10-06 Thread Rhodri James
On Mon, 05 Oct 2009 14:49:42 +0100, Chris Colbert wrote: I dont think so, because that would require logic outside of the controller class to determine which controller to instantiate. My whole purpose for Controller is to encapsulate this logic. So, if the data should be simulated, then i

ANN: ActivePython 2.6.3.7 (and PyPM) is now available

2009-10-06 Thread Sridhar Ratnakumar
I'm happy to announce that ActivePython 2.6.3.7 is now available for download from: http://www.activestate.com/activepython/ This is a patch-level release that updates ActivePython to core Python 2.6.3 along with the fixes for a couple of critical regressions that instigated the work on 2.6.

Re: bug with itertools.groupby?

2009-10-06 Thread Raymond Hettinger
On Oct 6, 4:06 pm, Kitlbast wrote: > Hi there, > > the code below on Python 2.5.2: > > from itertools import groupby > > info_list = [ >     {'profile': 'http://somesite.com/profile1', 'account': 61L}, >     {'profile': 'http://somesite.com/profile2', 'account': 64L}, >     {'profile': 'http://som

Re: package import dangers

2009-10-06 Thread Carl Banks
On Oct 6, 3:56 pm, Steven D'Aprano wrote: > On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > > The most common problem is that a file is used as module and as > > executable at the same time. > > > Like this: > > > --- test.py --- > > > class Foo(object): > >     pass > > > if __name_

Re: bug with itertools.groupby?

2009-10-06 Thread Kitlbast
Thanks guys! Miss sorting when reading docs.. ( However, I just create simple "groupby": def groupby(_list, key_func): res = {} for i in _list: k = key_func(i) if k not in res: res[k] = [i] else: res[k].append(i) return res and it work

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 12:28:00 -0700, Raymond Hettinger wrote: > [bearophile] >> I love the 'key', it makes my code simpler and it's simpler to >> understand. I am not opposed to the idea of keeping cmp, that in some >> rare cases may be useful or more natural. >> >> The problem is that if you allow

Re: creating class objects inside methods

2009-10-06 Thread Rhodri James
On Sun, 04 Oct 2009 19:44:48 +0100, horos11 wrote: [somehow managing to trim all other attributions: he's the innermost, then me next] > Thanks for the info, but a couple of points: > 1. it wasn't meant to be production code, simply a way to teach > python. Speaking as someone who does t

Re: bug with itertools.groupby?

2009-10-06 Thread Rhodri James
On Wed, 07 Oct 2009 00:06:43 +0100, Kitlbast wrote: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http:

Re: bug with itertools.groupby?

2009-10-06 Thread Diez B. Roggisch
Kitlbast schrieb: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http://somesite.com/profile3', 'account': 6

bug with itertools.groupby?

2009-10-06 Thread Kitlbast
Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http://somesite.com/profile3', 'account': 61L}, ] grouped_by_a

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > The most common problem is that a file is used as module and as > executable at the same time. > > Like this: > > --- test.py --- > > class Foo(object): > pass > > > if __name__ == "__main__": >import test >assert Foo i

Re: del an imported Class at EOF... why?

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 10:56:26 -0700, Ryan wrote: > Good day all! > > I've just inherited a large amount of python code. After spending some > time pour through the code, I've noticed that the original developer > (who is no longer w/ the company) constantly deletes the imported > classes at the en

Re: Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread Che M
On Oct 6, 5:31 pm, Robert Kern wrote: > On 2009-10-06 16:16 PM, tcumming...@gmail.com wrote: > > > Any body got any ideas how to do the following... > > > I would like to be able to write an app in python that keeps it's > > persistent data in a sqlite database file. > > > So far so good. The prob

Re: Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread Robert Kern
On 2009-10-06 16:16 PM, tcumming...@gmail.com wrote: Any body got any ideas how to do the following... I would like to be able to write an app in python that keeps it's persistent data in a sqlite database file. So far so good. The problem, is that I need the python app and the sqlite db file t

Combining python and sqlite DB into a single, "executeable".

2009-10-06 Thread tcumming123
Any body got any ideas how to do the following... I would like to be able to write an app in python that keeps it's persistent data in a sqlite database file. So far so good. The problem, is that I need the python app and the sqlite db file to exist in the same disk file. This way the app to acce

Re: del an imported Class at EOF... why?

2009-10-06 Thread Dave Angel
Carl Banks wrote: On Oct 6, 10:56 am, Ryan wrote: Good day all! I've just inherited a large amount of python code. After spending some time pour through the code, I've noticed that the original developer (who is no longer w/ the company) constantly deletes the imported classes at the end of

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Stephen Hansen
> > I really can't quite fathom why you'd want to use something so low-level as >> time.mktime... or just about anything in the time module :) >> > I didn't know anything better, > but (forgive me if I'm wrong) I find mx almost as low-level : > >>> mx.DateTime.strptime('01-01-53',"%d-%m-%y") > > w

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Christian Heimes
Ben Finney wrote: > If you're committed to changing the epoch anyway, I would recommend > using http://en.wikipedia.org/wiki/Astronomical_year_numbering> > (epoch at 4004 BCE) since it is widely used to unify dates referring to > human history. I prefer JDN or MJD (http://en.wikipedia.org/wiki/JDN

Re: Re: unittest.TestCase and functools.partial don't seem to mix

2009-10-06 Thread Joel Smith
Gabriel Genellina wrote: Note that you don't *have* to use partial in this case, as you're building the suite yourself. Just create the TestCase instances manually: suite = unittest.TestSuite([ TestGenericWindow('testit', 'brown'), TestGenericWindow('testit', 'blue'), Test

Re: sftp login without password

2009-10-06 Thread Joshua Kugler
David wrote: > transport.connect(username = username, pkey = mykey) > > I get a "AuthenticationException: Authentication failed." exception. > > > My ~/.ssh/id_rsa is correct because if, at console, I type > > bags...@bagvapp:~$ sftp bags...@192.168.92.129 > Connecting to 192.168.92.129... > sf

Re: Problem Displaying Pics

2009-10-06 Thread Victor Subervi
The code in question is generated automatically from another script. I took your idea of the \r\n\r\n and added triple quoting and now it prints out this: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from login import log

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Stef Mientki
Stephen Hansen wrote: On Mon, Oct 5, 2009 at 4:54 PM, Stef Mientki > wrote: hello, I want to handle datetime vars in a general way, so I use the default time-format, so I can use the standard cinversion procedures. Personally, I love mx.DateTime;

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Bearophile
Paul Rubin: > bearophile: >> I am having a very hard type (despite my implementation, explanations, >> etc) explaining to D programmers why for a flexible general-purpose >> function a key function argument is often better. They in the end have >> added something like that in the std lib, but with

Re: Problem Displaying Pics

2009-10-06 Thread Rami Chowdhury
On Tue, 06 Oct 2009 12:37:17 -0700, Victor Subervi wrote: I remember going round and round on this issue before until I finally got it right. I haven't changed the code. It worked before. I just tried your update and it gave me the same result :( Any other ideas? TIA, V I'm afraid changi

Re: Problem Displaying Pics

2009-10-06 Thread Victor Subervi
I remember going round and round on this issue before until I finally got it right. I haven't changed the code. It worked before. I just tried your update and it gave me the same result :( Any other ideas? TIA, V On Tue, Oct 6, 2009 at 2:24 PM, Rami Chowdhury wrote: > On Tue, 06 Oct 2009 12:19:56

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Paul Rubin
Raymond Hettinger writes: > Once Kernighan and Ritchie put C's qsort() into the food supply, > we were doomed. It was already too late. Knuth vol 3 came out in 1973(?) and its sorting half is mostly about comparison sorting. > FWIW, I think the standard library's unittest module is also a > co

Re: Python: Text file insert to MySQL

2009-10-06 Thread Gerhard Häring
Schedule wrote: > Hello, > > I am currenty using MySQL 5.1 community server and trying to import the > data of the comma delimited text file into the table using python 2.6 > scripts. I have installed Mysqldb 1.2.2. > > follwoing is my script: > [...] >7. > c.execute("INSERT INTO a (fir

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Raymond Hettinger
[bearophile] > I love the 'key', it makes my code simpler and it's simpler to > understand. I am not opposed to the idea of keeping cmp, that in some > rare cases may be useful or more natural. > > The problem is that if you allow to use the cmp, lot of programmers > will use it straight away, not

Re: Problem Displaying Pics

2009-10-06 Thread Rami Chowdhury
On Tue, 06 Oct 2009 12:19:56 -0700, Victor Subervi wrote: Hi; I have the following archaic code that worked just fine for another site. It is called with the following url: http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1 #!/usr/local/bin/python import cgitb; cgitb.enable() import My

Problem Displaying Pics

2009-10-06 Thread Victor Subervi
Hi; I have the following archaic code that worked just fine for another site. It is called with the following url: http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1 #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from lo

Re: regex (?!..) problem

2009-10-06 Thread Hans Mulder
Stefan Behnel wrote: Wolfgang Rohdewald wrote: I want to match a string only if a word (C1 in this example) appears at most once in it. def match(s): if s.count("C1") > 1: return None return s If this doesn't fit your requirements, you may want to provide some

Re: Problem with subprocess module on Windows with open file in append mode

2009-10-06 Thread Gabriel Genellina
En Tue, 06 Oct 2009 11:24:23 -0300, MRAB escribió: Gabriel Genellina wrote: En Sat, 03 Oct 2009 21:53:12 -0300, Andrew Savige escribió: When I run this little test program on Linux: import subprocess subprocess.call(["python","-V"], stderr=open("log.tmp","a")) the file log.tmp is appe

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Paul Rubin
Bearophile writes: > The problem is that if you allow to use the cmp, lot of programmers > will use it straight away, not even bothering to know what that > strange 'key' argument may be useful for. And they miss the how much > handy 'key' is. Given how often we hear "consenting adults" as justif

Python: Text file insert to MySQL

2009-10-06 Thread Schedule
Hello, I am currenty using MySQL 5.1 community server and trying to import the data of the comma delimited text file into the table using python 2.6 scripts. I have installed Mysqldb 1.2.2. follwoing is my script: 1. import MySQLdb, csv, sys 2. conn = MySQLdb.connect (host = "localhost"

Re: Strange performance issue

2009-10-06 Thread Dan Stromberg
Ulrich Eckhardt wrote: Dan Stromberg wrote: My new version formats an SD card and preallocates some file space in about 3 minutes with "Optimize Performance" selected, and in about 30 minutes with "Optimize for Quick Removal" selected. Needless to say, I don't like the 27 minute penalty much

Re: del an imported Class at EOF... why?

2009-10-06 Thread Carl Banks
On Oct 6, 10:56 am, Ryan wrote: > Good day all! > > I've just inherited a large amount of python code. After spending some > time pour through the code, I've noticed that the original developer > (who is no longer w/ the company) constantly deletes the imported > classes at the end of the .py file

Re: Why is this slower?

2009-10-06 Thread Paul Rubin
Joseph Reagle writes: > inSRC = set([bio.name for bio in bios.values()]) You should use: inSRC = set(bio.name for bio in bios.values()) without the square brackets. That avoids creating an intermediate list. -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange performance issue

2009-10-06 Thread Dan Stromberg
Steven D'Aprano wrote: On Mon, 05 Oct 2009 22:31:05 -0700, Dan Stromberg wrote: I'm rewriting 3 programs as one program - from Python with Tkinter to Python with pygtk, both on Windows XP. My new version formats an SD card and preallocates some file space in about 3 minutes with "Optimize P

Re: module path?

2009-10-06 Thread Christian Heimes
Dave Angel wrote: > The property is called __file__ > > So in this case,filename = settings.__file__ Actually it's an attribute set by Python's import machine. Since the __file__ attribute may contain a relative path it's a good idea to use os.path.abspath(__file__). Christian -- http://ma

del an imported Class at EOF... why?

2009-10-06 Thread Ryan
Good day all! I've just inherited a large amount of python code. After spending some time pour through the code, I've noticed that the original developer (who is no longer w/ the company) constantly deletes the imported classes at the end of the .py file. Why would one want to do such a thing? Ry

Re: Why is this slower?

2009-10-06 Thread Joseph Reagle
nn wrote: > Not only are you doing many function calls but you are assigning 12 > objects each time. Why not do this? > > for bio in bios.values(): > inSRC.add(bio) That obviously makes sense, but I was trying to get away from the verbosity of: inSRC = set([]) inSRC = set([])

Re: module path?

2009-10-06 Thread Aahz
In article <0d6b75ee-37ab-4106-8dd0-ff7a1a995...@a7g2000yqo.googlegroups.com>, akonsu wrote: > >thanks! i did not know about dir() method. dir() is a function, not a method. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "Normal is what cuts off your sixth

Re: package import dangers

2009-10-06 Thread Diez B. Roggisch
Ethan Furman wrote: > Greetings! > > I'm working on a package with multiple modules (and possibly packages), > and I would like to do it correctly. :) > > I have read of references to possible issues regarding a module being > imported (and run) more than once, but I haven't been able to find >

package import dangers

2009-10-06 Thread Ethan Furman
Greetings! I'm working on a package with multiple modules (and possibly packages), and I would like to do it correctly. :) I have read of references to possible issues regarding a module being imported (and run) more than once, but I haven't been able to find actual examples of such failing

ANN: GUI2Exe 0.4.0

2009-10-06 Thread Andrea Gavana
Hi All, I am happy to announce a new release of GUI2Exe (0.4.0). What is it? = GUI2Exe is my first attempt to unify all the available "executable builders" for Python in a single and simple to use graphical user interface. At the moment the supported executable builders are: -

Re: Storing a C pointer in a Python class instance

2009-10-06 Thread lallous
"Carl Banks" wrote in message news:d50bba1e-b272-4e39-8a58-377531278...@z4g2000prh.googlegroups.com... On Sep 30, 5:24 am, "lallous" wrote: Hello After using the PyCObject, I cannot pickle the class anymore. Any simple solution to this problem? (or resorting to __reduce__ is the only soluti

Re: PIL : How to write array to image ???

2009-10-06 Thread Scott David Daniels
Mart. wrote: On Oct 5, 5:14 pm, Martin wrote: On Oct 4, 10:16 pm, "Mart." wrote: On Oct 4, 9:47 am, Martin wrote: On Oct 3, 11:56 pm, Peter Otten <__pete...@web.de> wrote: Martin wrote: Dear group I'm trying to use PIL to write an array (a NumPy array to be exact) to an image. Peace

Re: Object Relational Mappers are evil (a meditation)

2009-10-06 Thread Simon Forman
On Tue, Oct 6, 2009 at 2:00 AM, Carl Banks wrote: > On Oct 5, 7:25 am, Aaron Watters wrote: >> This is a bit off topic except that many Python >> programmers seem to be allergic to typing SQL. >> >> RESOLVED:  Using ORMs leads lazy programmers >> to make bad database designs.  It's better to >> c

Re: Module inspect Bug

2009-10-06 Thread Tomas Zulberti
On Oct 6, 1:36 am, "Gabriel Genellina" wrote: > En Mon, 05 Oct 2009 11:59:01 -0300, Tomas Zulberti   > escribió: > > > Hi. I have a class that extends collections.MutableMapping. I am > > checking if it is abstract, using the moduleinspect. But isabstract > > returns a number different from zero

Re: Problem with subprocess module on Windows with open file in append mode

2009-10-06 Thread MRAB
Gabriel Genellina wrote: En Sat, 03 Oct 2009 21:53:12 -0300, Andrew Savige escribió: When I run this little test program on Linux: import subprocess subprocess.call(["python","-V"], stderr=open("log.tmp","a")) the file log.tmp is appended to each time I run it. When I run it on Windows, how

Re: 'Once' properties.

2009-10-06 Thread Scott David Daniels
Scott David Daniels wrote: ... Look into metaclasses: ... class Initialized(ClassBase): @classmethod def _init_class(class_): class_.a, class_.b = 1, 2 super(Initialized, class_)._init_class() Mea culpa: Here super is _not_ a good idea, and I had t

Re: Q: sort's key and cmp parameters

2009-10-06 Thread Bearophile
Raymond Hettinger: > Psychologically, the thing that I find to be interesting is > that beginners and intermediate users seem to take to key > functions more readily than old timers.  The key function seems > to be an easy thing to teach (perhaps because that's the > way Excel sorts and the way SQ

Re: unittest.TestCase and functools.partial don't seem to mix

2009-10-06 Thread Gabriel Genellina
En Mon, 05 Oct 2009 23:12:02 -0300, Joel Smith escribió: I want to make some test case classes that can have some data passed in to modify the way they behave. I can't see a straightforward manner to pass data to an __init__() method of a class derived from unittest.TestCase, or to pass

Re: Strange performance issue

2009-10-06 Thread Ulrich Eckhardt
Dan Stromberg wrote: > My new version formats an SD card and preallocates some file space in > about 3 minutes with "Optimize Performance" selected, and in about 30 > minutes with "Optimize for Quick Removal" selected. Needless to say, I > don't like the 27 minute penalty much. For performance, t

Re: WMI remote call in python script to create process on remote windows computer

2009-10-06 Thread Dave Angel
davidj411 wrote: import win32com.client computer = "server" strUser = "server\user_name" strPassword ="my_password" objSWbemLocator = win32com.client.Dispatch ("WbemScripting.SWbemLocator") objSWbemServices = objSWbemLocator.ConnectServer(computer, "root \cimv2",strUser,strPassword) objCreateProc

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread Gabriel Genellina
En Mon, 05 Oct 2009 18:15:15 -0300, Rami Chowdhury escribió: On Mon, 05 Oct 2009 13:46:09 -0700, Buck wrote: Thanks. I think we're getting closer to the core of this. To restate my problem more simply: My core goal is to have my scripts in some sort of organization better than a single d

Re: Is there a way to specify a superclass at runtime?

2009-10-06 Thread Mick Krippendorf
Chris Colbert schrieb: > > SIMULATION = False > > class SimController(object): > "do sim stuff here" > > class RealController(object): > " do real stuff here" > > class Controller(SuperKlass): > pass > > > so if SIMULATION == False I want to be able to instance a Controller > obje

Re: Object Relational Mappers are evil (a meditation)

2009-10-06 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : Aaron Watters schrieb: (snip) FOR EXAMPLE: Consider blogging. The most successful blog software is WORDPRESS. Here is the WordPress data model: http://blog.kapish.co.in/wp-content/uploads/2009/03/wp_2.7.png (snip) Now let's look at the Sakai Blogger tool data mo

Re: Object Relational Mappers are evil (a meditation)

2009-10-06 Thread Bruno Desthuilliers
Carl Banks a écrit : On Oct 5, 7:25 am, Aaron Watters wrote: This is a bit off topic except that many Python programmers seem to be allergic to typing SQL. RESOLVED: Using ORMs leads lazy programmers to make bad database designs. It's better to carefully design your database with no invisibl

Re: epydoc - can I provide multiple dirs to parse

2009-10-06 Thread Jean-Michel Pichavant
Montaseri wrote: Thank you It looks like it is possible to feed multiple dirs, Also, can you explain the --inheritance=STYLE for me. What does the author mean by values like "grouped", "listed", "included" I could not find any good document explaining these... Thanks Medi Sorry, I don't reme

Re: unicode issue

2009-10-06 Thread Gabriel Genellina
En Thu, 01 Oct 2009 12:10:58 -0300, Walter Dörwald escribió: On 01.10.09 16:09, Hyuga wrote: On Sep 30, 3:34 am, gentlestone wrote: _MAP = { # LATIN u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'A', u'Å': 'A', u'Æ': 'AE', u'Ç':'C', [...long table...] } def downcode(name):

Re: Skeletal animation

2009-10-06 Thread Tim Wintle
On Mon, 2009-10-05 at 18:36 +0200, Donn wrote: > see: http://www.panda3d.org/wiki/index.php/Attaching_an_Object_to_a_Joint +1 for Panda 3d. Their Node graph is very intuitive for animating joints, and Panda's API is very nice and clean. TimW -- http://mail.python.org/mailman/listinfo/python-li

Re: WMI remote call in python script to create process on remote windows computer

2009-10-06 Thread Tim Golden
davidj411 wrote: import win32com.client computer = "server" strUser = "server\user_name" strPassword ="my_password" objSWbemLocator = win32com.client.Dispatch ("WbemScripting.SWbemLocator") objSWbemServices = objSWbemLocator.ConnectServer(computer, "root \cimv2",strUser,strPassword) objCreateProc

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Ben Finney
Ben Finney writes: > There are many epochs that have been used in computing > http://en.wikipedia.org/wiki/Epoch_(reference_date)#Notable_epoch_dates_in_computing>, > all of which have their problems. Switching from the Unix epoch to some > other involves data conversion, and (as you point out) r

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Ben Finney
Stef Mientki writes: > I'ld expect times before 1-1-1970, simply to become negative numbers > (I'm interested in the age of living people, so that would suffice). > > Is there a general solution, (other library) or would it be better to > handle all dates in the Delphi format (number of days sinc

Why is this slower?

2009-10-06 Thread Joseph Reagle
I would think the commented code would be faster (fewer loops), but it is not (because of function calls). #Average user_time = 5.9975 over 4 iterations inSRC = set([bio.name for bio in bios.values()]) inEB = set([bio.name for bio in bios.values() if bio.eb_title]) inWP = set([bio

Re: Enormous Input and Output Test

2009-10-06 Thread n00m
What happened to performance of ver.2.6.2 (vs ver.2.5.x)? https://www.spoj.pl/forum/viewtopic.php?f=20&t=5949 -- http://mail.python.org/mailman/listinfo/python-list

Re: How to sort a list of strings on a substring

2009-10-06 Thread n00m
Here you are: LogList = [\ "inbound tcp office 192.168.0.125 inside 10.1.0.91 88", "inbound tcp office 192.168.0.220 inside 10.1.0.31 2967", "inbound udp lab 172.24.0.110 inside 10.1.0.6 161", "inbound udp office 192.168.0.220 inside 10.1.0.13 53"] LogList.sort(key=lambda x: x[x.

Re: Enormous Input and Output Test

2009-10-06 Thread n00m
> This takes 5 second on my machine using a file with 1,000,000 random... Surely it will fail to pass time limit too -- http://mail.python.org/mailman/listinfo/python-list

Re: Enormous Input and Output Test

2009-10-06 Thread n00m
> 50-80%% of users from the 1st page in ranklist are > super-extra-brilliant #5 there: http://www.spoj.pl/users/tourist/ This 14 y.o. schoolboy won IOI 2009, in this August, and he's about to get into Guiness' book as the youngest winner for all the history of international olympiads on informatic

Re: Why is this slower?

2009-10-06 Thread nn
On Oct 5, 12:46 pm, Joseph Reagle wrote: > I would think the commented code would be faster (fewer loops), but it is > not (because of function calls). > >     #Average user_time = 5.9975 over 4 iterations >     inSRC = set([bio.name for bio in bios.values()]) >     inEB = set([bio.name for bio in

WMI remote call in python script to create process on remote windows computer

2009-10-06 Thread davidj411
import win32com.client computer = "server" strUser = "server\user_name" strPassword ="my_password" objSWbemLocator = win32com.client.Dispatch ("WbemScripting.SWbemLocator") objSWbemServices = objSWbemLocator.ConnectServer(computer, "root \cimv2",strUser,strPassword) objCreateProc = objSWbemServices

unittest.TestCase and functools.partial don't seem to mix

2009-10-06 Thread Joel Smith
Hi List, I want to make some test case classes that can have some data passed in to modify the way they behave. I can't see a straightforward manner to pass data to an __init__() method of a class derived from unittest.TestCase, or to pass data to a test function within that class. Being a C+

Re: Creating class instance from module and class name

2009-10-06 Thread Bruno Desthuilliers
gentlestone a écrit : (snip) one more question - __class__ is the way for getting the classname from the class instance - obj.__class__ is a reference to the class object itself, not it's name. how can I get the module name? module_obj.__name__ And while we're at it: obj.__class__.__modu

Re: Creating class instance from module and class name

2009-10-06 Thread Diez B. Roggisch
Steven D'Aprano schrieb: On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: Suppose I've saved the class name and (don't know how) I've also saved the Class's module (package path or I don't know what's the name for XYZ "from X.Y.Z import ...). How can I construct a new class according to s

Re: Strange performance issue

2009-10-06 Thread Steven D'Aprano
On Mon, 05 Oct 2009 22:31:05 -0700, Dan Stromberg wrote: > I'm rewriting 3 programs as one program - from Python with Tkinter to > Python with pygtk, both on Windows XP. > > My new version formats an SD card and preallocates some file space in > about 3 minutes with "Optimize Performance" selecte

Re: Creating class instance from module and class name

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 00:09:08 -0700, gentlestone wrote: > one more question - __class__ is the way for getting the classname from > the class instance - Not quite. __class__ returns the class object, not the name. Given the class object, you ask for __name__ to get the name it was defined as[1].

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread Processor-Dev1l
On Oct 5, 8:29 pm, Robert Kern wrote: > On 2009-10-05 12:42 PM, Buck wrote: > > > > >> With the package layout, you would just do: > > >>     from parrot.sleeping import sleeping_in_a_bed > >>     from parrot.feeding.eating import eat_cracker > > >> This is really much more straightforward than yo

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-06 Thread Chris Withers
Jack Diederich wrote: It's Xah Lee, he's been trolling this and every other programing language group for over 10 years (preferably all at once). Let it go. I don't suppose there's any chance of just blocking the idiot, is there? Chris -- Simplistix - Content Management, Batch Processing & P

Re: Creating class instance from module and class name

2009-10-06 Thread Chris Rebert
On Tue, Oct 6, 2009 at 12:09 AM, gentlestone wrote: > On 6. Okt, 08:55 h., Steven D'Aprano > wrote: >> On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: >> > Suppose I've saved the class name and (don't know how) I've also saved >> > the Class's module (package path or I don't know what's th

  1   2   >