Created
October 26, 2009 00:55
-
-
Save goozbach/218348 to your computer and use it in GitHub Desktop.
Revisions
-
goozbach revised this gist
Oct 26, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,4 @@ print "globals" # dir should come from the config file print dir -
goozbach revised this gist
Oct 26, 2009 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,17 +4,18 @@ import sys config = ConfigParser.ConfigParser() _execdir = os.path.dirname(sys.argv[0]) _configfile = os.path.join(_execdir,'foo.ini') config.read(_configfile) print _configfile # print out a var from config print config.get('default', 'foo', 0) # -> "Python is fun!" # set the configs into global vars for foo in config.items('default'): item, value = foo globals()[item] = value print "globals" # dir should come from the config file print dir() -
goozbach renamed this gist
Oct 26, 2009 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
travisbhartwell renamed this gist
Oct 26, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import os import sys config = ConfigParser.ConfigParser() _execdir = os.path.dirname(sys.argv[0]) _configfile = os.path.join(_execdir,'/foo.ini') config.read(_configfile) print _configfile -
goozbach revised this gist
Oct 26, 2009 . 2 changed files with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # this is a comment [default] foo = yes bar = no cam = maybe var = 23 prefix = /var/lib/ dir = %(prefix)s/bar/ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,4 +16,5 @@ for foo in config.items('default'): globals()[item] = value print "globals" # dir should come from the config file print dir -
goozbach created this gist
Oct 26, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/usr/bin/python import ConfigParser import os import sys config = ConfigParser.ConfigParser() _execdir = os.path.dirname(sys.argv[0]) _configfile = _execdir + '/foo.ini' config.read(_configfile) print _configfile print config.get('default', 'foo', 0) # -> "Python is fun!" for foo in config.items('default'): item, value = foo globals()[item] = value print "globals" print dir