macbony
|
10 years ago
|
on: Which airlines ban the use of Knee Defenders during flight?
The problem is you, like an overweight person, think that you can get by with an economy ticket. I feel bad for your knees, but I'm reclining because I paid for the ability to recline even if it's only a few inches. If you are uncomfortable in your seat, fly a different airline or upgrade.
macbony
|
11 years ago
|
on: The NFL wants you to think these things are illegal
The Super Bowl is the only "Big Game" they refer to in the ads. Sure there are other "big games", but these are Super Bowl ads pure and simple.
macbony
|
11 years ago
|
on: My self-contained Tmux configuration
C-a a is an extra keypress but good enough for me.
macbony
|
12 years ago
|
on: Common Python Mistakes
No, the reason it exists is so you can override functionality of subclasses at run time, otherwise things like monkey patching would be impossible. I guess it COULD do a pass to see if the attr is an immutable or some form of primative type when __new__ is called and force those to be instantiated as instance attributes at the cost of internal consistency, but it seems pretty straight forward to me the way it works now. You don't need to be an expert, you just need a basic understand of how Python evaluates code and the difference between tags and variables.
macbony
|
12 years ago
|
on: Common Python Mistakes
I'm not really sure I understand your point. The value of x is still going to be in memory, but you may not have any references to it and it will be garbage collected. The disconnect is in thinking x is a variable and not an identifier. x points to the object in the parent until it is overridden. This allows me to dynamically alter the functionality of a class and all it's subclasses that don't override that functionality during runtime.
macbony
|
12 years ago
|
on: Common Python Mistakes
x isn't a variable, it's a tag. Because Python is dynamically typed, x can be an int one minute and a function the next, so every attribute on a class is stored as a pointer to an object, including attributes that are integers (which is an object) and functions (which are also objects). Because you aren't declaring the type of x (Python doesn't allow that), Python has to treat x = 1 the same way it'd treat def x(self).
macbony
|
12 years ago
|
on: Common Python Mistakes
If instead of x being an integer, it were a function x(), then it makes more sense. Really, for Python, there is no difference between the two in this example. When you assign a new value to B.x, you're overriding the value that B inherited from A. When you override the value in A, any subclass that doesn't have it's own overridden value will use the new A.x, but any subclass that is overridden will be unchanged.
macbony
|
12 years ago
|
on: Python Idioms [pdf]
I prefer
print("A {0} can be very cute!".format(pet))
.format() is very versatile.
d = {'first': 'Robert', 'last': 'Paulson'}
print("His name was {first} {last}!".format(**d))
>> His name was Robert Paulson!
class Person:
def __init__(self, first, last):
self.first, self.last = first, last
p = Person('Robert', 'Paulson')
print("His name is {0.first} {0.last}!".format(p))
>> His name was Robert Paulson!
You also do not need to know what type is being passed in as the __str__ method is used for .format().
macbony
|
13 years ago
|
on: Google’s Supposed Chromebook Pixel (And Its Touch Display) Stars In Leaked Video
That's where this one comes in?
macbony
|
13 years ago
|
on: Textmate to VIM
:t is the "copy" version of the command. It's shorter than :co[py].