Stephen Thorne wrote:
> Thankyou for you feedback, both of you.
No wuckas.
> http://thorne.id.au/users/stephen/scripts/eng2num.py contains your
suggestions.
This points to some javascript which prints "No."
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 22 Dec 2004 11:41:26 -0800, Scott David Daniels
<[EMAIL PROTECTED]> wrote:
> John Machin wrote:
> > Stephen Thorne wrote:
> > .def toNumber2(s):
> > . items = s.replace(',', '').split()
> > . numbers = [translation.get(item.strip(), -1) for item in items if
> > item.strip()]
> > . sta
Cool script just one little thing,
toNumber('One thousand') bites the dust.
Guess you should add another test, and s.lower() ;)
Stephen Thorne wrote:
{code snip}
> def toNumber(s):
+ s = s.lower()
> items = s.replace(',', '').split()
> numbers = [translation.get(item.strip(), -1) for i
John Machin wrote:
Stephen Thorne wrote:
.def toNumber2(s):
. items = s.replace(',', '').split()
. numbers = [translation.get(item.strip(), -1) for item in items if
item.strip()]
. stack = [0]
. for num in numbers:
. if num == -1:
. raise ValueError("Invalid string '%s'" % (s,)
Stephen Thorne wrote:
> On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva
> <[EMAIL PROTECTED]> wrote:
> > Is there any module available that converts word like 'one', 'two',
> > 'three' to corresponding digits 1, 2, 3??
>
> This seemed like an interesting problem! So I decided to solve it.
>
>
Stephen Thorne wrote:
>> Is there any module available that converts word like 'one', 'two',
>> 'three' to corresponding digits 1, 2, 3??
>
> This seemed like an interesting problem! So I decided to solve it.
> for i in range(4):
that's a slightly unusual definition of "digit", but it's a ni
On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva
<[EMAIL PROTECTED]> wrote:
> Is there any module available that converts word like 'one', 'two',
> 'three' to corresponding digits 1, 2, 3??
This seemed like an interesting problem! So I decided to solve it.
I started with
http://www.python.o
Gurpreet Sachdeva wrote:
> Is there any module available that converts word like 'one', 'two',
> 'three' to corresponding digits 1, 2, 3??
>
> Thanks and Regards,
> GSS
Hello,
This is not a module but is a way to do it
Hope this helps you.
# looku
Oops! That just does the opposite of what you want.
I guess you can tinker it a bit to do the reverse conversion unless
someone suggests a better module.
On Wed, 22 Dec 2004 10:41:46 +0530, Binu K S <[EMAIL PROTECTED]> wrote:
> You'll find a script here:
> http://www.python.org/pycon/dc2004/papers
You'll find a script here:
http://www.python.org/pycon/dc2004/papers/42/ex1-C/
Found it in the miscellany section at http://www.vex.net/parnassus/ (num2eng)
On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva
<[EMAIL PROTECTED]> wrote:
> Is there any module available that converts word like 'one
10 matches
Mail list logo