[Python.NET] Passing a C# DateTime object to a Python script

"Ian Hannah" <[email protected]> Wed, 30 May 2018 15:52:59 +0100
Newsgroups gmane.comp.python.dotnet
Message-ID <[email protected]>
Hi,

 

I have a simple python script:

 

def test(datetime_or_doy):

                print datetime_or_doy.strftime('%m/%d/%Y')

 

and I am using Python for .NET to try and call this method as follows:

 

dynamic np = Py.Import(@"pvlib");

double d = np.irradiance.test(DateTime.Now);

 

and I get the error:

 

Python.Runtime.PythonException: 'AttributeError : 'DateTime' object has no
attribute 'strftime''

 

Clearly I need to pass a Python datetime object from the C# code but how do
I do that?

 

Thanks

Ian

_________________________________________________
Python.NET mailing list - [email protected]
https://mail.python.org/mailman/listinfo/pythondotnet