Most Popular
1500 questions
3182
votes
7 answers
Understanding Python super() with __init__() methods
Why is super() used?
Is there a difference between using Base.__init__ and super().__init__?
class Base(object):
def __init__(self):
print "Base created"
class ChildA(Base):
def __init__(self):
Base.__init__(self)
…

Mizipzor
- 51,151
- 22
- 97
- 138
3178
votes
42 answers
From inside of a Docker container, how do I connect to the localhost of the machine?
I have a Nginx running inside a docker container. I have a MySql running on the host system. I want to connect to the MySql from within my container. MySql is only binding to the localhost device.
Is there any way to connect to this MySql or any…

Phil
- 46,436
- 33
- 110
- 175
3176
votes
30 answers
How do I find and restore a deleted file in a Git repository?
Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it.
I know I can checkout a file using git checkout --…

avdgaag
- 41,292
- 7
- 29
- 26
3161
votes
14 answers
How do I change the size of figures drawn with Matplotlib?
How do I change the size of figure drawn with Matplotlib?

tatwright
- 37,567
- 6
- 21
- 9
3156
votes
11 answers
Manually raising (throwing) an exception in Python
How do I raise an exception in Python so that it can later be caught via an except block?

TIMEX
- 259,804
- 351
- 777
- 1,080
3154
votes
14 answers
I ran into a merge conflict. How do I abort the merge?
I used git pull and had a merge conflict:
unmerged: some_file.txt
You are in the middle of a conflicted merge.
How do I abandon my changes to the file and keep only the pulled changes?

Gwyn Morfey
- 32,741
- 6
- 25
- 21
3152
votes
54 answers
How to stop EditText from gaining focus when an activity starts in Android?
I have an Activity in Android, with two elements:
EditText
ListView
When my Activity starts, the EditText immediately has the input focus (flashing cursor). I don't want any control to have input focus at startup. I…

Mark
- 39,551
- 15
- 41
- 47
3151
votes
20 answers
Is it possible to apply CSS to half of a character?
What I am looking for:
A way to style one HALF of a character. (In this case, half the letter being transparent)
What I have currently searched for and tried (With no luck):
Methods for styling half of a character/letter
Styling part of a character…

SimplyAzuma
- 25,214
- 3
- 23
- 39
3148
votes
16 answers
How can I access environment variables in Python?
How can I get the value of an environment variable in Python?

Amit Yadav
- 32,664
- 6
- 42
- 57
3138
votes
40 answers
Should I use the datetime or timestamp data type in MySQL?
Would you recommend using a datetime or a timestamp field, and why (using MySQL)?
I'm working with PHP on the server side.

Gad
- 41,526
- 13
- 54
- 78
3134
votes
34 answers
How can I upload files asynchronously with jQuery?
I would like to upload a file asynchronously with jQuery.
$(document).ready(function () {
$("#uploadbutton").click(function () {
var filename = $("#file").val();
$.ajax({
type: "POST",
url:…

Sergio del Amo
- 76,835
- 68
- 152
- 179
3129
votes
21 answers
How do I make function decorators and chain them together?
How do I make two decorators in Python that would do the following?
@make_bold
@make_italic
def say():
return "Hello"
Calling say() should return:
"Hello"

Imran
- 87,203
- 23
- 98
- 131
3127
votes
47 answers
Is there an "exists" function for jQuery?
How can I check the existence of an element in jQuery?
The current code that I have is this:
if ($(selector).length > 0) {
// Do something
}
Is there a more elegant way to approach this? Perhaps a plugin or a function?

Jake McGraw
- 55,558
- 10
- 50
- 63
3127
votes
19 answers
How do I modify a specific commit?
I have the following commit history:
HEAD
HEAD~
HEAD~2
HEAD~3
git commit --amend modifies the current HEAD commit. But how do I modify HEAD~3?

Sam Liao
- 43,637
- 15
- 53
- 61
3112
votes
65 answers
How do I print colored text to the terminal?
How do I output colored text to the terminal in Python?

aboSamoor
- 31,331
- 3
- 17
- 10