new script question

   3581   6   2
User Avatar
Member
383 posts
Joined:
Offline
Hi,

Discovering Python I am now in front of a weird behavior with a pre render script.

In the python shell when I type this :
import sys
open('D:\\_Houdini\\test.txt', ‘w’)

A new text file his create on the right place.

When I copy/paste it to the pre render param ( via the expression editor)
I got an error
invalid filename “D:\\_Houdini\test.txt”

so I have to write my path like so to make it to work :
open('D:\\_Houdini\\\test.txt', ‘w’)

any explaination for this ?
http://vimeo.com/vbkstudio [vimeo.com]
User Avatar
Member
4683 posts
Joined: Feb. 2012
Offline
Yeah because “\t” is an escape sequence for a tab character:
http://docs.python.org/2/reference/lexical_analysis.html#string-literals [docs.python.org]
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
What is the worst mistake ever made in computer science and programming that proved to be painful for programmers for years?
http://qr.ae/tLHCH [qr.ae]
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
383 posts
Joined:
Offline


Programming is so … unexpected.

anyway, thanks, guys, for the info.
http://vimeo.com/vbkstudio [vimeo.com]
User Avatar
Member
4683 posts
Joined: Feb. 2012
Offline
I think Tony Hoare's null reference is the biggest mistake ever made in CS:

“Speaking at a conference in 2009, Hoare apologized for inventing the null reference:

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.”

http://en.wikipedia.org/wiki/Tony_Hoare [en.wikipedia.org]

http://twistedoakstudios.com/blog/Post330_non-nullable-types-vs-c-fixing-the-billion-dollar-mistake [twistedoakstudios.com]
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
7871 posts
Joined: July 2005
Offline
vbk!!!
so I have to write my path like so to make it to work :
open('D:\\_Houdini\\\test.txt', ‘w’)

I think it's because the expression itself will get expanded first, so the backslash before test needs an additional level of escaping. The slash after the D: I would have expected to need escaping as well, maybe it does get stripped to D:_Houdini so that's valid too. The simple thing to do here is to just use the forward slash instead of the back slash. ie. open('D_Houdini/test.txt', ‘w’)
User Avatar
Member
383 posts
Joined:
Offline
Forward slash adopted !
everything's fine !
http://vimeo.com/vbkstudio [vimeo.com]
  • Quick Links