[capi-sig] String to number conversion

M.-A. Lemburg mal at egenix.com
Wed May 7 19:30:17 CEST 2008


On 2008-05-07 19:14, Rasmus Andersson wrote:
> 
> On 7 maj 2008, at 19.03, M.-A. Lemburg wrote:
 >
>>>> Not really. The point of the PyNumber_* API is to work on numbers
>>>> without actually caring or knowing the specific number types
>>>> (Include/abstract.h).
>>> Yes I know, but I can't really see a big need for this kind of 
>>> functionality in practice, but please, enlighten me! (maybe with a 
>>> scenario)
>>
>> Didn't I just give you a few ?
> 
> Either I'm unusually stupid today or I missed something -- where is the 
> scenario (using this proposed functionality in real world)? (sorry)

You asked for example of using the PyNumber_* API. All of these
can use strings as input for the processing chain:

  * work with numbers regardless of type, do the final
    conversion at the end

    (you only care about the final type)

  * work with numbers, creating Python objects that can be
    passed to other Python mechanisms such as marshal

    (you only care about the fact that you're dealing with
    a number, not the type)

  * parsing numeric data and preparing it for conversion to
    some other format, e.g. using PyString_Format()

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 07 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611


More information about the capi-sig mailing list