Archive for the ‘Idle Curiosities’ Category

How Long Can Python Variable Names Be? – I Crash My Computer to Find Out

Sunday, May 6th, 2007

I got to wondering if there was a maximum length for a Python variable name. I decided to take an empirical approach:

>>> for i in range(1,100000000):
...     varname='a'*i
...     exec('%s=1' % varname)
...     if i % 10000 == 0:
...             print i

It made it up to 50,000 before hitting a memory error. In the meantime my keyboard stopped working, and all of my windows stopped responding … I had to restart the whole computer!

So I guess the answer is your variable names can be as long as you have memory for. Does anyone have a different answer, or any critiques on my approach?

My search terms:

  1. python max size for variable name

What are Preprinted Inserts?

Tuesday, June 13th, 2006

I was reading this article: Why Consumers Love Getting Preprinted Inserts and I got to wondering what it was talking about! Searches didn’t turn up anything but newspaper prices, so I went ahead and made the leap of understanding that preprinted inserts are those things that come inserted into the newspaper with colorful ads.

I now figure the internet needs a page that tells what these things are so here’s my attempt at that. If you, dear reader, have a better definition, by all means please tell us.

My search terms:

  1. Preprinted Inserts
  2. What are Preprinted Inserts
  3. What are “Preprinted Inserts”

[tags]Advertising, Direct Marketing, Preprinted Inserts, Data Mining, ads, newspapers[/tags]

How to Type the ñ (enye or N with tilde)

Wednesday, April 5th, 2006

On Windows:
Just hold down ALT and type 0241 on your numeric keypad and you will get a nice ñ printed for you.

Again, that’s:
ALT + 0241 = ñ

And capital Ñ is:
Alt + 0209 = Ñ

Found this info on this page here with all the characters you could want.

On Ubuntu (Linux):
Go to System -> Preferences -> Keyboard and change the Compose key to something you don’t use like your right windows key.
Here is a screenshot of doing the setup.

Then you can type:
Compose key n ~ to get ñ
Compose key e ‘ to get é
etc…


Thanks to everyone on this forum post for the help!

[tags]ñ, Ñ, tilde, accents, keyboard shortcuts, ubuntu, compose, enye[/tags]

How to Tell if a Binary Number is Divisible by Three

Monday, April 3rd, 2006

Answer:
If the number of even bits minus the number of odd bits is a multiple of 3 (e.g. -3,0,3,6, etc) then the number is divisible by three.
(more…)

How Can a Heat Pump Be More Efficient Than 100%?

Monday, March 6th, 2006

I read somewhere that heat pumps are more efficient than resistance heaters. And this really got me confused. A resistance heater turns 100% of its input energy into heat. Where else would its energy go? So how on earth can anything be more efficient than 100%?

Well, after much research, it turns out that while a resistance heater turns 1 watt of electricity into 1 watt of heat energy, a heat pump can use 1 watt of electricity to move 3 or 4 watts of heat energy into a building.

I still can’t figure out why this doesn’t violate any laws of energy conservation or Thermodynamics? It seems like you could move 3 or 4 watts of heat energy into a heat engine and get back at least more than 1 watt. I’d still like to find out what prevents me from getting extra energy out of such a system.

Anyway, here were the best resources I found on that subject, but I’m afraid we’ll need an expert in Thermodynamics with a knack for putting complex concepts into laymen’s terms in order to answer this question fully.

  1. http://home.howstuffworks.com/question49.htm
  2. http://www.eco-hometec.co.uk/Heat%20Pump%20Efficiencies.htm
  3. http://hyperphysics.phy-astr.gsu.edu/hbase/thermo/heatpump.html
  4. http://rabi.phys.virginia.edu/105/2005/ps8s.html

Here are all of the searches I did:

  1. Why is a heat pump for efficient than a space heater
  2. how does a heat pump work?
  3. “Heat pump” thermodynamics resistance heating
  4. “heat pump” + violates + “conservation of energy”

[tags]Thermodynamics, heat pump, conservation of energy, carnot cycle, heat engine, free energy[/tags]