Skip to content

Commit d17268e

Browse files
committed
Clean-up README/CONTRIBUTING
1 parent d34a7af commit d17268e

File tree

2 files changed

+88
-70
lines changed

2 files changed

+88
-70
lines changed

CONTRIBUTING.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ contribution under the MIT license to this project.
88

99
## Getting Started
1010

11-
* Make sure you have a [GitHub account](https://github.com/signup/free)
12-
* Submit a ticket for your issue, assuming one does not already exist.
13-
* Clearly describe the issue including steps to reproduce when it is a bug.
14-
* Make sure you include what Python version and operating system you are using.
15-
* Fork the repository on GitHub
11+
- Make sure you have a [GitHub account](https://github.com/signup/free)
12+
- Submit a ticket for your issue, assuming one does not already exist.
13+
- Clearly describe the issue including steps to reproduce the bug.
14+
- Include what Python version and operating system you are using.
15+
- Fork the repository on GitHub
1616

1717
## Making Changes
1818

19-
* Create a topic branch from where you want to base your work.
20-
* This is usually the master branch.
21-
* Only target release branches if you are certain your fix must be on that
22-
branch.
23-
* To quickly create a topic branch based on master; `git checkout -b
24-
fix/develop/my_contribution master`. Please avoid working directly on the
25-
`master` branch for anything other than trivial changes.
26-
* Make commits of logical units.
27-
* Check for unnecessary whitespace with `git diff --check` before committing.
28-
* Make sure your commit messages are in the proper format.
29-
* Make sure you have added the necessary tests for your changes.
30-
* Run _all_ the tests to assure nothing else was accidentally broken.
31-
19+
- Create a topic branch from where you want to base your work.
20+
- This is usually the master branch.
21+
- Only target release branches if you are certain your fix must be on
22+
that branch.
23+
- To quickly create a topic branch based on master;
24+
`git checkout -b fix/develop/my_contribution master`.
25+
Please avoid working directly on the `master` branch for anything
26+
other than trivial changes.
27+
- Make commits of logical units.
28+
- Check for unnecessary whitespace with `git diff --check` before committing.
29+
- Make sure your commit messages are in the proper format.
30+
- Make sure you have added the necessary tests for your changes.
31+
- Run _all_ the tests to assure nothing else was accidentally broken.
3232

3333
## Submitting Changes
3434

35-
* Merge your topic branch into master and push to your fork of the repository.
36-
* Submit a pull request to the repository in the pythonnet organization.
37-
* After feedback has been given we expect responses within two weeks. After two
38-
weeks we may close the pull request if it isn't showing any activity.
35+
- Merge the topic branch into master and push to your fork of the repository.
36+
- Submit a pull request to the repository in the pythonnet organization.
37+
- After feedback has been given we expect responses within two weeks. After
38+
two weeks we may close the pull request if it isn't showing any activity.
3939

4040
# Additional Resources
4141

42-
* [General GitHub documentation](https://help.github.com/)
43-
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
42+
- [General GitHub documentation](https://help.github.com/)
43+
- [GitHub pull request documentation](https://help.github.com/send-pull-requests/)

README.md

+64-46
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,83 @@
1-
pythonnet
2-
=========
1+
# pythonnet - Python for .NET
32

4-
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.
3+
Python for .NET is a package that gives Python programmers nearly
4+
seamless integration with the .NET Common Language Runtime (CLR) and
5+
provides a powerful application scripting tool for .NET developers.
6+
It allows Python code to interact with the CLR, and may also be used to
7+
embed Python into a .NET application.
58

6-
[![Build Status](https://travis-ci.org/pythonnet/pythonnet.png?branch=master)](https://travis-ci.org/pythonnet/pythonnet)
9+
[![travis shield][]](https://travis-ci.org/pythonnet/pythonnet)
10+
[![appveyor shield][]](https://ci.appveyor.com/project/pythonnet/pythonnet-0kq5d/branch/master)
11+
[![license shield][]](./LICENSE)
712

8-
[![Build status](https://ci.appveyor.com/api/projects/status/g4flfwq46g2adv6a/branch/master?svg=true)](https://ci.appveyor.com/project/pythonnet/pythonnet-0kq5d/branch/master)
13+
## Calling .NET code from Python
914

10-
**Calling .NET code from Python**
11-
12-
Python for .NET allows CLR namespaces to be treated essentially as Python packages.
15+
Python for .NET allows CLR namespaces to be treated essentially
16+
as Python packages.
1317

1418
```python
15-
import clr
16-
from System import String
17-
from System.Collections import *
19+
import clr
20+
from System import String
21+
from System.Collections import *
1822
```
19-
To load an assembly, use the "AddReference" function in the "clr" module:
23+
24+
To load an assembly, use the `AddReference` function in the `clr` module:
2025

2126
```python
22-
import clr
23-
clr.AddReference("System.Windows.Forms")
24-
from System.Windows.Forms import Form
27+
import clr
28+
clr.AddReference("System.Windows.Forms")
29+
from System.Windows.Forms import Form
2530
```
2631

27-
**Embedding Python in .NET**
32+
## Embedding Python in .NET
33+
34+
- All calls to python should be inside
35+
a `using (Py.GIL()) {/_ Your code here _/}` block.
36+
- Import python modules using `dynamic mod = Py.Import("mod")`,
37+
then you can call functions as normal, eg `mod.func(args)`.
38+
- Use `mod.func(args, Py.kw("keywordargname", keywordargvalue))`
39+
to apply keyword arguments.
40+
- All python objects should be declared as `dynamic` type.
41+
- Mathematical operations involving python and literal/managed types must
42+
have the python object first, eg `np.pi_2` works, `2_np.pi` doesn't.
2843

29-
+ All calls to python should be inside a "using (Py.GIL()) {/* Your code here */}" block.
30-
+ Import python modules using dynamic mod = Py.Import("mod"), then you can call functions as normal, eg mod.func(args).
31-
+ Use mod.func(args, Py.kw("keywordargname", keywordargvalue)) to apply keyword arguments.
32-
+ All python objects should be declared as 'dynamic' type.
33-
+ Mathematical operations involving python and literal/managed types must have the python object first, eg np.pi*2 works, 2*np.pi doesn't
44+
### Example
3445

35-
EG:
3646
```csharp
3747
static void Main(string[] args)
3848
{
39-
using (Py.GIL()) {
40-
dynamic np = Py.Import("numpy");
41-
dynamic sin = np.sin;
42-
Console.WriteLine(np.cos(np.pi*2));
43-
Console.WriteLine(sin(5));
44-
double c = np.cos(5) + sin(5);
45-
Console.WriteLine(c);
46-
/* this block is temporarily disabled due to regression
47-
dynamic a = np.array(new List<float> { 1, 2, 3 });
48-
dynamic b = np.array(new List<float> { 6, 5, 4 }, Py.kw("dtype", np.int32));
49-
Console.WriteLine(a.dtype);
50-
Console.WriteLine(b.dtype);
51-
Console.WriteLine(a * b);
52-
*/
53-
Console.ReadKey();
54-
}
49+
using (Py.GIL())
50+
{
51+
dynamic np = Py.Import("numpy");
52+
dynamic sin = np.sin;
53+
Console.WriteLine(np.cos(np.pi*2));
54+
Console.WriteLine(sin(5));
55+
double c = np.cos(5) + sin(5);
56+
Console.WriteLine(c);
57+
/* this block is temporarily disabled due to regression
58+
dynamic a = np.array(new List<float> { 1, 2, 3 });
59+
dynamic b = np.array(new List<float> { 6, 5, 4 }, Py.kw("dtype", np.int32));
60+
Console.WriteLine(a.dtype);
61+
Console.WriteLine(b.dtype);
62+
Console.WriteLine(a * b); */
63+
Console.ReadKey();
64+
}
5565
}
5666
```
57-
outputs:
58-
```
59-
1.0
60-
-0.958924274663
61-
-0.6752620892
62-
float64
63-
int32
64-
[ 6. 10. 12.]
67+
68+
Output:
69+
70+
```c
71+
1.0
72+
-0.958924274663
73+
-0.6752620892
74+
float64
75+
int32
76+
[6. 10. 12.]
6577
```
78+
79+
[travis shield]: https://travis-ci.org/pythonnet/pythonnet.png?branch=master
80+
81+
[appveyor shield]: https://ci.appveyor.com/api/projects/status/g4flfwq46g2adv6a/branch/master?svg=true
82+
83+
[license shield]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square

0 commit comments

Comments
 (0)