By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

announce: FAQs suggested

P: n/a
http://effbot.org/pyfaq/suggest.htm has new FAQ's:

FAQ: How do I ask to exit from a doctest
FAQ: How do I say unsigned char in ctypes?
FAQ: How do I say returns void in ctypes?
FAQ: How do I calculate what quoted strings and numbers mean?

Enjoy, Pat LaVarre

Nov 10 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
p.*******@ieee.org wrote:
http://effbot.org/pyfaq/suggest.htm has new FAQ's:

FAQ: How do I ask to exit from a doctest
I don't consider that question /frequently/ /asked/ or that feature
frequently requested. Also, the KeyboardInterrupt approach is a hack.
FAQ: How do I say unsigned char in ctypes?
FAQ: How do I say returns void in ctypes?
That's in the ctypes documentation, where it belongs.

Peter
Nov 10 '06 #2

P: n/a
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say returns void in ctypes?
That's in the ctypes documentation, where it belongs.
Thank you, before I never had found "Use None for void a function not
returning anything" at:
http://starship.python.net/crew/thel...reference.html

Now I see, that find corresponds to:
http://docs.python.org/dev/lib/ctype...functions.html

I think this remains an FAQ, because I see void is missing from much
more prominent places:
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
http://docs.python.org/dev/lib/ctypes-return-types.html

Finding a way to suggest improving those docs would help more than
suggesting an FAQ, I agree.
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say unsigned char in ctypes?
That's in the ctypes documentation, where it belongs.
Yes and no. The whole FAQ suggested was:

FAQ: How do I say unsigned char in ctypes?
A: ctypes.c_ubyte
ctypes doesn't define c_uchar. This actually is doc'ed, it's just
annoying.

Per your kind correction above re void, I see we could also say:

FAQ: How do I say returns void in ctypes?
A: restype = None
ctypes doesn't define c_void. This actually is doc'ed obscurely, it's
just irregular.

Nov 10 '06 #3

P: n/a
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say returns void in ctypes?
That's in the ctypes documentation, where it belongs.

Thank you, before I never had found "Use None for void a function not
returning anything" at:
http://starship.python.net/crew/thel...reference.html

Now I see, that find corresponds to:
http://docs.python.org/dev/lib/ctype...functions.html

I think this remains an FAQ, because I see void is missing from much
more prominent places:
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
http://docs.python.org/dev/lib/ctypes-return-types.html

Finding a way to suggest improving those docs would help more than
suggesting an FAQ, I agree.
I might have hit this brick wall while working offline, with nothing
but the doc to hand.

http://www.google.com/search?q=site%...rg+ctypes+void
now, if not before, does fetch that key phrase:
"Use None for void a function not returning anything"

Nov 10 '06 #4

P: n/a
p.*******@ieee.org schrieb:
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say returns void in ctypes?
That's in the ctypes documentation, where it belongs.

Thank you, before I never had found "Use None for void a function not
returning anything" at:
http://starship.python.net/crew/thel...reference.html

Now I see, that find corresponds to:
http://docs.python.org/dev/lib/ctype...functions.html

I think this remains an FAQ, because I see void is missing from much
more prominent places:
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
I don't think it belongs in the above section because 'void' is not a type.
http://docs.python.org/dev/lib/ctypes-return-types.html
A note could probably be added to this section.
Finding a way to suggest improving those docs would help more than
suggesting an FAQ, I agree.
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say unsigned char in ctypes?
That's in the ctypes documentation, where it belongs.

Yes and no. The whole FAQ suggested was:

FAQ: How do I say unsigned char in ctypes?
A: ctypes.c_ubyte
ctypes doesn't define c_uchar. This actually is doc'ed, it's just
annoying.

Per your kind correction above re void, I see we could also say:

FAQ: How do I say returns void in ctypes?
A: restype = None
ctypes doesn't define c_void. This actually is doc'ed obscurely, it's
just irregular.

I don't think that this is irregular, see comment about void not being a type.

Thomas

Nov 10 '06 #5

P: n/a
Thanks again for making time to comment - insights into the perspective
of the author are invaluable. But if by chance you have time to
continue:
http://effbot.org/pyfaq/suggest.htm
http://docs.python.org/dev/lib/ctypes-return-types.html
A note could probably be added to this section.
Good. Next: Is there a place on the web where we can log that
conclusion to inspire its resolution?
void is missing from
http://docs.python.org/dev/lib/node452.html "Fundamental data types"

'void' is not a type.
Help, lost me?

1)

http://msdn.microsoft.com/library/en...data_types.asp
thinks void is a type. That's what I was reading in parallel with the
ctypes doc, as I tried to make ctypes and the Windows kernel32.dll talk
to each other.

2)

void foo(int ii) { ii = ii; }
is a C way of saying the return type of foo is the type void, in casual
conversation among programmers.

I mean, suppose I ask you what is the return type of foo? That is,
suppose I ask you what its ctypes restype should be?

We can answer like a C lawyer, tell me that my question is malformed,
tell me that foo returns no result, tell me that foo has no return
type, and claim that thus obviously its restype should be None, despite
the widespread string Api convention of distinguishing None from
consciously empty and not using None to mean consciously empty.

Or informally we can say the return type of foo is the type void,
because void is a type, and ctypes uses Python None to express the idea
of the void type, without adding the name c_void to tell you this.
I don't think that this is irregular,
Have I clearly explained why defining no c_void appears irregular to me
the C-literate Python-illiterate newbie?

Maybe also relevant is my Jvm/Jni background - I'm used to seeing void
expressed there as a type, not much different than int.

Was my newbie confusion here so very unique, or do these two FAQ's
exist:
FAQ: How do I say unsigned char in ctypes?
FAQ: How do I say returns void in ctypes?

Or can we hope to improve any of:
http://starship.python.net/crew/thel.../tutorial.html
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
http://docs.python.org/dev/lib/ctypes-return-types.html
?
That's in the ctypes documentation, where it belongs.
Thanks again for that claim.

Now also I see that returns void is defined by:
http://starship.python.net/crew/thel...reference.html
although not by:
http://starship.python.net/crew/thel.../tutorial.html

Once upon a time, I only knew the tutorial existed, not the reference.
The tutorial includes one well-buried mention of "see the reference
manual for details", but doesn't link to what reference manual is
meant.

I remember, as a newbie, I was slow to accept that Google
site:docs.python.org shouldn't be the only thing I read to understand
the ctypes of 2.5 Python.
...
Thanks all for the education.

I'm clear on this now, and delighted to remove the fixme: undoc'ed
comments from my source.

Nov 10 '06 #6

P: n/a
p.*******@ieee.org wrote:
>>http://docs.python.org/dev/lib/ctypes-return-types.html

A note could probably be added to this section.

Good. Next: Is there a place on the web where we can log that
conclusion to inspire its resolution?
ideally, you'd click "add a comment" on the relevant library reference
page, just like you did for the FAQ, but we're not quite there yet. in
the meantime, see this page:

http://docs.python.org/tut/about.html

</F>

Nov 10 '06 #7

P: n/a
p.*******@ieee.org schrieb:
Thanks again for making time to comment - insights into the perspective
of the author are invaluable. But if by chance you have time to
continue:
http://effbot.org/pyfaq/suggest.htm
http://docs.python.org/dev/lib/ctypes-return-types.html
A note could probably be added to this section.

Good. Next: Is there a place on the web where we can log that
conclusion to inspire its resolution?
The canonical place is the Python bug tracker. Best would be to suggest a sentence
or two for the docs.

Presonally, I would suggest to add something like this to the start of the docs, section 14.14.1.8:

"""
14.14.1.8 Return types

By default functions are assumed to return the C int type. Other return types can be specified by setting the restype attribute of the function object.

-For functions that do not return anything, restype should be set to None.
"""
void is missing from
http://docs.python.org/dev/lib/node452.html "Fundamental data types"

'void' is not a type.

Help, lost me?
What I mean is that you cannot create 'variables' of type void in C, so I would
say it is not a type. Do you think that ctypes should define
c_void = None
somewhere?

I think that would really be confusing. Consider:
>>c_int(42)
c_int(42)
>>c_void()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'NoneType' object is not callable
>>>
OTOH, void* is a type in C, also in ctypes, where it is spelled 'c_void_p'.

I hope this makes sense to you.

Thomas

Nov 10 '06 #8

P: n/a
p.*******@ieee.org schrieb:
http://effbot.org/pyfaq/suggest.htm
FAQ: How do I say returns void in ctypes?
That's in the ctypes documentation, where it belongs.

Thank you, before I never had found "Use None for void a function not
returning anything" at:
http://starship.python.net/crew/thel...reference.html
This sentence:
Use None for void a function not returning anything
of course makes no sense.

What I had in mind was:

Use None for a void function not returning anything

but that can certainly improved. Suggestions?
Thomas

Nov 10 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.