The reason for using the os.path.join() method is that it is platform-
independent. I think, however, that python on windows is now smart
enough to understand the forward slash delimiter, so your version will
work ok on a windows machine. Also, for what it's worth, it is
customary to specify each path component separately, that is:

  path = os.path.join(os.path.dirname
(__file__),'Templates','mytemplate2.html')

where 'Templates' and "mytemplate2.html' are separate function
arguments.

The reason for using the os.path.dirname(__file__) is to specify the
path relative to the current file, instead of the current working
directory (which is the case in your code). It is customary
programming practice not to rely on the current working directory
being set, but again in your example, it should work fine.



On Apr 6, 10:38 pm, GenghisOne <mdkach...@gmail.com> wrote:
> A stupid question about templating...
>
> Do I really need to use the whole os.path.join monstrosity to tell
> Python where my template lives?
>
> I commented it out and replaced it with a simple path...it seems to
> work fine.
>
> What am I missing here? Why are others using this os.path.join
> pattern?
>
> #path = os.path.join(os.path.dirname(__file__), 'Templates/
> mytemplate2.html' )
>     path = 'Templates/mytemplate2.html'
>     self.response.out.write(template.render(path, template_values))
>
> Thx.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to