Discussion:
[Python.NET] DocStringAttribute Example
Jonno
2014-03-05 15:59:16 UTC
Permalink
Hi,

Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?

I found the following in a thread a while back but it's not working for me:

### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
Tony Roberts
2014-03-07 18:19:51 UTC
Permalink
Hi,

if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the
class a docstring using DocStringAttribute.

I've created an issue for github for this and fixed it:
https://github.com/pythonnet/pythonnet/issues/14

In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).

cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-12 14:33:37 UTC
Permalink
Thanks Tony,

This is probably my ignorance of C# but I get the following error using the
same syntax as the example:

The type or namespace name 'DocStringAttribute' could not be found (are you
missing a using directive or an assembly reference?)

I have the:
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the
class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Tony Roberts
2014-03-12 14:46:28 UTC
Permalink
Hi,

have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.

cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-12 16:59:56 UTC
Permalink
My mistake Tony,

I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-12 19:33:23 UTC
Permalink
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?

I'm not familiar with how to build the pythondotnet source.
Post by Jonno
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an
example for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods
so that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-13 13:57:19 UTC
Permalink
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
the following error:
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Post by Jonno
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
Post by Jonno
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a
look at the Python.Test project that's used by the unit tests if you're not
sure how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an
example for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods
so that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-13 15:20:41 UTC
Permalink
Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather
than c:\Python27\DLLs).

Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.
Post by Jonno
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Post by Jonno
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
Post by Jonno
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a
look at the Python.Test project that's used by the unit tests if you're not
sure how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error
The type or namespace name 'DocStringAttribute' could not be found
(are you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an
example for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes & methods
so that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Tony Roberts
2014-03-13 16:33:10 UTC
Permalink
That's a fairly old version. The project's in a bit of a transition stage
at the moment. If you want to try out the latest version (still in
development) you should get the code from github
https://github.com/pythonnet/pythonnet (use the develop branch) and build
it yourself using the setup.py script, eg:

python setup.py install

As long as you have visual studio 2012 installed that *should* just work...

cheers,
Tony
Post by Jonno
Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather
than c:\Python27\DLLs).
Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.
Post by Jonno
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Post by Jonno
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
Post by Jonno
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a
look at the Python.Test project that's used by the unit tests if you're not
sure how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error
The type or namespace name 'DocStringAttribute' could not be found
(are you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an
example for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes &
methods so that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-13 21:34:45 UTC
Permalink
I'm afraid it didn't work for me.
I got a ton of errors. Many type or namespaces couldn't be found (NUnit +
many more).
Post by Tony Roberts
That's a fairly old version. The project's in a bit of a transition stage
at the moment. If you want to try out the latest version (still in
development) you should get the code from github
https://github.com/pythonnet/pythonnet (use the develop branch) and build
python setup.py install
As long as you have visual studio 2012 installed that *should* just work...
cheers,
Tony
Post by Jonno
Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather
than c:\Python27\DLLs).
Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.
Post by Jonno
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Post by Jonno
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
Post by Jonno
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Post by Tony Roberts
Hi,
have you added the Python.Runtime to your project references? Take a
look at the Python.Test project that's used by the unit tests if you're not
sure how to set up your project.
cheers,
Tony
Post by Jonno
Thanks Tony,
This is probably my ignorance of C# but I get the following error
The type or namespace name 'DocStringAttribute' could not be found
(are you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Post by Tony Roberts
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an
example for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Post by Jonno
Hi,
Is there an example how to format documentation in classes &
methods so that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
David Anthoff
2014-03-13 22:15:21 UTC
Permalink
Hi Jonno,



would be great if you could post the exact output with the errors here, or
even better open an issue with that info here
https://github.com/pythonnet/pythonnet/issues, so that we can fix that.



My suspicion is that this is related to NuGet package restore issues. You
might try to open pythonnet.sln in VS and build it once there (that should
restore the NuGet packages) and then try to run the command Tony mentioned.



Best,

David



From: PythonDotNet
[mailto:pythondotnet-bounces+anthoff=berkeley.edu-+ZN9ApsXKcEdnm+***@public.gmane.org] On Behalf Of
Jonno
Sent: Thursday, March 13, 2014 2:35 PM
To: A list for users and developers of Python for .NET
Subject: Re: [Python.NET] DocStringAttribute Example



I'm afraid it didn't work for me.

I got a ton of errors. Many type or namespaces couldn't be found (NUnit +
many more).



On Thu, Mar 13, 2014 at 11:33 AM, Tony Roberts <tony-***@public.gmane.org
<mailto:tony-***@public.gmane.org> > wrote:

That's a fairly old version. The project's in a bit of a transition stage at
the moment. If you want to try out the latest version (still in development)
you should get the code from github https://github.com/pythonnet/pythonnet
(use the develop branch) and build it yourself using the setup.py script,
eg:



python setup.py install



As long as you have visual studio 2012 installed that *should* just work...



cheers,

Tony





On Thu, Mar 13, 2014 at 3:20 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather than
c:\Python27\DLLs).



Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.



On Thu, Mar 13, 2014 at 8:57 AM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
the following error:

"dynamic module not initialized properly"

I'm on CPython 2.7.5, Win7 32bit.

Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.



On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?


I'm not familiar with how to build the pythondotnet source.



On Wed, Mar 12, 2014 at 11:59 AM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

My mistake Tony,



I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.



On Wed, Mar 12, 2014 at 9:46 AM, Tony Roberts <tony-***@public.gmane.org
<mailto:tony-***@public.gmane.org> > wrote:

Hi,



have you added the Python.Runtime to your project references? Take a look at
the Python.Test project that's used by the unit tests if you're not sure how
to set up your project.



cheers,

Tony



On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Thanks Tony,



This is probably my ignorance of C# but I get the following error using the
same syntax as the example:



The type or namespace name 'DocStringAttribute' could not be found (are you
missing a using directive or an assembly reference?)



I have the:

using Python.Runtime

statement.



On Fri, Mar 7, 2014 at 12:19 PM, Tony Roberts <tony-***@public.gmane.org
<mailto:tony-***@public.gmane.org> > wrote:

Hi,



if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the class
a docstring using DocStringAttribute.



I've created an issue for github for this and fixed it:
https://github.com/pythonnet/pythonnet/issues/14



In the same commit I added some unit tests which should do as an example for
you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).



cheers,

Tony





On Wed, Mar 5, 2014 at 3:59 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Hi,



Is there an example how to format documentation in classes & methods so that
a python docstring will be produced?



I found the following in a thread a while back but it's not working for me:



### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation:
WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}



_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet




_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet




_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet




_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet










_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-15 13:19:13 UTC
Permalink
I'll do both of those David.
Post by David Anthoff
Hi Jonno,
would be great if you could post the exact output with the errors here, or
even better open an issue with that info here
https://github.com/pythonnet/pythonnet/issues, so that we can fix that.
My suspicion is that this is related to NuGet package restore issues. You
might try to open pythonnet.sln in VS and build it once there (that should
restore the NuGet packages) and then try to run the command Tony mentioned.
Best,
David
*From:* PythonDotNet [mailto:pythondotnet-bounces+anthoff=
*Sent:* Thursday, March 13, 2014 2:35 PM
*To:* A list for users and developers of Python for .NET
*Subject:* Re: [Python.NET] DocStringAttribute Example
I'm afraid it didn't work for me.
I got a ton of errors. Many type or namespaces couldn't be found (NUnit +
many more).
That's a fairly old version. The project's in a bit of a transition stage
at the moment. If you want to try out the latest version (still in
development) you should get the code from github
https://github.com/pythonnet/pythonnet (use the develop branch) and build
python setup.py install
As long as you have visual studio 2012 installed that *should* just work...
cheers,
Tony
Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather
than c:\Python27\DLLs).
Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Hi,
have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.
cheers,
Tony
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Hi,
if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the
class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Jonno
2014-03-18 02:44:07 UTC
Permalink
Sorry it took a while but I submitted it as an issue:
https://github.com/pythonnet/pythonnet/issues/24
I got an error when building in VS2012 also.
Post by Jonno
I'll do both of those David.
Post by David Anthoff
Hi Jonno,
would be great if you could post the exact output with the errors here,
or even better open an issue with that info here
https://github.com/pythonnet/pythonnet/issues, so that we can fix that.
My suspicion is that this is related to NuGet package restore issues. You
might try to open pythonnet.sln in VS and build it once there (that should
restore the NuGet packages) and then try to run the command Tony mentioned.
Best,
David
*From:* PythonDotNet [mailto:pythondotnet-bounces+anthoff=
*Sent:* Thursday, March 13, 2014 2:35 PM
*To:* A list for users and developers of Python for .NET
*Subject:* Re: [Python.NET] DocStringAttribute Example
I'm afraid it didn't work for me.
I got a ton of errors. Many type or namespaces couldn't be found (NUnit +
many more).
That's a fairly old version. The project's in a bit of a transition stage
at the moment. If you want to try out the latest version (still in
development) you should get the code from github
https://github.com/pythonnet/pythonnet (use the develop branch) and
python setup.py install
As long as you have visual studio 2012 installed that *should* just work...
cheers,
Tony
Only way I could get this to work is to copy the files: clr.pyd,
nPython.exe, Python.Runtime.dll to the directory c:\Python27 (rather
than c:\Python27\DLLs).
Does anyone know why this would not work? Using sys.path.append() while
keeping the files elsewhere also doesn't work.
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Hi,
have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.
cheers,
Tony
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Hi,
if your class has a constructor then the class docstring will get
replaced with a description of the constructor, even if you explicitly gave
the class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
John Gill
2014-03-13 16:25:57 UTC
Permalink
I occasionally get this error on import of clr. Usually when I have Visual Studio open. Closing VS and retrying has always solved the issue up to now.

John

From: PythonDotNet [mailto:pythondotnet-bounces+jgill=***@python.org] On Behalf Of Jonno
Sent: Thursday, March 13, 2014 10:57 AM
To: A list for users and developers of Python for .NET
Subject: Re: [Python.NET] DocStringAttribute Example

Also when using clr.pyd from pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get the following error:
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5 installed.

On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org<mailto:jonnojohnson-***@public.gmane.org>> wrote:
Is it possible to compile the 2.0 Beta version containing the DocStringAttribute for clr version 2.0 or is there some incompatibility?

I'm not familiar with how to build the pythondotnet source.

On Wed, Mar 12, 2014 at 11:59 AM, Jonno <jonnojohnson-***@public.gmane.org<mailto:jonnojohnson-***@public.gmane.org>> wrote:
My mistake Tony,

I was using the 2.0 CLR version of pythondotnet which doesn't have the DocStringAttribute class.

On Wed, Mar 12, 2014 at 9:46 AM, Tony Roberts <tony-***@public.gmane.org<mailto:***@pyxll.com>> wrote:
Hi,

have you added the Python.Runtime to your project references? Take a look at the Python.Test project that's used by the unit tests if you're not sure how to set up your project.

cheers,
Tony

On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org<mailto:jonnojohnson-***@public.gmane.org>> wrote:
Thanks Tony,

This is probably my ignorance of C# but I get the following error using the same syntax as the example:

The type or namespace name 'DocStringAttribute' could not be found (are you missing a using directive or an assembly reference?)

I have the:
using Python.Runtime
statement.

On Fri, Mar 7, 2014 at 12:19 PM, Tony Roberts <tony-***@public.gmane.org<mailto:***@pyxll.com>> wrote:
Hi,

if your class has a constructor then the class docstring will get replaced with a description of the constructor, even if you explicitly gave the class a docstring using DocStringAttribute.

I've created an issue for github for this and fixed it: https://github.com/pythonnet/pythonnet/issues/14

In the same commit I added some unit tests which should do as an example for you to see how it should work (see the newly added file pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).

cheers,
Tony


On Wed, Mar 5, 2014 at 3:59 PM, Jonno <jonnojohnson-***@public.gmane.org<mailto:jonnojohnson-***@public.gmane.org>> wrote:
Hi,

Is there an example how to format documentation in classes & methods so that a python docstring will be produced?

I found the following in a thread a while back but it's not working for me:


### test.cs ##

using System;

using System.Runtime.InteropServices;

using Python.Runtime;



namespace PinvokeTest

{

[DocStringAttribute("Interface class to external functions.")]

public class Invoke {



[DocStringAttribute("External funtion simulation: WriteToFile(char)

will write a char to the terminal.")]

public static void WriteToFile(char arg) {

Console.WriteLine("Writing {0}", arg);

return;

}

}

}

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org<mailto:***@python.org>
https://mail.python.org/mailman/listinfo/pythondotnet


_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org<mailto:***@python.org>
https://mail.python.org/mailman/listinfo/pythondotnet


_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org<mailto:***@python.org>
https://mail.python.org/mailman/listinfo/pythondotnet


_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org<mailto:***@python.org>
https://mail.python.org/mailman/listinfo/pythondotnet




This communication and any attachments contain information which is confidential and may also be legally privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of disclosure, distribution, copying, printing or use of this communication or the information in it or in any attachments is strictly prohibited and may be unlawful. If you have received this communication in error, please return it with the title "received in error" to ***@tokiomillennium.com and then permanently delete the email and any attachments from your system.

E-mail communications cannot be guaranteed to be secure or error free, as information could be intercepted, corrupted, amended, lost, destroyed, arrive late or incomplete, or contain viruses. It is the recipient's responsibility to ensure that e-mail transmissions and any attachments are virus free. We do not accept liability for any damages or other consequences caused by information that is intercepted, corrupted, amended, lost, destroyed, arrives late or incomplete or contains viruses.
******************************************
Jonno
2014-03-13 21:18:55 UTC
Permalink
I tried with VS2012 closed but it didn't help me.
Post by John Gill
I occasionally get this error on import of clr. Usually when I have
Visual Studio open. Closing VS and retrying has always solved the issue
up to now.
John
*From:* PythonDotNet [mailto:pythondotnet-bounces+jgill=
*Sent:* Thursday, March 13, 2014 10:57 AM
*To:* A list for users and developers of Python for .NET
*Subject:* Re: [Python.NET] DocStringAttribute Example
Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
"dynamic module not initialized properly"
I'm on CPython 2.7.5, Win7 32bit.
Can anyone suggest what might be causing this? I have .NET Framework 4.5 installed.
Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?
I'm not familiar with how to build the pythondotnet source.
My mistake Tony,
I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.
Hi,
have you added the Python.Runtime to your project references? Take a look
at the Python.Test project that's used by the unit tests if you're not sure
how to set up your project.
cheers,
Tony
Thanks Tony,
This is probably my ignorance of C# but I get the following error using
The type or namespace name 'DocStringAttribute' could not be found (are
you missing a using directive or an assembly reference?)
using Python.Runtime
statement.
Hi,
if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the
class a docstring using DocStringAttribute.
https://github.com/pythonnet/pythonnet/issues/14
In the same commit I added some unit tests which should do as an example
for you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).
cheers,
Tony
Hi,
Is there an example how to format documentation in classes & methods so
that a python docstring will be produced?
### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;
namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {
[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
This communication and any attachments contain information which is
confidential and may also be legally privileged. It is for the exclusive
use of the intended recipient(s). If you are not the intended recipient(s)
please note that any form of disclosure, distribution, copying, printing or
use of this communication or the information in it or in any attachments is
strictly prohibited and may be unlawful. If you have received this
communication in error, please return it with the title "received in error"
and any attachments from your system.
E-mail communications cannot be guaranteed to be secure or error free, as
information could be intercepted, corrupted, amended, lost, destroyed,
arrive late or incomplete, or contain viruses. It is the recipient's
responsibility to ensure that e-mail transmissions and any attachments are
virus free. We do not accept liability for any damages or other
consequences caused by information that is intercepted, corrupted, amended,
lost, destroyed, arrives late or incomplete or contains viruses.
******************************************
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
David Anthoff
2014-03-13 16:55:36 UTC
Permalink
This might be related to https://github.com/pythonnet/pythonnet/issues/3
(i.e. the stuff you can download from sourceforge does NOT work with .Net
4.5.1). The develop version that is on
https://github.com/pythonnet/pythonnet fixes this bug. We hope to release a
beta version of this that can be installed via pip soon.



Best,

David



From: PythonDotNet
[mailto:pythondotnet-bounces+anthoff=berkeley.edu-+ZN9ApsXKcEdnm+***@public.gmane.org] On Behalf Of
Jonno
Sent: Thursday, March 13, 2014 6:57 AM
To: A list for users and developers of Python for .NET
Subject: Re: [Python.NET] DocStringAttribute Example



Also when using clr.pyd from
pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip I cannot import clr. I get
the following error:

"dynamic module not initialized properly"

I'm on CPython 2.7.5, Win7 32bit.

Can anyone suggest what might be causing this? I have .NET Framework 4.5
installed.



On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Is it possible to compile the 2.0 Beta version containing the
DocStringAttribute for clr version 2.0 or is there some incompatibility?


I'm not familiar with how to build the pythondotnet source.



On Wed, Mar 12, 2014 at 11:59 AM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

My mistake Tony,



I was using the 2.0 CLR version of pythondotnet which doesn't have the
DocStringAttribute class.



On Wed, Mar 12, 2014 at 9:46 AM, Tony Roberts <tony-***@public.gmane.org
<mailto:tony-***@public.gmane.org> > wrote:

Hi,



have you added the Python.Runtime to your project references? Take a look at
the Python.Test project that's used by the unit tests if you're not sure how
to set up your project.



cheers,

Tony



On Wed, Mar 12, 2014 at 2:33 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Thanks Tony,



This is probably my ignorance of C# but I get the following error using the
same syntax as the example:



The type or namespace name 'DocStringAttribute' could not be found (are you
missing a using directive or an assembly reference?)



I have the:

using Python.Runtime

statement.



On Fri, Mar 7, 2014 at 12:19 PM, Tony Roberts <tony-***@public.gmane.org
<mailto:tony-***@public.gmane.org> > wrote:

Hi,



if your class has a constructor then the class docstring will get replaced
with a description of the constructor, even if you explicitly gave the class
a docstring using DocStringAttribute.



I've created an issue for github for this and fixed it:
https://github.com/pythonnet/pythonnet/issues/14



In the same commit I added some unit tests which should do as an example for
you to see how it should work (see the newly added file
pythonnet/src/testing/doctest.cs and pythonnet/src/tests/test_docstring.py).



cheers,

Tony





On Wed, Mar 5, 2014 at 3:59 PM, Jonno <jonnojohnson-***@public.gmane.org
<mailto:jonnojohnson-***@public.gmane.org> > wrote:

Hi,



Is there an example how to format documentation in classes & methods so that
a python docstring will be produced?



I found the following in a thread a while back but it's not working for me:



### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation:
WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}



_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet




_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet




_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
<mailto:PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org>
https://mail.python.org/mailman/listinfo/pythondotnet
Loading...