반응형

전체 글 1480

What is the difference between __str__ and __repr__?

What is the difference between __str__ and __repr__ in Python? Alex summarized well but, surprisingly, was too succinct. First, let me reiterate the main points in Alex’s post: The default implementation is useless (it’s hard to think of one which wouldn’t be, but yeah) __repr__ goal is to be unambiguous __str__ goal is to be readable Container’s __str__ uses contained objects’ __repr__ Default ..

How do you disable browser autocomplete on web form field / input tags?

How do you disable autocomplete in the major browsers for a specific input (or form field)? Firefox 30 ignores autocomplete="off" for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following commentary from May 5, 2014: The password manager always prompts if it wants to save a password. Passwords are not saved without permission from th..

How do I efficiently iterate over each entry in a Java Map?

If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of elements depend on the specific map implementation that I have for the interface? Map map = ... for (Map.Entry entry : map.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue()); } On..

Stash only one file out of multiple files that have changed with Git?

How can I stash only one of multiple changed files on my branch? git stash push -p -m "my commit message" -p let's you select the hunks that should be stashed; whole files can be selected as well. You'll be prompted with a few actions for each hunk: y - stash this hunk n - do not stash this hunk q - quit; do not stash this hunk or any of the remaining ones a - stash this hunk and all later hunks..

What is the difference between public, protected, package-private and private in Java?

In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with inheritance? The official tutorial may be of some use to you. Class Package Subclass (same pkg) Subclass (diff pkg) World public + + + + + protected + + + + no modifier + + + private + + : accessible blank :..

반응형