Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: python3 string format

Thread Tools

Re: python3 string format

Ian Kelly
Posts: n/a
On Tue, Mar 26, 2013 at 4:51 AM, Shiyao Ma <(E-Mail Removed)> 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:

I'm not sure why that one is implemented in a .h file.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: python3 string format Shiyao Ma Python 0 03-26-2013 10:51 AM
Re: python3 string format Ian Kelly Python 0 03-26-2013 06:16 AM
python3 string format Shiyao Ma Python 0 03-26-2013 04:24 AM
Re: raw format string in string format method? Chris Angelico Python 3 03-01-2013 12:00 AM
Re: is the same betweent python3 and python3.2? Andrew Berg Python 0 06-16-2012 11:11 AM