help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I am trying to get pyeval to work.


From: Doug Stewart
Subject: Re: I am trying to get pyeval to work.
Date: Tue, 28 May 2019 08:02:41 -0400



On Tue, May 28, 2019 at 1:26 AM Mike Miller <address@hidden> wrote:
On Tue, May 28, 2019 at 00:21:02 -0400, Doug Stewart wrote:
> I am trying to do
> python_cmd('import  smtplib,  ssl')
> and then latter do:
>
> python_cmd('context = ssl.create_default_context()')
> but it says that there is no ssl
>
> error: Python exception: NameError: name 'ssl' is not defined
>     occurred at line 1 of the Python code block:
>     context = ssl.create_default_context()
> error: called from
>     python_cmd at line 179 column 7
>     pythcmds at line 11 column 1
>
> when I do it in python it all works. I was just trying to get it to work
> from octave.
> I tried
> pyexec('import  smtplib,  ssl')
> and this does not work.

The preferred and simplest way to do this would be

    context = py.ssl.create_default_context()

To summarize, there is no need to import anything, just call the fully
qualified py.library.function name.

Btw, the `python_cmd` function is part of the Symbolic package and is
completely unrelated to the Pythonic package (for now).

If you _really_ want to use pyeval and pyexec, this also works

    pyexec('import ssl')
    pyexec('context = ssl.create_default_context()')

or this

    pyexec('import ssl')
    context = pyeval('ssl.create_default_context()')

But I would much prefer people use the fully transparent and Matlab
compatible syntax `context = py.ssl.create_default_context()`.

HTH,

--
mike


Mike:
 On the IRC a person asked if we could send an email from inside of octave. Matlab has a function sendmail.
So I thought about doing it from python. this next code works in python and you can do:
system('python email1a.py')  and this works from inside octave
https://www.dropbox.com/s/35in67pc6lajyne/email1a.py?dl=0

Then I tried to use pyexec  and do it from inside of octave.
This is how far I have gotten  --  I cant get the last 3 lines of email1a.py to work.
any help would be good.

https://www.dropbox.com/s/nzbh1z3cy0biuxf/pythcmds1a.m?dl=0





--
DASCertificate for 206392


reply via email to

[Prev in Thread] Current Thread [Next in Thread]