Hi Chris,
On Monday 08 April 2013 14:45:40 Chris Nighswonger wrote:
> > However, this code borks:
> > ...
> > __DATA__
> >
> > __Python__
> >
> > def pykota_version():
> > from pykota.version import __version__
> > return __version__
> >
> > The error is:
> > File "<string>", line 3
> >
> > from pykota.version import
> >
> > ^
> >
> > SyntaxError: invalid syntax
Using perl Makefile.PL -debug when building Inline::Python gives a good hint.
With this flag it will print loads of information including Python source code
it compiles to stderr.
This gives us:
py_eval: code:
def pykota_version():
from pykota.version import
py_eval: main_module=0x7fd023985be8
py_eval: globals=0x229aac0
py_eval: type=1
py_eval: context=257
File "<string>", line 3
from pykota.version import
^
SyntaxError: invalid syntax
I've never used DATA file handles in Perl much less with Inline::Python, so
I'm not exactly sure. But the debug output looks like the Python source code
ends at __version__. So I guess, the code reading the DATA file processes
everything from __Python__ to the next marker and treats every word enclosed
in double underscores as such marker.
Indeed, every other way of giving Python source code to Inline::Python seems
to work ok.
Regards,
Stefan