Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
Re: Some specific exec behavior ?
Gabriel Genellina
1/1/2008 6:59:00 PM
En Tue, 01 Jan 2008 16:39:21 -0200, Stef Mientki <stef.mientki@gmail.com>
escribi�:
> I find 2 strange behaviors in exec-function,
> and I can't find anything in the documentation.
> (Python 2.4.3 Enthought edition)
>
> 1. A function definition may not span more than 1 line, e.g.
> This generates an exception:
> def _func (x,y):
> return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
>
> while this works correct:
> def _func (x,y): return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
>
> 2. an emtpy line at the end also generates an exception
>
> Is this behavior correct ?
> where should I find information about it ?
It's correct; source lines must be separated by '\n' only (NOT '\r\n' as
in a Windows text file) and the last line must end in '\n'.
It's documented, but under the compile() built-in function:
http://docs.python.org/lib/built-in-f...
perhaps the docs for exec
should refer there.
--
Gabriel Genellina
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Some specific exec behavior ?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password