erocarrera / erocarrera/pythonika

Pythonika symbols are not localized, might overwrite user-defined Global` symbols

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
Mathematica
Stars
35
Forks
11
PR merge metrics
No merged PRs in 30d

Description

```
It appears that Pythonika's symbols, including its private variables (such as
"code") are not put in a separate context. If I already have a variable named
"code", it will be overwritten, then removed when loading and using Pythonika.

I suggest putting all symbols in a separate context (e.g. Py`) and all private
symbols into a separate subcontext, using the usual way when writing packages.
Then adding this context to the context path.

Please see page 6 of
http://www.edenwaith.com/development/tutorials/mathlink/ML_Tut.pdf on how to do
this.

The usual way is starting with

BeginPackage["Py`"]

Then mentioning the names all all symbols that will be available to the user
here (this is a side-effect of creating the usage message here in the example,
but you don't need to do this, listing the names of all symbols like Py,
PyReal, etc. is enough)

Then creating yet another sub-context with Begin (not BeginPackage, meaning all
symbols created there will be private)

Begin["Py`Private`"]

rest of the tm-file goes here

End[]
EndPackage[]

Finally, I think the Remove should be Remove["Py`Private`code"], not simply
Remove["code"]. But in this case it's maybe better not to remove anything at
all, after all code will be a private variable invisible to the user.

Thanks for a great package!

```

Original issue reported on code.google.com by `szhor...@gmail.com` on 16 Dec 2011 at 3:43

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.