Is Python type safe?
Roy Smith
roy at panix.com
Tue Mar 16 20:22:15 EST 2004
In article <c388ik$24slfg$1 at ID-169208.news.uni-berlin.de>,
"Greg Ewing (using news.cis.dfn.de)" <wmwd2zz02 at sneakemail.com> wrote:
> Roy Smith wrote:
> > Neither C++ nor Python will let you add the integer 3 to the string
> > "four",
>
> Actually, C++ (and C) will:
>
> cosc353% cat foo.c
> #include <stdio.h>
> main() {
> const char *s = "four" + 3;
> printf("%s\n", s);
> }
> cosc353% g++ foo.c -o foo
> cosc353% foo
> r
I can't believe I forgot about that! Of course, if we're going to play
those games, there's always:
Roy-Smiths-Computer:play$ cat sub.c
main ()
{
printf ("%d\n", "eight" - "sixteen");
exit (0);
}
Roy-Smiths-Computer:play$ ./sub
-8
More information about the Python-list
mailing list