dynamic data types

C

Charlie

Hi,

The description of Python always mentions "very high level dynamic data
types". Now, I can't seem to find any examples of these (nothing
described with this term anyway). Is this simply refering to built-in
dynamic data structures such as lists and dictionaries, with a great
deal of operators defined on? Or is there something else meant by
"dynamic data types" in Python?

Regards,

Charlie
 
R

rbt

Charlie said:
Hi,

The description of Python always mentions "very high level dynamic data
types". Now, I can't seem to find any examples of these (nothing
described with this term anyway). Is this simply refering to built-in
dynamic data structures such as lists and dictionaries, with a great
deal of operators defined on? Or is there something else meant by
"dynamic data types" in Python?

Regards,

Charlie

I've always thought of it like this... in C, we have to do something
like this when declaring a variable:

int x = 0;

We had to specifically tell the language compiler that x is an integer.
In Python, all we have to do is:

x = 0

The interpretor knows that x is an integer. We can also change the type
like this:

str(x)
float(x)
long(x)

etc...

To me, this is why Python types are called dynamic. They are easy to
setup and easy to modify when compared to older, more static languages.

Bye
 
B

beliavsky

rbt said:
I've always thought of it like this... in C, we have to do something
like this when declaring a variable:
int x = 0;
We had to specifically tell the language compiler that x is an integer.
In Python, all we have to do is:
The interpretor knows that x is an integer. We can also change the type
like this:
str(x)
float(x)
long(x)

Just to clarify, str(x) does not change x, but

x = str(x)

does. Probably rbt knows this. I wonder how often this feature should
be employed. In my Python programs, most variables keep the same type
throughout. This makes a code easier for me to understand, and this
constraint should facilitate translation of the code to a statically
typed language (perhaps even a variant of Python) in the future, if
necessary.

The ability to grow a list with "append" is a very convenient feature
of Python. The C++ vector is similar but stores elements of the same
type, whereas a Python list or tuple can store elements of different
types.
 
P

Peter Hansen

Charlie said:
The description of Python always mentions "very high level dynamic data
types". Now, I can't seem to find any examples of these (nothing
described with this term anyway). Is this simply refering to built-in
dynamic data structures such as lists and dictionaries, with a great
deal of operators defined on? Or is there something else meant by
"dynamic data types" in Python?

I'd say this is "list", "dict", "set", all the similar ones,
plus anything custom defined by the programmer... plus probably
just about any other data type in Python, since they're all
"high level", the "very" part is meaningless, and they're
pretty much all more "dynamic" than most similar things in,
say, a language that's, uh, "less dynamic". ;-)

Really, think of it as marketing propaganda, and don't worry
exactly what the original author of the words intended it
to apply to.

-Peter
 
P

Paul Simmonds

I would assume that they're refering to the fact that even the basic
data types such as int are derived from object, and hence have methods:<type 'object'>

Java, for example, has both an Integer object and a basic int data
type. One word. Yuck.

Paul S.
 
S

Steven Bethard

Paul said:
I would assume that they're refering to the fact that even the basic
data types such as int are derived from object, and hence have methods:


<type 'object'>

Java, for example, has both an Integer object and a basic int data
type. One word. Yuck.

Heh heh. Yeah, I can remember that annoyance well. I believe Java
1.5's supposed to have auto-boxing and -unboxing though, which should
make this less of a pain...

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top