Parsing files in python

2012-12-23 Thread Kene Meniru
Hello: I am writing a program that is made up of a collection of POV-Ray macros. POV-Ray is available at povray.org. It is a ray-tracing program that reads a scene description language (SDL) to create photo-realistic images. At this time my program (for modeling building information) is so huge

Re: Parsing files in python

2012-12-24 Thread Kene Meniru
Chris Angelico wrote: > I'm hoping you meant for that to be public; if not, my apologies for > forwarding a private message. > > On Mon, Dec 24, 2012 at 8:45 PM, Kene Meniru > wrote: >> Chris Angelico wrote: >>> from povray_macros import * >>> >>

Re: Parsing files in python

2012-12-24 Thread Kene Meniru
Chris Angelico wrote: > On Mon, Dec 24, 2012 at 9:32 PM, Kene Meniru > wrote: >> You are saying I can create a python module that can parse this file >> format without using a system like python-ply? I know how to parse >> strings using python but considering that te

Can't seem to start on this

2013-01-02 Thread Kene Meniru
This sounds so simple but being new to python I am finding it hard to get started. I want to create a module which I will call "B". There will be other modules called "C", "D", etc, which will most likely be imported in "B". Then I want the user to import "B" ONLY into another file I will call

Re: Can't seem to start on this

2013-01-02 Thread Kene Meniru
Mitya Sirenef wrote: > > Where is snap_size from? Where is LinearMark from? You don't need to > instantiate LinearMark in B, do it in A. > I want to hide as much of the python syntax from the file "A" so the user just concentrates on using the classes as illustrated. snap_size is a global se

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
Mitya Sirenef wrote: > So, how many instances do you want to make.. what kind of different > functionality / properties they will have? > > - mitya > I am porting a modeling system I created using POV-Ray scene description language available at sourceforge at http://sourceforge.net/project

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
D'Arcy J.M. Cain wrote: > > OK, "global variables" is the clue that you need to rethink this. Try > to stay away from global variables as much as possible except for maybe > some simple setup variables within the same file. Consider something > like this instead. > The global variable is not

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
D'Arcy J.M. Cain wrote: >> As I mentioned, the file "A" can be considered a scene file. I do not > > I don't know what a "scene" file is. > A scene file is applicable to programs like POV-Ray at www.povray.org. It is a file that is used to describe 3D objects such as box, sphere, polygon, etc

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
D'Arcy J.M. Cain wrote: > That works too. It's just that you had users writing Python code but > assumed that a three line subclass was beyond them. Not requiring them > to write any Python code is a better option than the first one (global > variables) that you proposed. That's all I am trying

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
Mitya Sirenef wrote: > > I'm not familiar with POV-Ray. I want to note that with python standard > style, class names look like this: ClassName, instances look like this: > instance_name; it sounds like you want LMark to be an instance? Or you > want instances in A to use class naming style? >

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
Mitya Sirenef wrote: > > Ok but if the user creates two sites, how does he then manipulate them, > if you are not binding instances in A? (e.g. you are not doing site1 = > Site("New Site")). > > If the user only ever needs one site, that's fine. > > -m > There can only be one site for each

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
Mitya Sirenef wrote: > Ok but if the user creates two sites, how does he then manipulate them, > if you are not binding instances in A? (e.g. you are not doing site1 = > Site("New Site")). > > If the user only ever needs one site, that's fine. > > -m In case of situations where the user need

Re: Can't seem to start on this

2013-01-03 Thread Kene Meniru
Mitya Sirenef wrote: > That's what I thought, just wanted to confirm. > > However, if your objective to make it as easy for the user as possible, > is it not easier to bind dining to a name and then do this?: > > dining.move(x, y, z) > Absolutely. I just found that out after replying to your c

python math problem

2013-02-15 Thread Kene Meniru
I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the g

Re: python math problem

2013-02-15 Thread Kene Meniru
Bob Brusa wrote: > Kene, > are you sure your length is 120? It seems to be 25. I did these > calculations with length = 25 and then your numbers make perfect sense. > Bob Thanks. You are right I was actually using 25 -- Kene :: kemen...@gmail.com -- http://mail.python.org/mai

Re: python math problem

2013-02-15 Thread Kene Meniru
Joel Goldstick wrote: > > This is not a string, it is scientific notion for 1.53... times 10 to the > -15th power. Because of rounding errors caused by doing floating point > math on in binary, you get a very small number instead of 0. > I was just doing some testing and it was not equating to

Running external module and accessing the created objects

2013-03-08 Thread Kene Meniru
Program summary: I have a module called user.py that imports another module called app.py. Functions in app.py are used in user.py to describe 3D objects. These objects are saved in another object described in doc.py. app.py contains a function called view(). When called in user.py, it signal

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Steven D'Aprano wrote: > What do you mean, "objects are saved in another object"? > doc.py has a dictionary. When the user describes a wall, it is passed to the doc object to be saved in the dictionary. > > What happens if the user launches appwin with a different argument? > > If appwin c

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
OK. Sorry to have caused all the confusion. Let me try this again. To use my program the user needs a script file I will call user.py. Functions from my program must be imported into this file with something like "from myapp import *". myapp.py is a module in my program that has all the functio

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Dave Angel wrote: > On 03/09/2013 10:34 AM, Kene Meniru wrote: >> To use my program the user needs a script file I will call user.py. >> Functions from my program must be imported into this file with >> something like "from myapp import *". > > And d

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Rick Johnson wrote: > On Saturday, March 9, 2013 9:34:53 AM UTC-6, Kene Meniru wrote: > > Interactive Input > > > Create an interactive environment where

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Dave Angel wrote: >>> >>> So the solution I am looking for is to have a graphic window open that >>> watches user.py for changes. > > It would then have to be a separate executable. This is my thinking too. > Are you really saying > you want this window to keep "running" after the script ends

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Kene Meniru wrote: > Dave Angel wrote: >> If you really want two processes, then you should consider having the >> user run the the graphic app, with a commandline parameter of user.py, >> and have it create the user.py process. The user.py process runs till >> it has

Re: Running external module and accessing the created objects

2013-03-11 Thread Kene Meniru
Here's the answer to this question. The summary of the question: how to run a module (called myapp.py) from another module (called myappwin.py) and be able to access the namespace of myapp.py from myappwin.py. -- # contents of myapp.py import math class

Re: Running external module and accessing the created objects

2013-03-11 Thread Kene Meniru
Dave Angel wrote: > On 03/11/2013 07:57 PM, Kene Meniru wrote: > > I hope you're just kidding. execfile() and exec() are two of the most > dangerous mechanisms around. import or __import__() would be much > better, as long as your user hasn't already run myapp.py a

Re: Running external module and accessing the created objects

2013-03-11 Thread Kene Meniru
Dave Angel wrote: > On 03/11/2013 07:57 PM, Kene Meniru wrote: > > I hope you're just kidding. execfile() and exec() are two of the most > dangerous mechanisms around. import or __import__() would be much > better, as long as your user hasn't already run myapp.py

Re: Running external module and accessing the created objects

2013-03-12 Thread Kene Meniru
Michael Torrie gmail.com> writes: > It's not possible to setuid a python script, so I don't see how execfile > or exec is any more dangerous than the user creating a shell script that > rm -rf * things, and then running it. > > Bash "exec's" scripts all the time that users create and provide. H

Re: Running external module and accessing the created objects

2013-03-12 Thread Kene Meniru
Dave Angel davea.name> writes: > > The __import__() function is defined > http://docs.python.org/2/library/functions.html#__import__ > Thanks. The name of the imported file will change with each user and for each project so according to the this reference using this in my situation makes s

Embed vtk window in a QTabWidget

2013-03-28 Thread Kene Meniru
Hi: I know this may not be the right place to post this but I found some other PyQt questions and I am desperate. My app is the Window class object below and I am trying to embed a QVTKRenderWindowInteractor class called ConeWindow in its QTabWidget. First of all running ConeWindow gives out