A package for unique random selection
Project description
Unique Picker
Unique Picker is a Python package that allows you to randomly select an item from a list without repeating any item until all items in the list are covered. Once all items are selected, the list is reshuffled, and the process continues.
Installation
You can install the package using pip:
pip install unique-picker
Usage
Import the Package
import uniquePicker
How to Use
Use the choice function to randomly select an item from a list:
data_list = [1, 2, 3, 4, 5]
for _ in range(10):
print(uniquePicker.choice(data_list))
Output
The choice function ensures that:
- No item is repeated until all items in the list are selected.
- After all items are used, the list is reshuffled for the next cycle.
Example Output:
css
3
5
1
4
2
(all items reshuffled)
4
3
2
5
1
Features
- Random selection without immediate repetition.
- Automatic reshuffling after all items are covered.
- Easy-to-use API, just like Python’s random.choice.
Code Example
Here’s a complete working example:
import uniquePicker
# Define your list
data_list = ['apple', 'banana', 'cherry', 'date', 'elderberry']
# Select items
print("Random selections without repeats:")
for _ in range(10):
print(uniquePicker.choice(data_list))
How It Works
- The unique_picker.choice function internally uses a class to manage the list and its current state.
- It shuffles the list when all items are exhausted, ensuring fair and unique selection in cycles.
License
This package is distributed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unique_picker-0.0.2-py3-none-any.whl.
File metadata
- Download URL: unique_picker-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd31b10aa48bf51e0f7c910494725ad77ee818a7cd1a1656c1bbba102d9bbbdb
|
|
| MD5 |
33b0c35f5815b294a4f912d86d42969b
|
|
| BLAKE2b-256 |
3ba93dff628462c0cd3f9cbeab25127eebe9f9c2b8dd119c97b3e5e9db3a5dfc
|