Skip to content

Instantly share code, notes, and snippets.

@goozbach
Created October 26, 2009 00:55
Show Gist options
  • Select an option

  • Save goozbach/218348 to your computer and use it in GitHub Desktop.

Select an option

Save goozbach/218348 to your computer and use it in GitHub Desktop.

Revisions

  1. goozbach revised this gist Oct 26, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion get.py
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,4 @@

    print "globals"
    # dir should come from the config file
    print dir()
    print dir
  2. goozbach revised this gist Oct 26, 2009. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions get.py
    Original 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 = _execdir + '/foo.ini'
    _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
    print dir()
  3. goozbach renamed this gist Oct 26, 2009. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @travisbhartwell travisbhartwell renamed this gist Oct 26, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1 → gistfile2.txt
    Original 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 = _execdir + '/foo.ini'
    _configfile = os.path.join(_execdir,'/foo.ini')
    config.read(_configfile)
    print _configfile

  5. goozbach revised this gist Oct 26, 2009. 2 changed files with 9 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions foo.ini
    Original 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/
    1 change: 1 addition & 0 deletions gistfile1
    Original 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
  6. goozbach created this gist Oct 26, 2009.
    19 changes: 19 additions & 0 deletions gistfile1
    Original 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