does lack of type declarations make Python unsafe?
Anton Vredegoor
anton at vredegoor.doge.nl
Sun Jun 29 09:53:12 EDT 2003
kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) wrote:
>> And in neither C++ nor Java can you express "c is a container", either
>> directly or indirectly, except in comments
>
> That is incorrect for Java, and for most C++ class libraries.
>
> List c = new ArrayList();
> c.add("foo");
> c.add("bar");
> System.out.println( c instanceof Collection );
> System.out.println( c.size() );
> for(Iterator it = c.iterator(); it.hasNext(); ) {
> System.out.println( it.next() );
> }
As some googling seems to indicate this is an extendable list of
references. Since int doesn't derive from object, this will probably
fail:
c.add(1)
One decaffeinated Java with extra coffein please :-)
Anton
---
z,w=zip(range(99,0,-1)+['no'],'s'*98+' s')," on the wall"
n,t="%s bottle%s of beer","take one down, pass it around"
for x,y in zip(z,z[1:]):print'\n'.join((n%x+w,n%x,t,n%y+w,''))
More information about the Python-list
mailing list