Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35427
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'processed': 0.05; 'that?': 0.05; '------------': 0.07; 'nicely': 0.07; 'parameter': 0.07; 'parser': 0.07; 'parsing': 0.07; 'python': 0.09; 'imported': 0.09; 'macros': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'script,': 0.09; 'subject:files': 0.09; 'suggestions.': 0.09; 'terry': 0.09; 'useless': 0.09; 'subject:python': 0.11; 'language': 0.14; 'file,': 0.15; 'languages.': 0.15; 'conditional': 0.16; 'globals(),': 0.16; 'hello:': 0.16; 'instances,': 0.16; 'locations.': 0.16; 'losing': 0.16; 'macros.': 0.16; 'namespace.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'strength': 0.16; 'variations': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'duplicate': 0.17; 'jan': 0.18; '(or': 0.18; 'appropriate': 0.20; 'define': 0.20; 'parameters': 0.20; 'proposed': 0.20; 'import': 0.21; 'nearly': 0.23; "python's": 0.23; 'random': 0.24; 'tried': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'wondering': 0.26; 'separate': 0.27; 'mix': 0.27; 'interface': 0.27; 'header:X -Complaints-To:1': 0.28; 'actual': 0.28; 'domain.': 0.29; 'factor': 0.29; 'proposing': 0.29; 'words': 0.29; 'class': 0.29; 'this.': 0.29; 'classes': 0.30; 'becomes': 0.30; 'writes': 0.30; 'basic': 0.30; 'expect': 0.31; 'located': 0.31; 'file': 0.32; 'could': 0.32; 'getting': 0.33; 'certain': 0.33; 'instead,': 0.33; 'to:addr:python-list': 0.33; 'knowledge': 0.33; 'know.': 0.33; 'point.': 0.33; 'tutorial': 0.33; 'another': 0.33; 'skip:- 20': 0.34; 'skip:b 20': 0.34; 'text': 0.34; 'along': 0.35; 'needed': 0.35; 'whatever': 0.35; 'mine': 0.35; 'pm,': 0.35; 'received:org': 0.36; 'really': 0.36; 'created': 0.36; 'but': 0.36; 'others.': 0.36; 'should': 0.36; 'does': 0.37; 'why': 0.37; '(for': 0.37; 'passed': 0.37; 'subject:: ': 0.38; 'description': 0.39; 'to:addr:python.org': 0.39; 'called': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'most': 0.61; 'information': 0.63; 'managing': 0.64; 'fun': 0.64; 'become': 0.65; 'legal': 0.65; 'offer': 0.65; 'facilities': 0.69; 'hoping': 0.72; 'calculations': 0.84; 'received:fios.verizon.net': 0.84; 'comment.': 0.91; 'noise': 0.91; 'scene': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Parsing files in python |
| Date | Sun, 23 Dec 2012 20:46:49 -0500 |
| References | <20121223171955.GB32535@ifeobi.illom.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-251-66.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
| In-Reply-To | <20121223171955.GB32535@ifeobi.illom.net> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1232.1356313637.29569.python-list@python.org> (permalink) |
| Lines | 87 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356313637 news.xs4all.nl 6943 [2001:888:2000:d::a6]:34535 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35427 |
Show key headers only | View raw
On 12/23/2012 12:19 PM, Kene Meniru wrote:
> 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 that I am finding it difficult
> managing the macros and I am not even near completion.
>
> I am hoping to move this program to python and am wondering the best
> way to approach this.
>
> I would like to model my program after LaTeX. Basically the user
> writes a text file using certain key words and numbers and my python
> program reads this file, calls the classes that will then work
> together to calculate the information that is needed to create an
> accurate model. The result of this calculation will be an output to
> another text file in the appropriate format such as POV-Ray SDL,
> OpenSCAD script, etc. This file output can then be rendered by the
> corresponding program to produce the actual 3D model. The macros I
> have now currently does this but like I said it is getting tedious
> and most importantly the fun factor is losing its strength for me.
>
> I have been advised to check out python-ply and I have come across
> others. I have not really tried any yet and before I dive into any
> one of them I was wondering what else I should know. The following is
> a sample of what the text file that will be processed by this
> proposed system will contain. I appreciate any pointers and
> suggestions.
Mine is "Don't do that." Seriously. What I understand is that you are
proposing to design and write a parser for yet another Domain Specific
Language -- that will require knowledge to use that is useless outside
the specific domain. I expect that is will come to duplicate the basic
facilities of existing languages. Users will want to be able to
calculate, make conditional calculations and constructions, iterate*,
and define functions (subroutines, macros). Why bother to reinvent all
that? It often becomes a mess. (Or you will offer or people will want to
mix Python with the dsl. That also can become a mess.)
Instead, write a pypovray package incorporating the POV macros, that can
be imported into a python program. Write a tutorial for the specific
parts of Python that users will need.
For instances, someone wants to place duplicate or parameterized models
on a rectangular grid, along an arc, or even at random locations.
> ------------possible user file content for parsing ------------ // in
> the following the python interface program reads //+ the contents of
> the file "other.file" as if its content //+ were located at this
> point.
# this is a python comment. trivial difference from //
> include other.file
import other.file # with Python's variations
# or
exec(open('other.file')) # but it is nearly always better to
# keep the separate namespace. What if a name in other.file
# is the same as used below?
import pypovray as ppr
> //In the following the python interface makes "snap_size" a //+
> global parameter
> declare snap_size = 10
snap_size = 10 # the extra word is just noise
> // In the following "buildingLevel" is a class that is //+ called
> and passed the parameters in parenthesis. buildingLevel("FirstLevel",
> 3000)
>
> // In the following "snapOffset" is a class that is //+ called and
> passed the parameters in parenthesis.
> snapOffset("Closet-S1_r1", "Closet-S2_r3", <0,0,0>)
Already legal Python
# at the end of the file
ppr.run(args)
# Reads globals(), which python has nicely created for you, to create
the master scene description and output whatever is needed for povray.
It could be part of a template.py file you provide.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Parsing files in python Terry Reedy <tjreedy@udel.edu> - 2012-12-23 20:46 -0500
csiph-web