#!/usr/bin/python
#
# Author: Shannon -jj Behrens
# Date: Fri Mar 3 16:43:43 PST 2006
#
# In response to: http://secretartofscience.com/blog/?p=8
#
# Although Python isn't a prototype-based language, it's possible to do a lot
# of these same wacky ideas in Python.
#
# By the way, Io is a cool, new prototype based language. I've blogged about
# it before. There was also a knockoff of Python that was prototype based, but
# I don't remember the name--email me if you must know.
#
# Ok, let's start by changing our class on the fly.
class Draws(object):
def draw(self):
print "draw"
class DrawsSmall(Draws):
def draw(self):
print "small:",
Draws.draw(self)
obj = Draws()
obj.draw()
obj.__class__ = DrawsSmall
obj.draw()
# This time, let's mixin something on the fly.
class DrawsBig(Draws):
def draw(self):
print "big:",
Draws.draw(self)
obj = Draws()
obj.draw()
class MixedIn(DrawsBig, Draws): pass
obj.__class__ = MixedIn
obj.draw()
# This time, do it dynamically. I'll leave it as an exercise to the reader to
# implement "replace_parent_class".
import random
def inject_parent_class(obj, Class):
NewClass = type("DynamicGeneratedClass",
(Class,) + obj.__class__.__bases__, {})
obj.__class__ = NewClass
obj = Draws()
obj.draw()
Class = random.choice([DrawsBig, DrawsSmall])
inject_parent_class(obj, Class)
obj.draw()
I decided to give Ubuntu 20.04 a try on my 2015 15" MacBook Pro. I didn't actually install it; I just live booted from a USB thumb drive which was enough to try out everything I wanted. In summary, it's not perfect, and issues with my camera would prevent me from switching, but given the right hardware, I think it's a really viable option. The first thing I wanted to try was what would happen if I plugged in a non-HiDPI screen given that my laptop has a HiDPI screen. Without sub-pixel scaling, whatever scale rate I picked for one screen would apply to the other. However, once I turned on sub-pixel scaling, I was able to pick different scale rates for the internal and external displays. That looked ok. I tried plugging in and unplugging multiple times, and it didn't crash. I doubt it'd work with my Thunderbolt display at work, but it worked fine for my HDMI displays at home. I even plugged it into my TV, and it stuck to the 100% scaling I picked for the othe
Comments