[cse491] On putting absolute paths in your code

C. Titus Brown ctb at msu.edu
Mon Nov 23 19:18:08 PST 2009


On Mon, Nov 23, 2009 at 07:16:09PM -0800, C. Titus Brown wrote:
> I would really, really appreciate it if you could avoid hard-coding
> paths into your code -- e.g. several of you have been putting
> 
>    file_server = FileServer('/user/nermal/cse491/trunk/templates')
> 
> into your code.  You can just do
> 
>    templates_path = os.path.abspath('./templates')
>    file_server = FileServer(templates_path)
> 
> If you put hard-coded paths in it makes life difficult for me when I
> download your code to run it on my own computers...

BTW, the latter code has the advantage that it will run from another
directory, e.g. hw10/, without having to change anything at all... It's
like magic!!

--titus
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2009 mailing list