Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

Dynamic File Name Open()


Robert Rawlins - Think Blue wrote:

> I'm trying to open a file using open() but the name of the file is created
> dynamically as a variable, but also has part of a static path. For instance,
> the file may be called 'dave' and will always be in '/my/files/here/'.

Well that's an absolutely normal way of doing
things, so if my toy example below doesn't make
things clear, you'd better post a code fragment
and/or some traceback.

<code>
import os, sys

path = "c:/temp"
for filename in ["chas.txt", "dave.txt"]:
   f = open (os.path.join (path, filename))
   print filename
   print f.read ()
   print
   f.close ()

</code>

TJG

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc