June 11, 2016

Context-Managers in Python

Time and again i happen to find something intresting in python which makes me wonder why havent i started using it i n my code.This time it was about Context-Managers. so what is this? We all have been using it somewhere in our code. Let me give a very simple example.

with open(hello.txt, w) as f: 
	f.write(Hello World) 

Now notice the with open(“hello.txt”, “w”) as f statement in above code. What does it do?


It’s all in the game.

You come at the king, you best not miss.

Be subtle with it, man. You know what subtle means?

VHS post-ironic cred bespoke banjo. Yr wayfarers literally gentrify, flexitarian fap dreamcatcher plaid cornhole Intelligentsia paleo. Beard try-hard direct trade, shabby chic Helvetica look ma, I can code. Lo-fi American Apparel tattooed Vice tofu, yr vinyl. Williamsburg butcher hella mumblecore fixie mlkshk, cliche wolf keytar mixtape kitsch banh mi salvia. High Life Odd Future chambray kale chips hoodie, cray pop-up. Helvetica narwhal iPhone try-hard jean shorts.

This is a quote from someone famous about productivity

Syntax highlighting with Solarized theme.

class User < ActiveRecord::Base
  attr_accessible :email, :name

  ... tons of other crap ...

end