Name: [17764] John Graves
Member: 62 months
Authored: 4 videos
Description: PhD Student at Auckland University of Technology. See http://bit.ly/JohnGravesLinkedIn for more details. ...

ConfigObj 4.7.2 [ID:1968] (1/1)

in series: ConfigObj 4.7.2

video tutorial by John Graves, added 04/10

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

Michael Foord's ConfigObj module provides one of the best tools for handling the task of configuration file management. This video introduces basic features of the module using the pydbgr (also an interesting tool) to step line-by-line through the application of ConfigObj to several .ini files. A demo of the configuration file validator (using a configuration specification file) starts about 8 minutes 20 seconds into the screencast. [Recorded with ScreenFlow on a Mac]

# configobj_demo.py
def show_ini(myFile):
	file = open(myFile)
	lines = file.readlines()
	file.close()
	for line in lines:
		print line.rstrip()
		
show_ini('config.ini')

from configobj import ConfigObj

# Show Nested Sections
config = ConfigObj('config.ini')
print config
print config['Favourites']
print config['Favourites']['software']
print config['Favourites']['software']['language']

# Show Unicode
config = ConfigObj('config.ini',encoding='UTF-8')
print config
print config['Favourites']['city']

# Show unrepr (UN-represent) Mode
show_ini('config2.ini')

config = ConfigObj('config2.ini',unrepr=True)
print config

def show_type(item):
    print item, config[item], type(config[item])
show_type('myString')
show_type('myFloat')
show_type('myInt')
show_type('myDict')
show_type('myTuple')
show_type('myList')
show_type('myScalar')

# Show validation
show_ini('config3.ini')
show_ini('configspec3.ini')

from validate import Validator

config = ConfigObj('config3.ini',configspec='configspec3.ini')
validator = Validator()
print config.validate(validator)

















Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 784 (since July 30th)
  • Plays in last week: 0
  • Published: 55 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

4. Bill Chipman Mon, 17 May 2010 07:23

Very good introduction to ConfigObj. Thanks.


Nicely done demonstration, John! I think I will use ConfigObj in my project as well.

Thanks, Stefan


Your video has been edited. This is an automatic post by ShowMeDo.


Your video has been edited. This is an automatic post by ShowMeDo.


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for John

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com