pymoney-general Mailing List for PyMoney
Brought to you by:
facundobatista
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(2) |
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: Jeff K. <jt...@ya...> - 2005-07-02 12:56:12
|
Facundo Batista wrote: > The order of distrib() results is not assured. If it doesn't slow down the distrib() implementation (i.e. only a sort() before returning), then perhaps the order of the results (if splitting on only one divider) should be assured, and selected with a keyword argument, defaulting to descending order. If the results of distrib() are unsorted, most applications using the method (again in the case of a single divider) will implement the same boilerplate to sort in ascending or descending order after each call. distrib_multiple() could be a separate method, to support a list of dividers mentioned in option 3. I think support for multiple dividers should be in there somehow, since it will be kind of tricky for most library users to implement a correct one on their own if they have a need. |
From: Jeff K. <jt...@ya...> - 2005-07-02 12:40:31
|
Facundo Batista wrote: > The basic idea is to distribute a Currency amount between different > parts, and being sure that you're not losing information (well, money, > ;). But we saw three methods of doing it: > >>> Currency(1).distrib(3) > [Currency("0.33"), Currency("0.33"), Currency("0.34")] This is an easily understood example of why the distrib() method will be necessary for Currency objects. It hadn't really sunk in until Raymond mentioned pymoney's missing '/' operator on python-dev. Something like the 1-into-3 example should always be prominently mentioned in the documentation, as well as the docstring for distrib(). It should probably also appear in some sort of exception message when a user tries to use division with a Currency object. It would also be useful to show for comparison a correct and efficient distrib() for Decimal objects. If the recommendation is to convert to Decimal when doing averages and other risky/lossy math, then it would be good to show the cannonical Decimal distrib() function in convenient location in the pymoney docs. A distrib() function should not be added to stdlib decimal, obviously. |
From: Jeff K. <jt...@ya...> - 2005-07-02 04:07:49
|
FWIW, I think that pymoney should consider a system of abstract multiple currencies if the goal is an eventual PEP and inclusion into the python stdlib. Hardcoding even relatively static ISO standards data into python stdlib seems like a backward compatibility headache in the making. It would seem like an add-on library will be necessary for any non-trivial application *using* pymoney currency features, so maybe the data should reside there, keeping the currency-neutral portion of pymoney-proper as small as possible. Perhaps an XML or YAML file format containing ISO and other concrete currency data could be shared among Python, Perl, PHP and Ruby. This shared data would be encoded into python source when pymoney(-addon) releases are made. |
From: Jeff K. <jt...@ya...> - 2005-07-02 03:46:27
|
Per my original suggestion, here are some mappings of ISO country code to ISO currency code. If anyone is planning pymoney's API design, they may provide a useful experimental tool, or a starting point for more refined mappings. I'm not the right person to comment on the utility of these types of mappings, I generally only work with local USD currency. I just thought I'd follow through on my initial idea and see what multicurrency people come up with after looking it over. (eliminate attachment of file currencymappings.py, exceeds 40kb posting limit) # Map of ISO country codes to ISO currency codes # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible cntry_to_curr = { 'AF' : ('AFN',), 'AL' : ('ALL',), 'DZ' : ('DZD',), 'AS' : ('USD',), 'AD' : ('EUR',), 'AO' : ('AOA',), 'AI' : ('XCD',), 'AQ' : None, 'AG' : ('XCD',), 'AR' : ('ARS',), 'AM' : ('AMD',), 'AW' : ('AWG',), 'AU' : ('AUD',), 'AT' : ('EUR',), 'AZ' : ('AZM',), 'BS' : ('BSD',), 'BH' : ('BHD',), 'BD' : ('BDT',), 'BB' : ('BBD',), 'BY' : ('BYR',), 'BE' : ('EUR',), 'BZ' : ('BZD',), 'BJ' : ('XOF',), 'BM' : ('BMD',), 'BT' : ('BTN',), 'BO' : ('BOB',), 'BA' : ('BAM',), 'BW' : ('BWP',), 'BV' : None, 'BR' : ('BRL',), 'IO' : None, 'VG' : ('USD',), 'BN' : ('BND',), 'BG' : ('BGN',), 'BF' : ('XOF',), 'BI' : ('BIF',), 'KH' : ('KHR',), 'CM' : ('XAF',), 'CA' : ('CAD',), 'CV' : ('CVE',), 'KY' : ('KYD',), 'CF' : ('XAF',), 'TD' : ('XAF',), 'CL' : ('CLP',), 'CN' : ('CNY',), 'CX' : ('AUD',), 'CC' : ('AUD',), 'CO' : ('COP',), 'KM' : ('KMF',), 'CG' : ('XAF',), 'CK' : ('NZD',), 'CR' : ('CRC',), 'CI' : ('XOF',), 'HR' : ('HRK',), 'CU' : ('CUP',), 'CY' : ('CYP',), 'CZ' : ('CZK',), 'CD' : ('CDF',), 'DK' : ('DKK',), 'DJ' : ('DJF',), 'DM' : ('XCD',), 'DO' : ('DOP',), 'EC' : ('USD',), 'EG' : ('EGP',), 'SV' : ('USD', 'SVC'), 'GQ' : ('XAF',), 'ER' : ('ERN',), 'EE' : ('EEK',), 'ET' : ('ETB',), 'FO' : ('DKK',), 'FK' : ('FKP',), 'FJ' : ('FJD',), 'FI' : ('EUR',), 'MK' : ('MKD',), 'FR' : ('EUR',), 'GF' : ('EUR',), 'PF' : ('XPF',), 'TF' : None, 'GA' : ('XAF',), 'GM' : ('GMD',), 'GE' : ('GEL',), 'DE' : ('EUR',), 'GH' : ('GHC',), 'GI' : ('GIP',), 'GR' : ('EUR',), 'GL' : ('DKK',), 'GD' : ('XCD',), 'GP' : ('EUR',), 'GU' : ('USD',), 'GT' : ('GTQ',), 'GN' : ('GNF',), 'GW' : ('XOF',), 'GY' : ('GYD',), 'HT' : ('HTG',), 'HM' : None, 'HN' : ('HNL',), 'HK' : ('HKD',), 'HU' : ('HUF',), 'IS' : ('ISK',), 'IN' : ('INR',), 'ID' : ('IDR',), 'IR' : ('IRR',), 'IQ' : ('IQD',), 'IE' : ('EUR',), 'IL' : ('ILS',), 'IT' : ('EUR',), 'JM' : ('JMD',), 'JP' : ('JPY',), 'JO' : ('JOD',), 'KZ' : ('KZT',), 'KE' : ('KES',), 'KI' : ('AUD',), 'KW' : ('KWD',), 'KG' : ('KGS',), 'LA' : ('LAK',), 'LV' : ('LVL',), 'LB' : ('LBP',), 'LS' : ('LSL',), 'LR' : ('LRD',), 'LY' : ('LYD',), 'LI' : ('CHF',), 'LT' : ('LTL',), 'LU' : ('EUR',), 'MO' : ('MOP',), 'MG' : ('MGF',), 'MW' : ('MWK',), 'MY' : ('MYR',), 'MV' : ('MVR',), 'ML' : ('XOF',), 'MT' : ('MTL',), 'MH' : ('USD',), 'MQ' : ('EUR',), 'MR' : ('MRO',), 'MU' : ('MUR',), 'YT' : ('EUR',), 'MX' : ('MXN',), 'FM' : ('USD',), 'MD' : ('MDL',), 'MC' : ('EUR',), 'MN' : ('MNT',), 'MS' : ('XCD',), 'MA' : ('MAD',), 'MZ' : ('MZM',), 'MM' : ('MMK',), 'NA' : ('NAD','ZAR'), 'NR' : ('AUD',), 'NP' : ('NPR',), 'NL' : ('EUR',), 'AN' : ('ANG',), 'NC' : ('XPF',), 'NZ' : ('NZD',), 'NI' : ('NIO',), 'NE' : ('XOF',), 'NG' : ('NGN',), 'NU' : ('NZD',), 'NF' : ('AUD',), 'KP' : ('KPW',), 'MP' : ('USD',), 'NO' : ('NOK',), 'OM' : ('OMR',), 'PK' : ('PKR',), 'PW' : ('USD',), 'PA' : ('PAB',), 'PG' : ('PGK',), 'PY' : ('PYG',), 'PE' : ('PEN',), 'PH' : ('PHP',), 'PN' : ('NZD',), 'PL' : ('PLN',), 'PT' : ('EUR',), 'PR' : ('USD',), 'QA' : ('QAR',), 'RE' : ('EUR',), 'RO' : ('ROL',), 'RU' : ('RUB',), 'RW' : ('RWF',), 'SH' : ('SHP',), 'KN' : ('XCD',), 'LC' : ('XCD',), 'PM' : ('EUR',), 'VC' : ('XCD',), 'WS' : ('WST',), 'SM' : ('EUR',), 'ST' : ('STD',), 'SA' : ('SAR',), 'SN' : ('XOF',), 'CS' : ('CSD','EUR'), 'SC' : ('SCR',), 'SL' : ('SLL',), 'SG' : ('SGD',), 'SK' : ('SKK',), 'SI' : ('SIT',), 'SB' : ('SBD',), 'SO' : ('SOS',), 'ZA' : ('ZAR',), 'GS' : None, 'KR' : ('KRW',), 'ES' : ('EUR',), 'LK' : ('LKR',), 'SD' : ('SDD',), 'SR' : ('SRG',), 'SJ' : ('NOK',), 'SZ' : ('SZL',), 'SE' : ('SEK',), 'CH' : ('CHF',), 'SY' : ('SYP',), 'TW' : ('TWD',), 'TJ' : ('TJS',), 'TZ' : ('TZS',), 'TH' : ('THB',), 'TL' : ('USD',), 'TG' : ('XOF',), 'TK' : ('NZD',), 'TO' : ('TOP',), 'TT' : ('TTD',), 'TN' : ('TND',), 'TR' : ('TRL',), 'TM' : ('TMM',), 'TC' : ('USD',), 'TV' : ('AUD',), 'UG' : ('UGX',), 'UA' : ('UAH',), 'AE' : ('AED',), 'GB' : ('GBP',), 'US' : ('USD',), 'UM' : None, 'UY' : ('UYU',), 'VI' : ('USD',), 'UZ' : ('UZS',), 'VU' : ('VUV',), 'VA' : ('EUR',), 'VE' : ('VEB',), 'VN' : ('VND',), 'WF' : ('XPF',), 'EH' : ('MAD',), 'YE' : ('YER',), 'ZM' : ('ZMK',), 'ZW' : ('ZWD',), } # Map assigning unique names to combinations of ISO country # codes and ISO currency codes. # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible # TODO: Eliminate None-value currency entries, or keep? # Proposal 1: # 2 letter country code, dash, ISO currency code curr_unique_map1 = { 'AD-EUR' : ('AD','EUR'), 'AE-AED' : ('AE','AED'), 'AF-AFN' : ('AF','AFN'), 'AG-XCD' : ('AG','XCD'), 'AI-XCD' : ('AI','XCD'), 'AL-ALL' : ('AL','ALL'), 'AM-AMD' : ('AM','AMD'), 'AN-ANG' : ('AN','ANG'), 'AO-AOA' : ('AO','AOA'), #'AQ-None' : ('AQ','None'), 'AR-ARS' : ('AR','ARS'), 'AS-USD' : ('AS','USD'), 'AT-EUR' : ('AT','EUR'), 'AU-AUD' : ('AU','AUD'), 'AW-AWG' : ('AW','AWG'), 'AZ-AZM' : ('AZ','AZM'), 'BA-BAM' : ('BA','BAM'), 'BB-BBD' : ('BB','BBD'), 'BD-BDT' : ('BD','BDT'), 'BE-EUR' : ('BE','EUR'), 'BF-XOF' : ('BF','XOF'), 'BG-BGN' : ('BG','BGN'), 'BH-BHD' : ('BH','BHD'), 'BI-BIF' : ('BI','BIF'), 'BJ-XOF' : ('BJ','XOF'), 'BM-BMD' : ('BM','BMD'), 'BN-BND' : ('BN','BND'), 'BO-BOB' : ('BO','BOB'), 'BR-BRL' : ('BR','BRL'), 'BS-BSD' : ('BS','BSD'), 'BT-BTN' : ('BT','BTN'), #'BV-None' : ('BV','None'), 'BW-BWP' : ('BW','BWP'), 'BY-BYR' : ('BY','BYR'), 'BZ-BZD' : ('BZ','BZD'), 'CA-CAD' : ('CA','CAD'), 'CC-AUD' : ('CC','AUD'), 'CD-CDF' : ('CD','CDF'), 'CF-XAF' : ('CF','XAF'), 'CG-XAF' : ('CG','XAF'), 'CH-CHF' : ('CH','CHF'), 'CI-XOF' : ('CI','XOF'), 'CK-NZD' : ('CK','NZD'), 'CL-CLP' : ('CL','CLP'), 'CM-XAF' : ('CM','XAF'), 'CN-CNY' : ('CN','CNY'), 'CO-COP' : ('CO','COP'), 'CR-CRC' : ('CR','CRC'), 'CS-CSD' : ('CS','CSD'), 'CS-EUR' : ('CS','EUR'), 'CU-CUP' : ('CU','CUP'), 'CV-CVE' : ('CV','CVE'), 'CX-AUD' : ('CX','AUD'), 'CY-CYP' : ('CY','CYP'), 'CZ-CZK' : ('CZ','CZK'), 'DE-EUR' : ('DE','EUR'), 'DJ-DJF' : ('DJ','DJF'), 'DK-DKK' : ('DK','DKK'), 'DM-XCD' : ('DM','XCD'), 'DO-DOP' : ('DO','DOP'), 'DZ-DZD' : ('DZ','DZD'), 'EC-USD' : ('EC','USD'), 'EE-EEK' : ('EE','EEK'), 'EG-EGP' : ('EG','EGP'), 'EH-MAD' : ('EH','MAD'), 'ER-ERN' : ('ER','ERN'), 'ES-EUR' : ('ES','EUR'), 'ET-ETB' : ('ET','ETB'), 'FI-EUR' : ('FI','EUR'), 'FJ-FJD' : ('FJ','FJD'), 'FK-FKP' : ('FK','FKP'), 'FM-USD' : ('FM','USD'), 'FO-DKK' : ('FO','DKK'), 'FR-EUR' : ('FR','EUR'), 'GA-XAF' : ('GA','XAF'), 'GB-GBP' : ('GB','GBP'), 'GD-XCD' : ('GD','XCD'), 'GE-GEL' : ('GE','GEL'), 'GF-EUR' : ('GF','EUR'), 'GH-GHC' : ('GH','GHC'), 'GI-GIP' : ('GI','GIP'), 'GL-DKK' : ('GL','DKK'), 'GM-GMD' : ('GM','GMD'), 'GN-GNF' : ('GN','GNF'), 'GP-EUR' : ('GP','EUR'), 'GQ-XAF' : ('GQ','XAF'), 'GR-EUR' : ('GR','EUR'), #'GS-None' : ('GS','None'), 'GT-GTQ' : ('GT','GTQ'), 'GU-USD' : ('GU','USD'), 'GW-XOF' : ('GW','XOF'), 'GY-GYD' : ('GY','GYD'), 'HK-HKD' : ('HK','HKD'), #'HM-None' : ('HM','None'), 'HN-HNL' : ('HN','HNL'), 'HR-HRK' : ('HR','HRK'), 'HT-HTG' : ('HT','HTG'), 'HU-HUF' : ('HU','HUF'), 'ID-IDR' : ('ID','IDR'), 'IE-EUR' : ('IE','EUR'), 'IL-ILS' : ('IL','ILS'), 'IN-INR' : ('IN','INR'), #'IO-None' : ('IO','None'), 'IQ-IQD' : ('IQ','IQD'), 'IR-IRR' : ('IR','IRR'), 'IS-ISK' : ('IS','ISK'), 'IT-EUR' : ('IT','EUR'), 'JM-JMD' : ('JM','JMD'), 'JO-JOD' : ('JO','JOD'), 'JP-JPY' : ('JP','JPY'), 'KE-KES' : ('KE','KES'), 'KG-KGS' : ('KG','KGS'), 'KH-KHR' : ('KH','KHR'), 'KI-AUD' : ('KI','AUD'), 'KM-KMF' : ('KM','KMF'), 'KN-XCD' : ('KN','XCD'), 'KP-KPW' : ('KP','KPW'), 'KR-KRW' : ('KR','KRW'), 'KW-KWD' : ('KW','KWD'), 'KY-KYD' : ('KY','KYD'), 'KZ-KZT' : ('KZ','KZT'), 'LA-LAK' : ('LA','LAK'), 'LB-LBP' : ('LB','LBP'), 'LC-XCD' : ('LC','XCD'), 'LI-CHF' : ('LI','CHF'), 'LK-LKR' : ('LK','LKR'), 'LR-LRD' : ('LR','LRD'), 'LS-LSL' : ('LS','LSL'), 'LT-LTL' : ('LT','LTL'), 'LU-EUR' : ('LU','EUR'), 'LV-LVL' : ('LV','LVL'), 'LY-LYD' : ('LY','LYD'), 'MA-MAD' : ('MA','MAD'), 'MC-EUR' : ('MC','EUR'), 'MD-MDL' : ('MD','MDL'), 'MG-MGF' : ('MG','MGF'), 'MH-USD' : ('MH','USD'), 'MK-MKD' : ('MK','MKD'), 'ML-XOF' : ('ML','XOF'), 'MM-MMK' : ('MM','MMK'), 'MN-MNT' : ('MN','MNT'), 'MO-MOP' : ('MO','MOP'), 'MP-USD' : ('MP','USD'), 'MQ-EUR' : ('MQ','EUR'), 'MR-MRO' : ('MR','MRO'), 'MS-XCD' : ('MS','XCD'), 'MT-MTL' : ('MT','MTL'), 'MU-MUR' : ('MU','MUR'), 'MV-MVR' : ('MV','MVR'), 'MW-MWK' : ('MW','MWK'), 'MX-MXN' : ('MX','MXN'), 'MY-MYR' : ('MY','MYR'), 'MZ-MZM' : ('MZ','MZM'), 'NA-NAD' : ('NA','NAD'), 'NA-ZAR' : ('NA','ZAR'), 'NC-XPF' : ('NC','XPF'), 'NE-XOF' : ('NE','XOF'), 'NF-AUD' : ('NF','AUD'), 'NG-NGN' : ('NG','NGN'), 'NI-NIO' : ('NI','NIO'), 'NL-EUR' : ('NL','EUR'), 'NO-NOK' : ('NO','NOK'), 'NP-NPR' : ('NP','NPR'), 'NR-AUD' : ('NR','AUD'), 'NU-NZD' : ('NU','NZD'), 'NZ-NZD' : ('NZ','NZD'), 'OM-OMR' : ('OM','OMR'), 'PA-PAB' : ('PA','PAB'), 'PE-PEN' : ('PE','PEN'), 'PF-XPF' : ('PF','XPF'), 'PG-PGK' : ('PG','PGK'), 'PH-PHP' : ('PH','PHP'), 'PK-PKR' : ('PK','PKR'), 'PL-PLN' : ('PL','PLN'), 'PM-EUR' : ('PM','EUR'), 'PN-NZD' : ('PN','NZD'), 'PR-USD' : ('PR','USD'), 'PT-EUR' : ('PT','EUR'), 'PW-USD' : ('PW','USD'), 'PY-PYG' : ('PY','PYG'), 'QA-QAR' : ('QA','QAR'), 'RE-EUR' : ('RE','EUR'), 'RO-ROL' : ('RO','ROL'), 'RU-RUB' : ('RU','RUB'), 'RW-RWF' : ('RW','RWF'), 'SA-SAR' : ('SA','SAR'), 'SB-SBD' : ('SB','SBD'), 'SC-SCR' : ('SC','SCR'), 'SD-SDD' : ('SD','SDD'), 'SE-SEK' : ('SE','SEK'), 'SG-SGD' : ('SG','SGD'), 'SH-SHP' : ('SH','SHP'), 'SI-SIT' : ('SI','SIT'), 'SJ-NOK' : ('SJ','NOK'), 'SK-SKK' : ('SK','SKK'), 'SL-SLL' : ('SL','SLL'), 'SM-EUR' : ('SM','EUR'), 'SN-XOF' : ('SN','XOF'), 'SO-SOS' : ('SO','SOS'), 'SR-SRG' : ('SR','SRG'), 'ST-STD' : ('ST','STD'), 'SV-SVC' : ('SV','SVC'), 'SV-USD' : ('SV','USD'), 'SY-SYP' : ('SY','SYP'), 'SZ-SZL' : ('SZ','SZL'), 'TC-USD' : ('TC','USD'), 'TD-XAF' : ('TD','XAF'), #'TF-None' : ('TF','None'), 'TG-XOF' : ('TG','XOF'), 'TH-THB' : ('TH','THB'), 'TJ-TJS' : ('TJ','TJS'), 'TK-NZD' : ('TK','NZD'), 'TL-USD' : ('TL','USD'), 'TM-TMM' : ('TM','TMM'), 'TN-TND' : ('TN','TND'), 'TO-TOP' : ('TO','TOP'), 'TR-TRL' : ('TR','TRL'), 'TT-TTD' : ('TT','TTD'), 'TV-AUD' : ('TV','AUD'), 'TW-TWD' : ('TW','TWD'), 'TZ-TZS' : ('TZ','TZS'), 'UA-UAH' : ('UA','UAH'), 'UG-UGX' : ('UG','UGX'), #'UM-None' : ('UM','None'), 'US-USD' : ('US','USD'), 'UY-UYU' : ('UY','UYU'), 'UZ-UZS' : ('UZ','UZS'), 'VA-EUR' : ('VA','EUR'), 'VC-XCD' : ('VC','XCD'), 'VE-VEB' : ('VE','VEB'), 'VG-USD' : ('VG','USD'), 'VI-USD' : ('VI','USD'), 'VN-VND' : ('VN','VND'), 'VU-VUV' : ('VU','VUV'), 'WF-XPF' : ('WF','XPF'), 'WS-WST' : ('WS','WST'), 'YE-YER' : ('YE','YER'), 'YT-EUR' : ('YT','EUR'), 'ZA-ZAR' : ('ZA','ZAR'), 'ZM-ZMK' : ('ZM','ZMK'), 'ZW-ZWD' : ('ZW','ZWD'), } # Map assigning unique names to combinations of ISO country # codes and ISO currency codes. # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible # TODO: Eliminate None-value currency entries, or keep? # Proposal 2: # 2 letter country code, first letter of ISO currency code curr_unique_map2 = { 'ADE' : ('AD','EUR'), 'AEA' : ('AE','AED'), 'AFA' : ('AF','AFN'), 'AGX' : ('AG','XCD'), 'AIX' : ('AI','XCD'), 'ALA' : ('AL','ALL'), 'AMA' : ('AM','AMD'), 'ANA' : ('AN','ANG'), 'AOA' : ('AO','AOA'), #'AQN' : ('AQ','None'), 'ARA' : ('AR','ARS'), 'ASU' : ('AS','USD'), 'ATE' : ('AT','EUR'), 'AUA' : ('AU','AUD'), 'AWA' : ('AW','AWG'), 'AZA' : ('AZ','AZM'), 'BAB' : ('BA','BAM'), 'BBB' : ('BB','BBD'), 'BDB' : ('BD','BDT'), 'BEE' : ('BE','EUR'), 'BFX' : ('BF','XOF'), 'BGB' : ('BG','BGN'), 'BHB' : ('BH','BHD'), 'BIB' : ('BI','BIF'), 'BJX' : ('BJ','XOF'), 'BMB' : ('BM','BMD'), 'BNB' : ('BN','BND'), 'BOB' : ('BO','BOB'), 'BRB' : ('BR','BRL'), 'BSB' : ('BS','BSD'), 'BTB' : ('BT','BTN'), #'BVN' : ('BV','None'), 'BWB' : ('BW','BWP'), 'BYB' : ('BY','BYR'), 'BZB' : ('BZ','BZD'), 'CAC' : ('CA','CAD'), 'CCA' : ('CC','AUD'), 'CDC' : ('CD','CDF'), 'CFX' : ('CF','XAF'), 'CGX' : ('CG','XAF'), 'CHC' : ('CH','CHF'), 'CIX' : ('CI','XOF'), 'CKN' : ('CK','NZD'), 'CLC' : ('CL','CLP'), 'CMX' : ('CM','XAF'), 'CNC' : ('CN','CNY'), 'COC' : ('CO','COP'), 'CRC' : ('CR','CRC'), 'CSC' : ('CS','CSD'), 'CSE' : ('CS','EUR'), 'CUC' : ('CU','CUP'), 'CVC' : ('CV','CVE'), 'CXA' : ('CX','AUD'), 'CYC' : ('CY','CYP'), 'CZC' : ('CZ','CZK'), 'DEE' : ('DE','EUR'), 'DJD' : ('DJ','DJF'), 'DKD' : ('DK','DKK'), 'DMX' : ('DM','XCD'), 'DOD' : ('DO','DOP'), 'DZD' : ('DZ','DZD'), 'ECU' : ('EC','USD'), 'EEE' : ('EE','EEK'), 'EGE' : ('EG','EGP'), 'EHM' : ('EH','MAD'), 'ERE' : ('ER','ERN'), 'ESE' : ('ES','EUR'), 'ETE' : ('ET','ETB'), 'FIE' : ('FI','EUR'), 'FJF' : ('FJ','FJD'), 'FKF' : ('FK','FKP'), 'FMU' : ('FM','USD'), 'FOD' : ('FO','DKK'), 'FRE' : ('FR','EUR'), 'GAX' : ('GA','XAF'), 'GBG' : ('GB','GBP'), 'GDX' : ('GD','XCD'), 'GEG' : ('GE','GEL'), 'GFE' : ('GF','EUR'), 'GHG' : ('GH','GHC'), 'GIG' : ('GI','GIP'), 'GLD' : ('GL','DKK'), 'GMG' : ('GM','GMD'), 'GNG' : ('GN','GNF'), 'GPE' : ('GP','EUR'), 'GQX' : ('GQ','XAF'), 'GRE' : ('GR','EUR'), #'GSN' : ('GS','None'), 'GTG' : ('GT','GTQ'), 'GUU' : ('GU','USD'), 'GWX' : ('GW','XOF'), 'GYG' : ('GY','GYD'), 'HKH' : ('HK','HKD'), #'HMN' : ('HM','None'), 'HNH' : ('HN','HNL'), 'HRH' : ('HR','HRK'), 'HTH' : ('HT','HTG'), 'HUH' : ('HU','HUF'), 'IDI' : ('ID','IDR'), 'IEE' : ('IE','EUR'), 'ILI' : ('IL','ILS'), 'INI' : ('IN','INR'), #'ION' : ('IO','None'), 'IQI' : ('IQ','IQD'), 'IRI' : ('IR','IRR'), 'ISI' : ('IS','ISK'), 'ITE' : ('IT','EUR'), 'JMJ' : ('JM','JMD'), 'JOJ' : ('JO','JOD'), 'JPJ' : ('JP','JPY'), 'KEK' : ('KE','KES'), 'KGK' : ('KG','KGS'), 'KHK' : ('KH','KHR'), 'KIA' : ('KI','AUD'), 'KMK' : ('KM','KMF'), 'KNX' : ('KN','XCD'), 'KPK' : ('KP','KPW'), 'KRK' : ('KR','KRW'), 'KWK' : ('KW','KWD'), 'KYK' : ('KY','KYD'), 'KZK' : ('KZ','KZT'), 'LAL' : ('LA','LAK'), 'LBL' : ('LB','LBP'), 'LCX' : ('LC','XCD'), 'LIC' : ('LI','CHF'), 'LKL' : ('LK','LKR'), 'LRL' : ('LR','LRD'), 'LSL' : ('LS','LSL'), 'LTL' : ('LT','LTL'), 'LUE' : ('LU','EUR'), 'LVL' : ('LV','LVL'), 'LYL' : ('LY','LYD'), 'MAM' : ('MA','MAD'), 'MCE' : ('MC','EUR'), 'MDM' : ('MD','MDL'), 'MGM' : ('MG','MGF'), 'MHU' : ('MH','USD'), 'MKM' : ('MK','MKD'), 'MLX' : ('ML','XOF'), 'MMM' : ('MM','MMK'), 'MNM' : ('MN','MNT'), 'MOM' : ('MO','MOP'), 'MPU' : ('MP','USD'), 'MQE' : ('MQ','EUR'), 'MRM' : ('MR','MRO'), 'MSX' : ('MS','XCD'), 'MTM' : ('MT','MTL'), 'MUM' : ('MU','MUR'), 'MVM' : ('MV','MVR'), 'MWM' : ('MW','MWK'), 'MXM' : ('MX','MXN'), 'MYM' : ('MY','MYR'), 'MZM' : ('MZ','MZM'), 'NAN' : ('NA','NAD'), 'NAZ' : ('NA','ZAR'), 'NCX' : ('NC','XPF'), 'NEX' : ('NE','XOF'), 'NFA' : ('NF','AUD'), 'NGN' : ('NG','NGN'), 'NIN' : ('NI','NIO'), 'NLE' : ('NL','EUR'), 'NON' : ('NO','NOK'), 'NPN' : ('NP','NPR'), 'NRA' : ('NR','AUD'), 'NUN' : ('NU','NZD'), 'NZN' : ('NZ','NZD'), 'OMO' : ('OM','OMR'), 'PAP' : ('PA','PAB'), 'PEP' : ('PE','PEN'), 'PFX' : ('PF','XPF'), 'PGP' : ('PG','PGK'), 'PHP' : ('PH','PHP'), 'PKP' : ('PK','PKR'), 'PLP' : ('PL','PLN'), 'PME' : ('PM','EUR'), 'PNN' : ('PN','NZD'), 'PRU' : ('PR','USD'), 'PTE' : ('PT','EUR'), 'PWU' : ('PW','USD'), 'PYP' : ('PY','PYG'), 'QAQ' : ('QA','QAR'), 'REE' : ('RE','EUR'), 'ROR' : ('RO','ROL'), 'RUR' : ('RU','RUB'), 'RWR' : ('RW','RWF'), 'SAS' : ('SA','SAR'), 'SBS' : ('SB','SBD'), 'SCS' : ('SC','SCR'), 'SDS' : ('SD','SDD'), 'SES' : ('SE','SEK'), 'SGS' : ('SG','SGD'), 'SHS' : ('SH','SHP'), 'SIS' : ('SI','SIT'), 'SJN' : ('SJ','NOK'), 'SKS' : ('SK','SKK'), 'SLS' : ('SL','SLL'), 'SME' : ('SM','EUR'), 'SNX' : ('SN','XOF'), 'SOS' : ('SO','SOS'), 'SRS' : ('SR','SRG'), 'STS' : ('ST','STD'), 'SVS' : ('SV','SVC'), 'SVU' : ('SV','USD'), 'SYS' : ('SY','SYP'), 'SZS' : ('SZ','SZL'), 'TCU' : ('TC','USD'), 'TDX' : ('TD','XAF'), #'TFN' : ('TF','None'), 'TGX' : ('TG','XOF'), 'THT' : ('TH','THB'), 'TJT' : ('TJ','TJS'), 'TKN' : ('TK','NZD'), 'TLU' : ('TL','USD'), 'TMT' : ('TM','TMM'), 'TNT' : ('TN','TND'), 'TOT' : ('TO','TOP'), 'TRT' : ('TR','TRL'), 'TTT' : ('TT','TTD'), 'TVA' : ('TV','AUD'), 'TWT' : ('TW','TWD'), 'TZT' : ('TZ','TZS'), 'UAU' : ('UA','UAH'), 'UGU' : ('UG','UGX'), #'UMN' : ('UM','None'), 'USU' : ('US','USD'), 'UYU' : ('UY','UYU'), 'UZU' : ('UZ','UZS'), 'VAE' : ('VA','EUR'), 'VCX' : ('VC','XCD'), 'VEV' : ('VE','VEB'), 'VGU' : ('VG','USD'), 'VIU' : ('VI','USD'), 'VNV' : ('VN','VND'), 'VUV' : ('VU','VUV'), 'WFX' : ('WF','XPF'), 'WSW' : ('WS','WST'), 'YEY' : ('YE','YER'), 'YTE' : ('YT','EUR'), 'ZAZ' : ('ZA','ZAR'), 'ZMZ' : ('ZM','ZMK'), 'ZWZ' : ('ZW','ZWD'), } ____________________________________________________ Yahoo! Sports Rekindle the Rivalries. Sign up for Fantasy Football http://football.fantasysports.yahoo.com |
From: Jeff K. <jt...@ya...> - 2005-07-02 03:41:55
|
Per my original suggestion, here are some mappings of ISO country code to ISO currency code. If anyone is planning pymoney's API design, they may provide a useful experimental tool, or a starting point for more refined mappings. I'm not the right person to comment on the utility of these types of mappings, I generally only work with local USD currency. I just thought I'd follow through on my initial idea and see what multicurrency people come up with after looking it over. (also attached as file currencymappings.py, probably merge into pymoney_dat.py) # Map of ISO country codes to ISO currency codes # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible cntry_to_curr = { 'AF' : ('AFN',), 'AL' : ('ALL',), 'DZ' : ('DZD',), 'AS' : ('USD',), 'AD' : ('EUR',), 'AO' : ('AOA',), 'AI' : ('XCD',), 'AQ' : None, 'AG' : ('XCD',), 'AR' : ('ARS',), 'AM' : ('AMD',), 'AW' : ('AWG',), 'AU' : ('AUD',), 'AT' : ('EUR',), 'AZ' : ('AZM',), 'BS' : ('BSD',), 'BH' : ('BHD',), 'BD' : ('BDT',), 'BB' : ('BBD',), 'BY' : ('BYR',), 'BE' : ('EUR',), 'BZ' : ('BZD',), 'BJ' : ('XOF',), 'BM' : ('BMD',), 'BT' : ('BTN',), 'BO' : ('BOB',), 'BA' : ('BAM',), 'BW' : ('BWP',), 'BV' : None, 'BR' : ('BRL',), 'IO' : None, 'VG' : ('USD',), 'BN' : ('BND',), 'BG' : ('BGN',), 'BF' : ('XOF',), 'BI' : ('BIF',), 'KH' : ('KHR',), 'CM' : ('XAF',), 'CA' : ('CAD',), 'CV' : ('CVE',), 'KY' : ('KYD',), 'CF' : ('XAF',), 'TD' : ('XAF',), 'CL' : ('CLP',), 'CN' : ('CNY',), 'CX' : ('AUD',), 'CC' : ('AUD',), 'CO' : ('COP',), 'KM' : ('KMF',), 'CG' : ('XAF',), 'CK' : ('NZD',), 'CR' : ('CRC',), 'CI' : ('XOF',), 'HR' : ('HRK',), 'CU' : ('CUP',), 'CY' : ('CYP',), 'CZ' : ('CZK',), 'CD' : ('CDF',), 'DK' : ('DKK',), 'DJ' : ('DJF',), 'DM' : ('XCD',), 'DO' : ('DOP',), 'EC' : ('USD',), 'EG' : ('EGP',), 'SV' : ('USD', 'SVC'), 'GQ' : ('XAF',), 'ER' : ('ERN',), 'EE' : ('EEK',), 'ET' : ('ETB',), 'FO' : ('DKK',), 'FK' : ('FKP',), 'FJ' : ('FJD',), 'FI' : ('EUR',), 'MK' : ('MKD',), 'FR' : ('EUR',), 'GF' : ('EUR',), 'PF' : ('XPF',), 'TF' : None, 'GA' : ('XAF',), 'GM' : ('GMD',), 'GE' : ('GEL',), 'DE' : ('EUR',), 'GH' : ('GHC',), 'GI' : ('GIP',), 'GR' : ('EUR',), 'GL' : ('DKK',), 'GD' : ('XCD',), 'GP' : ('EUR',), 'GU' : ('USD',), 'GT' : ('GTQ',), 'GN' : ('GNF',), 'GW' : ('XOF',), 'GY' : ('GYD',), 'HT' : ('HTG',), 'HM' : None, 'HN' : ('HNL',), 'HK' : ('HKD',), 'HU' : ('HUF',), 'IS' : ('ISK',), 'IN' : ('INR',), 'ID' : ('IDR',), 'IR' : ('IRR',), 'IQ' : ('IQD',), 'IE' : ('EUR',), 'IL' : ('ILS',), 'IT' : ('EUR',), 'JM' : ('JMD',), 'JP' : ('JPY',), 'JO' : ('JOD',), 'KZ' : ('KZT',), 'KE' : ('KES',), 'KI' : ('AUD',), 'KW' : ('KWD',), 'KG' : ('KGS',), 'LA' : ('LAK',), 'LV' : ('LVL',), 'LB' : ('LBP',), 'LS' : ('LSL',), 'LR' : ('LRD',), 'LY' : ('LYD',), 'LI' : ('CHF',), 'LT' : ('LTL',), 'LU' : ('EUR',), 'MO' : ('MOP',), 'MG' : ('MGF',), 'MW' : ('MWK',), 'MY' : ('MYR',), 'MV' : ('MVR',), 'ML' : ('XOF',), 'MT' : ('MTL',), 'MH' : ('USD',), 'MQ' : ('EUR',), 'MR' : ('MRO',), 'MU' : ('MUR',), 'YT' : ('EUR',), 'MX' : ('MXN',), 'FM' : ('USD',), 'MD' : ('MDL',), 'MC' : ('EUR',), 'MN' : ('MNT',), 'MS' : ('XCD',), 'MA' : ('MAD',), 'MZ' : ('MZM',), 'MM' : ('MMK',), 'NA' : ('NAD','ZAR'), 'NR' : ('AUD',), 'NP' : ('NPR',), 'NL' : ('EUR',), 'AN' : ('ANG',), 'NC' : ('XPF',), 'NZ' : ('NZD',), 'NI' : ('NIO',), 'NE' : ('XOF',), 'NG' : ('NGN',), 'NU' : ('NZD',), 'NF' : ('AUD',), 'KP' : ('KPW',), 'MP' : ('USD',), 'NO' : ('NOK',), 'OM' : ('OMR',), 'PK' : ('PKR',), 'PW' : ('USD',), 'PA' : ('PAB',), 'PG' : ('PGK',), 'PY' : ('PYG',), 'PE' : ('PEN',), 'PH' : ('PHP',), 'PN' : ('NZD',), 'PL' : ('PLN',), 'PT' : ('EUR',), 'PR' : ('USD',), 'QA' : ('QAR',), 'RE' : ('EUR',), 'RO' : ('ROL',), 'RU' : ('RUB',), 'RW' : ('RWF',), 'SH' : ('SHP',), 'KN' : ('XCD',), 'LC' : ('XCD',), 'PM' : ('EUR',), 'VC' : ('XCD',), 'WS' : ('WST',), 'SM' : ('EUR',), 'ST' : ('STD',), 'SA' : ('SAR',), 'SN' : ('XOF',), 'CS' : ('CSD','EUR'), 'SC' : ('SCR',), 'SL' : ('SLL',), 'SG' : ('SGD',), 'SK' : ('SKK',), 'SI' : ('SIT',), 'SB' : ('SBD',), 'SO' : ('SOS',), 'ZA' : ('ZAR',), 'GS' : None, 'KR' : ('KRW',), 'ES' : ('EUR',), 'LK' : ('LKR',), 'SD' : ('SDD',), 'SR' : ('SRG',), 'SJ' : ('NOK',), 'SZ' : ('SZL',), 'SE' : ('SEK',), 'CH' : ('CHF',), 'SY' : ('SYP',), 'TW' : ('TWD',), 'TJ' : ('TJS',), 'TZ' : ('TZS',), 'TH' : ('THB',), 'TL' : ('USD',), 'TG' : ('XOF',), 'TK' : ('NZD',), 'TO' : ('TOP',), 'TT' : ('TTD',), 'TN' : ('TND',), 'TR' : ('TRL',), 'TM' : ('TMM',), 'TC' : ('USD',), 'TV' : ('AUD',), 'UG' : ('UGX',), 'UA' : ('UAH',), 'AE' : ('AED',), 'GB' : ('GBP',), 'US' : ('USD',), 'UM' : None, 'UY' : ('UYU',), 'VI' : ('USD',), 'UZ' : ('UZS',), 'VU' : ('VUV',), 'VA' : ('EUR',), 'VE' : ('VEB',), 'VN' : ('VND',), 'WF' : ('XPF',), 'EH' : ('MAD',), 'YE' : ('YER',), 'ZM' : ('ZMK',), 'ZW' : ('ZWD',), } # Map assigning unique names to combinations of ISO country # codes and ISO currency codes. # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible # TODO: Eliminate None-value currency entries, or keep? # Proposal 1: # 2 letter country code, dash, ISO currency code curr_unique_map1 = { 'AD-EUR' : ('AD','EUR'), 'AE-AED' : ('AE','AED'), 'AF-AFN' : ('AF','AFN'), 'AG-XCD' : ('AG','XCD'), 'AI-XCD' : ('AI','XCD'), 'AL-ALL' : ('AL','ALL'), 'AM-AMD' : ('AM','AMD'), 'AN-ANG' : ('AN','ANG'), 'AO-AOA' : ('AO','AOA'), #'AQ-None' : ('AQ','None'), 'AR-ARS' : ('AR','ARS'), 'AS-USD' : ('AS','USD'), 'AT-EUR' : ('AT','EUR'), 'AU-AUD' : ('AU','AUD'), 'AW-AWG' : ('AW','AWG'), 'AZ-AZM' : ('AZ','AZM'), 'BA-BAM' : ('BA','BAM'), 'BB-BBD' : ('BB','BBD'), 'BD-BDT' : ('BD','BDT'), 'BE-EUR' : ('BE','EUR'), 'BF-XOF' : ('BF','XOF'), 'BG-BGN' : ('BG','BGN'), 'BH-BHD' : ('BH','BHD'), 'BI-BIF' : ('BI','BIF'), 'BJ-XOF' : ('BJ','XOF'), 'BM-BMD' : ('BM','BMD'), 'BN-BND' : ('BN','BND'), 'BO-BOB' : ('BO','BOB'), 'BR-BRL' : ('BR','BRL'), 'BS-BSD' : ('BS','BSD'), 'BT-BTN' : ('BT','BTN'), #'BV-None' : ('BV','None'), 'BW-BWP' : ('BW','BWP'), 'BY-BYR' : ('BY','BYR'), 'BZ-BZD' : ('BZ','BZD'), 'CA-CAD' : ('CA','CAD'), 'CC-AUD' : ('CC','AUD'), 'CD-CDF' : ('CD','CDF'), 'CF-XAF' : ('CF','XAF'), 'CG-XAF' : ('CG','XAF'), 'CH-CHF' : ('CH','CHF'), 'CI-XOF' : ('CI','XOF'), 'CK-NZD' : ('CK','NZD'), 'CL-CLP' : ('CL','CLP'), 'CM-XAF' : ('CM','XAF'), 'CN-CNY' : ('CN','CNY'), 'CO-COP' : ('CO','COP'), 'CR-CRC' : ('CR','CRC'), 'CS-CSD' : ('CS','CSD'), 'CS-EUR' : ('CS','EUR'), 'CU-CUP' : ('CU','CUP'), 'CV-CVE' : ('CV','CVE'), 'CX-AUD' : ('CX','AUD'), 'CY-CYP' : ('CY','CYP'), 'CZ-CZK' : ('CZ','CZK'), 'DE-EUR' : ('DE','EUR'), 'DJ-DJF' : ('DJ','DJF'), 'DK-DKK' : ('DK','DKK'), 'DM-XCD' : ('DM','XCD'), 'DO-DOP' : ('DO','DOP'), 'DZ-DZD' : ('DZ','DZD'), 'EC-USD' : ('EC','USD'), 'EE-EEK' : ('EE','EEK'), 'EG-EGP' : ('EG','EGP'), 'EH-MAD' : ('EH','MAD'), 'ER-ERN' : ('ER','ERN'), 'ES-EUR' : ('ES','EUR'), 'ET-ETB' : ('ET','ETB'), 'FI-EUR' : ('FI','EUR'), 'FJ-FJD' : ('FJ','FJD'), 'FK-FKP' : ('FK','FKP'), 'FM-USD' : ('FM','USD'), 'FO-DKK' : ('FO','DKK'), 'FR-EUR' : ('FR','EUR'), 'GA-XAF' : ('GA','XAF'), 'GB-GBP' : ('GB','GBP'), 'GD-XCD' : ('GD','XCD'), 'GE-GEL' : ('GE','GEL'), 'GF-EUR' : ('GF','EUR'), 'GH-GHC' : ('GH','GHC'), 'GI-GIP' : ('GI','GIP'), 'GL-DKK' : ('GL','DKK'), 'GM-GMD' : ('GM','GMD'), 'GN-GNF' : ('GN','GNF'), 'GP-EUR' : ('GP','EUR'), 'GQ-XAF' : ('GQ','XAF'), 'GR-EUR' : ('GR','EUR'), #'GS-None' : ('GS','None'), 'GT-GTQ' : ('GT','GTQ'), 'GU-USD' : ('GU','USD'), 'GW-XOF' : ('GW','XOF'), 'GY-GYD' : ('GY','GYD'), 'HK-HKD' : ('HK','HKD'), #'HM-None' : ('HM','None'), 'HN-HNL' : ('HN','HNL'), 'HR-HRK' : ('HR','HRK'), 'HT-HTG' : ('HT','HTG'), 'HU-HUF' : ('HU','HUF'), 'ID-IDR' : ('ID','IDR'), 'IE-EUR' : ('IE','EUR'), 'IL-ILS' : ('IL','ILS'), 'IN-INR' : ('IN','INR'), #'IO-None' : ('IO','None'), 'IQ-IQD' : ('IQ','IQD'), 'IR-IRR' : ('IR','IRR'), 'IS-ISK' : ('IS','ISK'), 'IT-EUR' : ('IT','EUR'), 'JM-JMD' : ('JM','JMD'), 'JO-JOD' : ('JO','JOD'), 'JP-JPY' : ('JP','JPY'), 'KE-KES' : ('KE','KES'), 'KG-KGS' : ('KG','KGS'), 'KH-KHR' : ('KH','KHR'), 'KI-AUD' : ('KI','AUD'), 'KM-KMF' : ('KM','KMF'), 'KN-XCD' : ('KN','XCD'), 'KP-KPW' : ('KP','KPW'), 'KR-KRW' : ('KR','KRW'), 'KW-KWD' : ('KW','KWD'), 'KY-KYD' : ('KY','KYD'), 'KZ-KZT' : ('KZ','KZT'), 'LA-LAK' : ('LA','LAK'), 'LB-LBP' : ('LB','LBP'), 'LC-XCD' : ('LC','XCD'), 'LI-CHF' : ('LI','CHF'), 'LK-LKR' : ('LK','LKR'), 'LR-LRD' : ('LR','LRD'), 'LS-LSL' : ('LS','LSL'), 'LT-LTL' : ('LT','LTL'), 'LU-EUR' : ('LU','EUR'), 'LV-LVL' : ('LV','LVL'), 'LY-LYD' : ('LY','LYD'), 'MA-MAD' : ('MA','MAD'), 'MC-EUR' : ('MC','EUR'), 'MD-MDL' : ('MD','MDL'), 'MG-MGF' : ('MG','MGF'), 'MH-USD' : ('MH','USD'), 'MK-MKD' : ('MK','MKD'), 'ML-XOF' : ('ML','XOF'), 'MM-MMK' : ('MM','MMK'), 'MN-MNT' : ('MN','MNT'), 'MO-MOP' : ('MO','MOP'), 'MP-USD' : ('MP','USD'), 'MQ-EUR' : ('MQ','EUR'), 'MR-MRO' : ('MR','MRO'), 'MS-XCD' : ('MS','XCD'), 'MT-MTL' : ('MT','MTL'), 'MU-MUR' : ('MU','MUR'), 'MV-MVR' : ('MV','MVR'), 'MW-MWK' : ('MW','MWK'), 'MX-MXN' : ('MX','MXN'), 'MY-MYR' : ('MY','MYR'), 'MZ-MZM' : ('MZ','MZM'), 'NA-NAD' : ('NA','NAD'), 'NA-ZAR' : ('NA','ZAR'), 'NC-XPF' : ('NC','XPF'), 'NE-XOF' : ('NE','XOF'), 'NF-AUD' : ('NF','AUD'), 'NG-NGN' : ('NG','NGN'), 'NI-NIO' : ('NI','NIO'), 'NL-EUR' : ('NL','EUR'), 'NO-NOK' : ('NO','NOK'), 'NP-NPR' : ('NP','NPR'), 'NR-AUD' : ('NR','AUD'), 'NU-NZD' : ('NU','NZD'), 'NZ-NZD' : ('NZ','NZD'), 'OM-OMR' : ('OM','OMR'), 'PA-PAB' : ('PA','PAB'), 'PE-PEN' : ('PE','PEN'), 'PF-XPF' : ('PF','XPF'), 'PG-PGK' : ('PG','PGK'), 'PH-PHP' : ('PH','PHP'), 'PK-PKR' : ('PK','PKR'), 'PL-PLN' : ('PL','PLN'), 'PM-EUR' : ('PM','EUR'), 'PN-NZD' : ('PN','NZD'), 'PR-USD' : ('PR','USD'), 'PT-EUR' : ('PT','EUR'), 'PW-USD' : ('PW','USD'), 'PY-PYG' : ('PY','PYG'), 'QA-QAR' : ('QA','QAR'), 'RE-EUR' : ('RE','EUR'), 'RO-ROL' : ('RO','ROL'), 'RU-RUB' : ('RU','RUB'), 'RW-RWF' : ('RW','RWF'), 'SA-SAR' : ('SA','SAR'), 'SB-SBD' : ('SB','SBD'), 'SC-SCR' : ('SC','SCR'), 'SD-SDD' : ('SD','SDD'), 'SE-SEK' : ('SE','SEK'), 'SG-SGD' : ('SG','SGD'), 'SH-SHP' : ('SH','SHP'), 'SI-SIT' : ('SI','SIT'), 'SJ-NOK' : ('SJ','NOK'), 'SK-SKK' : ('SK','SKK'), 'SL-SLL' : ('SL','SLL'), 'SM-EUR' : ('SM','EUR'), 'SN-XOF' : ('SN','XOF'), 'SO-SOS' : ('SO','SOS'), 'SR-SRG' : ('SR','SRG'), 'ST-STD' : ('ST','STD'), 'SV-SVC' : ('SV','SVC'), 'SV-USD' : ('SV','USD'), 'SY-SYP' : ('SY','SYP'), 'SZ-SZL' : ('SZ','SZL'), 'TC-USD' : ('TC','USD'), 'TD-XAF' : ('TD','XAF'), #'TF-None' : ('TF','None'), 'TG-XOF' : ('TG','XOF'), 'TH-THB' : ('TH','THB'), 'TJ-TJS' : ('TJ','TJS'), 'TK-NZD' : ('TK','NZD'), 'TL-USD' : ('TL','USD'), 'TM-TMM' : ('TM','TMM'), 'TN-TND' : ('TN','TND'), 'TO-TOP' : ('TO','TOP'), 'TR-TRL' : ('TR','TRL'), 'TT-TTD' : ('TT','TTD'), 'TV-AUD' : ('TV','AUD'), 'TW-TWD' : ('TW','TWD'), 'TZ-TZS' : ('TZ','TZS'), 'UA-UAH' : ('UA','UAH'), 'UG-UGX' : ('UG','UGX'), #'UM-None' : ('UM','None'), 'US-USD' : ('US','USD'), 'UY-UYU' : ('UY','UYU'), 'UZ-UZS' : ('UZ','UZS'), 'VA-EUR' : ('VA','EUR'), 'VC-XCD' : ('VC','XCD'), 'VE-VEB' : ('VE','VEB'), 'VG-USD' : ('VG','USD'), 'VI-USD' : ('VI','USD'), 'VN-VND' : ('VN','VND'), 'VU-VUV' : ('VU','VUV'), 'WF-XPF' : ('WF','XPF'), 'WS-WST' : ('WS','WST'), 'YE-YER' : ('YE','YER'), 'YT-EUR' : ('YT','EUR'), 'ZA-ZAR' : ('ZA','ZAR'), 'ZM-ZMK' : ('ZM','ZMK'), 'ZW-ZWD' : ('ZW','ZWD'), } # Map assigning unique names to combinations of ISO country # codes and ISO currency codes. # Only use official, currently published standards data # User applications may substitute own mapping for unusual # or time-dependent historical currency use per locale. # Initial data from: # http://europa.eu.int/comm/translation/currencies/entable1.htm # TODO: Find free ISO mapping if possible # TODO: Eliminate None-value currency entries, or keep? # Proposal 2: # 2 letter country code, first letter of ISO currency code curr_unique_map2 = { 'ADE' : ('AD','EUR'), 'AEA' : ('AE','AED'), 'AFA' : ('AF','AFN'), 'AGX' : ('AG','XCD'), 'AIX' : ('AI','XCD'), 'ALA' : ('AL','ALL'), 'AMA' : ('AM','AMD'), 'ANA' : ('AN','ANG'), 'AOA' : ('AO','AOA'), #'AQN' : ('AQ','None'), 'ARA' : ('AR','ARS'), 'ASU' : ('AS','USD'), 'ATE' : ('AT','EUR'), 'AUA' : ('AU','AUD'), 'AWA' : ('AW','AWG'), 'AZA' : ('AZ','AZM'), 'BAB' : ('BA','BAM'), 'BBB' : ('BB','BBD'), 'BDB' : ('BD','BDT'), 'BEE' : ('BE','EUR'), 'BFX' : ('BF','XOF'), 'BGB' : ('BG','BGN'), 'BHB' : ('BH','BHD'), 'BIB' : ('BI','BIF'), 'BJX' : ('BJ','XOF'), 'BMB' : ('BM','BMD'), 'BNB' : ('BN','BND'), 'BOB' : ('BO','BOB'), 'BRB' : ('BR','BRL'), 'BSB' : ('BS','BSD'), 'BTB' : ('BT','BTN'), #'BVN' : ('BV','None'), 'BWB' : ('BW','BWP'), 'BYB' : ('BY','BYR'), 'BZB' : ('BZ','BZD'), 'CAC' : ('CA','CAD'), 'CCA' : ('CC','AUD'), 'CDC' : ('CD','CDF'), 'CFX' : ('CF','XAF'), 'CGX' : ('CG','XAF'), 'CHC' : ('CH','CHF'), 'CIX' : ('CI','XOF'), 'CKN' : ('CK','NZD'), 'CLC' : ('CL','CLP'), 'CMX' : ('CM','XAF'), 'CNC' : ('CN','CNY'), 'COC' : ('CO','COP'), 'CRC' : ('CR','CRC'), 'CSC' : ('CS','CSD'), 'CSE' : ('CS','EUR'), 'CUC' : ('CU','CUP'), 'CVC' : ('CV','CVE'), 'CXA' : ('CX','AUD'), 'CYC' : ('CY','CYP'), 'CZC' : ('CZ','CZK'), 'DEE' : ('DE','EUR'), 'DJD' : ('DJ','DJF'), 'DKD' : ('DK','DKK'), 'DMX' : ('DM','XCD'), 'DOD' : ('DO','DOP'), 'DZD' : ('DZ','DZD'), 'ECU' : ('EC','USD'), 'EEE' : ('EE','EEK'), 'EGE' : ('EG','EGP'), 'EHM' : ('EH','MAD'), 'ERE' : ('ER','ERN'), 'ESE' : ('ES','EUR'), 'ETE' : ('ET','ETB'), 'FIE' : ('FI','EUR'), 'FJF' : ('FJ','FJD'), 'FKF' : ('FK','FKP'), 'FMU' : ('FM','USD'), 'FOD' : ('FO','DKK'), 'FRE' : ('FR','EUR'), 'GAX' : ('GA','XAF'), 'GBG' : ('GB','GBP'), 'GDX' : ('GD','XCD'), 'GEG' : ('GE','GEL'), 'GFE' : ('GF','EUR'), 'GHG' : ('GH','GHC'), 'GIG' : ('GI','GIP'), 'GLD' : ('GL','DKK'), 'GMG' : ('GM','GMD'), 'GNG' : ('GN','GNF'), 'GPE' : ('GP','EUR'), 'GQX' : ('GQ','XAF'), 'GRE' : ('GR','EUR'), #'GSN' : ('GS','None'), 'GTG' : ('GT','GTQ'), 'GUU' : ('GU','USD'), 'GWX' : ('GW','XOF'), 'GYG' : ('GY','GYD'), 'HKH' : ('HK','HKD'), #'HMN' : ('HM','None'), 'HNH' : ('HN','HNL'), 'HRH' : ('HR','HRK'), 'HTH' : ('HT','HTG'), 'HUH' : ('HU','HUF'), 'IDI' : ('ID','IDR'), 'IEE' : ('IE','EUR'), 'ILI' : ('IL','ILS'), 'INI' : ('IN','INR'), #'ION' : ('IO','None'), 'IQI' : ('IQ','IQD'), 'IRI' : ('IR','IRR'), 'ISI' : ('IS','ISK'), 'ITE' : ('IT','EUR'), 'JMJ' : ('JM','JMD'), 'JOJ' : ('JO','JOD'), 'JPJ' : ('JP','JPY'), 'KEK' : ('KE','KES'), 'KGK' : ('KG','KGS'), 'KHK' : ('KH','KHR'), 'KIA' : ('KI','AUD'), 'KMK' : ('KM','KMF'), 'KNX' : ('KN','XCD'), 'KPK' : ('KP','KPW'), 'KRK' : ('KR','KRW'), 'KWK' : ('KW','KWD'), 'KYK' : ('KY','KYD'), 'KZK' : ('KZ','KZT'), 'LAL' : ('LA','LAK'), 'LBL' : ('LB','LBP'), 'LCX' : ('LC','XCD'), 'LIC' : ('LI','CHF'), 'LKL' : ('LK','LKR'), 'LRL' : ('LR','LRD'), 'LSL' : ('LS','LSL'), 'LTL' : ('LT','LTL'), 'LUE' : ('LU','EUR'), 'LVL' : ('LV','LVL'), 'LYL' : ('LY','LYD'), 'MAM' : ('MA','MAD'), 'MCE' : ('MC','EUR'), 'MDM' : ('MD','MDL'), 'MGM' : ('MG','MGF'), 'MHU' : ('MH','USD'), 'MKM' : ('MK','MKD'), 'MLX' : ('ML','XOF'), 'MMM' : ('MM','MMK'), 'MNM' : ('MN','MNT'), 'MOM' : ('MO','MOP'), 'MPU' : ('MP','USD'), 'MQE' : ('MQ','EUR'), 'MRM' : ('MR','MRO'), 'MSX' : ('MS','XCD'), 'MTM' : ('MT','MTL'), 'MUM' : ('MU','MUR'), 'MVM' : ('MV','MVR'), 'MWM' : ('MW','MWK'), 'MXM' : ('MX','MXN'), 'MYM' : ('MY','MYR'), 'MZM' : ('MZ','MZM'), 'NAN' : ('NA','NAD'), 'NAZ' : ('NA','ZAR'), 'NCX' : ('NC','XPF'), 'NEX' : ('NE','XOF'), 'NFA' : ('NF','AUD'), 'NGN' : ('NG','NGN'), 'NIN' : ('NI','NIO'), 'NLE' : ('NL','EUR'), 'NON' : ('NO','NOK'), 'NPN' : ('NP','NPR'), 'NRA' : ('NR','AUD'), 'NUN' : ('NU','NZD'), 'NZN' : ('NZ','NZD'), 'OMO' : ('OM','OMR'), 'PAP' : ('PA','PAB'), 'PEP' : ('PE','PEN'), 'PFX' : ('PF','XPF'), 'PGP' : ('PG','PGK'), 'PHP' : ('PH','PHP'), 'PKP' : ('PK','PKR'), 'PLP' : ('PL','PLN'), 'PME' : ('PM','EUR'), 'PNN' : ('PN','NZD'), 'PRU' : ('PR','USD'), 'PTE' : ('PT','EUR'), 'PWU' : ('PW','USD'), 'PYP' : ('PY','PYG'), 'QAQ' : ('QA','QAR'), 'REE' : ('RE','EUR'), 'ROR' : ('RO','ROL'), 'RUR' : ('RU','RUB'), 'RWR' : ('RW','RWF'), 'SAS' : ('SA','SAR'), 'SBS' : ('SB','SBD'), 'SCS' : ('SC','SCR'), 'SDS' : ('SD','SDD'), 'SES' : ('SE','SEK'), 'SGS' : ('SG','SGD'), 'SHS' : ('SH','SHP'), 'SIS' : ('SI','SIT'), 'SJN' : ('SJ','NOK'), 'SKS' : ('SK','SKK'), 'SLS' : ('SL','SLL'), 'SME' : ('SM','EUR'), 'SNX' : ('SN','XOF'), 'SOS' : ('SO','SOS'), 'SRS' : ('SR','SRG'), 'STS' : ('ST','STD'), 'SVS' : ('SV','SVC'), 'SVU' : ('SV','USD'), 'SYS' : ('SY','SYP'), 'SZS' : ('SZ','SZL'), 'TCU' : ('TC','USD'), 'TDX' : ('TD','XAF'), #'TFN' : ('TF','None'), 'TGX' : ('TG','XOF'), 'THT' : ('TH','THB'), 'TJT' : ('TJ','TJS'), 'TKN' : ('TK','NZD'), 'TLU' : ('TL','USD'), 'TMT' : ('TM','TMM'), 'TNT' : ('TN','TND'), 'TOT' : ('TO','TOP'), 'TRT' : ('TR','TRL'), 'TTT' : ('TT','TTD'), 'TVA' : ('TV','AUD'), 'TWT' : ('TW','TWD'), 'TZT' : ('TZ','TZS'), 'UAU' : ('UA','UAH'), 'UGU' : ('UG','UGX'), #'UMN' : ('UM','None'), 'USU' : ('US','USD'), 'UYU' : ('UY','UYU'), 'UZU' : ('UZ','UZS'), 'VAE' : ('VA','EUR'), 'VCX' : ('VC','XCD'), 'VEV' : ('VE','VEB'), 'VGU' : ('VG','USD'), 'VIU' : ('VI','USD'), 'VNV' : ('VN','VND'), 'VUV' : ('VU','VUV'), 'WFX' : ('WF','XPF'), 'WSW' : ('WS','WST'), 'YEY' : ('YE','YER'), 'YTE' : ('YT','EUR'), 'ZAZ' : ('ZA','ZAR'), 'ZMZ' : ('ZM','ZMK'), 'ZWZ' : ('ZW','ZWD'), } ____________________________________________________ Yahoo! Sports Rekindle the Rivalries. Sign up for Fantasy Football http://football.fantasysports.yahoo.com |
From: Mariano D. <ch...@si...> - 2005-07-02 00:14:44
|
Facundo Batista wrote: > I proposed originally that we have a structure, after parsing the ISO list at > http://www.iso.org/iso/en/prods-services/popstds/currencycodeslist.html?printable=true > like the following: [... snip ...] Damn! Please, ignore my previous post... at least for now. I've just subscribed to the list and replied to this thread without reading the posts about the sprint. For some reason I thought they weren't important (maybe because I wasn't there :p) Now I see that you've already come to some kind of agreement about these structures... so I need to take a look at what you decided before opening my mouth again. Sorry about the noise! -- Mariano |
From: Mariano D. <ch...@si...> - 2005-07-02 00:08:06
|
Facundo Batista wrote: [... snip ...] > I have issues with the three structures proposed so far: > > 1. Mine: Clearly wrong! The currency string is repeated and we can not use > it as a dictionary key. > > 2. Darek's: Don't like the not-flat property > > 3. Jeff's: Brings another layer of complexity: How do you choose (as a > developer) and how do you predict (as user) the inserted two letters? > About Jeff's proposal: I think the "inserted two letters" are the ISO standard code for the country, aren't they? If they are, we don't have to predict anything, given that I know the currency I need to work with, and the country in wich I need to use it. > > Before chosing one, keeping proposing others, or discuss the actual ones, I > think that we must focus in specifying what we need: > > 1. What information we want in the structure (or structures) > My biggest problem with any of the structures discussed so far is that they seem to be too rigid. I think we need an extensible structure. Maybe that's because I live in Argentina... and we have "experience" changing currencies (and even using "pseudo-currencies") at leaste once every ten years or so... So today our currency is "ARS". But what if next year it's "Australes" again? If that happen, I'd like to extend and/or update the structures to reflect that change, and even using BOTH currencies at the same time... at least for a few months. I like Jeff's proposal, because it links together a country-code and a currency-code. That way, I can use as many currencies as I need for a given country, assuming I won't be forced to choose an "ISO" code for the currency (what's the ISO code for "Patacones" or "LECOPS" or "Guaraníes" or any of the pseudo-currencies that the argentinian government created not so long ago?) I'm sure the structure should have a country code and a currency code. > 2. The standard source of that information > For the country I'd choose the standard two-letter ISO code . For the currency, we might use the standard ISO code too, but it should be possible to add new currency-codes to the structure, even if they aren't standard. > 3. How we want to access that information > I'm not sure how I'd like to access that structure a) Given a country, access its currency(ies); b) Given a currency, access the country(ies) where it is used; c) both; > Then, we could specify the structure/s that we'll use. > > So, start shooting! :) > There you're :) -- Mariano |
From: Facundo B. <fac...@gm...> - 2005-07-01 16:21:50
|
People: News from the second day of the sprint. * Added and changed some attributes to the context: beautifiers for fancy formatted printing. * Changed the behaviour of str(): it now behaves like .formatted_str() without any arguments. To get the plain string of the currency's value, call Currency.value(). * Worked a lot cleaning the PEP, and corrected a lot of English mistakes. * Defined the behaviour of distrib() and implemented its test cases. For more references, see the updated PEP (please do the update, don't see it in the web because it take time to refresh). I want to thank specially to John Pinner, Rob Collins, Joe Wrigley and Didier Gouillaume for participating in the first Money sprint! . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Facundo B. <fac...@gm...> - 2005-07-01 14:51:26
|
On 7/1/05, Darek Suchojad <ds...@ti...> wrote: > Then let's add it. We can always get rid of it if it doesn't survive > the public discussion on the PEP. OK. We was forgetting another issue here. Some people don't want the distribution to be to the cent, dime, or whatever, but to a specific value. So, here is what I think will be pretty much the final version of distrib(). Take a look to the examples, because my idea is to include them as test cases. Please send other examples if you feel that is good to test other corners of the problem. ---------------------- distrib(nparts=3DNone, proportions=3DNone, LSV=3DNone) You can call distrib() with nparts XOR proportions. You can not callit with both of them, neither with none of them. In any case, you also can pass LSV. If you call it with ``nparts`` (an integer or something that can be int()'ed), the system will distribute the amount in that quantity of parts, in the same proportion:: >>> Currency(1).distrib(nparts=3D3) (Currency('0.33'), Currency('0.33'), Currency('0.34')) >>> >>> Currency(1).distrib(nparts=3D7) (Currency('0.15'), Currency('0.14'), Currency('0.15'), Currency('0.14'), Currency('0.14'), Currency('0.14'), Currency('0.14')) If you call it with ``proportions`` (a tuple or something that can be tuple()'d; and in each position of the tuple, a Decimal or something that could be Decimal()'ed), the system will distribute the amount regarding those proportions:: >>> Currency(1).distrib(proportions=3D[1,2]) [Currency("0.33"), Currency("0.67")] >>> >>> Currency(3).distrib(proportions=3D[2,1,3,3]) [Currency("0.66"), Currency("0.33"), Currency("1.01"), Currency("1.00")] ``LSV`` means "least significant value, and is the value to which the system will aproximate the finals results. The default is ``10**(-dec_places)``, so if you have ``dec_places=3D2``, ``LSV`` will be ``0.01`` (which is what we used in the examples above). It must be a Decimal or something that can be Decimal()'ed. >>> Currency(1).distrib(nparts=3D3, LSV=3DDecimal("0.1")) (Currency('0.40'), Currency('0.30'), Currency('0.30')) >>> >>> Currency(1).distrib(nparts=3D7, LSV=3D"0.05") (Currency('0.15'), Currency('0.10'), Currency('0.15'), Currency('0.15'), Currency('0.15'), Currency('0.15'), Currency('0.15')) >>> >>> Currency(1).distrib(proportions=3D[1,2], LSV=3D"0.2") [Currency("0.40"), Currency("0.60")] >>> >>> Currency(3).distrib(proportions=3D[2,1,3,3], LSV=3DDecimal("0.15")) [Currency("0.60"), Currency("0.30"), Currency("1.05"), Currency("1.05")] This is needed (at least) in Sweden, where they're used to round to 50 cents when dealing with coins. ---------------- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Darek S. <ds...@ti...> - 2005-07-01 11:51:42
|
Facundo Batista wrote: > I'm not worried about code complex, just how much we increase the > complexity of the API to the final user. > > Personally, I think that is not that much. I, too, guess it won't be that complex. > I'm +0 to expose an API that allows the user to do (1) and (3), pretty > much the one you sent before. Then let's add it. We can always get rid of it if it doesn't survive the public discussion on the PEP. darek |
From: Facundo B. <fac...@gm...> - 2005-07-01 10:20:08
|
On 7/1/05, Darek Suchojad <ds...@ti...> wrote: > If you decide it's going to be too complex then feel free to ignore > this suggestion. I'm not more than +0 on combining 1) and 3), it seemed > to be a simple addition, that's why I proposed it. I'm not worried about code complex, just how much we increase the complexity of the API to the final user. Personally, I think that is not that much. I'm +0 to expose an API that allows the user to do (1) and (3), pretty much the one you sent before. . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Darek S. <ds...@ti...> - 2005-07-01 10:10:33
|
Facundo Batista wrote: > Yes, it'd be possible. > > But what basically you're saying is, ok, with the option 3 we include > option 1, but with a more complex API. Is really needed to make the > API more complex? Because if not, we'll got the (1) and not for the > (3)... Heck, I'd even thought about combining 1) 3) and 2) somewhow but decided to not write about it ;-) (I can imagine a situation when I want to explicitly distribute the RS, but well, don't have a strong use-case actually, just an imagination). If you decide it's going to be too complex then feel free to ignore this suggestion. I'm not more than +0 on combining 1) and 3), it seemed to be a simple addition, that's why I proposed it. darek |
From: Facundo B. <fac...@gm...> - 2005-07-01 09:51:26
|
On 7/1/05, Darek Suchojad <ds...@ti...> wrote: > Facundo Batista wrote: >=20 > > 1. Returning the different currencies, splitting almost equally:: > ... > > 3. Returning the different currencies, splitting differently:: > ... >=20 > Is it possible to have a combination of 1) and 3), with 1) being > a special case of 3)? That is, something along the lines of: >=20 > def distrib(self,nparts=3DNone,proportions=3DNone): > if nparts: > return self._real_distrib([1] * nparts) > return self._real_distrib(proportions) Yes, it'd be possible. But what basically you're saying is, ok, with the option 3 we include option 1, but with a more complex API. Is really needed to make the API more complex? Because if not, we'll got the (1) and not for the (3)... Regards, . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Darek S. <ds...@ti...> - 2005-07-01 09:42:39
|
Facundo Batista wrote: > 1. Returning the different currencies, splitting almost equally:: > > >>> Currency(1).distrib(3) > [Currency("0.33"), Currency("0.33"), Currency("0.34")] > >>> Currency(1).distrib(7) > [Currency("0.14"), Currency("0.14"), Currency("0.14"), > Currency("0.14"), Currency("0.15"), Currency("0.15"), > Currency("0.14")] > 2. Returning the almost exact part, with the rest (a kind of divmod() > but not to integers):: > > >>> Currency(1).distrib(3) > (Currency("0.33"), Currency("0.01")) > >>> Currency(1).distrib(7) > (Currency("0.14"), Currency("0.02")) > 3. Returning the different currencies, splitting differently:: > > >>> Currency(1).distrib([1,2]) > [Currency("0.33"), Currency("0.67")] > >>> Currency(3).distrib([2,1,3,3]) > [Currency("0.66"), Currency("0.33"), Currency("1.01"), Currency("1.00")] > > What do you think? Is it possible to have a combination of 1) and 3), with 1) being a special case of 3)? That is, something along the lines of: def distrib(self,nparts=None,proportions=None): if nparts: return self._real_distrib([1] * nparts) return self._real_distrib(proportions) darek |
From: Facundo B. <fac...@gm...> - 2005-07-01 08:52:25
|
We've been thinking yesterday how the Currency's distrib method should work. We figured out three posibilities, but we're not be able to choose a winner. The basic idea is to distribute a Currency amount between different parts, and being sure that you're not losing information (well, money, ;). But we saw three methods of doing it: 1. Returning the different currencies, splitting almost equally:: >>> Currency(1).distrib(3) [Currency("0.33"), Currency("0.33"), Currency("0.34")] >>> Currency(1).distrib(7) [Currency("0.14"), Currency("0.14"), Currency("0.14"), Currency("0.14"), Currency("0.15"), Currency("0.15"), Currency("0.14")] The order of the results is not assured. The difference between max(results) and min(results) will be only one Less significant Digit. 2. Returning the almost exact part, with the rest (a kind of divmod() but not to integers):: >>> Currency(1).distrib(3) (Currency("0.33"), Currency("0.01")) >>> Currency(1).distrib(7) (Currency("0.14"), Currency("0.02")) If with the original value OV splited in N parts, it returns the division and the rest (DV, RS), the following applies: DV * N + RS =3D OV 3. Returning the different currencies, splitting differently:: >>> Currency(1).distrib([1,2]) [Currency("0.33"), Currency("0.67")] >>> Currency(3).distrib([2,1,3,3]) [Currency("0.66"), Currency("0.33"), Currency("1.01"), Currency("1.00")= ] The rest of the better-possible-division will be assigned to the greatest(s) value(s) of the result. What do you think? . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Facundo B. <fac...@gm...> - 2005-06-30 16:10:42
|
People: News from the first day of the sprint. * We'll have two structures to keep the ISO currency information, the first one will be: {..., CurrCode : (CurrName, CurrNumber), ... } from ISO 4217, and the second will be: [..., (CountryCode, CountryName, CurrCode), ....] from ISO 4217 and ISO 3166. John Pinner is actually building these two structures (lot of work!), to be sure that this is OK. * The curr_type default will be None, and it will not be mandatory to configure it before start using the module. * I created in CVS the test_money.py file, for the test cases, and filled with a loooot of test cases. * Put a create_currency() method in the context. The idea is to be able to create a currency object directly from the context (using the settings of that context and not the in-current-thread one). * We defined the arithmetic operations in which it'll be allowed to use Currency. For more references, see the updated PEP (please do the update, don't see it in the web because it take time to refresh). Thanks! . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Facundo B. <fac...@gm...> - 2005-06-28 10:05:56
|
I proposed originally that we have a structure, after parsing the ISO list = at http://www.iso.org/iso/en/prods-services/popstds/currencycodeslist.html?pri= ntable=3Dtrue like the following: {..., "ARS": ("ARGENTINA", "Argentine Peso", "032"), ... } Darek Suchojad noted that the first code, as different countrys have the exactly same currency, will be reapeated (which is a problem as we're using a dictionary), so he proposed: {..., "ARS": (("ARGENTINA", "Argentine Peso", "032"),), ... "USD": (("AMERICAN SAMOA", "US Dollar", "840"), ("BRITISH INDIAN OCEAN TERRITORY", "US Dollar", "840"), ... ), ... } Jeff Kowalczyk went a step further and suggested a new denomination for currencies, just to make them univocal, proposing the following structure (note how he flattened the structure). { ..., "AS-USD" : ("AMERICAN SAMOA", "US Dollar", "840"), "IO-USD" : ("BRITISH INDIAN OCEAN TERRITORY", "US Dollar", "840"), "US-USD" : ("UNITED STATES", "US Dollar", "840"), ..., } This brings the need of another structure, to map the original currency string to the invented ones, something like { ..., "USD":("AS-USD", "IO-USD", "US-USD"), ...} I have issues with the three structures proposed so far: 1. Mine: Clearly wrong! The currency string is repeated and we can not use it as a dictionary key. 2. Darek's: Don't like the not-flat property 3. Jeff's: Brings another layer of complexity: How do you choose (as a developer) and how do you predict (as user) the inserted two letters? Before chosing one, keeping proposing others, or discuss the actual ones, I think that we must focus in specifying what we need: 1. What information we want in the structure (or structures) 2. The standard source of that information 3. How we want to access that information Then, we could specify the structure/s that we'll use. So, start shooting! :) Regards, . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ |
From: Batista, F. <Fac...@te...> - 2005-05-23 17:05:35
|
[ds...@us...] #- Two caveats. #-=20 #- 1. "as uniformly as possible" is vague, and while I can create some #- testcases and I *know* that #- >>> Currency(1).distrib(7) #-=20 #- should return #-=20 #- (Currency('0.15'), Currency('0.15'), Currency('0.14'), #- Currency('0.14'), Currency('0.14'), Currency('0.14'), #- Currency('0.14')) #-=20 #- I'm not sure how to express it in a manner that would leave no #- doubts. #-=20 #- 2. sorted is a builtin in 2.4 My personal opinion is that distrib() shoould not assure order. If you = want some order, order it, :p What it should specify is that there won't be more than one LSN (less significant number) between the min() and max() result of distrib. . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci=F3n contenida en este mensaje y cualquier archivo anexo al = mismo, son para uso exclusivo del destinatario y pueden contener informaci=F3n confidencial o propietaria, cuya divulgaci=F3n es sancionada por la = ley. Si Ud. No es uno de los destinatarios consignados o la persona = responsable de hacer llegar este mensaje a los destinatarios consignados, no est=E1 autorizado a divulgar, copiar, distribuir o retener informaci=F3n (o = parte de ella) contenida en este mensaje. Por favor notif=EDquenos respondiendo = al remitente, borre el mensaje original y borre las copias (impresas o = grabadas en cualquier medio magn=E9tico) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef=F3nica = Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr=F3nicos pueden ser alterados, motivo por el cual Telef=F3nica Comunicaciones Personales S.A. no aceptar=E1 ninguna = obligaci=F3n cualquiera sea el resultante de este mensaje. Muchas Gracias. |
From: Darek S. <ds...@us...> - 2005-05-23 08:46:34
|
Batista, Facundo wrote: Hi, > #- What about that case? > #- > #- >>> Currency(1).distrib(7) > #- > #- Should it be > #- > #- (Currency('0.16'), Currency('0.14'), Currency('0.14'), > #- Currency('0.14'), > #- Currency('0.14'), Currency('0.14'), Currency('0.14')) > #- > #- or > #- > #- (Currency('0.15'), Currency('0.15'), Currency('0.14'), > #- Currency('0.14'), > #- Currency('0.14'), Currency('0.14'), Currency('0.14')) ? > > The latter. And it must be defined if the bigger ones will be at the > beggining, at the end, or in random places in the structure (I'm not > choosing one of the options, but we must define which we'll choose and then > use it). Hm, did you really mean *random* here? Couldn't it be simply implementation-dependent? Perhaps something along the lines of: distrib(amount, n[, sorted=False[, descending=False]]) Returns amount distributed into n parts as uniformly as possible. Optional argument sorted indicates that the result should be sorted (in ascending order by default). If sorted is given and not False, and optional fourth argument descending is not False, the result will be returned in descending order. If sorted is False or omitted, the order of returned parts is implementation-dependent. Two caveats. 1. "as uniformly as possible" is vague, and while I can create some testcases and I *know* that >>> Currency(1).distrib(7) should return (Currency('0.15'), Currency('0.15'), Currency('0.14'), Currency('0.14'), Currency('0.14'), Currency('0.14'), Currency('0.14')) I'm not sure how to express it in a manner that would leave no doubts. 2. sorted is a builtin in 2.4 darek |
From: Batista, F. <Fac...@te...> - 2005-05-18 08:42:23
|
[ds...@us...] #- Batista, Facundo wrote: #-=20 #- [snip useful comments] #-=20 #- All points taken, I guess I was just too impatient ;-) #-=20 #- > #- PS. I'm not submitting it to the sf.net patch tracker, should = I? #- >=20 #- > Just test cases in this first stage. #-=20 #- Sure, will do. Thank you!! . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci=F3n contenida en este mensaje y cualquier archivo anexo al = mismo, son para uso exclusivo del destinatario y pueden contener informaci=F3n confidencial o propietaria, cuya divulgaci=F3n es sancionada por la = ley. Si Ud. No es uno de los destinatarios consignados o la persona = responsable de hacer llegar este mensaje a los destinatarios consignados, no est=E1 autorizado a divulgar, copiar, distribuir o retener informaci=F3n (o = parte de ella) contenida en este mensaje. Por favor notif=EDquenos respondiendo = al remitente, borre el mensaje original y borre las copias (impresas o = grabadas en cualquier medio magn=E9tico) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef=F3nica = Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr=F3nicos pueden ser alterados, motivo por el cual Telef=F3nica Comunicaciones Personales S.A. no aceptar=E1 ninguna = obligaci=F3n cualquiera sea el resultante de este mensaje. Muchas Gracias. |
From: Darek S. <ds...@us...> - 2005-05-17 17:10:27
|
Batista, Facundo wrote: [snip useful comments] All points taken, I guess I was just too impatient ;-) > #- PS. I'm not submitting it to the sf.net patch tracker, should I? > > Just test cases in this first stage. Sure, will do. darek |
From: Batista, F. <Fac...@te...> - 2005-05-17 02:05:10
|
[ds...@us...] #- I'm sending two files, which are an attempt to implement my current #- understanding of the PEP. They're not finished (Currency.distrib #- and DefaultContext.distrib methods are still to be written,=20 #- I also need #- to add more tests) and I'm not really sure that all of those For these early stages, we should only code the test_cases, as to put = in black&white our PEP understanding. Later, when the discussion is settled, we'll code the module itself. This procedure assure us that we have an explained PEP with examples = and detailed cases (the test cases), and we don't do the same work several = times (just code money.py when we finish the other step). However, I did a small check to money.py, and found two big issues: - We should inheritate decimal.Context, and let it to do all the work, = we should only configure it. Or better, just use it, and provide = getcontext() and setcontext() methods, and the DefaultContext struct in money.py but = then using those from decimal. - In Currency, we should *use* Decimal, not *inheritate* it. Anyway, we'll define these when we code money.py, not now, ;) #- PS. I'm not submitting it to the sf.net patch tracker, should I? Just test cases in this first stage. Thank you! . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ |
From: Batista, F. <Fac...@te...> - 2005-05-16 22:12:35
|
[Darek Suchojad] #- """ #- Config Decimal: #- - prec (Config): 28 (*) #- - rounding (Config): round-half-up (*) #- ... #- (*) Those marked are the Decimal's default. #- """ #-=20 #- I understand that "Decimal" here means decimal.DefaultContext, = right? #- If so, than its default rounding type is ROUND_HALF_EVEN. Both yes. It should say Decimal, and it should say ROUND_HALF_EVEN. = It's not indispensable you to submit a bug regarding this, but it'll help me to remember to change it! Thanks anyway. #- And the last one. The PEP says that the Rounded exception will #- be off by default, but what about that case? #-=20 #-=20 #- getcontext().prec =3D 2 #-=20 #- c1 =3D Currency('5.1') #- c2 =3D Currency('5.2') #-=20 #- print c1+c2 #-=20 #- Currently it will "raise decimal.Inexact: Changed in rounding" #- exception. Is that okay? "Rounded" means that you lost some digits, but those digits are zero. = We don't want an exception there: >>> getcontext() Context(prec=3D2, rounding=3DROUND_HALF_EVEN, Emin=3D-999999999, = Emax=3D999999999, capitals=3D1, flags=3D[Inexact, Rounded], traps=3D[Inexact, Overflow, InvalidOperation, DivisionByZero]) >>> Decimal("5.0") + Decimal("5.0") Decimal("10") "Inexact" means that you lost some digits, and those digits matter: >>> Decimal("5.1") + Decimal("5.2") Traceback (most recent call last): ... Inexact: Changed in rounding . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci=F3n contenida en este mensaje y cualquier archivo anexo al = mismo, son para uso exclusivo del destinatario y pueden contener informaci=F3n confidencial o propietaria, cuya divulgaci=F3n es sancionada por la = ley. Si Ud. No es uno de los destinatarios consignados o la persona = responsable de hacer llegar este mensaje a los destinatarios consignados, no est=E1 autorizado a divulgar, copiar, distribuir o retener informaci=F3n (o = parte de ella) contenida en este mensaje. Por favor notif=EDquenos respondiendo = al remitente, borre el mensaje original y borre las copias (impresas o = grabadas en cualquier medio magn=E9tico) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef=F3nica = Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr=F3nicos pueden ser alterados, motivo por el cual Telef=F3nica Comunicaciones Personales S.A. no aceptar=E1 ninguna = obligaci=F3n cualquiera sea el resultante de este mensaje. Muchas Gracias. |
From: Batista, F. <Fac...@te...> - 2005-05-16 15:29:13
|
[ds...@us...] #- What about that case? #-=20 #- >>> Currency(1).distrib(7) #-=20 #- Should it be #-=20 #- (Currency('0.16'), Currency('0.14'), Currency('0.14'),=20 #- Currency('0.14'), #- Currency('0.14'), Currency('0.14'), Currency('0.14')) #-=20 #- or #-=20 #- (Currency('0.15'), Currency('0.15'), Currency('0.14'),=20 #- Currency('0.14'), #- Currency('0.14'), Currency('0.14'), Currency('0.14')) ? The latter. And it must be defined if the bigger ones will be at the beggining, at the end, or in random places in the structure (I'm not choosing one of the options, but we must define which we'll choose and = then use it). Thanks. . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci=F3n contenida en este mensaje y cualquier archivo anexo al = mismo, son para uso exclusivo del destinatario y pueden contener informaci=F3n confidencial o propietaria, cuya divulgaci=F3n es sancionada por la = ley. Si Ud. No es uno de los destinatarios consignados o la persona = responsable de hacer llegar este mensaje a los destinatarios consignados, no est=E1 autorizado a divulgar, copiar, distribuir o retener informaci=F3n (o = parte de ella) contenida en este mensaje. Por favor notif=EDquenos respondiendo = al remitente, borre el mensaje original y borre las copias (impresas o = grabadas en cualquier medio magn=E9tico) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef=F3nica = Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr=F3nicos pueden ser alterados, motivo por el cual Telef=F3nica Comunicaciones Personales S.A. no aceptar=E1 ninguna = obligaci=F3n cualquiera sea el resultante de este mensaje. Muchas Gracias. |
From: Darek S. <ds...@us...> - 2005-05-15 20:52:32
|
Hi, I'm sending two files, which are an attempt to implement my current understanding of the PEP. They're not finished (Currency.distrib and DefaultContext.distrib methods are still to be written, I also need to add more tests) and I'm not really sure that all of those if context is None: context = getcontext() checks in almost all of Currency methods are needed, but the PEP clearly says that "Definitely the idea is not to get a context per Currency value.". Hm, I'm not sure, perhaps changing it to something like def __add__(self, other, context=None): """ Returns self + other. """ result = Currency(Decimal.__add__(self,other,context or getcontext())) return context._round_to_dec_quant(result) would be better? I haven't also touched ISO-4217 and/or ISO-3166 tables at all, because it's still unclear how should they look like. I'm not an threading guy, so getcontext() and setcontext() methods should be taken special care of (though I simply copy&pasted them from decimal module). Anyway, it's an attempt, I hope it will be useful, but feel free to tell me it's a crappy code :-) darek PS. I'm not submitting it to the sf.net patch tracker, should I? |