Skip to main content
Commonmark migration
Source Link

Python 2

#Python 2 Here'sHere's another python one.

import sys class Stdout(object): def __init__(self, target): self.target = target def write(self, string): self.target.write("5") sys.stdout = Stdout(sys.stdout) print 2 + 2 

This overwrites the stdout with a class that always returns 5. Pretty clever, eh?

#Python 2 Here's another python one.

import sys class Stdout(object): def __init__(self, target): self.target = target def write(self, string): self.target.write("5") sys.stdout = Stdout(sys.stdout) print 2 + 2 

This overwrites the stdout with a class that always returns 5. Pretty clever, eh?

Python 2

Here's another python one.

import sys class Stdout(object): def __init__(self, target): self.target = target def write(self, string): self.target.write("5") sys.stdout = Stdout(sys.stdout) print 2 + 2 

This overwrites the stdout with a class that always returns 5. Pretty clever, eh?

Source Link

#Python 2 Here's another python one.

import sys class Stdout(object): def __init__(self, target): self.target = target def write(self, string): self.target.write("5") sys.stdout = Stdout(sys.stdout) print 2 + 2 

This overwrites the stdout with a class that always returns 5. Pretty clever, eh?