Home.Verilog.Digital Design.Digital Basics.Python.RF Basics.
Custom Search

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
Digital-logic Design...  Dream for many students… start learning front-end…

Legal Disclaimer

@TYH :- 4G LTE Long Term Evolution Tutorial, CloudComputing
Verilog Tutorial.
Get Noticed:- Submit your own content to be published on fullchipdesign.com

Send it to fullchip@gmail.com

Digital Basics Tutorial.
File read operations.

Class & global var.

File write op's.

Glob module.

Conditional stms.

String 2 hex.

UNIX in Python.

Diamond Pattern.

TypeError - arg.

TyprError - str.

TypeError - strconv.


Function call.

Read bin files.

Use of glob module in Python code 

Program to read  and display files in a directory with a particular extension using glob module are discussed in this section

Program list_files.py

Result :

Suppose we want to read a directory for the html files (*.htm) and print the names of the files.

For the following files vhdl1.htm, vhdl2.htm, …, vhdln.htm in a directory

From the python shell we run

>> list_files.py

file in directory vhdl1.htm

file in directory vhdl2.htm


file in directory vhdln.htm



import glob

import string

import os

import commands


files = glob.glob("*.htm*")


for filename in files:

        print "file in directory %s" % (filename)