Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20995

Re: Need to write python source with python

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <crstop@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'perl,': 0.05; '"""': 0.07; 'python': 0.08; '__name__': 0.09; 'to:addr:comp.lang.python': 0.09; 'subject:python': 0.10; "'__main__':": 0.16; '2.7.2': 0.16; 'ast,': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'later': 0.19; 'seems': 0.20; 'programming': 0.20; "haven't": 0.20; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'string': 0.24; "python's": 0.24; 'suspect': 0.24; 'cc:2**0': 0.26; 'code.': 0.26; 'import': 0.27; "i'm": 0.28; 'script': 0.28; 'pass': 0.29; 'class': 0.29; 'example': 0.29; 'cc:addr:python.org': 0.29; 'rarely': 0.30; 'subject:source': 0.30; 'app': 0.31; 'actually': 0.31; 'file.': 0.31; 'there': 0.33; 'header:User-Agent:1': 0.33; 'file': 0.34; 'realize': 0.34; 'skip:# 10': 0.34; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'subject:with': 0.37; 'received:209.85': 0.38; 'could': 0.38; 'that.': 0.39; 'received:209': 0.39; 'from:no real name:2**0': 0.64; 'due': 0.66; 'fit.': 0.67; 'otten': 0.84; 'subject:write': 0.84
Received-SPF pass (google.com: domain of crstop@gmail.com designates 10.68.229.65 as permitted sender) client-ip=10.68.229.65;
Authentication-Results mr.google.com; spf=pass (google.com: domain of crstop@gmail.com designates 10.68.229.65 as permitted sender) smtp.mail=crstop@gmail.com
Newsgroups comp.lang.python
Date Tue, 28 Feb 2012 10:30:24 -0800 (PST)
In-Reply-To <mailman.245.1330451754.3037.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2001:480:10:160:5e26:aff:fe59:9b7d; posting-account=2FdWbgkAAACrRLNFffjv9vTu0_2N97nl
References <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <mailman.245.1330451754.3037.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
MIME-Version 1.0
Subject Re: Need to write python source with python
From crstop@gmail.com
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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>
Message-ID <mailman.250.1330453833.3037.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330453833 news.xs4all.nl 6914 [2001:888:2000:d::a6]:37603
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20995

Show key headers only | View raw


On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote:
> crstop@gmail.com wrote:
> 
> > I'm new to Python but have experience with a few other programming
> > languages(Java, Perl, JavaScript).
> > 
> > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py)
> > a python class and functions from python. I will also need to later read
> > and edit the file. I realize I could just write strings using the
> > available string and file writing methods but suspect there is a better
> > way than that.
> > 
> > I have read about pickle, ast, and Django; searched this group and the web
> > but haven't found a solution that seems to fit. Any suggestion?
> 
> Due to Python's dynamic nature it is rarely necessary to generate Python 
> code. What are you actually trying to achieve?

I'm trying to generate the script file that will launch a PythonCard resource file.

very basic example from the documentation.

    #!/usr/bin/python
    """
    __version__ = "$Revision: 1.10 $"
    __date__ = "$Date: 2004/04/24 22:13:31 $"
    """

    from PythonCard import model
    
    class Minimal(model.Background):
        pass
    
    if __name__ == '__main__':
        app = model.Application(Minimal)
        app.MainLoop() 

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Need to write python source with python crstop@gmail.com - 2012-02-28 09:36 -0800
  Re: Need to write python source with python Peter Otten <__peter__@web.de> - 2012-02-28 18:56 +0100
    Re: Need to write python source with python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-28 10:09 -0800
    Re: Need to write python source with python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-28 10:09 -0800
    Re: Need to write python source with python crstop@gmail.com - 2012-02-28 10:30 -0800
    Re: Need to write python source with python crstop@gmail.com - 2012-02-28 10:30 -0800
      Re: Need to write python source with python Peter Otten <__peter__@web.de> - 2012-02-28 20:25 +0100
        Re: Need to write python source with python crstop@gmail.com - 2012-02-28 11:36 -0800
        Re: Need to write python source with python crstop@gmail.com - 2012-02-28 11:36 -0800

csiph-web