|
RIP The old thread. To open the new thread, here's something I wish I knew all those years ago: code:
|
# ¿ Mar 6, 2017 15:54 |
|
|
# ¿ Apr 29, 2024 16:21 |
|
https://github.com/kennethreitz/pipenv
|
# ¿ Mar 7, 2017 15:31 |
|
Or use ('Hearts', 12) for the Queen of Hearts Then if you use a set() instead of a custom container, you can write {card for card in deck if card[0] == 'Hearts'} If you want, use a namedtuple so you can use card.suit or card.rank
|
# ¿ Jan 13, 2018 16:18 |
|
NtotheTC posted:Does anyone know if pipenv can replicate the behaviour of vex? (https://pypi.python.org/pypi/vex) I've always found vex to be lightyears ahead of virtualenvwrapper for development (activating and deactivating virtualenvs manually is a horrible pattern) but I've never used pipenv and people seem very happy with it pipenv run python myscript.py
|
# ¿ Jan 22, 2018 04:16 |
|
Stick a \u200E in it https://www.w3.org/International/questions/qa-bidi-unicode-controls
|
# ¿ Jan 26, 2018 04:04 |
|
What's messing up is the bidi algorithm in the big table of stuff http://unicode.org/reports/tr9/#Table_Bidirectional_Character_Types you can see that numbers are weak, so they're influenced by the text surrounding them. in this case, some implementations see it as part of the hebrew text because it's just numbers, resetting when the encounter a dollar sign, others recognize it as belonging to the dollar sign, or surrouding letters
|
# ¿ Jan 26, 2018 04:14 |
|
The March Hare posted:Yeah, I just tossed the hard ltr char right after the name and it looks fine now. Thanks~ code:
|
# ¿ Jan 26, 2018 06:00 |
|
Sad Panda posted:I was learning some Comp Sci and that involved learning about linear search, binary search, bubble sort, insertion sort and merge sort. I decided that the best way to make sure that I understand them was to code them. It's worth pointing out that many of these algorithms operate on *fixed length arrays* not *python lists*. When you're calling pop, insert, append, you're changing the length of the list, as well as changing the list. With these old algorithms, you probably want to stick to arr[0] = ..... Or maybe, build a new list entirely. The code always gets a bit tricky when you're using one data structure in place of two: For example: this operates like an insert sort (find smallest, put at end of new list), but it doesn't re-use the front old list to store the values code:
Insertion sort divides the list into two pieces, the smallest element and all elements larger than it. Bubble sort tries to make the list slightly less unsorted with each pass, moving elements to the right position. Both of these strategies can be adapted to build other sorting algorithms, and sometimes the tactics from the 60's and 70's aren't as valid today You could make different tactics: like keeping the min, max as you scan through the list, and build up a new list from either end. Or perhaps change the strategy: break the list into (smaller than, bigger than) rather than (min, bigger than). Then sort either half. You can start to develop a feel for different ways to sort structures. It might be worth looking at how python does it too, it uses a wonderful trick: Break the list into pre-sorted chunks and merge them. It's a little of both worlds: Scanning through a list to find out of place elements, and breaking the list down into smaller pieces to operate on.
|
# ¿ Mar 18, 2018 20:11 |
|
|
# ¿ Apr 29, 2024 16:21 |
|
It's in a list Python has collection types, dict, and list, which are used for json arrays and objects: code:
If you're asking questions like this, you might want to run through, or skim over the python tutorial, just to get a feel for some of the names of things. https://docs.python.org/3/tutorial/ You can pick the right version of the tutorial to match your version of python
|
# ¿ Apr 2, 2018 02:30 |