[issue46190] Omit k in random.sample()
New submission from Tilman Krummeck : random.sample can be used to choose k items from a given sequence. Currently, k is a mandatory parameter. I suggest to make k optional and instead, if omitted, pick a random value from the range of 0 and the length of the sequence. Of course, doing this must also consider any possible value of 'count' -- components: Extension Modules messages: 409283 nosy: TilmanKrummeck priority: normal severity: normal status: open title: Omit k in random.sample() type: enhancement ___ Python tracker <https://bugs.python.org/issue46190> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46190] Omit k in random.sample()
Tilman Krummeck added the comment: I use this mostly in tests to randomize my inputs. So currently I'm doing something like this: result = random.sample(items, random.randint(0, len(items))) I guess if someone would omit 'k' he wouldn't care about the result (which is probably a use-case when using random functions). This would mostly be a convenience improvement for lazy guys like myself. -- ___ Python tracker <https://bugs.python.org/issue46190> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46190] Omit k in random.sample()
Tilman Krummeck added the comment: My suggestion is not to set k=1 when omitted but to assign it a random value that is something between 0 and the maximum possible value which is: sum(counts) if counts else len(population) -- ___ Python tracker <https://bugs.python.org/issue46190> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46190] Omit k in random.sample()
Tilman Krummeck added the comment: Well, it's not bizarre, it's a use-case I'm facing quite often. But thanks for the clarification, I haven't had very large populations in mind - this makes indeed sense. -- ___ Python tracker <https://bugs.python.org/issue46190> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46190] Omit k in random.sample()
Tilman Krummeck added the comment: Hmm, ok, that sounds obvious. Thanks for the clarification. -- ___ Python tracker <https://bugs.python.org/issue46190> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31888] Creating a UUID with a list throws bad exception
New submission from Tilman Krummeck : I found a problem by accident on Python 3.5.3 with the uuid library. Running this: from uuid import UUID UUID(["string"]) This throws an AttributeError: Traceback (most recent call last): File "", line 1, in File "C:\Users\Tilman Krummeck\AppData\Local\Programs\Python\Python35-32\lib\uuid.py", line 137, in __init__ hex = hex.replace('urn:', '').replace('uuid:', '') AttributeError: 'list' object has no attribute 'replace' This is for sure not intended to work, but should throw a type error in my opinion even before trying to create that UUID object. -- components: Library (Lib) messages: 305148 nosy: TilmanKrummeck priority: normal severity: normal status: open title: Creating a UUID with a list throws bad exception type: behavior versions: Python 3.5 ___ Python tracker <https://bugs.python.org/issue31888> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35027] distutils.core.setup does not raise TypeError when if classifiers, keywords and platforms fields are not specified as a list
New submission from Tilman Krummeck : The python documentation states at this point: "Changed in version 3.7: setup now raises a TypeError if classifiers, keywords and platforms fields are not specified as a list." https://docs.python.org/3.7/distutils/setupscript.html#additional-meta-data I wrote a simple foo example that does show, that eigther the documentation is wrong or a bug exists in setup(). Here's what I get in my console: (venv) D:\Workspaces\pyCharm\dist_utils_test>setup.py sdist running sdist running check warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list) writing manifest file 'MANIFEST' creating foo-1.0 creating foo-1.0\foo making hard links in foo-1.0... hard linking README -> foo-1.0 hard linking setup.py -> foo-1.0 hard linking foo\__init__.py -> foo-1.0\foo hard linking foo\foo.py -> foo-1.0\foo creating dist Creating tar archive removing 'foo-1.0' (and everything under it) (venv) D:\Workspaces\pyCharm\dist_utils_test>pip install dist/foo-1.0.tar.gz Processing d:\workspaces\pycharm\dist_utils_test\dist\foo-1.0.tar.gz Building wheels for collected packages: foo Running setup.py bdist_wheel for foo ... done Stored in directory: C:\Users\Tilman Krummeck\AppData\Local\pip\Cache\wheels\c3\f0\b9\c1066a85814139442fec00ee29293f0f96f0c6e0d6c24ed149 Successfully built foo Installing collected packages: foo Successfully installed foo-1.0 I'm doing this on Python 3.7 (32bit) with pip 18.1 and setuptools 40.4.3. -- components: Distutils files: dist_utils_test.zip messages: 328048 nosy: TilmanKrummeck, dstufft, eric.araujo priority: normal severity: normal status: open title: distutils.core.setup does not raise TypeError when if classifiers, keywords and platforms fields are not specified as a list type: behavior versions: Python 3.7 Added file: https://bugs.python.org/file47884/dist_utils_test.zip ___ Python tracker <https://bugs.python.org/issue35027> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35027] distutils.core.setup does not raise TypeError when if classifiers, keywords and platforms fields are not specified as a list
Tilman Krummeck added the comment: I guess it's now or never. Give me some time to check the developer's guide and I'll submit a doc fix for this. -- ___ Python tracker <https://bugs.python.org/issue35027> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35027] distutils.core.setup does not raise TypeError when if classifiers, keywords and platforms fields are not specified as a list
Change by Tilman Krummeck : -- keywords: +patch pull_requests: +9370 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue35027> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35027] distutils.core.setup does not raise TypeError when if classifiers, keywords and platforms fields are not specified as a list
Tilman Krummeck added the comment: I've submitted the PR just now: https://github.com/python/cpython/pull/10032. The CLA is signed but most probably not processed yet. -- ___ Python tracker <https://bugs.python.org/issue35027> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com