Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2008 11:19:05 -0700, Alex wrote: > Hi all, > > The subject says pretty much all Only to people who know what the Perl BEGIN{} block means. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Open a file with default handler app?

2008-03-12 Thread andrei . avk
On Mar 11, 11:50 pm, [EMAIL PROTECTED] wrote: > > Hey there, > I've had to do the same things for a program that I'm writing. The > following command should do the trick: > > os.startfile("yourfilehere") > > from the os module. Hope this helps! That's perfect, thanks a ton++! -- http://mail.pyth

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Justus Schwabedal
What do you need it for anyway? I just read about it and I think it's useless in python. On Mar 13, 2008, at 1:03 AM, Steven D'Aprano wrote: > On Wed, 12 Mar 2008 11:19:05 -0700, Alex wrote: > >> Hi all, >> >> The subject says pretty much all > > Only to people who know what the Perl BEGIN{} bl

Re: Access function name from within a function

2008-03-12 Thread Steven D'Aprano
On Thu, 13 Mar 2008 00:16:13 +0100, Hellmut Weber wrote: > Hi, > i would liek to define an error routine which print amongs other things > the name of the function from which it has been called. You mean like Python exceptions already do? >>> def broken(): ... x = 100 + 'foo' ... retur

Big file

2008-03-12 Thread Andrew Rekdal
I am working in the class constructor defining elements of an application. The problem is the file is getting unmanageble and I am wanting to extend the contructor __init__ to another file. Is it possible to import directly into the contructor the contents of another module file? If so how wou

Re: image matching algorithms

2008-03-12 Thread Yu-Xi Lim
Daniel Fetchinson wrote: > The photos are just coming straight from my digital camera. Same > format (JPEG), varying size (6-10 megapixel) and I would like to be > able to pick one and then query the database for similar ones. For > example: I pick a photo which is more or less a portrait of someon

Re: Big file

2008-03-12 Thread Simon Forman
On Mar 12, 5:42 pm, "Andrew Rekdal" <[EMAIL PROTECTED]> wrote: > I am working in the class constructor defining elements of an application. > The problem is the file is getting unmanageble and I am wanting to extend the > contructor __init__ to another file. > > Is it possible to import directly

Re: image matching algorithms

2008-03-12 Thread Daniel Fetchinson
> > The photos are just coming straight from my digital camera. Same > > format (JPEG), varying size (6-10 megapixel) and I would like to be > > able to pick one and then query the database for similar ones. For > > example: I pick a photo which is more or less a portrait of someone, > > the query

Re: no more comparisons

2008-03-12 Thread Terry Reedy
| > Hmm, wasn't aware they were taking it that far. You should almost | > always avoid using the cmp parameter because it's very inefficient; | | I don't see what's so inefficient about it necessarily. The key function is called once per list item, for n calls total. The comparision function is

escape string to store in a database?

2008-03-12 Thread andrei . avk
Hi, I'd like to store chunks of text, some of them may be very large, in a database, and have them searchable using 'LIKE %something%' construct. These pieces of text may have single and double quotes in them, I tried escaping them using re module and string module and either I did something wrong,

Re: escape string to store in a database?

2008-03-12 Thread Carsten Haese
On Wed, 2008-03-12 at 18:18 -0700, [EMAIL PROTECTED] wrote: > These pieces of text may have single and double quotes in > them, I tried escaping them using re module and string module and > either I did something wrong, or they escape either single quotes or > double quotes, not both of these. So t

Re: Big file

2008-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2008 19:42:44 -0500, Andrew Rekdal wrote: > I am working in the class constructor defining elements of an > application. The problem is the file is getting unmanageble and I am > wanting to extend the contructor __init__ to another file. > > Is it possible to import directly into t

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Carl Banks
On Mar 12, 8:11 pm, Justus Schwabedal <[EMAIL PROTECTED]> wrote: > What do you need it for anyway? I just read about it and I think it's > useless > in python. Perl, like Python, has a separate compilation and run times. One day, someone who was trying to use Perl for something asked, "You know,

Re: Big file

2008-03-12 Thread hdante
On Mar 12, 9:42 pm, "Andrew Rekdal" <[EMAIL PROTECTED]> wrote: > I am working in the class constructor defining elements of an application. > The problem is the file is getting unmanageble and I am wanting to extend the > contructor __init__ to another file. > > Is it possible to import directly

Re: Big file

2008-03-12 Thread Andrew Rekdal
Well, I can see how this could get real messy but within defining a GUI there are many elements and so the block of elements such as a wx.notebook for instance I would hope I could place all the code for this in another file and somehow include it into place. This way I can work on layered pane

Re: no more comparisons

2008-03-12 Thread Dan Bishop
On Mar 12, 6:52 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > Paul Rubin wrote: > > The cmp option should not be removed. However, requiring > > it to be specified as a keyword parameter instead of just > > passed as an unlabelled arg is fine. > > Sure; I would have no problem with that. > > But tha

Re: app runs fine with interpreter, but not under py2exe

2008-03-12 Thread Doug Morse
Hi Harald and C.L.P., Precision.py is part of the Numeric package. AFAIKT, the problem is during the module initialization. The first lines of Precision.py are: from multiarray import zeros import string typecodes = {'Character':'c', 'Integer':'1sil', 'UnsignedInteger':'bwu', 'Float':'fd', 'Co

Re: macro in python

2008-03-12 Thread Dan Stromberg
On Wed, 27 Feb 2008 16:24:02 +0530, bharath venkatesh wrote: > hi .. > how to create macro in python for set of instruction that is done > frequently but too less in number to ignore the overhead of function > call ... > hi ..    how to create macro in python for set of > instruction that is d

Re: string / split method on ASCII code?

2008-03-12 Thread Steven D'Aprano
Sorry for breaking threading by replying to a reply, but I don't seem to have the original post. On Wed, 2008-03-12 at 15:29 -0500, Michael Wieher wrote: > Hey all, > > I have these annoying textilfes that are delimited by the ASCII char > for << (only its a single character) and >> (again a sin

Re: Creating a file with $SIZE

2008-03-12 Thread [EMAIL PROTECTED]
On Mar 12, 7:37 am, "k.i.n.g." <[EMAIL PROTECTED]> wrote: > We use dd command in Linux to create a file with of required size. If you just want to get your work done, you might consider the cygwin dd command. Learning to write python is a worthwhile endeavour in any case. -- http://mail.python.or

How to port Python code into C++ code automatically?

2008-03-12 Thread Bo
I want to port a Python project (about 10,000 line python code) to C+ +. Is there any automatically tool to do this kind of things? e.g., SWIG(http://www.swig.org/)? Any comment is welcome! Thanks! -- http://mail.python.org/mailman/listinfo/python-list

help please, splitter windows like in maya or 3ds max

2008-03-12 Thread moonrie
hi, everyone there, I am doing a 3D modeling project. I like to do it with Python( am a newbie), but have no idea with the wxSplitterWindow to create the 4-view windows( top, front, side, perspective), like the mfc CSplitterWnd guy), anyone can give me some help with wxPython? thanks in advance.

Re: a Roguelike in Python

2008-03-12 Thread Patrick Mullen
On Wed, Mar 12, 2008 at 9:23 AM, Carl Banks <[EMAIL PROTECTED]> wrote: > Even though it's typically used for graphical games, PyGame would be a > good way to make a cross-platform "text-mode" game. It should be > pretty straightforward to simulate a text mode terminal using a grid > of sprites

Handling global variables (Newbie)

2008-03-12 Thread David S
Hi, I have an error occurring at self.build_root = os.path.abspath(os.path.split(__file__)[0]) The error states 'NameError: global name '__file__' is not defined' In Python 2.5 I ran my script as a module in IDLE gui. How does _file_ get defined? Yours, David -- http://mail.python.

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Jeff Schwab
Alex wrote: > The subject says pretty much all, i would very appreciate an answer. I > tried to search the various forums and groups, but didn't find any > specific answer... I'd like an answer to this, too. In Perl, I mostly used it for one-liners, when a variable needed to be initialized to s

Socket Performance

2008-03-12 Thread sleddd
Can anyone explain why socket performance (throughput) varies depending on the amount of data send and recv are called with? For example: try creating a local client/server (running on the same computer) where the server sends the client a fixed amount of data. Using method A, recv(8192) and senda

Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread Larry
Thanks to all those who replied to this post. I'm gonna try your suggestions. They are a great help. -- http://mail.python.org/mailman/listinfo/python-list

Re: help please, splitter windows like in maya or 3ds max

2008-03-12 Thread "Andrew Rekdal"
This seems to work... split then split each side. then tandem the size. import wx class Layout(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) sizer = wx.BoxSizer(wx.HORIZONTAL) panel = wx.Panel(self,-1) splitter = wx.SplitterWindow(panel)

Class Inheritance

2008-03-12 Thread "Andrew Rekdal"
I am trying to bring functions to a class by inheritance... for instance in layout_ext I have.. --- layout_ext.py- class Layout() def...some function that rely on css in Layout.py def... ---EOF-- in the main application file I have... Layout.py--- from layout_ext import Lay

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Paddy
On Mar 13, 1:37 am, Carl Banks <[EMAIL PROTECTED]> wrote: > On Mar 12, 8:11 pm, Justus Schwabedal <[EMAIL PROTECTED]> > wrote: > > > What do you need it for anyway? I just read about it and I think it's > > useless > > in python. > > Perl, like Python, has a separate compilation and run times. One

Re: How to port Python code into C++ code automatically?

2008-03-12 Thread Paddy
On Mar 13, 3:15 am, Bo <[EMAIL PROTECTED]> wrote: > I want to port a Python project (about 10,000 line python code) to C+ > +. Is there any automatically tool to do this kind of things? e.g., > SWIG(http://www.swig.org/)? > > Any comment is welcome! > > Thanks! There isn't a magic porting tool ava

Generator woes

2008-03-12 Thread Erich
Hi all, I am trying to get the following generator to work to these goals: 1. When it recieves an exception (via a throw()) it yeilds the value of handler.remaining. Otherwise it yeilds None. 2. Send adds data to the generator. Goal 2 is working great. Goal 1 on the other hand, is not working. T

Re: Generator woes

2008-03-12 Thread Erich
On Mar 13, 12:33 am, Erich <[EMAIL PROTECTED]> wrote: > Hi all, > > I am trying to get the following generator to work to these goals: > > 1. When it recieves an exception (via a throw()) it yeilds the value > of handler.remaining. Otherwise it yeilds None. > 2. Send adds data to the generator. > >

Re: Creating a file with $SIZE

2008-03-12 Thread k.i.n.g.
On Mar 13, 8:07 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Mar 12, 7:37 am, "k.i.n.g." <[EMAIL PROTECTED]> wrote:> We use dd command > in Linux to create a file with of required size. > > If you just want to get your work done, you might consider the cygwin > dd command. > Learning t

Re: How to port Python code into C++ code automatically?

2008-03-12 Thread Jeff Schwab
Bo wrote: > I want to port a Python project (about 10,000 line python code) to C+ > +. Is there any automatically tool to do this kind of things? e.g., That's not trivial. Python is very heavily oriented toward run-time processing, whereas C++ favors compile-time processing. > e.g., SWIG(http:/

Re: no more comparisons

2008-03-12 Thread Paul Rubin
"Terry Reedy" <[EMAIL PROTECTED]> writes: > | I don't see what's so inefficient about it necessarily. > > The key function is called once per list item, for n calls total. The > comparision function is called once per comparision. There are at least > n-1 such calls and typically something on

Dispatch("Excel.Application") failed

2008-03-12 Thread lialie
Hi, Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in my env setting? My excel version is 2003. any suggestion? Thanks. Traceback (most recent call last): File "testexcel.py", line 3, in ? excel = Dispatch("Excel.Application") File "C:\Python24\Lib\site-packages\win32com\cli

copying all data(tags and values) after a particular XML tag

2008-03-12 Thread bijeshn
i've an XML file with the following structure . . . . . what i want to do is copy all data(tags and all) between N and N+k appearances of . I am a python newbie. How do I do it? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: a Roguelike in Python

2008-03-12 Thread andrei . avk
On Mar 12, 8:25 am, [EMAIL PROTECTED] wrote: > Seeing the 7DRL start up recently, i wanted to see what one was made > of. Python is the language i'm most familiar with so i searched for > some code to look at, but i couldn't find any. Can anyone direct me to > the right place? > > I did some search

Re: copying all data(tags and values) after a particular XML tag

2008-03-12 Thread Chris
On Mar 13, 8:21 am, [EMAIL PROTECTED] wrote: > i've an XML file with the following structure > > > > > . > . > . > . > . > > > > what i want to do is copy all data(tags and all) between N and N+k > appearances of . I am a python newbie. How do I do it? > > Thanks. You can take a look at t

Re: no more comparisons

2008-03-12 Thread Terry Reedy
"Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message news:[EMAIL PROTECTED] | "Terry Reedy" <[EMAIL PROTECTED]> writes: | > | I don't see what's so inefficient about it necessarily. | > | > The key function is called once per list item, for n calls total. The | > comparision function i

<    1   2