← Back to team overview

sikuli-driver team mailing list archive

[Bug 567303] Re: Use of "__file__" gives NameError

 

@Brentmeister
The original post wanted to know the scripts name (and path).

For this you can use getBundlePath().

So if you have a fixed structure like the above, every script would be
able to find and use any path in this construct using the standard
features of os.path module.

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/567303

Title:
  Use of "__file__" gives NameError

Status in Sikuli:
  Fix Released

Bug description:
  Trying to use __file__ python functionality results in Sikuli throwing
  a NameError exception.

  Example Code:
  script_name = __file__

  
  I think I might get why this happens.  It's the same behavior as if using __file__ in a python command line interpreter session.

  But, it would be nice for this to work inside of Sikuli the same as if
  running command "python testfile.py" from command line.

  So, I am requesting that Sikuli is modified to recognize __file__ as
  valid python code that gives the current script name.  Or,
  alternatively to implement a new Sikuli specific command to get the
  name of the current running file.

  Thanks!

  Current Setup:
  Sikuli 0.9.9
  Windows XP, 32-bit

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/567303/+subscriptions