Confusing docs for ftplib.FTP's password

I find this a bit confusing:

Should that and actually be or?

And what does automatically generated mean?

To answer that question I suggest you read the source of the ftplib module.

There is a convention that of using a username of anonymous and a made up password that used to be expected to be your email address if I remember right. I think any old string as password would work.

But I do think that the OP is correct, and it should be or. The parameter has a default of '' and so “not given” and “empty string” should be equivalent.

1 Like

Due to ambiguities in human language syntax and semantics, both “and” could be plausibly interpreted to mean the same thing here, i.e. that if the passwd parameter is any one of "", "-" or not passed, a password is generated. The current “and” could be validly interpreted to mean “Conditions A [not given] and B [empty string or hyphen] both mean a password will be automatically generated”, as well as “Both condition A and condition B are required for a password to be automatically generated”. The former is presumably what is intended, but the latter is how you, I and likely most readers would interpret it on first glance.

Using “or” avoids the ambiguity in this case, so I would indeed suggest going ahead with that change.

As far as I can tell from checking the code, the only “automatic generation” I can spot is a snippet to what @barry-scott referred to, automatically sending a password of anonymous@ if the both the username and password are not supplied or "anonymous". The code comment is specifically instructive as to why a real email address is not sent in this case:

        if user == 'anonymous' and passwd in {'', '-'}:
            # If there is no anonymous ftp password specified
            # then we'll just use anonymous@
            # We don't send any other thing because:
            # - We want to remain anonymous
            # - We want to stop SPAM
            # - We don't want to let ftp sites to discriminate by the user,
            #   host or country.
            passwd = passwd + 'anonymous@'

As a non-FTP expert, that’s certainly not what I would think when told that a password would be “automatically generated”; I’m aware of the anonymous/anonymous convention for anonymous FTP, but I don’t think I would have necessarily made that connection with the description given there. Therefore, it seems useful to modify that explanation accordingly to at least briefly clearly describe what this actually does.

1 Like

It doesn’t mean that both conditions need to be fulfilled for automatic password generation to occur in Albanian and other Indo-European languages. Unlike in English, where ‘or’ is appropriate, the second ‘if’ is redundant in this context.

It should be: “If not given or it is…”