Python module templates (was python calling python) 
Author Message
 Python module templates (was python calling python)

Quote:

> [Alex Martelli]

> > A fine touch might include:

> > def main(args=sys.argv):
> >     # whatever

> I tried many styles for this, and finally decided that the most useful
> idiom might be:

>     def main(*arguments):
>        import getopt
>        options, arguments = getopt.getopt(...)
>        for option, value in options:
>            ...
>        # rest of programs with arguments...

>     ...

>     if __name__ == '__main__':
>         apply(main, sys.argv[1:])

> so I use it almost identically in all my programs.  From another module,
> one could just use:

>     module.main(OPTION, OPTION..., ARGUMENT, ARGUMENT...)

> passing strings for each.

Do you chaps have a module template? What does it have in it?

Cheers,
Simon Brunning
TriSystems Ltd.

-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.



Sun, 09 Feb 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Anybody doing irc-stuff with Python / status of irc-modules for Python

2. fintl.py -- a python module to aid i18n (was Re: International Python)

3. python-mySQL module documentation other that python.org?

4. PROPOSAL: A Generic Python Object Interface for Python C Modules

5. PROPOSAL: A Generic Python Object Interface for Python C Modules

6. PROPOSAL: A Generic Python Object Interface for Python C Modules

7. python calling python

8. Again calling Python from C from Python

9. Calling Python from C from Python

10. Calling Python from C from Python

11. Calling Python Code Snippets within Python Application

12. Python calling C with callback to Python - crash!

 

 
Powered by phpBB® Forum Software