Ready to Start Your Career?

Part 3: Creating Modules for Juliar in Python

Rattar 's profile image

By: Rattar

September 13, 2016

juliar-python-p3In the last tutorial, we learned how to use optionals correctly: this tutorial we will learn how to make modules and have juliar only load certain commands.We do this by creating a def commands():Please NOTE that we are not doing def commands(content,optionals);This is a special exception, since it's technically not a command, but rather used as a description. For the sake of the tutorial we will call it descriptor. This descriptor should only do the following: return the list of usable commands.This is very useful for two reasons:
  1. If you want to create def that you wish not to be a command.
  2. You and other people editing your module can clearly see what commands the module provides for use in Juliar.
If you do not create def commands, all commands will be exported, which is fine; however, we want to stay away from this behavior if we are developing an advanced module.If you have a command:
  • def copy(obj1):
  • return obj1+obj1
  • def repeat(content,optionals):
  • return copy(content)
You obviously don't want to export copy (if you are not sure why, read part 1 & 2 of this tutorial again), but command copy will be exported automatically. We do not want to export copy. Copy is just a helper def for repeat def.Also, if your module contains 20 commands, you may not know which commands the module contains. Placing the descriptor def commands(): at the top so that it provides a convenient way to see what are the commands called that are being exported to Juliar.Let's make a sample script and test it in Juliar def commands():
  • return "repeat repeatmore"
  • def copy(obj1):
  • return obj1+obj1
  • def repeat(content,optionals):
  • return copy(content)
  • def copy2x(obj1):
  • return copy(obj1)+copy(obj1)
  • def repeatmore(content,optionals):
  • return copy2x(content)
  • Save the file as
Let's test it in Juliar. Import a module in juliar via *import=py*Juliar should output the following commands: repeat repeatmore. Take a note that copy2x, commands, and copy have not been exported. You can freely use repeat and repeatmore.Now let's try removing def commands():return "repeat repeatmore" and reimporting the module to juliar via *import=py*You will notice that copy, repeat, copy2x, repeatmore have been imported.Let's try to execute copy...We will get an error... Aaah. So remember to use def commands(): to your advantage!:)Congratulations, you've gotten an orange belt in creating a module in Juliar.Hope you enjoyed the tutorial! If you have any other questions, please check out the official website of Juliar at or post the questions here.
Schedule Demo
Build your Cybersecurity or IT Career
Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry