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
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,
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(",",
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
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
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
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!
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
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
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
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
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
"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
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
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
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
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
-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
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
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
20 matches
Mail list logo