Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f352040

Browse files
committed
Remove outdate FAQ content
1 parent c5b266e commit f352040

1 file changed

Lines changed: 8 additions & 32 deletions

File tree

Doc/faq/programming.rst

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,11 @@ There are various techniques.
901901
Is there an equivalent to Perl's chomp() for removing trailing newlines from strings?
902902
-------------------------------------------------------------------------------------
903903

904-
Starting with Python 2.2, you can use ``S.rstrip("\r\n")`` to remove all
905-
occurrences of any line terminator from the end of the string ``S`` without
906-
removing other trailing whitespace. If the string ``S`` represents more than
907-
one line, with several empty lines at the end, the line terminators for all the
908-
blank lines will be removed::
904+
You can use ``S.rstrip("\r\n")`` to remove all occurrences of any line
905+
terminator from the end of the string ``S`` without removing other trailing
906+
whitespace. If the string ``S`` represents more than one line, with several
907+
empty lines at the end, the line terminators for all the blank lines will
908+
be removed::
909909

910910
>>> lines = ("line 1 \r\n"
911911
... "\r\n"
@@ -916,15 +916,6 @@ blank lines will be removed::
916916
Since this is typically only desired when reading text one line at a time, using
917917
``S.rstrip()`` this way works well.
918918

919-
For older versions of Python, there are two partial substitutes:
920-
921-
- If you want to remove all trailing whitespace, use the ``rstrip()`` method of
922-
string objects. This removes all trailing whitespace, not just a single
923-
newline.
924-
925-
- Otherwise, if there is only one line in the string ``S``, use
926-
``S.splitlines()[0]``.
927-
928919

929920
Is there a scanf() or sscanf() equivalent?
930921
------------------------------------------
@@ -1042,15 +1033,8 @@ list, deleting duplicates as you go::
10421033
else:
10431034
last = mylist[i]
10441035

1045-
If all elements of the list may be used as dictionary keys (i.e. they are all
1046-
hashable) this is often faster ::
1047-
1048-
d = {}
1049-
for x in mylist:
1050-
d[x] = 1
1051-
mylist = list(d.keys())
1052-
1053-
In Python 2.5 and later, the following is possible instead::
1036+
If all elements of the list may be used as set keys (i.e. they are all
1037+
:term:`hashable`) this is often faster ::
10541038

10551039
mylist = list(set(mylist))
10561040

@@ -1420,15 +1404,7 @@ not::
14201404

14211405
C.count = 314
14221406

1423-
Static methods are possible since Python 2.2::
1424-
1425-
class C:
1426-
def static(arg1, arg2, arg3):
1427-
# No 'self' parameter!
1428-
...
1429-
static = staticmethod(static)
1430-
1431-
With Python 2.4's decorators, this can also be written as ::
1407+
Static methods are possible::
14321408

14331409
class C:
14341410
@staticmethod

0 commit comments

Comments
 (0)