python
Slice 2d array into smaller 2d arrays
Is there a way to slice a 2d array in numpy into smaller 2d arrays?
How to know if an object has an attribute in Python
Is there a way in Python to determine if an object has some attribute? For example:
Insert line at middle of file with Python?
Is there a way to do this? Say I have a file that’s a list of names that goes like this:
How to embed matplotlib in pyqt – for Dummies
I am currently trying to embed a graph I want to plot in a pyqt4 user interface I designed. As I am almost completely new to programming – I do not get how people did the embedding in the examples I found – this one (at the bottom) and that one.
Create an empty list in Python with certain size
I want to create an empty list (or whatever is the best way) that can hold 10 elements.
Fast punctuation removal with pandas
This is a self-answered post. Below I outline a common problem in the NLP domain and propose a few performant methods to solve it.
python re.sub group: number after number
How can I replace foobar with foo123bar?
Are lists thread-safe?
I notice that it is often suggested to use queues with multiple threads, instead of lists and .pop(). Is this because lists are not thread-safe, or for some other reason?
Why can’t I use a list as a dict key in python?
I’m a bit confused about what can/can’t be used as a key for a python dict.