[Tutor] ValueError: Procedure probably called with too many arguments (8 bytes in excess)

2018-05-06 Thread Brad M
Hi all: I am experimenting with python calling some .DLL and this is my setup: scan.py memscan = ctypes.WinDLL('mahdll', use_last_error=True) print(memscan.say_something(1,2)) # So I pass to int to the DLL function. DLL: #include __declspec(dllexport) int say_something(int a, int b) { print

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-20 Thread Pierre Dagenais
Not very elegant, but it'll work. I don't suppose there is a >> function for determining the number of digits after the decimal, is it? > > It looks like you are trying to avoid rounding errors in decimal arithmetic. > You might be interested in Python's decimal.Decimal type then. That's right,

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-19 Thread Peter Otten
Pierre Dagenais wrote: > > > On 13-12-31 04:09 PM, Keith Winston wrote: >> Hi PierreD, I think if you iterate over your strings with something like >> this, it will do what you want, if I understand correctly (snum is your >> string number, like "123,321"): >> >> fnum = float(snum.replace(",",

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-18 Thread Pierre Dagenais
On 13-12-31 04:09 PM, Keith Winston wrote: > Hi PierreD, I think if you iterate over your strings with something like > this, it will do what you want, if I understand correctly (snum is your > string number, like "123,321"): > > fnum = float(snum.replace(",", ".") > > keith: rank beginner, tak

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-03 Thread eryksun
On Fri, Jan 3, 2014 at 11:53 AM, emile wrote: > On 12/31/2013 12:56 PM, Mark Lawrence wrote: >> >> import locale >> >> # Set to users preferred locale: >> locale.setlocale(locale.LC_ALL, '') >> # Or a specific locale: >> locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8") >> print(locale.atof("3,14

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-03 Thread emile
On 12/31/2013 12:56 PM, Mark Lawrence wrote: import locale # Set to users preferred locale: locale.setlocale(locale.LC_ALL, '') # Or a specific locale: locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8") print(locale.atof("3,14")) This is a good solution, but be aware that it could impact othe

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2013-12-31 Thread Keith Winston
Hi PierreD, I think if you iterate over your strings with something like this, it will do what you want, if I understand correctly (snum is your string number, like "123,321"): fnum = float(snum.replace(",", ".") keith: rank beginner, take everything with a grain of salt!

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2013-12-31 Thread Keith Winston
Playing with this, a list comprehension is perfect: fnumlist = [float(num.replace(",", ".")) for num in snumlist] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2013-12-31 Thread Mark Lawrence
On 31/12/2013 13:53, Pierre Dagenais wrote: Hi, I'm trying to convert a list of strings to float. Unfortunately the numbers are written with a decimal comma instead of a decimal point. What is the best way to replace these commas with decimal points? Do I need to write a function that will itera

[Tutor] ValueError: could not convert string to float: '13,2'

2013-12-31 Thread Pierre Dagenais
Hi, I'm trying to convert a list of strings to float. Unfortunately the numbers are written with a decimal comma instead of a decimal point. What is the best way to replace these commas with decimal points? Do I need to write a function that will iterate over every alphanumeric, replace the comma

Re: [Tutor] ValueError

2011-05-07 Thread Kushal Kumaran
On Wed, May 4, 2011 at 3:13 PM, Peter Otten <__pete...@web.de> wrote: > Kushal Kumaran wrote: > >> On Tue, May 3, 2011 at 5:31 PM, Peter Otten <__pete...@web.de> wrote: >>> >>> >>> Also you should make the try...except as narrow as possible >>> >>> try: >>> centimeters = float(centimeters) >>> exc

Re: [Tutor] ValueError

2011-05-04 Thread Peter Otten
Kushal Kumaran wrote: > On Tue, May 3, 2011 at 5:31 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> Also you should make the try...except as narrow as possible >> >> try: >> centimeters = float(centimeters) >> except ValueError as e: >> print e >> >> is likely to catch the float conversion whi

Re: [Tutor] ValueError

2011-05-04 Thread Alan Gauld
"Kushal Kumaran" wrote Also you should make the try...except as narrow as possible try: centimeters = float(centimeters) except ValueError as e: print e ... I would have expected it to be the other way. If you cannot reasonable expect to continue after an exception, then the try block shou

Re: [Tutor] ValueError

2011-05-03 Thread Kushal Kumaran
On Tue, May 3, 2011 at 5:31 PM, Peter Otten <__pete...@web.de> wrote: > > > Also you should make the try...except as narrow as possible > > try: >    centimeters = float(centimeters) > except ValueError as e: >    print e > > is likely to catch the float conversion while with many statements in th

Re: [Tutor] ValueError

2011-05-03 Thread Johnson Tran
I am using python 2.5...and adding raw_input has fixed the issue, thank you! On May 3, 2011, at 5:01 AM, Peter Otten wrote: > Johnson Tran wrote: > >> Thanks for the replies..so I added the "try" block but it still does not >> seem to be outputting my default error message: >> >> def Conversion

Re: [Tutor] ValueError

2011-05-03 Thread Peter Otten
Johnson Tran wrote: > Thanks for the replies..so I added the "try" block but it still does not > seem to be outputting my default error message: > > def Conversion(): > try: > > print "This program converts the first value from inches to > centimeters and second value

Re: [Tutor] ValueError

2011-05-03 Thread Johnson Tran
Thanks for the replies..so I added the "try" block but it still does not seem to be outputting my default error message: def Conversion(): try: print "This program converts the first value from inches to centimeters and second value centimeters to inches." print "(1

Re: [Tutor] ValueError

2011-05-03 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/03/2011 06:30 AM, Johnson Tran wrote: > Hi All, > > i am trying to create a program module with two functions (conversion inches > to centimeters then centimeter to inches, I have my program working although > I am trying to adda Value Error

Re: [Tutor] ValueError

2011-05-03 Thread Nitin Pawar
When you take input its bydefault is in string format you might want to typecast and validate teh input On Tue, May 3, 2011 at 4:00 PM, Johnson Tran wrote: > Hi All, > > i am trying to create a program module with two functions (conversion > inches to centimeters then centimeter to inches, I ha

[Tutor] ValueError

2011-05-03 Thread Johnson Tran
Hi All, i am trying to create a program module with two functions (conversion inches to centimeters then centimeter to inches, I have my program working although I am trying to adda Value Error function to my program but cannot seem to it to work: def Conversion(): print "This program con