@@ -55,38 +55,56 @@ Reference
5555FTP objects
5656^^^^^^^^^^^
5757
58+ .. Use substitutions for some param docs so we don't need to repeat them
59+ in multiple places.
60+
61+ .. |param_doc_user | replace ::
62+ The username to log in with (default: ``'anonymous'``).
63+
64+ .. |param_doc_passwd | replace ::
65+ The password to use when logging in.
66+ If not given, and if *passwd* is the empty string or ``"-"``,
67+ a password will be automatically generated.
68+
69+ .. Ideally, we'd like to use the :rfc: directive, but Sphinx will not allow it.
70+
71+ .. |param_doc_acct | replace ::
72+ Account information to be used for the ``ACCT`` FTP command.
73+ Few systems implement this.
74+ See `RFC-959 <https://datatracker.ietf.org/doc/html/rfc959.html>`__
75+ for more details.
76+
77+ .. |param_doc_source_address | replace ::
78+ A 2-tuple ``(host, port)`` for the socket to bind to as its
79+ source address before connecting.
80+
5881.. class :: FTP(host='', user='', passwd='', acct='', timeout=None, \
5982 source_address=None, *, encoding='utf-8')
6083
6184 Return a new instance of the :class: `FTP ` class.
62- When *host * is given, the method call :meth: `connect(host) <connect> `
63- is made by the constructor.
64- When *user * is given, additionally the method call
65- :meth: `login(user, passwd, acct) <connect> ` is made.
6685
6786 :param str host:
6887 The hostname to connect to.
88+ If given, :code: `connect(host) ` is implicitly called by the constructor.
6989
7090 :param str user:
71- The username to log in with.
72- If empty string, ``"anonymous" `` is used.
91+ |param_doc_user |
92+ If given, :code: `login(host, passwd, acct) ` is implicitly called
93+ by the constructor.
7394
7495 :param str passwd:
75- The password to use when logging in.
76- If not given, and if *passwd * is the empty string or ``"-" ``,
77- a password will be automatically generated.
96+ |param_doc_passwd |
7897
7998 :param str acct:
80- Account information; see the ACCT FTP command.
99+ | param_doc_acct |
81100
82101 :param timeout:
83- A timeout in seconds for blocking operations like :meth: `connect `.
84- If not specified, the global default timeout setting will be used .
102+ A timeout in seconds for blocking operations like :meth: `connect `
103+ (default: the global default timeout setting) .
85104 :type timeout: int | None
86105
87106 :param source_address:
88- *source_address * is a 2-tuple ``(host, port) `` for the socket
89- to bind to as its source address before connecting.
107+ |param_doc_source_address |
90108 :type source_address: tuple | None
91109
92110 :param str encoding:
@@ -140,17 +158,29 @@ FTP objects
140158
141159 .. method :: FTP.connect(host='', port=0, timeout=None, source_address=None)
142160
143- Connect to the given host and port. The default port number is ``21 ``, as
144- specified by the FTP protocol specification. It is rarely needed to specify a
145- different port number. This function should be called only once for each
146- instance; it should not be called at all if a host was given when the instance
147- was created. All other methods can only be used after a connection has been
148- made.
149- The optional *timeout * parameter specifies a timeout in seconds for the
150- connection attempt. If no *timeout * is passed, the global default timeout
151- setting will be used.
152- *source_address * is a 2-tuple ``(host, port) `` for the socket to bind to as
153- its source address before connecting.
161+ Connect to the given host and port.
162+ This function should be called only once for each instance;
163+ it should not be called if a *host * argument was given
164+ when the :class: `FTP ` instance was created.
165+ All other :class: `!FTP ` methods can only be called
166+ after a connection has successfully been made.
167+
168+ :param str host:
169+ The host to connect to.
170+
171+ :param int port:
172+ The TCP port to connect to (default: ``21 ``,
173+ as specified by the FTP protocol specification).
174+ It is rarely needed to specify a different port number.
175+
176+ :param timeout:
177+ A timeout in seconds for the connection attempt
178+ (default: the global default timeout setting).
179+ :type timeout: int | None
180+
181+ :param source_address:
182+ |param_doc_source_address |
183+ :type source_address: tuple | None
154184
155185 .. audit-event :: ftplib.connect self,host,port ftplib.FTP.connect
156186
@@ -167,14 +197,21 @@ FTP objects
167197
168198 .. method :: FTP.login(user='anonymous', passwd='', acct='')
169199
170- Log in as the given *user *. The *passwd * and *acct * parameters are optional and
171- default to the empty string. If no *user * is specified, it defaults to
172- ``'anonymous' ``. If *user * is ``'anonymous' ``, the default *passwd * is
173- ``'anonymous@' ``. This function should be called only once for each instance,
174- after a connection has been established; it should not be called at all if a
175- host and user were given when the instance was created. Most FTP commands are
176- only allowed after the client has logged in. The *acct * parameter supplies
177- "accounting information"; few systems implement this.
200+ Log on to the connected FTP server.
201+ This function should be called only once for each instance,
202+ after a connection has been established;
203+ it should not be called if the *host * and *user * arguments were given
204+ when the :class: `FTP ` instance was created.
205+ Most FTP commands are only allowed after the client has logged in.
206+
207+ :param str user:
208+ |param_doc_user |
209+
210+ :param str passwd:
211+ |param_doc_passwd |
212+
213+ :param str acct:
214+ |param_doc_acct |
178215
179216
180217 .. method :: FTP.abort()
0 commit comments