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

2007-01-04 Thread casevh
Here is my attempt to convert the C code, not written with speed in mind and I was too lazy too time it. :-) from itertools import izip def pi(): result = list() d = 0 e = 0 f = [2000] * 2801 for c in xrange(2800, 0, -14): for b, g in izip(xrange(c, 1,

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

2007-01-04 Thread John Nagle
Diez B. Roggisch wrote: 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

pow() works but sqrt() not!?

2007-01-04 Thread siggi
Hi all, this is a newbie question on : Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 PC with WinXP In http://www.python.org/doc/2.3.5/lib/module-math.html I read: sqrt( x) Return the square root of x. Now the test for module math with function pow():

NYC Python User Group Meeting

2007-01-04 Thread John Clark
Greetings! The next New York City Python Users Group meeting is this Tuesday, Jan. 9th, 6:30pm at at the Millennium Partners office at 666 Fifth Avenue (53rd St. and 5th Ave.) on the 8th Floor. We welcome all those in the NYC area who are interested in Python to attend. However, we need a list of

Re: When argparse will be in the python standard installation

2007-01-04 Thread Martin v. Löwis
Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. It's not necessary that the implementation is retained, only that the interface is preserved.

Re: minidom utf-8 encoding

2007-01-04 Thread Martin v. Löwis
fscked schrieb: 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? Works fine for me: py d = minidom.Document() py r =

Re: pow() works but sqrt() not!?

2007-01-04 Thread tonisk
you forgot to import math module import math math.sqrt(9) 3.0 if you want math functions to your current namespace use: from math import * -- Tõnis On Jan 4, 10:13 am, siggi [EMAIL PROTECTED] wrote: Hi all, this is a newbie question on : Python 2.5 (r25:51908, Sep 19 2006, 09:52:17)

Re: Cannot build 2.5 on FC6 x86

2007-01-04 Thread Martin v. Löwis
Paul Watson schrieb: 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? The only suggestion then is that you (or somebody else) would

Re: question on creating class

2007-01-04 Thread Thomas Heller
wcc schrieb: 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

Re: pow() works but sqrt() not!?

2007-01-04 Thread siggi
Thank you very much, Tõnis!: *** 1 *** you forgot to import math module import math Nope, I did not! But I used sqrt(9), and not math.sqrt(9). The latter works excellent, thank you! From now on, I will use import math and math.fuction() for EVERY mathematical function, even for pow() etc. just

Re: question on creating class

2007-01-04 Thread Jussi Salmela
wcc kirjoitti: 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

Re: where to ask questions related to comtypes?

2007-01-04 Thread Thomas Heller
wcc schrieb: 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)? It seems the python-win32 mailing list is the place where the most COM knowledge is, so that would be most appropriate.

Re: pow() works but sqrt() not!?

2007-01-04 Thread Fredrik Lundh
siggi wrote: What is a namespace and what is the difference between import math and from math import * ? http://preview.tinyurl.com/t4pxq for more on this, *please* read the relevant sections in the tutorial. Python's all about namespaces, and trial and error is not a very good way to

Re: pow() works but sqrt() not!?

2007-01-04 Thread tonisk
if you want math functions to your current namespace use: from math import *What is a namespace and what is the difference between import math and from math import * ? for namespaces read this http://www.network-theory.co.uk/docs/pytut/tut_68.html import math creates new namespace math

Re: array of class

2007-01-04 Thread Bruno Desthuilliers
Podi a écrit : Or more compactly: words = [Word(w) for w in 'this is probably what you want'.split()] print words I didn't want to introduce yet some more confusing stuff !-) Indeed, the for loop is perfectly fine and totally readable. Let's save the confusing stuff to the Perl folks.

Re: pow() works but sqrt() not!?

2007-01-04 Thread siggi
Thank you Tõnis, both for the link and your patient explanation :-) Siggi tonisk [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] if you want math functions to your current namespace use: from math import *What is a namespace and what is the difference between import math

Draw rectangle on a Window DC

2007-01-04 Thread Raymond
Hi: I want to Draw rectangle on Dc when gived a position. Can you teach me? Let me view your code? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: array of class / code optimization

2007-01-04 Thread Bruno Desthuilliers
mm a écrit : Yes, it was the (), equivalent to thiks like new() create new object from class xy. Yeps. In Python there's no 'new' operator. Instead, classes are themselves 'callable' objects, acting as instance factory. It's very handy since it let's you replace a class with a factory

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

2007-01-04 Thread Christophe
[EMAIL PROTECTED] a écrit : Raymond Hettinger: 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:

Re: static object

2007-01-04 Thread Bruno Desthuilliers
Ben Finney a écrit : (snip) The Singleton pattern does what you say here. Implementing a proper Singleton in Python is complicated and hard to understand. Really ? Using __new__ and a class attribute, it doesn't seem so complicated - nor difficult to understand... --

Re: Convert Perl to Python

2007-01-04 Thread itoakya
pyperl - Perl for Python This is a Python extension module that makes it possible to embed Perl interpreter(s) in any Python program. It can be used to invoke arbitrary Perl code, load any Perl modules and make calls directly into Perl functions. The Perl code invoked

Re: question on creating class

2007-01-04 Thread Steven D'Aprano
On Wed, 03 Jan 2007 23:27:57 -0800, wcc wrote: Hello, How do I create a class using a variable as the class name? Try a class factory. def create_class(classname): class Klass(object): def __init__(self): print Creating object of %s... % self.__class__.__name__

Re: pow() works but sqrt() not!?

2007-01-04 Thread Fredrik Lundh
siggi wrote: Nope, I did not! But I used sqrt(9), and not math.sqrt(9). The latter works excellent, thank you! From now on, I will use import math and math.fuction() for EVERY mathematical function, even for pow() etc. just to be on the safe side! pow and math.pow are two slightly different

Re: code optimization (calc PI)

2007-01-04 Thread Nick Craig-Wood
mm [EMAIL PROTECTED] wrote: (Yes, I konw whats an object is...) BTW. I did a translation of a pi callculation programm in C to Python. (Do it by your own... ;-) Calc PI for 800 digs(?). (german: Stellen) int a=1,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;

Re: Iterate through list two items at a time

2007-01-04 Thread Wade Leftwich
Wade Leftwich wrote: 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

Re: Iterate through list two items at a time

2007-01-04 Thread Peter Otten
Wade Leftwich wrote: from itertools import groupby def chunk(it, n=0): if n == 0: return iter([it]) def groupfun((x,y)): return int(x/n) grouped = groupby(enumerate(it), groupfun) counted = (y for (x,y) in grouped) return ((z for (y,z) in x) for x in

Extending Embedded Python and execute external script

2007-01-04 Thread Vertilka
What i need from my C application to do ? 1) To execute a python script from file. 2) The python script will call functions in my C application. According to the answer from Ravi Teja (topic C app and Python), I need to extend embedded python in my C application. I saw several functions:

Re: Extending Embedded Python and execute external script

2007-01-04 Thread Fredrik Lundh
Vertilka [EMAIL PROTECTED] wrote: I saw several functions: PyRun_AnyFileExFlags, PyRun_SimpleFileExFlags, PyRun_FileExFlags. Questions: 1) Which one should i use in order to achieve what i need ? PyRun_SimpleFile or PyRun_SimpleString should be good enough. Using SimpleString is more

Re: pow() works but sqrt() not!?

2007-01-04 Thread siggi
Thanks for the explanation. I am astonished what an interpreted language is able to do! Fredrik Lundh [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] siggi wrote: Nope, I did not! But I used sqrt(9), and not math.sqrt(9). The latter works excellent, thank you! From now on,

Re: Iterate through list two items at a time

2007-01-04 Thread Wade Leftwich
Peter Otten wrote: Wade Leftwich wrote: from itertools import groupby def chunk(it, n=0): if n == 0: return iter([it]) def groupfun((x,y)): return int(x/n) grouped = groupby(enumerate(it), groupfun) counted = (y for (x,y) in grouped) return

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

2007-01-04 Thread Piet van Oostrum
Sebastian 'lunar' Wiesner [EMAIL PROTECTED] (SW) wrote: SW I don't see a problem with SUID on scripts. If you restrict write access SW to the owner, modification is hardly possible. SW However, if you allow world-wide write access to your binaries and SW scripts, both can easily be modified...

Re: pow() works but sqrt() not!?

2007-01-04 Thread Boris Borcic
siggi wrote: Hi all, this is a newbie question on : Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 PC with WinXP In http://www.python.org/doc/2.3.5/lib/module-math.html I read: sqrt( x) Return the square root of x. Now the test for module math

Best way to implement a timed queue?

2007-01-04 Thread Thomas Ploch
Hello folks, I am having troubles with implementing a timed queue. I am using the 'Queue' module to manage several queues. But I want a timed access, i.e. only 2 fetches per second max. I am horribly stuck on even how I actually could write it. Has somebody done that before? And when yes, how is

connection hangs

2007-01-04 Thread jeff . dyke
I am using ftplib in some code that does exactly what you would expect. It ftp's files. Its running inside a service running on windows xp and windows 2003 servers, approximately 20 installations each installation sends between 100 and 1000 files per day. Occasionally the process will hang

Packaging up a Python/Twisted Matrix application...

2007-01-04 Thread Chaz Ginger
I have a rather large Python/Twisted Matrix application that will be run on Windows, Linux and perhaps Macs. I was wondering if there are any tools that can be used to create an installer that will bring in Python, Twisted Matrix, my application libraries and anything else I need? I have tried

Re: Packaging up a Python/Twisted Matrix application...

2007-01-04 Thread Felipe Almeida Lessa
On 1/4/07, Chaz Ginger [EMAIL PROTECTED] wrote: I have a rather large Python/Twisted Matrix application that will be run on Windows, Linux and perhaps Macs. I was wondering if there are any tools that can be used to create an installer that will bring in Python, Twisted Matrix, my application

Re: code optimization (calc PI) / New Algorithme for PI

2007-01-04 Thread Michael M.
Mainly, it was fload-div. Changed to int-div (python //) runs faster. Yes, this gmpy sounds good for calc things like that. But not available on my machine. ImportError: No module named gmpy Anyway, thanks for posting. This gmpy module can be very intersting. But right now, the focus was, if

Re: Packaging up a Python/Twisted Matrix application...

2007-01-04 Thread Chris Mellon
On 1/4/07, Chaz Ginger [EMAIL PROTECTED] wrote: I have a rather large Python/Twisted Matrix application that will be run on Windows, Linux and perhaps Macs. I was wondering if there are any tools that can be used to create an installer that will bring in Python, Twisted Matrix, my application

Re: Best way to implement a timed queue?

2007-01-04 Thread Jan Dries
Thomas Ploch wrote: I am having troubles with implementing a timed queue. I am using the 'Queue' module to manage several queues. But I want a timed access, i.e. only 2 fetches per second max. I am horribly stuck on even how I actually could write it. Has somebody done that before? And when

Re: code optimization (calc PI) / New Algorithme for PI

2007-01-04 Thread casevh
Yes, this gmpy sounds good for calc things like that. But not available on my machine. ImportError: No module named gmpy What type of machine? The home page for gmpy is http://sourceforge.net/projects/gmpy/ I have Windows versions available at http://home.comcast.net/~casevh/ casevh --

Re: pow() works but sqrt() not!?

2007-01-04 Thread siggi
Thanks for that, too! Would be interesting to learn how these different algorithms influence the precision of the result!? Boris Borcic [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] siggi wrote: Hi all, this is a newbie question on : Python 2.5 (r25:51908, Sep 19 2006,

Re: code optimization (calc PI) / New Algorithme for PI

2007-01-04 Thread Michael M.
[EMAIL PROTECTED] wrote: Yes, this gmpy sounds good for calc things like that. But not available on my machine. ImportError: No module named gmpy What type of machine? Windoof with Cygwin. The home page for gmpy is http://sourceforge.net/projects/gmpy/ I have Windows versions

Re: Python Wrapper for C# Com Object

2007-01-04 Thread bg_ie
Thomas Heller skrev: [EMAIL PROTECTED] schrieb: [EMAIL PROTECTED] skrev: Hi, I wish to write a Python wrapper for my C# COM object but am unsure where to start. I have a dll and a tlb file, and I can use this object in C via the following code - // ConsolApp.cpp : Defines the

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

2007-01-04 Thread Neil Cerutti
On 2007-01-03, dwelden [EMAIL PROTECTED] wrote: I have successfully used the sort lambda construct described in http://mail.python.org/pipermail/python-list/2006-April/377443.html. However, how do I take it one step further such that some values can be sorted ascending and others descending?

Re: minidom utf-8 encoding

2007-01-04 Thread fscked
Martin v. Löwis wrote: fscked schrieb: 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? Works fine for me: py d =

Using External Libraries with python?

2007-01-04 Thread Ognjen Bezanov
Hello, I have some external C libraries I would like to use with python. I have been searching on the internet and found many such modules/bindings for libraries (e.g. Py-Lame) but have not yet come across any information of how to actually go about creating such bindings, so I was wondering if

Re: Best way to implement a timed queue?

2007-01-04 Thread Bjoern Schliessmann
Thomas Ploch wrote: I am having troubles with implementing a timed queue. I am using the 'Queue' module to manage several queues. But I want a timed access, i.e. only 2 fetches per second max. I am horribly stuck on even how I actually could write it. Has somebody done that before? And when

what is this?

2007-01-04 Thread Eric Price
Hello; I'm studying some code examples from the python cookbook site. I came across this: def colsplit(l, cols): rows = len(l) / cols if len(l) % cols: rows += 1 m = [] for i in range(rows): m.append(l[i::rows]) return m What I'd like to know is what is the double

Re: minidom utf-8 encoding

2007-01-04 Thread Martin v. Löwis
fscked schrieb: Well, let me clarify. If I just print it to the screen/console it works fine, but when I do: out.write( doc.toprettyxml()) it just removes the character that would be the ö. I can post the code if anyone wants to see it, but it is fairly straightforward. I find that

Re: Using External Libraries with python?

2007-01-04 Thread Martin v. Löwis
Ognjen Bezanov schrieb: I have some external C libraries I would like to use with python. I have been searching on the internet and found many such modules/bindings for libraries (e.g. Py-Lame) but have not yet come across any information of how to actually go about creating such bindings,

Re: what is this?

2007-01-04 Thread Huayang Xia
Sequence slicing [starting-at-index : but-less-than-index [ : step]]. Start defaults to 0, end to len(sequence), step to 1. So l[i::rows] means: slicing start from i, ending with len(l) and step with rows. So function colsplit(l, cols) returns a list of sequence with conversion of: Assume cols =

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

2007-01-04 Thread Peter Otten
Neil Cerutti wrote: Another trick is to factor the key application out of the sort. This may be a good idea if when you want to minimize the number of times your key function is called. The idea is to mangle the list temporarily so you can use an unkeyed sort, and then unmangle the sorted

Re: Best way to implement a timed queue?

2007-01-04 Thread Martin v. Löwis
Thomas Ploch schrieb: I am having troubles with implementing a timed queue. I am using the 'Queue' module to manage several queues. But I want a timed access, i.e. only 2 fetches per second max. I am horribly stuck on even how I actually could write it. Has somebody done that before? And when

Why is pow a builtin, anyways?

2007-01-04 Thread Carl Banks
siggi wrote: Now the test for module math with function pow(): --- pow(9,9) 387420489 Fine, but sqrt() fails: --- sqrt(9) I get this error message 'Traceback (most recent call last): File pyshell#3, line 1, in module

Re: minidom utf-8 encoding

2007-01-04 Thread fscked
Martin v. Löwis wrote: ...snip... I find that hard to believe. There is no code in Python that does removal of characters, and I can't see any other reason why it gets removed. OTOH, what I do get when writing to a file is a UnicodeError, when it tries to convert the Unicode string that

Re: question on creating class

2007-01-04 Thread wcc
Thanks for all replies. I'll just to have to figure our which suggested method I should use. To answer Jussi's question, this is why I asked the question. I have the book by Mark: Python Programming on Win32. In Charpter 12: Advanced Python and COM there is a sample code named:

Re: where to ask questions related to comtypes?

2007-01-04 Thread wcc
Thank you Thomas. On Jan 3, 11:10 pm, Thomas Heller [EMAIL PROTECTED] wrote: wcc schrieb: 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)?It seems the python-win32 mailing list is

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

2007-01-04 Thread Neil Cerutti
On 2007-01-04, Peter Otten [EMAIL PROTECTED] wrote: Neil Cerutti wrote: Another trick is to factor the key application out of the sort. This may be a good idea if when you want to minimize the number of times your key function is called. The idea is to mangle the list temporarily so you can

Re: When argparse will be in the python standard installation

2007-01-04 Thread Steven Bethard
Martin v. Löwis wrote: Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. It's not necessary that the implementation is retained, only that the

Re: what is this?

2007-01-04 Thread Paul Watson
Eric Price wrote: Hello; I'm studying some code examples from the python cookbook site. I came across this: def colsplit(l, cols): rows = len(l) / cols if len(l) % cols: rows += 1 m = [] for i in range(rows): m.append(l[i::rows]) return m What I'd like

Re: what is this?

2007-01-04 Thread Paul Watson
Paul Watson wrote: Eric Price wrote: Hello; I'm studying some code examples from the python cookbook site. I came across this: def colsplit(l, cols): rows = len(l) / cols if len(l) % cols: rows += 1 m = [] for i in range(rows): m.append(l[i::rows]) return

Re: Using External Libraries with python?

2007-01-04 Thread Chris Mellon
On 1/4/07, Martin v. Löwis [EMAIL PROTECTED] wrote: Ognjen Bezanov schrieb: I have some external C libraries I would like to use with python. I have been searching on the internet and found many such modules/bindings for libraries (e.g. Py-Lame) but have not yet come across any

Set type?

2007-01-04 Thread _
How do you check to see if a variable is a set? I would like to use if type(var) is types.SetType: blah but that is not available in types module. I am using 2.4 -- http://mail.python.org/mailman/listinfo/python-list

Re: what is this?

2007-01-04 Thread Eric Price
From: Paul Watson [EMAIL PROTECTED] Probably most helpful to you is: http://developer.mozilla.org/es4/proposals/slice_syntax.html Oh, the step. Okay, thanks ;) Eric _ Communicate instantly! Use your Hotmail address to sign into

Re: Set type?

2007-01-04 Thread belinda thom
I've seen people do that using an exception, e.g. try: foo except : #variable foo not defined On Jan 4, 2007, at 10:48 AM, _ wrote: How do you check to see if a variable is a set? I would like to use if type(var) is types.SetType: blah but that is not available in types module.

Re: Set type?

2007-01-04 Thread Robert Kern
_ wrote: How do you check to see if a variable is a set? I would like to use if type(var) is types.SetType: blah but that is not available in types module. I am using 2.4 In [1627]: type(set()) is set Out[1627]: True -- Robert Kern I have come to believe that the whole world is an

Re: Set type?

2007-01-04 Thread Fredrik Lundh
_ wrote: How do you check to see if a variable is a set? I would like to use if type(var) is types.SetType: blah but that is not available in types module. I am using 2.4 # set or subclass of set if isinstance(var, set): ... # exact match if type(var)

Re: Using External Libraries with python?

2007-01-04 Thread Fredrik Lundh
Ognjen Bezanov wrote: I have some external C libraries I would like to use with python. I have been searching on the internet and found many such modules/bindings for libraries (e.g. Py-Lame) but have not yet come across any information of how to actually go about creating such bindings,

Re: Set type?

2007-01-04 Thread Klaas
Fredrik Lundh wrote: if type(var) is types.SetType: blah but that is not available in types module. I am using 2.4 # set or subclass of set if isinstance(var, set): ... or if isinstance(var, (set, frozenset)): ... -Mike --

py2exe setup strange error

2007-01-04 Thread Croteam
Hello, I was trying to install my script (.py) to (.exe) and when I run setup script with cmd I get the error: python mysetup.py py2exe error: COREDLL.dll: No such file or directory Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does Python never add itself to the Windows path?

2007-01-04 Thread robert
Ben Sizer wrote: robert wrote: Ben Sizer wrote: My opinion is that this is not as big a problem as some may feel that it is. Unlike Unix systems, the PATH variable is rarely used. It is a big problem. It is not less than the majority of Python users (at least those who do things on the

Re: A python library to convert RTF into PDF ?

2007-01-04 Thread leonel . gayard
Why not use OO.org to convert DOC to PDF? It does so natively, IIRC. I can't insert variables if the template is a DOC file. This is why we are using RTF. Felipe Almeida Lessa wrote: On 3 Jan 2007 10:52:02 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have tried to convert them to

bug in copy.deepcopy or in getattr or in my understanding?

2007-01-04 Thread Emin
Dear experts, I got some unexpected behavior in getattr and copy.deepcopy (see transcript below). I'm not sure if this is actually a bug in copy.deepcopy or if I'm doing something too magical with getattr. Comments would be appreciated. Thanks, -Emin # Transcript follows

Re: Draw rectangle on a Window DC

2007-01-04 Thread paul
Raymond schrieb: Hi: I want to Draw rectangle on Dc when gived a position. Can you teach me? Let me view your code? Well, you haven't given us much background but I'd suggest if your boss asks you to draw a rectangle on your corporate domain controller and the position allows this, you better

subclassing a module: misleading(?) error message

2007-01-04 Thread Erik Johnson
I ran into a problem I didn't understand at first. I got part of it figured out. Let me first demonstrate the original problem: cat Super.py class Super(object): def __init__(self): self._class = 'Super' def hello(self): print %s says 'Hello' % self._class cat Sub.py

Re: When argparse will be in the python standard installation

2007-01-04 Thread John J. Lee
Steven Bethard [EMAIL PROTECTED] writes: Martin v. Löwis wrote: Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. It's not necessary that

Re: subclassing a module: misleading(?) error message

2007-01-04 Thread Carl Banks
Erik Johnson wrote: My questions are: Why does python complain about a function here? (it's a class definition statement, right?) Because you're calling the function with the wrong number of arguments. Is there really a function being called here? Yes. (Well, it's not exactly a function,

Problem Running Working Code on Mac

2007-01-04 Thread goodepic
I'm newish to python and just got my first mac, so sorry if this is stupid. I have a little app developed by someone else in wxGlade that implements a complex stats package and language package, all in python. It works fine on my work PC, but not on my laptop. I have a new macbook 2ghz core

Re: Problem Running Working Code on Mac

2007-01-04 Thread goodepic
Also, if it makes a difference, the lines quoted in the error message were actually written automatically by wxGlade. -- http://mail.python.org/mailman/listinfo/python-list

Re: subclassing a module: misleading(?) error message

2007-01-04 Thread Huayang Xia
So you know you are subclassing a module. There is an answer @ http://www.velocityreviews.com/forums/showpost.php?p=1819038postcount=2 On Jan 4, 3:49 pm, Erik Johnson ej at somewhere.com wrote: I ran into a problem I didn't understand at first. I got part of it figured out. Let me first

Re: Problem Running Working Code on Mac

2007-01-04 Thread hg
goodepic wrote: I'm newish to python and just got my first mac, so sorry if this is stupid. I have a little app developed by someone else in wxGlade that implements a complex stats package and language package, all in python. It works fine on my work PC, but not on my laptop. I have a new

cache line length of a machine

2007-01-04 Thread John
How do I find out the cache line length of a machine in python? Thanks, --j -- http://mail.python.org/mailman/listinfo/python-list

Re: When argparse will be in the python standard installation

2007-01-04 Thread Steven Bethard
Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. Martin v. Löwis wrote: It's not necessary that the implementation is retained, only that

[ANN] argparse 0.4 - Command-line parsing library

2007-01-04 Thread Steven Bethard
Announcing argparse 0.4 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ New in this

Turn off line wrap for lists?

2007-01-04 Thread _
(I did google for this, I promise) How do I get python NOT to insert newlines into string representations of lists when I do something like this: strCollector += %s % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100) ? I would like to set a default never to do this, if possible. (Never

Re: Turn off line wrap for lists?

2007-01-04 Thread Carsten Haese
On Thu, 2007-01-04 at 17:01 -0800, _ wrote: (I did google for this, I promise) How do I get python NOT to insert newlines into string representations of lists when I do something like this: strCollector += %s % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100) What makes you think

Re: Turn off line wrap for lists?

2007-01-04 Thread Michael Tobis
_ wrote: (I did google for this, I promise) How do I get python NOT to insert newlines into string representations of lists when I do something like this: strCollector += %s % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100) It shouldn't and doesn't insert newlines. ##

Re: minidom utf-8 encoding

2007-01-04 Thread Martin v. Löwis
fscked schrieb: # Create the boxes base element boxes = doc.createElement(boxes) myfile = open('ClientsXMLUpdate.txt') csvreader = csv.reader(myfile) for row in csvreader: mainbox = doc.createElement(box) doc.appendChild(boxes) r2 = csv.reader(myfile) b = r2.next()

Re: pow() works but sqrt() not!?

2007-01-04 Thread Dan Bishop
On Jan 4, 10:00 am, siggi [EMAIL PROTECTED] wrote: Thanks for that, too! Would be interesting to learn how these different algorithms [for pow] influence the precision of the result!? For an integer (i.e., int or long) x and a nonnegative integer y, x**y is exact: 101 ** 12

Re: pow() works but sqrt() not!?

2007-01-04 Thread Gabriel Genellina
At Thursday 4/1/2007 10:12, siggi wrote: Thanks for the explanation. I am astonished what an interpreted language is able to do! Python is as interpreted as Java. Its numerical capabilities are more or less independent of this fact, I'd say. -- Gabriel Genellina Softlab SRL

Re: Draw rectangle on a Window DC

2007-01-04 Thread Gabriel Genellina
At Thursday 4/1/2007 07:07, Raymond wrote: I want to Draw rectangle on Dc when gived a position. Can you teach me? Let me view your code? This is more a Windows question. See http://msdn.microsoft.com/library/en-us/gdi/rectangl_4b03.asp pyfrom win32gui import GetDC pyhdc=GetDC(0) pyfrom

clarification on open file modes

2007-01-04 Thread tubby
Does a py script written to open and read binary files on Windows affect files on a Linux or Mac machine in a negative way? My concern is portability and safety. I want scripts written within Windows to work equally well on Linux and Mac computers. Is this the safest, most portable way to open

What is proper way to require a method to be overridden?

2007-01-04 Thread jeremito
I am writing a class that is intended to be subclassed. What is the proper way to indicate that a sub class must override a method? Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: bug in copy.deepcopy or in getattr or in my understanding?

2007-01-04 Thread Gabriel Genellina
At Thursday 4/1/2007 17:26, Emin wrote: I got some unexpected behavior in getattr and copy.deepcopy (see transcript below). I'm not sure if this is actually a bug in copy.deepcopy or if I'm doing something too magical with getattr. Comments would be appreciated. Both examples are different.

Re: pow() works but sqrt() not!?

2007-01-04 Thread Grant Edwards
On 2007-01-05, Gabriel Genellina [EMAIL PROTECTED] wrote: At Thursday 4/1/2007 10:12, siggi wrote: Thanks for the explanation. I am astonished what an interpreted language is able to do! Python is as interpreted as Java. But it's far more interactive -- at least when compared with my limited

Re: subclassing a module: misleading(?) error message

2007-01-04 Thread Gabriel Genellina
At Thursday 4/1/2007 17:49, Erik Johnson wrote: Python 2.3.4 (#1, Feb 7 2005, 15:50:45) Traceback (most recent call last): File stdin, line 1, in ? File Sub.py, line 4, in ? class Sub(Super): TypeError: function takes at most 2 arguments (3 given) Why does python complain about a

Re: What is proper way to require a method to be overridden?

2007-01-04 Thread Thomas Ploch
jeremito schrieb: I am writing a class that is intended to be subclassed. What is the proper way to indicate that a sub class must override a method? Thanks, Jeremy What do you mean by 'indicate'? Writing it to the docstring of the class/method? Writing a comment? class Foo:

Weekly Python Patch/Bug Summary

2007-01-04 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 418 open ( +5) / 3522 closed ( +1) / 3940 total ( +6) Bugs: 959 open (+13) / 6405 closed ( +5) / 7364 total (+18) RFE : 250 open ( +2) / 245 closed ( -1) / 495 total ( +1) New / Reopened Patches __ update

Re: What is proper way to require a method to be overridden?

2007-01-04 Thread Robert Kern
jeremito wrote: I am writing a class that is intended to be subclassed. What is the proper way to indicate that a sub class must override a method? raise NotImplementedError -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by

Re: clarification on open file modes

2007-01-04 Thread Gabriel Genellina
At Thursday 4/1/2007 23:46, tubby wrote: I understand that doing the following on Windows to a binary file (a jpeg or exe files for example) can cause file corruption, is that correct? fp = open(file_name, 'r') fp.close() How can a simple open in read mode corrupt data??? You can't corrupt

  1   2   >