473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: WindowsXP/ CTypes - How to convert ctypes array to a string?

du**********@gmail.com wrote:
I've used CTYPES module to access a function from a dll. This function
provides me the version of the dll. This information is accessible to
me as an array of 4 long inetegers. information as :
2, 1, 5, 0

I want to display these elements concatenated as "v2.1.5.0". This
string ( I'm thinking of writing the above 4 array elements to a
string) is to be displayed as label in a GUI ( the GUI used is Tk)

Please suggest how can I write these elements to a string to get me
the desired results as "v2.1.5.0". And, is writing to a string is
right way?
any special reason why you're not reading replies to your previous post?

here's what I wrote last time.

expecting that Python/ctypes should be able to figure out that you
want an array of 4 integers printed as a dot-separated string is a
bit optimistic, perhaps. but nothing that a little explicit string
formatting cannot fix:
>>from ctypes import *
versionArr = c_long * 4
version = versionArr(1, 2, 3, 4)
"%d.%d.%d.%d" % tuple(version)
'1.2.3.4'

inserting a "v" in the format string gives you the required result:
>>"v%d.%d.%d.%d" % tuple(version)
'v1.2.3.4'

</F>

Aug 19 '08 #1
0 1669

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Heller | last post by:
ctypes 0.9.1 released - Sept 14, 2004 ===================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
0
by: looping | last post by:
Hi, I need to get the FileVersion of some files on Windows. The best way look like to use function GetFileVersionInfo from the Windows API. I first try with pywin32 and it work well, but with...
4
by: Neal Becker | last post by:
In an earlier post, I was interested in passing a pointer to a structure to fcntl.ioctl. This works: c = create_string_buffer (...) args = struct.pack("iP", len(c), cast (pointer (c),...
1
by: moreati | last post by:
Recently I discovered the re module doesn't support POSIX character classes: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for...
3
by: Andrew Lentvorski | last post by:
Basically, I'd like to use the ctypes module as a much more descriptive "struct" module. Is there a way to take a ctypes.Structure-based class and convert it to/from a binary string? Thanks,...
1
by: dudeja.rajat | last post by:
Hi, I'm using the CTYPES module of python to load a dll. My dll contains a Get_Version function as: long __stdcall af1xEvdoRDll_GetVersion(long version); This function accepts a long array of...
0
by: Fredrik Lundh | last post by:
dudeja.rajat@gmail.com wrote: expecting that Python/ctypes should be able to figure out that you want an array of 4 integers printed as a dot-separated string is a bit optimistic, perhaps. ...
0
by: dudeja.rajat | last post by:
Hi, I've used CTYPES module to access a function from a dll. This function provides me the version of the dll. This information is accessible to me as an array of 4 long inetegers. information...
0
by: dudeja.rajat | last post by:
On Tue, Aug 19, 2008 at 12:20 PM, Fredrik Lundh <fredrik@pythonware.comwrote: Fredrik, My apology for any confusion created. I read all the replies. In fact I'm thankful to you all guys who are...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.