mirror of
https://github.com/gsi-upm/sitc
synced 2024-11-18 04:22:28 +00:00
145 lines
3.4 KiB
Plaintext
145 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"![](http://www.upm.es/sfs/Rectorado/Gabinete%20del%20Rector/Logos/UPM/EscPolitecnica/EscUpmPolit_p.gif \"UPM\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Course Notes for Learning Intelligent Systems"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Modules and Packages\n",
|
|
"\n",
|
|
"*Modules* contains definitions and objects that can be reused in other programmes.\n",
|
|
"\n",
|
|
"*Packages* contain subpackages of modules. They are directories and provide the namespace for modules.\n",
|
|
"\n",
|
|
"For example, let's have this package babel, a subpackage messages and the modules plurals and catalog:\n",
|
|
"\n",
|
|
"<code>\n",
|
|
"babel/\n",
|
|
" messages/\n",
|
|
" \\_\\_init\\_\\_.py\n",
|
|
" plurals.py\n",
|
|
" catalog.py\n",
|
|
"</code>\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# We can import the module plural with import, but we should use the full name\n",
|
|
"import babel.messages.plurals\n",
|
|
"plurals.get_plural()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import babel.messages.plurals\n",
|
|
"babel.messages.plurals.get_plural()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from babel.messages import plurals # with from-import, we can use the short name\n",
|
|
"plurals.get_plural()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from babel.messages.plurals import get_plural # now we can use directly get_plural()\n",
|
|
"get_plural()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"To write a module, it is just needed to include the code in a file ended with \".py\" and the name of the file is the name of the module.\n",
|
|
"\n",
|
|
"Packages are directories that should have a file \\_\\_.init\\_\\_.py, that can be an empty file or contain initialization code.\n",
|
|
"\n",
|
|
"Read this if you want to distribute your modules [https://wiki.python.org/moin/CheeseShopTutorial]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Licence"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
|
|
"\n",
|
|
"© 2016 Carlos A. Iglesias, Universidad Politécnica de Madrid."
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.5.1"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
}
|