[docs] Typo in collections.Counter class example

Georg Brandl georg at python.org
Sun Oct 6 12:37:42 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 05.06.2013 19:16, schrieb Михаил Голубев:
> Hello,
> 
> It seems that I found micro bug in Python documentation describing 
> collections.Counter class 
> <http://docs.python.org/3.3/library/collections.html#counter-objects>. 
> There is the following snippet of code
> 
> c.most_common()[:-n:-1]         # n least common elements
> 
> Actually this expression returns not /n/ least common elements, but rather
> /n - 1,/ beacuse second boundary  is not included (as usual with slices). 
> You probably meant c.most_common()[-n:] orc.most_common()[:-n-1:-1] if
> reverse ordering is nesessary.

Hi Mikhail,

thanks for the report; this is now fixed and will appear online soon.

cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)

iEYEARECAAYFAlJRPXYACgkQN9GcIYhpnLAtSgCaApE3cvKKFIhzGywsaeYgD6W3
cewAoLAFPh8sEA7HP5ulqF5w5L6p5gvg
=vHAo
-----END PGP SIGNATURE-----


More information about the docs mailing list