RE: random choice from dictionary

2018-12-23 Thread Avi Gross
I did say some would use enumerate but I was rushing to go to my nephews wedding and my enum became emum which is meaningless 😊 If the goal is to make a relatively efficient algorithm and the index made by enumerate is not needed, then I judged that the overhead of enumerate(data) returning two

Re: random choice from dictionary

2018-12-23 Thread sarah123ed
Maybe something like this: import random k = list(data.keys()) random.shuffle(k) result = data[k[0]] -- https://mail.python.org/mailman/listinfo/python-list

Re: random choice from dictionary

2018-12-23 Thread sarah123ed
Maybe something like this? import random k = list(data.keys()) random.shuffle(k) selected = f[k[0]] -- https://mail.python.org/mailman/listinfo/python-list

Re: random choice from dictionary

2018-12-23 Thread Ben Bacarisse
"Avi Gross" writes: > The following is a function that iterates over the dictionary one key at a > time and when it reaches a random one, it returns the key without further > evaluation. On the average, it takes N/2 iterations for N keys. Asking to > make a list(data) may be efficient in terms of

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread ant
sntshkm...@gmail.com wrote: >> did you check your dists via twine? >> >> $ twine check --verbose dist/* > > I checked with `twine check dist/*` (there's no --verbose option though). > I only get warning about markdown right, i see later in my history i used the twine check without the verbo

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread sntshkmr60
> did you check your dists via twine? > > $ twine check --verbose dist/* I checked with `twine check dist/*` (there's no --verbose option though). I only get warning about markdown > also make sure you are using up to date versions of > setuptools, wheel and twine > > > $ pip install -

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread ant
sntshkm...@gmail.com wrote: >> .pypirc >>= >> [distutils] >> index-servers= >> testpypi >> >> [testpypi] >> repository: https://test.pypi.org/legacy/ >> username: UserName >> password: Password > > >> twine upload --repository testpypi dist/* > > Tried your suggestion for .pypirc file. Sti

Re: random choice from dictionary

2018-12-23 Thread MRAB
On 2018-12-23 19:52, Avi Gross wrote: There are quite a few places the new pythonic way of doing things requires extra steps to get an iterator to expand into a list so Abdul-Rahmann probably is right that there is no easy way to get a random key from a standard dictionary. Other than the expecte

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread sntshkmr60
> .pypirc >= > [distutils] > index-servers= > testpypi > > [testpypi] > repository: https://test.pypi.org/legacy/ > username: UserName > password: Password > twine upload --repository testpypi dist/* Tried your suggestion for .pypirc file. Still the same error. Has something changed an

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread ant
ant wrote: ... > .pypirc >= > [distutils] > index-servers= > testpypi > > [testpypi] > repository: https://test.pypi.org/legacy/ > username: UserName > password: Password >= > > > and my upload command is: > > >= > #!/bin/sh > # > # upload ngfp to test pypi > > NGFP_SRC_HOME="/ho

Re: Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread ant
sntshkm...@gmail.com wrote: > I'm trying to upload my package to PyPi, but before that I wanted to upload > my package to TestPyPi. > > I'm following https://packaging.python.org/guides/using-testpypi/ > > I'm issuing this command: `twine upload --repository-url > https://test.pypi.org/legacy/ di

RE: random choice from dictionary

2018-12-23 Thread Avi Gross
There are quite a few places the new pythonic way of doing things requires extra steps to get an iterator to expand into a list so Abdul-Rahmann probably is right that there is no easy way to get a random key from a standard dictionary. Other than the expected answers to make a customized dictionar

Why am I getting Error 405 while uploading my package to https://test.pypi.org/legacy?

2018-12-23 Thread sntshkmr60
I'm trying to upload my package to PyPi, but before that I wanted to upload my package to TestPyPi. I'm following https://packaging.python.org/guides/using-testpypi/ I'm issuing this command: `twine upload --repository-url https://test.pypi.org/legacy/ dist/*` Here is the output: ``` Enter yo

[SOLVED] Re: ah, progress...

2018-12-23 Thread ant
dieter wrote: ... thank you for your help. :) i finally worked through the changes needed at last. my current package in testing PyPI is at: https://test.pypi.org/project/ngfp/ which uses my code from: https://salsa.debian.org/ant-guest/gfpoken-in-python i ended up needing to

Re: Mask two images with python

2018-12-23 Thread Umar Yusuf
On Wednesday, 19 December 2018 06:36:01 UTC+1, Umar Yusuf wrote: > Hello there, > How do I supper impose an image design on a transparent png image? > > I have tried to use OpenCV's "cv2.bitwise_and" function to no success. I > posted the detail question here: > https://stackoverflow.com/questi

Re: random choice from dictionary

2018-12-23 Thread Abdur-Rahmaan Janhangeer
random.choice(list(data)) is great. fine with arbitrary selection. else, given data.keys(), how do i get the first key? yours -- Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius

Re: random choice from dictionary

2018-12-23 Thread Chris Angelico
On Sun, Dec 23, 2018 at 7:34 PM Abdur-Rahmaan Janhangeer wrote: > > greetings, > > just a check, is this: > > random.choice(list(data.keys())) > > the only way to get a random key from a dictionary? if not any plan to a > more convenient naming? Does it have to be truly random, or are you okay wi

random choice from dictionary

2018-12-23 Thread Abdur-Rahmaan Janhangeer
greetings, just a check, is this: random.choice(list(data.keys())) the only way to get a random key from a dictionary? if not any plan to a more convenient naming? yours, -- Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius