Re: type classobj not defined?

2007-01-03 Thread Denis Kasak
Wesley Brooks wrote: > Dear Users, > > I'm in the process of adding assert statements to a large piece of > code to aid with bug hunting and came across the following issue; > > Using python in a terminal window you can do the following: > >> type(False) == bool > True > > I would like to check

Re: Unsubscribing from the list

2007-01-03 Thread J. Clifford Dyer
Nice move, using Perl/PHP for that. It's always fun to piss people off by apologizing. ;) Cheers, Cliff Dotan Cohen wrote: > On 03/01/07, Robert Kern <[EMAIL PROTECTED]> wrote: >> He misunderstood you (as I nearly did, too). The way you phrased >> "decided that >> there was no futher interest o

Re: Py_BuildValue or PyList_SetItem()

2007-01-03 Thread Sheldon
Jack Diederich skrev: > On Wed, Jan 03, 2007 at 01:16:38PM -0800, Sheldon wrote: > > I have a function that creates python objects out of C arrays and > > returns them to Python. Below is a working example that I later want to > > expand to return 12 arrays back to Python. The problem is that whe

Re: Iterate through list two items at a time

2007-01-03 Thread J. Clifford Dyer
Gabriel Genellina wrote: > b=iter(a) > for x in b: >y=b.next() >print x,y > So as not to choke on odd-length lists, you could try a = [1,2,3,4,5,6,7] b = iter(a) for x in b: try: y=b.next() except StopIteration: y=None print x,y Substitute in whatever for y

static object

2007-01-03 Thread meelab
Dear All, I am looking for a way to create a "static object" or a "static class" - terms might be inappropriate - having for instance: class StaticClass: . . and then staticObject1 = StaticClass() staticObject2 = StaticClass() so that staticObject1 and staticObject2 refers exactly to th

Re: static object

2007-01-03 Thread bearophileHUGS
That looks like some kind of singleton. Why don't you use a module instead of a class? Another solution is to define your data as class attributes. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: static object

2007-01-03 Thread Thomas Ploch
meelab schrieb: > Dear All, > > I am looking for a way to create a "static object" or a "static class" - > terms might be inappropriate - having for instance: > > class StaticClass: > . > . > > and then > staticObject1 = StaticClass() > staticObject2 = StaticClass() > > so that staticOb

Re: pythoncom module

2007-01-03 Thread Gabriel Genellina
At Friday 29/12/2006 05:55, Scripter47 wrote: I need a module called "pythoncom" anyone that knows where a can find that module??? It's part of the pywin32 package https://sourceforge.net/project/showfiles.php?group_id=78018 -- Gabriel Genellina Softlab SRL

Re: import order or cross import

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 07:56, Duncan Booth wrote: However, you really should try to separate scripts from modules otherwise the double use as both __main__ and a named module is going to come back and bite you. I second this. Something with a __main__ can use (import) other modules, but shoud

Re: static object

2007-01-03 Thread Russell Owen
In article <[EMAIL PROTECTED]>, meelab <[EMAIL PROTECTED]> wrote: > Dear All, > > I am looking for a way to create a "static object" or a "static class" - > terms might be inappropriate - having for instance: > > class StaticClass: > . > . > > and then > staticObject1 = StaticClass() >

Re: Unsubscribing from the list

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 13:21, Dotan Cohen wrote: The first sentance under the heading "Python-list Subscribers" is: The subscribers list is only available to the list administrator. Admin address: Password: As I'm not an admin, I read no further. That page uses the default MailMan administrati

Re: Unsubscribing from the list

2007-01-03 Thread Roel Schroeven
Robert Kern schreef: > Dotan Cohen wrote: >> On 03/01/07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >>> Robert provided *detailed* instructions, which you ignored. I quoted >>> the same instructions in my reply, which you also ignored. the sentence >>> after the one where you stopped reading also

Re: Sorting on multiple values, some ascending, some descending

2007-01-03 Thread dwelden
> The simplest way is to take advantage of sort-stability and do > successive sorts. For example, to sort by a primary key ascending and > a secondary key decending: > >L.sort(key=lambda r: r.secondary, reverse=True) >L.sort(key=lambda r: r.primary) > Excellent! That looks just like what I

Dumping objects into spreadsheet readable text (design question)

2007-01-03 Thread _
Hi Pythonistas and Pythonistos, I am doing some fairly complex statistical analyses and trying to display the output in a form readable to technicians not yet enlightened by the wonders of python (ie they still use either Excel, S-PLUS/R, or Matlab only). I need to dump the results into text such

minidom utf-8 encoding

2007-01-03 Thread fscked
Hi guys/gals. I am trying to write and xml file from data parsed from a csv. I can get everything to work except that I cannot get minidom to do --> ö which needless to say is driving me nuts. Any suggestions? What it ends up doing is just removing the character from the datastream. -- http:/

Re: type classobj not defined?

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 13:57, Wesley Brooks wrote: >type(b) But the following fails: >type(b) == classobj Traceback (most recent call last): File "", line 1, in ? NameError: name 'classobj' is not defined Do you want to test if you got a `b` class, or just for any class? See inspect.iscla

Re: code optimization (calc PI)

2007-01-03 Thread Michael
Yes. But it still runns very slowly. If someone is really interested in speed optimization, I can publish my PI-calc code. Maybe for some Python compiler/interpreter hackers... ;-) (There are only 2 while-loops, one within another, and some simple basic calculations. Nothing special.) Stefan

Re: static object

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 19:38, meelab wrote: I am looking for a way to create a "static object" or a "static class" - terms might be inappropriate - having for instance: class StaticClass: . . and then staticObject1 = StaticClass() staticObject2 = StaticClass() so that staticObject1 and

Re: static object

2007-01-03 Thread Felipe Almeida Lessa
On 1/3/07, meelab <[EMAIL PROTECTED]> wrote: > I am looking for a way to create a "static object" or a "static class" - > terms might be inappropriate - having for instance: An example will speak better than me: class Card(object): __cards = {} def __init__(self, number, suit): s

Re: code optimization (calc PI)

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 12:50, mm wrote: Hmm... it's a question. It was not that easy to translate this [EMAIL PROTECTED] C-Program into readable code and then to Python. But it works. Because that code was written with C in mind, and uses some C subtlecies (uhm, got it right?) obscuring the or

Re: code optimization (calc PI)

2007-01-03 Thread Matimus
> If someone is really interested in speed optimization, I can publish my > PI-calc code. I wouldn't mind seeing it. Chances are you will get much better help if you post your code anyway. -Matt -- http://mail.python.org/mailman/listinfo/python-list

new office formats, REs and Python

2007-01-03 Thread tubby
How are Python users dealing with some of the new OASIS Open Document formats (Open Office) or MS Open XML formats. These formats store data in a file which is actual a zip archive that contains numerous files and folders. For example, a file saved from Open Office 2.0 named 'test.odt' can be u

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread Michael M.
Ok, here is the code. It is a translation of the following code, found on the internet. * The C is very fast, Python not. * Target: Do optimization, that Python runs nearly like C. Auf 800 Stellen in 160 Zeichen... -- int a=1,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5; for

Re: Sorting on multiple values, some ascending, some descending

2007-01-03 Thread bearophileHUGS
dwelden wrote: > >L.sort(key=lambda r: r.secondary, reverse=True) > >L.sort(key=lambda r: r.primary) > Excellent! That looks just like what I needed. Note that there is the (probably little used) operator.attrgetter() too, with that you can avoid the possibly slow lambda: L.sort(key=attrge

Re: static object

2007-01-03 Thread Ben Finney
meelab <[EMAIL PROTECTED]> writes: > In other words, that is a class which would result in only 1 instance > always the same no matter how many times I will "instantiate" it. The "Singleton" pattern does what you say here. Implementing a proper Singleton in Python is complicated and hard to under

Re: C/C++, Perl, etc. to Python converter

2007-01-03 Thread Diez B. Roggisch
> > I think that it *is* possible to do it, but a whole lot of work had to > be done to achieve this. It is all about how many rules (like how to > convert this block of unreadable code of language X into a readable > python block) you are willing to find/program (and these are a lot). It > is a

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread Gabriel Genellina
At Wednesday 3/1/2007 22:10, Michael M. wrote: Ok, here is the code. It is a translation of the following code, found on the internet. * The C is very fast, Python not. * Target: Do optimization, that Python runs nearly like C. Why? Python is strong in other aspects, *not* on computation spee

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread bearophileHUGS
Michael M.: > * The C is very fast, Python not. > * Target: Do optimization, that Python runs nearly like C. Python can't be fast as C for that kind of programs. Note that your original C program gives less digits than the Python program. Your original takes about ~15.2 s on my PC. The following v

Re: How do I add users using Python scripts on a Linux machine

2007-01-03 Thread [EMAIL PROTECTED]
I find that I can often live with a 0-60 sec. pause. and set command in a queue like then have a cron that runs once a min as the user you need to run this on that looks at the queue and sees if there are any pending I often use a sql database for this -- http://mail.python.org/mailman/listinfo

Re: Cannot build 2.5 on FC6 x86

2007-01-03 Thread Paul Watson
Martin v. Löwis wrote: > Paul Watson schrieb: >> ./configure >> make >> make test >> >> The result appears to hang after the test_tkl... line. I had to kill >> the 'make test' process which terminated it. Any suggestions? > > There isn't (or shouldn't be) any "test_tkl..." line. What precisely >

Re: Iterate through list two items at a time

2007-01-03 Thread Wade Leftwich
Jeffrey Froman wrote: > Dave Dean wrote: > > > I'm looking for a way to iterate through a list, two (or more) items at a > > time. > > Here's a solution, from the iterools documentation. It may not be the /most/ > beautiful, but it is short, and scales well for larger groupings: > > >>> from iter

ANN: Urwid 0.9.7.2 - Console UI Library

2007-01-03 Thread Ian Ward
Announcing Urwid 0.9.7.2 Urwid home page: http://excess.org/urwid/ Tarball: http://excess.org/urwid/urwid-0.9.7.2.tar.gz About this release: === This maintenance release significantly improves the performance of Urwid when run in UTF-8 mode. A UT

Re: Cannot build 2.5 on FC6 x86

2007-01-03 Thread Frank Millman
Paul Watson wrote: > Martin v. Löwis wrote: > > Paul Watson schrieb: > >> ./configure > >> make > >> make test > >> > >> The result appears to hang after the test_tkl... line. I had to kill > >> the 'make test' process which terminated it. Any suggestions? > > > > Sorry, I mis-typed. It is not

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread Steven D'Aprano
On Thu, 04 Jan 2007 02:10:44 +0100, Michael M. wrote: > print "\nTiming a 1 million loop 'for loop' ..." > start = time.clock() > for x in range(100): >y = x # do something Why not "pass # do nothing"? > end = time.clock() > print "Time elapsed = ", end - start, "seconds" Are you awar

Re: Unsubscribing from the list

2007-01-03 Thread Dotan Cohen
On 03/01/07, Jan Dries <[EMAIL PROTECTED]> wrote: > Dotan Cohen wrote: > > On 03/01/07, Robert Kern <[EMAIL PROTECTED]> wrote: > >> He misunderstood you (as I nearly did, too). The way you phrased "decided > >> that > >> there was no futher interest on the page for me" is somewhat ambiguous: it >

where to ask questions related to comtypes?

2007-01-03 Thread wcc
Hello group, Is there a separate mailing list for comtypes? Or this is the appropriate place to post questions related to this package(from Thomas Heller)? Thanks, -- wcc -- http://mail.python.org/mailman/listinfo/python-list

Re: new office formats, REs and Python

2007-01-03 Thread Fredrik Lundh
tubby wrote: > How are Python users dealing with some of the new OASIS Open Document > formats (Open Office) or MS Open XML formats. These formats store data > in a file which is actual a zip archive that contains numerous files and > folders. For example, a file saved from Open Office 2.0 name

MI5 Persecution: Counter-surveillance sweep by Nationwide Investigations Group

2007-01-03 Thread MI5Victim
Counter-surveillance sweep by Nationwide Investigations Group In July 1994 the private detective agency Nationwide Investigations Group conducted an electronic counter-surveillance sweep of my parents' home in London. They checked for radio transmitter devices, and tested the telephone line for

question on creating class

2007-01-03 Thread wcc
Hello, How do I create a class using a variable as the class name? For example, in the code below, I'd like replace the line class TestClass(object): with something like class eval(className) (object): Is it possible? Thanks for your help. className = "TestClass" class TestClass(object):

Re: question on creating class

2007-01-03 Thread tonisk
You can always rename your defined clas afterwards class TestClass: pass myClass = TestClass -- Tõnis On Jan 4, 9:27 am, "wcc" <[EMAIL PROTECTED]> wrote: > Hello, > > How do I create a class using a variable as the class name? > > For example, in the code below, I'd like replace the line >

Re: MI5 Persecution: Counter-surveillance sweep by Nationwide Investigations Group

2007-01-03 Thread bryan rasmussen
>As I said above, I don't know very much > about these things, so I can't comment on the capabilities or otherwise of > this equipment. >But clearly the "watchers" are using > technology which in 1994 was beyond the detection capabilities of a good > private detective >agency. > Lisp did that 20

Re: question on creating class

2007-01-03 Thread tonisk
Or if you have required class name in variable, then use: class TestClass: pass globals()[className] = TestClass -- Tõnis On Jan 4, 9:27 am, "wcc" <[EMAIL PROTECTED]> wrote: > Hello, > > How do I create a class using a variable as the class name? > > For example, in the code below, I'd like

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread casevh
Michael M. wrote: > Ok, here is the code. It is a translation of the following code, found > on the internet. > > * The C is very fast, Python not. > * Target: Do optimization, that Python runs nearly like C. There is an error in the translated code. It returns 1600 digits instead of 800 digits.

Re: code optimization (calc PI) / Full Code of PI calc in Python and C.

2007-01-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Michael M. wrote: > * The C is very fast, Python not. > * Target: Do optimization, that Python runs nearly like C. As someone else already asked: Why? You can't beat a compiled to machine code language with an interpreted one when doing integer arithmetic. > counter=c >

<    1   2