When I was surfing in “Python Library” I made some observations and I want
to share them with you in attention to have an answer :
1) I suggest some changes in the following sections :
-------------------------------------------------------------------------------------------------
*date.replace(year=self.year, month=self.month, day=self.day)
… . For example, if "d == date(2002, 12, 31)", then "d.replace(day=26) ==
date(2002, 12, 26)".
->change to:
*date.replace(year=self.year, month=self.month, day=self.day)
… . For example:
>>> d=date(2002,12,31)
>>> d.replace(day=26)
datetime.date(2002, 12, 26)
-----------------------------------------------------------------------------------------------
*date.weekday()
… . For example, "date(2002, 12, 4).weekday() == 2", a Wednesday. … .
→change to :
*date.weekday()
… . For example:
>>> date(2002, 12, 4).weekday()
2 (a Wednesday)
------------------------------------------------------------------------------
*date.isoweekday()
… . For example, "date(2002, 12, 4).isoweekday() == 3", a Wednesday. … .
→change to:
*date.isoweekday()
… . For example:
>>> date(2002, 12, 4).isoweekday()
3
--------------------------------------------------------------------------------------------------------------
*date.isoformat()
… . For example, "date(2002, 12, 4).isoformat() == '2002-12-04'".
→change to:
*date.isoformat()
… . For example:
>>> date(2002, 12, 4).isoformat()
'2002-12-04'
-------------------------------------------------------------------------------------------------------------------
*date.ctime()
..., for example "date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'". … .
→change to :
*date.ctime()
..., for example:
>>> date(2002, 12, 4).ctime()
'Wed Dec 4 00:00:00 2002'
---------------------------------------------------------------------------------------------------------------
*datetime.ctime()
..., for example "datetime(2002, 12, 4, 20, 30, 40).ctime() == 'Wed Dec 4
20:30:40
2002'". ....
→change to:
*datetime.ctime()
..., for example:
>>> datetime(2002, 12, 4, 20, 30, 40).ctime()
'Wed Dec 4 20:30:40 2002'
Those are examples in script format that the reader can try them which make
the documentation more understandable for beginners like me.
2) If we compare some methods between them we will find some methods more
generalized than others, So why we continue to use the latter :
* List.insert(i,x) vs List.append(x) vs List.extend(x) :
list.append(x) is restricted in the number of items in comparison with
list.extend(x) and it is restricted in the position of items in comparison with
list.insert(i,x), So I don’t see the utility of list.append(x) in front of the
two others method.
* For log function I suggest this optimization in its presentation :
math.log(x[, base])
With one argument, return the natural logarithm of *x* (to base *e*).
With two arguments, return the logarithm of *x* to the given *base*,
calculated as "log(x)/log(base)".
math.log2(x)
Return the base-2 logarithm of *x*. This is usually more accurate than
"log(x, 2)".
…
math.log10(x)
Return the base-10 logarithm of *x*. This is usually more accurate than
"log(x, 10)".
--------
math.log(x[, base])
*return the logarithm of *x* to the given *base*, calculated as
"log(x)/log(base)".
*if base is omitted=> return the natural logarithm of *x* (to base *e*).
*if base=2 => math.log2(x): Return the base-2 logarithm of *x*. This is
usually more accurate than "log(x, 2)".
*if base=10 => math.log10(x): Return the base-10 logarithm of *x*. This is
usually more accurate than "log(x, 10)".
Thank you for your attention and I wish I was helpful [😊]
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor