Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41910
| References | <CAJQX3Dz-zZd7yL5Wc6hPJaP0=Mj0kCWAUvvonVH07stttRHivg@mail.gmail.com> <CALwzidkss-vdd5yPdwtMrgqANa8YEGKm3jPCgGG4vrvuR=LAdA@mail.gmail.com> <CAJQX3Dx2SV-uPznaRtTLAMYQD_dMW=r8hQfBpBSdAvKtzAGCog@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-03-26 09:07 -0600 |
| Subject | Re: python3 string format |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3749.1364310482.2939.python-list@python.org> (permalink) |
On Tue, Mar 26, 2013 at 4:51 AM, Shiyao Ma <i@introo.me> wrote:
> Thx for your reply.
> I am using pycharm and simply press "go to declaration" which directs me to
> a py file, containing the following code:
> def format(*args, **kwargs): # known special case of str.format
> """
> S.format(*args, **kwargs) -> string
>
> Return a formatted version of S, using substitutions from args and
> kwargs.
> The substitutions are identified by braces ('{' and '}').
> """
> pass
I would guess that Python declaration is maintained and used by
PyCharm for code intelligence.
> I am curious how you find the corresponding c source code.
The str object is mostly implemented in Objects/unicodeobject.c. The
int object is mostly implemented in Objects/longobject.c. Other
built-in types can also be found in that directory. Each has a
PyMethodDef[] global array that declares the implementations of the
object's methods. Finding the implementation is then just a matter of
grepping the source for its name.
The function I pointed you to before implements the str.__format__
method. The str.format method itself is at:
http://hg.python.org/cpython/file/84e73ace3d7e/Objects/stringlib/unicode_format.h#l942
I'm not sure why that one is implemented in a .h file.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python3 string format Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-26 09:07 -0600
csiph-web