Skip to content

Instantly share code, notes, and snippets.

@stuaxo stuaxo/config_parse.ipynb
Last active Jan 14, 2018

Embed
What would you like to do?
http://buklijas.info simple solution
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[other]\r\n",
"list_queue1 = 192.168.1.34 192.168.1.35 192.168.1.36 192.168.1.34\r\n"
]
}
],
"source": [
"!cat config_ini.ini"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['192.168.1.34', '192.168.1.35', '192.168.1.36', '192.168.1.34']\n"
]
}
],
"source": [
"import ConfigParser\n",
"import io\n",
"import shlex\n",
"\n",
"def main():\n",
" config = ConfigParser.ConfigParser(allow_no_value=True)\n",
" config.read('config_ini.ini')\n",
" testing_1 = shlex.split(config.get('other', 'list_queue1'))\n",
" print(testing_1)\n",
" \n",
"if __name__ == '__main__':\n",
" main()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.