[gt-users] A series of questions regarding GenomeTools C and its Python interface
Sascha Steinbiss
steinbiss at zbh.uni-hamburg.de
Tue Apr 28 19:27:38 CEST 2009
James Casbon wrote:
> I have a couple of itches to scratch about the python bindings which I
> had not been mentioning until now...
Oh, of course. I am not primarily a Python programmer, being more
comfortable with C and Ruby, so I am always thankful for some advice ;)
> Firstly, python code should be indented with four spaces. The python
> style guide - http://www.python.org/dev/peps/pep-0008/ - says:
> "Use 4 spaces per indentation level."
> It's unequivocal. I might knock up a patch if you indicate it would
> be accepted.
Okay, of course. Would it suffice to have
http://pypi.python.org/pypi/PythonTidy/1.16 process the current code to
comply to the coding conventions? If you want to patch this, I will of
course gladly accept a patch against the current git master head.
> Secondly, what's with all this obj._as_parameter and from_param stuff?
> You seem to be putting a classmethod in every class to return an
> object variable. Just access the variable. The other thing
> from_parameter does is check the object is the correct class. I'm
> not sure why you are doing this - to ensure the type of
> _as_parameter_?
Yep, that is exactly why this is done -- to ensure the type of the
object given to a C library function wrapped by ctypes so users get a
proper Python exception instead of a failed C-side assertion or segfault.
See
http://python.net/crew/theller/ctypes/tutorial.html#calling-functions-with-your-own-custom-data-types
for more details.
> cheers,
> James
Sascha
--
Sascha Steinbiss
Center for Bioinformatics
University of Hamburg
Bundesstr. 43
20146 Hamburg
Germany
Email: steinbiss at zbh.uni-hamburg.de
URL: http://www.zbh.uni-hamburg.de/steinbiss
Phone: +49 (40) 42838 7322
FAX: +49 (40) 42838 7312
More information about the gt-users
mailing list