Charlie:
  In my experience, which goes back 35 years, constants like this are
pretty much what the word implies -- constant.  They are used to
communicate between two software packages which were made by different
people on different machines using different languages. If the value
of the "magic number" where to change, both parties would have to
rewrite their interface code.

Therefore, in practice, these codes once defined will never change, so
you should not have any trouble if you just hard code the number into
your program.

It is a good practice to define it as a named object for documentation
purposes, so the next guy who reads your program (or yourself five
years later) can understand what the number means in the interface.
--
Vernon Cole

<Python>

# ------
#constants from
http://www.indesignscriptingreference.com/CS3/JavaScript/SaveOptions-enum.htm
SaveOptionsNo = 1852776480     #does not save changes
SaveOptionsYes = 2036691744    #saves changes
SaveOptionsAsk = 1634954016    #Displays a prompts asking whether to
save changes.
# ------

# ... <lots of program code here> ...

Application.quit(SaveOptionsNo)  #shut down the application and do not
save changes

</Python>

If you never use SaveOptionsYes or SaveOptionsAsk, and are really
concerned with efficiency, then make them comments, for documentation
sake, but leave them where the code values are obvious. Also document
where you got them from, as in the sample above.
--
Vernon Cole

On Tue, Jan 27, 2009 at 9:55 AM, Charlie Clark <char...@begeistert.org> wrote:
>
> Hiya,
>
> I'm pretty new to COM but fairly used to Python. Still got most things to 
> work just struggling a little with reading a constant.
>
> I'm currently scripting Adobe InDesign (CS4) where I create a document, 
> export a PDF and close it withouth saving. All the documentation I've come 
> across refers to a SaveOptions constant (yes or no) that I presumably can 
> extract from InDesign somehow. While I have managed to come across the right 
> value for this constant:
>
> http://www.indesignscriptingreference.com/CS3/JavaScript/SaveOptions-enum.htm
>
> it's also pretty clear to me that this might break easily and isn't quite the 
> correct way of doing this. I've read about using introspection to generate 
> the constants in win32com.client but haven't been able to get this to work. 
> Is this a once only procedure or is it possible at run time?
>
> Thanks in advance for any pointers!
>
> Charlie
> --
> Charlie Clark
> Helmholtzstr. 20
> Düsseldorf
> D- 40215
> Tel: +49-211-938-5360
> GSM: +49-178-782-6226
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to