Re: import and package confusion

2009-04-30 Thread Dale Amon
On Thu, Apr 30, 2009 at 08:32:31AM +0200, Jeroen Ruigrok van der Werven wrote: -On [20090430 02:21], Dale Amon (a...@vnl.com) wrote: import sys sys.path.extend (['../lib', '../bin']) from VLMLegacy.CardReader import CardReader rdr = CardReader (../example/B767.dat,PRINTABLE) iotypes

Re: import and package confusion

2009-04-30 Thread Dale Amon
On Thu, Apr 30, 2009 at 02:38:03AM -0400, Dave Angel wrote: As Scott David Daniels says, you have two built-in choices, depending on Python version. If you can use __import__(), then realize that mod = __import__(WINGTL) will do an import, using a string as the import name. I don' t

Re: import and package confusion

2009-04-30 Thread Dale Amon
On Thu, Apr 30, 2009 at 04:33:57AM -0300, Gabriel Genellina wrote: En Thu, 30 Apr 2009 03:04:40 -0300, alex23 wuwe...@gmail.com escribió: Are you familiar with __import__? iotypes = [WINGTL,VLMPC,VLM4997] for iotype in iotypes: packagename = VLMLegacy. + iotype + .Conditions classname

Re: import and package confusion

2009-04-30 Thread Dale Amon
Gabriel gave me the key to a fine solution, so just to put a bow tie on this thread: #!/usr/bin/python import sys sys.path.extend (['../lib', '../bin']) from VLMLegacy.CardReader import CardReader rdr = CardReader (../example/B767.dat,PRINTABLE) iotypes = [WINGTL,VLMPC,VLM4997] for iotype

import and package confusion

2009-04-29 Thread Dale Amon
I am going around in circles right now and have to admit I do not understand what is going on with import of hierarchical packages/modules. Perhaps someone can get me on the road again. Here is a subset of what I am trying to accomplish: The package directory set up: VLMLegacy/

Re: import and package confusion

2009-04-29 Thread Dale Amon
I am trying to get to the heart of what it is I am missing. Is it the case that if you have a module C in a package A: A.C that there is no way to load it such that you can use: x = A.C() in your code? This is just a simpler case of what I'm trying to do now, which has a

Re: import and package confusion

2009-04-29 Thread Dale Amon
On Wed, Apr 29, 2009 at 01:12:33PM -0700, Scott David Daniels wrote: Dale Amon wrote: I am trying to get to the heart of what it is I am missing. Is it the case that if you have a module C in a package A: A.C that there is no way to load it such that you can use: x = A.C() in your

Re: import and package confusion

2009-04-29 Thread Dale Amon
On Wed, Apr 29, 2009 at 04:34:03PM -0400, Dale Amon wrote: type = VLM4997 type.Header(args) type.Plan(args) type.Conditions(args) Where the type might change from execution to execution or even on different iterations. Actually let me make that reflect more

Re: import and package confusion

2009-04-29 Thread Dale Amon
On Wed, Apr 29, 2009 at 03:06:13PM -0700, Scott David Daniels wrote: You did not answer the question above, and I think the answer is the root of your misunderstanding. A class and a module are _not_the_same_thing_. sys is not a package, it is a module. Just because you put a class inside a

Re: import and package confusion

2009-04-29 Thread Dale Amon
Well, I've managed to get close to what I want, and just so you can see: #!/usr/bin/python import sys sys.path.extend (['../lib', '../bin']) from VLMLegacy.CardReader import CardReader rdr = CardReader (../example/B767.dat,PRINTABLE) iotypes = [WINGTL,VLMPC,VLM4997] for iotype in iotypes:

Re: import and package confusion

2009-04-29 Thread Dale Amon
On Wed, Apr 29, 2009 at 04:06:23PM -0700, Scott David Daniels wrote: Dale Amon wrote: The point I take away from this is that packages and modules have dotted names, but Classes do not and there is no way to do exactly what I wanted to do. Nope. You have not been clear with what you

Re: Re: import and package confusion

2009-04-29 Thread Dale Amon
On Wed, Apr 29, 2009 at 10:02:46PM -0400, Dave Angel wrote: The dot syntax works very predictably, and quite flexibly. The problem was that by using the same name for module and class, you didn't realize you needed to include both. It is one of the hazards of working in many very

regexp strangeness

2009-04-09 Thread Dale Amon
This finds nothing: import re import string card = abcdef DEC029 = re.compile([^0-9A-Z/ $*,.\-:#@'=\[(+\^!);\\\]%_?]) errs = DEC029.findall(card.strip(\n\r)) print errs This works correctly: import re import string card = abcdef DEC029 = re.compile([^0-9A-Z/

Computed attribute names

2009-04-08 Thread Dale Amon
There are a number of things which I have been used to doing in other OO languages which I have not yet figured out how to do in Python, the most important of which is passing method names as args and inserting them into method calls. Here are two cases I have been trying to figure out for a

Re: Computed attribute names

2009-04-08 Thread Dale Amon
On Wed, Apr 08, 2009 at 09:03:00PM +0200, paul wrote: I'd say you can use: Thanks. I could hardly ask for a faster response on a HowTo than this! signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Unix programmers and Idle

2009-04-03 Thread Dale Amon
On Mon, Mar 30, 2009 at 10:54:56PM -0700, Niklas Norrthon wrote: I make sure my scripts are on the form: # imports # global initialization (not depending on sys.argv) def main(): # initialization (might depend on sys.argv) # script logic # other functions if __name__ ==

Re: Unix programmers and Idle

2009-04-03 Thread Dale Amon
Just in case anyone else finds it useful, to be precise I use: if opts.man: p1 = Popen([echo, __doc__], stdout=PIPE) p2 = Popen([pod2man], stdin=p1.stdout, stdout=PIPE) p3 = Popen([nroff,-man], stdin=p2.stdout, stdout=PIPE) output =

Unix programmers and Idle

2009-03-30 Thread Dale Amon
I wonder if someone could point me at documentation on how to debug some of the standard Unix type things in Idle. I cannot seem to figure out how to set my argument line for the program I am debugging in an Idle window. for example: vlmdeckcheck.py --strict --debug file.dat There must

Re: Unix programmers and Idle

2009-03-30 Thread Dale Amon
On Mon, Mar 30, 2009 at 08:11:10PM -0500, Dave Angel wrote: I don't know what Idle has to do with it. sys.args contains the command line arguments used to start a script. Dale Amon wrote: I wonder if someone could point me at documentation on how to debug some of the standard Unix type

Re: Unix programmers and Idle

2009-03-30 Thread Dale Amon
On Mon, Mar 30, 2009 at 09:47:24PM -0500, Dave Angel wrote: See http://docs.python.org/library/idle.html and search for command line According to that page (for Python 2.6.1), you can set those parameters on the command line that starts IDLE itself. I haven't tried it yet, as I'm using