i come back to python; just some questions

Daniel Fackrell dfackrell at DELETETHIS.linuxmail.org
Mon Jul 15 12:24:11 EDT 2002


"ppcdev" <ppcdev at hotmail.com> wrote in message
news:2fa5f3a9.0207140808.e4d7d38 at posting.google.com...
> hi. i used to develop little windows application in python some years
> ago. today i come back to this language because i 'd like to test the
> security of some ftp servers. it's really easy to connect to a ftp
> server with python (for newer newbies here it is ):
>
> import socket; s=socket.socket(socket.AF_INET, socket.SOCK_STREAM);
> vr=s.connect(('127.0.0.1',21)); s.setblocking(0); s.send('user
> user1\r\n');
> d=s.recv(1024); print d;
>
> i was working on an old pentium II and wanted to send a very long
> string in the USER parameter but it made my computer bug.. is it
> normal???
>
> str='a'; r=range(1024);
> for x in r[:]:
>     str=str+str
>
> but it even bugs with a value of 512 and 256 for r=range(..)
>
>
> thanks

As others have already posted, your code will create a string that is much
longer than you probably want.  If you are wanting 1024 copies of 'str' in a
new string (yes, 'str' is a bad name to use as it eclipses the builtin
type), then perhaps you want something more like:

longString = 1024 * "This is a string"

--
Daniel Fackrell (dfackrell at linuxmail.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list