Re: How to exit a pycomp?

Jacob Smullyan <[email protected]>
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Tue, Nov 09, 2004 at 06:40:26PM +0000, Andreas Kaempf wrote:
> Hello,
> 
> Is there a proper Skunk way to exit a pycomp before control reaches the
> end? return does not seem to do the trick, and sys.exit() does not feel
> right.  There is a <:halt:> tag which would work from stml, but what
> about within Python?

Definitely don't use sys.exit()!  That ends the entire process.  But
you have other options.

Generally speaking, my practice would to declare a function in the
pycomp in which almost all the work is done, and have very little code
at the top level of the component.  That way, you can use return to
simplify your control structure, among other benefits.

You can also raise DT.DTExcept.DTHaltError, which is what <:halt:>
does.  You have to pass it some bogus info, though:

  raise DT.DTExcept.DTHaltError(1, ":")

which isn't very pretty!  IMHO, using a wrapper function is a lot
cleaner.

(In stoat, you can just raise a ReturnValue for this purpose, but in
AE, a ReturnValue will get raised again if the component type isn't
DT_DATA.)

Hope that helps,

js

> 
> Cheers,
> Andreas
> 
> -----
> Enter a new world ... http://www.realmofmusic.com
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> _______________________________________________
> Skunkweb-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/skunkweb-list
> 

-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBkRhNuqamFyFXXLIRAuH+AJ0Su5/i1k4/oGzGQz4GuvYeh15cMACgyvpM
OGw4nv+WuEeifGq8QyvcrwU=
=9qwl
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.