Creating a variable of a specific type

Dan Williams dan at
Thu Feb 5 11:53:40 CET 2004

Hi people

I understand that Python is strongly, but also dynamically typed. However, I
need to create a variable which initially isn't actually set to anything,
but still needs to be of a certain type. I've looked around a bit, but I'm
not entirely sure how to do this.

Specifically, I have a bit of C++ code which says:

struct in_addr ipAddress;
struct sockaddr_in serverAddress;
map<int, socklen_t> clientAddressSizes;
fd_set primarySocketTable;
map<int, pthread_t> socketThreads;

...this is an except of a sample of different types that I am using. From
looking at the documentation for the Python socket module, for instance, I
can see that the function socket.inet_ntoa() requires a variable in struct
in_addr form, just like in C++. The difference is that I don't know how to
set up a 'blank' variable, if you see what I mean!

I'm sure it's just a simple thing that has eluded me somehow, but in
addition to answering this question if anyone can speak any wisdom about the
other data types I have listed above, and their equivalents in Python, that
would be helpful.



More information about the Python-list mailing list