• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AppleScript calling Python function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AppleScript calling Python function


  • Subject: AppleScript calling Python function
  • From: Simon Forster <email@hidden>
  • Date: Wed, 21 Apr 2004 08:56:30 +0100

This is a bit of a neophyte question(s) which is probably more Python than AppleScript but I need help and you guys may point out something obvious that I'm missing!

I've written a very simple Python module which I want to call via AppleScript from within FileMaker Pro.

Problem: I need to load my module so that I can call the Python function with the appropriate arguments. To put this in some form of context. From the command line:

python
>>> sys.path.append('/Users/simonforster/Development/Python/Lib')
>>> import regex_domain3
>>> regex_domain3.GetDomain('www.look4generics.com/storvas .htm')
'www.look4generics.com'

Now, in theory I can write an AppleScript which'll mimic this approach. i.e. Set the python path, import the module, do the do. But this seems incredibly wasteful. (Bear in mind that the AppleScript call is stateless. i.e. each time I run it it'll be analogous to starting a completely new shell).

So, how do I set python's path for my user? And, FWIW, if I "echo $PYTHONPATH" in the Terminal, I get a blank line. My research suggests that this is a valid environment variable though. Don't understand.

On a wider front, being able to integrate Python with AppleScript gives one a very powerful tool. Is there a better way to pass arguments to a Python function from within AppleScript?

TIA for any help/pointers.

Simon Forster
_____________________________________________________
LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
Tel: +44 (0)70 9230 5244 Fax: +44 (0)70 9230 5247
_____________________________________________________
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: AppleScript calling Python function
      • From: Steven Majewski <email@hidden>
  • Prev by Date: Create list of lists?
  • Next by Date: Re: Changing Spelling Dictionary?
  • Previous by thread: Re: Create list of lists?
  • Next by thread: Re: AppleScript calling Python function
  • Index(es):
    • Date
    • Thread