How to protect/encrypt a python module? [duplicate] - python

This question already has answers here:
How do I protect Python code from being read by users?
(29 answers)
Closed 3 years ago.
My project is open sourced, except for a single module where I don't want people to know the implementation. Actually, I don't mind one or two people cracking the thing open if they are determined enough, but I want most to give up at the first sight.
I only want the implementation of that single module to be hidden, the interface still fully usable if people want to contribute to the project. That is to say, I want people to be able to do things like:
import my_hidden_module
my_hidden_module.do_stuff()
My project mostly runs on Windows so Windows-exclusive suggestions are ok.
I'm totally new to this hiding code thing so I don't know where to start. It would be appreciated if someone could give me a direction to look into.

1) You can use classes and private variables or
2) use name =='main', but that will not implement the code on interface
3) looks dumb but you can comment on top of that function to not to be CHANGED
else you can see - How do I protect Python code?

Related

Documentation for XML code

At this moment I am searching documentations or trying to make documentations for the XML-Code which builds the script boxes in Choregraphe. For example, like you could see in the next images (1 and 2): what does „Input name="Multiplicand" type="2" type_size="1" nature="1" inner="0"“mean in the basic script boxes just like “Multiply.py”? It would mean one variable as input value in type number with "onEvent" in choregraphe graphic interface according to the image3, I guess.
It's very hard to find them on the official documentation website from Aldebaran or even by Google results. In principle I could already find it out with just trying to change the values and see the changes in choregraphe, but it's not very smart and takes a while. At this point, I’m really forward to hearing from you. That would be very helpful for the next students who want to understand more about choregraphe and who want to build choregraphe script boxes by themselves in Python code level.
Yes, that "Multiplicand" you see in the xml is the input you can edit via the gui.
You can create and edit Choregraphe boxes entirely through the GUI, editing their inputs, outputs and parameters; I recommend doing that instead of touching the XML; because the exact format used in the .xar file may change in future versions. I have used Choregraphe quite a bit and have never felt the need to directly edit the .xar (except maybe when resolving git conflicts, but that was years ago and since then we've been avoiding having to ever merge a .xar file).

Where can I learn more about making GUI for python software [duplicate]

This question already has answers here:
How to make a gui in python [closed]
(10 answers)
Closed 9 years ago.
I've taken some lessons and courses about Python 3.X programing and I've even constructed a few command line apps, but when it comes to build a full GUI desktop app I can't seem to grasp a consensus on how to do so and I'm see my self left with many questions and no "one" recommended path to start at it.
Witch framework do I use?
Do I even use a framework?
How do I install it?
My true question is: "Where do I start and where do I go from there?". I feel that that may even enlighten me and hopefully others as well about the same concepts applied to other programing languages.
The intent of this post is to receive the necessary support to begin making desktop apps for someone who already have some knowledge of the language it self. Answers here should have a highly readable format, it's personal opinions should be explained and links should be given, rendering a good communitarian guide to Python 3.X graphical apps making.
you can try learning pyside, its a Qt binding for python and zetcode has really good tutorials from the scratch if you wanna start learning.. you can download it from here..

Python from Python: restricting functionality? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Python, safe, sandbox
I'm building a corporate web system in Python which allows scripts to be uploaded and run serverside. Given I'm already developing in Python and its such a nice simple language, it seems like a good language to write the scripts in. However, there is a security hazard there, I want to block all function calls except a limited subset. Is there a mechanism I can use to do this, or some other technique? Do I need to use something else, Lua perhaps? I'm developing in Pyramid/Pylons.
This is a terrible idea, but just to let you know about the option:
You could sanitize a string that contains the Python code (and by sanitize I mean you need to do like a few hundred malicious unit tests and heavily test that the sanitation is adequate) with RegEx to only match the function calls you want and then call eval() on the string.

What is a Class in python, what does it do, why is it needed? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Do I correctly understand what a class is?
Before you rant and rage and scream at me, understand that I tried searching everywhere, from google to this very site on what exactly a class in python is. I have found definitions of sorts, but have never been able to understand them fully. So here's the question. What is a class in python, what does it do, and why is it used?
Class (in any language) basically help in implementing OOPS. By Following these principles, it becomes easier to maintain code & make changes etc.
I guess you start off by reading what OOPS is & then come back to Python.

When Should I Start Thinking About Moving to Python 3? [duplicate]

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
Why won't you switch to Python 3.x?
I see there are already a lot of duplicate questions asking whether or not new Python programmers should learn 2 or 3. I am not asking that question.
I am already a Python 2 programmer. I started tinkering with it some years ago. I started using it almost exclusively for my personal projects about a year ago. I even recently switched from a PHP job to a Python job. However, all this has been with Python 2.
Python 3 is out now, and I know that is is not backwards compatible with 2, although it is similar. I don't think I'm going to have any problem learning Python 3. However, I am going to have a problem transitioning old code, if it becomes necessary. Also, if development efforts move from Python 2 to 3, I can't be stuck developing on a deprecated platform.
It seems that for the moment, Python 2 is still going strong, and there isn't really any push to transition to 3. That can't last forever, though. When should I start to make a move?
The best answer I can give you is change when you need to. If you have no need for Python 3, then don't switch. If you aren't sure if you need to switch, chances are that you don't.
That said, once Python 3 becomes the more widely used version (in a few years, not anytime soon), you'll probably want to switch just because it will be more supported (more libraries, etc).
If you don't have any Python 2-specific libraries, you could write new projects in Python 3 just to ease the transition, but you don't need to at this point.
If you can switch now, you might as well. Learning the newest will always help in the future.
Being that you have been using 2, then there is no concern that you won't know how to use that.

Categories