Re: What's The Best Editor for python

2006-03-26 Thread Charles Krug
On 2006-03-26, Andrew Gwozdziewycz [EMAIL PROTECTED] wrote: If you want something that won't get in your way, you should really use /bin/ed. It's probably simpler to use then searching the archives. /bin/ed will also run in cygwin for windows. Can one of you say to me what's the best editor

Want to re-pack() a Frame displaying a collection

2006-03-19 Thread Charles Krug
List, I'd like to do the following with Tkinter's Frame() object: 1. Display a collection of pack()-able objects. Easy. Done. I hold the objects in a dictionary, mostly so that the owning program can refer to them uniformly. 2. Whenever the collection is added to or deleted from, re-pack()

Re: is there a better way?

2006-02-11 Thread Charles Krug
On 2006-02-11, Alex Martelli [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Problem: You have a list of unknown length, such as this: list = [X,X,X,O,O,O,O]. You want to extract all and only the X's. You know the X's are all up front and you know that the item after

Re: Is there any books such as 'effective python' or else about the performance?

2006-02-11 Thread Charles Krug
On 2006-02-11, Kenneth Xie [EMAIL PROTECTED] wrote: att, thx. A lot of the ideas discussed in Effective C++ et al are things that Python does for us already. C++ works at a much lower layer of abstraction and you need to deal explicitly with freestore for any nontrivial class. EC++ is mostly

Re: Another try at Python's selfishness

2006-02-08 Thread Charles Krug
On 2006-02-08, Ben Wilson [EMAIL PROTECTED] wrote: But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie) I will agree to that, as I consider myself still new. _But_, it's a stumbling stone only briefly. Get enough nagging error messages, and you learn and

Re: breadth first search

2006-02-08 Thread Charles Krug
On 2006-02-08, News [EMAIL PROTECTED] wrote: I am new in using Python Anyone know how to implement breadth first search using Python? Can Python create list dynamically, I want to implement a program which will read data from a file and store each line into a list, is this possible? Please

Re: Having Trouble with Scoping Rules

2006-01-31 Thread Charles Krug
On 2006-01-31, Fredrik Lundh [EMAIL PROTECTED] wrote: def ExpensiveObject(): global _expensiveObject if _expensiveObject is None: _expensiveObject = A VERY Expensive object print CREATED VERY EXPENSIVE OBJECT return _expensiveObject

Re: Costly object creation (was : Having Trouble with Scoping Rules)

2006-01-31 Thread Charles Krug
On 2006-01-31, bruno at modulix [EMAIL PROTECTED] wrote: See other answers in this thread for how to solve the UnboundLocalError problem. Now about your *real* problem - which is nothing new -, you may want to read about some known solutions: http://en.wikipedia.org/wiki/Singleton_pattern

Having Trouble with Scoping Rules

2006-01-30 Thread Charles Krug
List: I've a module that's not doing what I expect. My guess is that I don't quite understand the scoping rules the way I should. I have an object that's costly to create. My thought was to create it at the module level like this: # expensive Object Module _expensiveObject = None def

Re: Having Trouble with Scoping Rules

2006-01-30 Thread Charles Krug
On 2006-01-31, Farshid Lashkari [EMAIL PROTECTED] wrote: You need to declare _expensiveObject as global inside your function. Whenever you assign something to a variable that resides in the global scope inside a function, you need to declare it as global at the beginning of the function. So

Re: How do I tell if I'm running in the PyWin interpreter?

2006-01-28 Thread Charles Krug
On 2006-01-28, Peter Otten [EMAIL PROTECTED] wrote: Charles Krug wrote: Is there a way to detect that I'm running the the PyWin interpreter so that I can bypass its raw_input behavior? You could test if pywin_specific_module in sys.modules: # use workaraound Or maybe you can get away

Re: How do I tell if I'm running in the PyWin interpreter?

2006-01-28 Thread Charles Krug
On 2006-01-28, Charles Krug [EMAIL PROTECTED] wrote: On 2006-01-28, Peter Otten [EMAIL PROTECTED] wrote: Charles Krug wrote: Is there a way to detect that I'm running the the PyWin interpreter so that I can bypass its raw_input behavior? You could test if pywin_specific_module

How do I tell if I'm running in the PyWin interpreter?

2006-01-27 Thread Charles Krug
Here's the deal: I've a dead-simple command-line program I'm using to test things that I can't (for various reasons) test in the IDE. Here's a do-nothing subset that shows the idea: # insanely simply command interpreter import Commands import sys myPrompt = '$ ' # Raw Input doesn't QUITE do

Re: How do I tell if I'm running in the PyWin interpreter?

2006-01-27 Thread Charles Krug
On 2006-01-28, Steven D'Aprano [EMAIL PROTECTED] wrote: As the comment says, when I run this under Python Win, I get an (pretty sure) Tkinter interface, not a command line, and I don't get my EOFError when I expect to. When do you expect to get an EOFError? The only way I get an EOFError is

Re: Trying to generate a list of the subclasses of C

2006-01-18 Thread Charles Krug
On 2006-01-16, Alex Martelli [EMAIL PROTECTED] wrote: Charles Krug [EMAIL PROTECTED] wrote: ... I'm trying to create a list of all of C's subclasses: There's a class method for that very purpose: class C(object): pass ... class D(C): pass ... class E(C): pass ... C

Trying to generate a list of the subclasses of C

2006-01-16 Thread Charles Krug
List: I have this: # classC.py class C(object): pass class D(C): pass class E(C): pass def CSubclasses(): for name in dir(): pass I'm trying to create a list of all of C's subclasses: import classC print C aList = [] for name in dir(classC): print name, try: if

Re: File Paramaterized Abstract Factory

2006-01-11 Thread Charles Krug
On 2006-01-11, Fredrik Lundh [EMAIL PROTECTED] wrote: Charles Krug wrote: What I'd like is to do something like this: factoryFile = sys.argv[1] # we assume that argv[1] implements a # correct ThingMaker interface. sys.argv[1] is a string, so I assume that you

File Paramaterized Abstract Factory

2006-01-10 Thread Charles Krug
List: I have an idea for an abstract factory that parameterizes the factory with an input module. The general ideom can be expressed thus: class ThingFactory(object): def CreateThisThing() : return ThisThing() def CreateThatThing() : return ThatThing() def CreateTheOtherThing() :

Re: Python's Performance

2005-10-11 Thread Charles Krug
On Mon, 10 Oct 2005 11:21:18 -0700, Donn Cave [EMAIL PROTECTED] wrote: Iron- Python). is it still an interpreter if it generates machine code? Is what an interpreter? I am not very well acquainted with these technologies, but it sounds like variations on the implementation of an

Re: When someone from Britain speaks, Americans hear a British accent...

2005-10-11 Thread Charles Krug
On Mon, 10 Oct 2005 15:46:34 -0500, Terry Hancock [EMAIL PROTECTED] wrote: On Saturday 08 October 2005 04:35 am, Steve Holden wrote: I must have been working at NASA at the time; they are well known for embiggening prices. Not nearly as much as the DoD, from what I hear. Truthfully, I

Re: Creating a list of Mondays for a year

2005-09-19 Thread Charles Krug
On Mon, 19 Sep 2005 12:10:04 GMT, Chris [EMAIL PROTECTED] wrote: Thanks to everyone for your help! That fit the need perfectly. In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Is there a way to make python create a list of Mondays for a given year? For example, mondays =

Re: How to program efficient pattern searches in a list of float numbers?

2005-09-19 Thread Charles Krug
On 19 Sep 2005 00:02:34 -0700, malv [EMAIL PROTECTED] wrote: Simple case: In this list, how to find all occurences of intervals of n adjacent indexes having at least one list-member with a value between given limits. Visualizing the list as a two-dimensional curve, this is like horizontally

Re: Having trouble importing against PP2E files

2005-07-09 Thread Charles Krug
On Fri, 08 Jul 2005 22:43:55 +0300, Elmo Mäntynen [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Import Error: no module named PP2E.launchmodes However if I copy launchmodes.py into my work directory, it imports successfully. Both Examples above and

Having trouble importing against PP2E files

2005-07-08 Thread Charles Krug
List: I'm trying to use the example files from Programming Python, 2nd Ed. I've copied them into c:\Python24\Examples\PP2E. Launching any of the examples programs by themselves seems to work spiffily. Using regedit, I appended c:\Python24\Examples\PP2E to Pythonpath from the immediate window,

Re: Excellent Site for Developers

2005-06-25 Thread Charles Krug
On Sat, 25 Jun 2005 14:50:48 GMT, Brian [EMAIL PROTECTED] wrote: Do Re Mi chel La Si Do wrote: rather... super troll 100% Agreed. Can anyone say, This looks like spam... Feels like spam... and is about as useful here in the Python forums as spam -- therfore my conclusion is that

Re: Python choice of database

2005-06-21 Thread Charles Krug
On Mon, 20 Jun 2005 23:42:21 -0800, EP [EMAIL PROTECTED] wrote: Oren suggested: How about using the filesystem as a database? For the number of records you describe it may work surprisingly well. A bonus is that the database is easy to manage manually. I tried this for one application

Re: Loop until condition is true

2005-06-21 Thread Charles Krug
On Tue, 21 Jun 2005 12:05:25 +0200, Magnus Lycka [EMAIL PROTECTED] wrote: Remi Villatel wrote: while True: some(code) if final_condition is True: break # # What I don't find so nice is to have to build an infinite loop only to break it. This is a common Python

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-20 Thread Charles Krug
On Mon, 20 Jun 2005 06:36:42 GMT, Ron Adam [EMAIL PROTECTED] wrote: Ron Adam wrote: You might be able to use a dictionary of tuples. call_obj = {(type_obj1,0):obj1a, (type_obj1,0):obj1b, (type_boj2,1):obj2a, (type_obj2,1):obj2b, etc... }

Couple functions I need, assuming they exist?

2005-06-20 Thread Charles Krug
List: First, I'm reading that aString.split() is depreciated. What's the current best practice for this? Or am I mistaking that: myWords = split(aString, aChar) is depreciated but myWords = aString.split(aChgar) is not? Second question, I've written a script that generates a LaTeX source

Re: Couple functions I need, assuming they exist?

2005-06-20 Thread Charles Krug
On 20 Jun 2005 15:51:07 GMT, Duncan Booth [EMAIL PROTECTED] wrote: Peter Hansen wrote: The target of the problems (my daughter) would prefer that the thousands be delimited. Is there a string function that does this? You refer to something like putting a comma between groups of three

Re: performance of Nested for loops

2005-05-20 Thread Charles Krug
On 20 May 2005 15:35:10 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there a better way to code nested for loops as far as performance is concerned. what better way can we write to improve the speed. for example: N=1 for i in range(N): for j in range(N): do_job1

Re: How to detect a double's significant digits

2005-05-05 Thread Charles Krug
On 5 May 2005 10:37:00 -0700, mrstephengross [EMAIL PROTECTED] wrote: Hi all... How can I find out the number of significant digits (to the right of the decimal place, that is) in a double? At least, I *think* that's what I'm asking for. For instance: 0.103 -- 3 0.0103 -- 4 0.00103 -- 5

Has anyone built a file reader for NIST IHEad?

2005-05-04 Thread Charles Krug
List: I'm playing with some image algorithms and one of the examples discusses fingerprint comparison. The NIST has fingerprint sample files for download, in NIST IHead format. Has anyone built a reader for that format? Thanks Charles --

Re: OOP

2005-04-28 Thread Charles Krug
On 28 Apr 2005 10:34:44 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hey yall, I'm new to Python and I love it. Now I can get most of the topics covered with the Python tutorials I've read but the one thats just stumping me is Object Orientation. I can't get the grasp of it. Does anyone

Is there a better interactive plotter then pylab?

2005-04-27 Thread Charles Krug
List: I'm trying to us pylab to see what I'm doing with some DSP algorithms, in case my posts about convolution and ffts weren't giving it away. I've been using pylab's plot function, but I'm finding it a bit cumbersome. It works, but if I switch from the interactive window to the plot window

Re: Is there a better interactive plotter then pylab?

2005-04-27 Thread Charles Krug
On Wed, 27 Apr 2005 20:56:07 -0500, John Hunter [EMAIL PROTECTED] wrote: Charles == Charles Krug [EMAIL PROTECTED] writes: Charles List: I'm trying to us pylab to see what I'm doing with Charles some DSP algorithms, in case my posts about convolution Charles and ffts weren't giving

Pythonic way to do static local variables?

2005-04-25 Thread Charles Krug
I've a function that needs to maintain an ordered sequence between calls. In C or C++, I'd declare the pointer (or collection object) static at the function scope. What's the Pythonic way to do this? Is there a better solution than putting the sequence at module scope? Thanks. --

Re: Pythonic way to do static local variables?

2005-04-25 Thread Charles Krug
On Mon, 25 Apr 2005 21:30:18 -0500, Jaime Wyant [EMAIL PROTECTED] wrote: Well, if you're a c++ programmer, Well, my forte is embedded systems and device controls . . . then you've probably ran into `functors' at one time or another. You can emulate it by making a python object that is

Is there a package with convolution and related methods?

2005-04-21 Thread Charles Krug
List: Is there a Python package with Convolution and related methods? I'm working on modeling some DSP processes in Python. I've rolled one up, but don't feel much like reinventing the wheel, especially if there's already something like Insanely Efficient FFT for Python already. Thanks

How can I verify that a passed argument is an interible collection?

2005-04-21 Thread Charles Krug
List: I'm working on some methods that operate on (mathematical) vectors as in: def Convolution(x, y) Returns a list containing the convolution of vectors x and y Is there any way to determine at runtime that x and y are iterible collections? Do I *coughs* simply *coughs* trap the exception

Re: Is there a package with convolution and related methods?

2005-04-21 Thread Charles Krug
On Thu, 21 Apr 2005 13:13:17 -0400, David M. Cooke [EMAIL PROTECTED] wrote: Charles Krug [EMAIL PROTECTED] writes: List: Is there a Python package with Convolution and related methods? I'm working on modeling some DSP processes in Python. I've rolled one up, but don't feel much like