| Author |
Message |
Cerulean Gokenin
Joined: 22 Oct 2004 Posts: 742 Location: London, England
|
Posted: Sat Oct 30, 2004 8:23 pm Post subject: Creating your own data types |
|
|
Out of complete curiosity:
Is it possible? Not as in the sense reimplement __mul__, __add__, etc, but as in:
somevariable = 3kl
Just like doing i = 4 is the same as i = int(4)? |
|
| Back to top |
|
 |
Algorithms Dragon
Joined: 21 Oct 2004 Posts: 343 Location: Florida
|
Posted: Mon Nov 01, 2004 2:32 pm Post subject: |
|
|
Huh?  |
|
| Back to top |
|
 |
Cerulean Gokenin
Joined: 22 Oct 2004 Posts: 742 Location: London, England
|
Posted: Mon Nov 01, 2004 3:35 pm Post subject: |
|
|
Lol, its a pointless question, but I was just wondering. You know, like anything inside quotation marks is a string, anything from 0-9 without quotation marks is an integer, etc.
Like..
type(134) -> int
type("hello") -> str
Can you make your own, i.e
type(7A) -> hex
Without touching the Python source, of course
Why, you ask? Because I always wondered. |
|
| Back to top |
|
 |
Algorithms Dragon
Joined: 21 Oct 2004 Posts: 343 Location: Florida
|
Posted: Mon Nov 01, 2004 8:51 pm Post subject: |
|
|
| Your own built-in type, no. Not without changing the source of Python and recompiling. You can make your own user defined instance which could as like a built-in type you such desired. |
|
| Back to top |
|
 |
|