Ir al contenido principal

This is my blog, more about me at marianoguerra.github.io

🦋 @marianoguerra.org 🐘 @marianoguerra@hachyderm.io 🐦 @warianoguerra

puedo?

puedo copypastear un cuento largo?

The Last Question by Isaac Asimov © 1956

The last question was asked for the first time, half in jest, on May 21, 2061, at a time when humanity first stepped into the light. The question came about as a result of a five dollar bet over highballs, and it happened this way:

Alexander Adell and Bertram Lupov were two of the faithful attendants of Multivac. As well as any human beings could, they knew what lay behind the cold, clicking, flashing face -- miles and miles of face -- of that giant computer. They had at least a vague notion of the general plan of relays and circuits that had long since grown past the point where any single human could possibly have a firm grasp of the whole.

Multivac was self-adjusting and self-correcting. It had to be, for nothing human could adjust and correct it quickly enough or even adequately enough -- so Adell and Lupov attended the monstrous giant only lightly and superficially, yet as well as any men could. They fed it data, adjusted questions to its needs and translated the answers that were issued. Certainly they, and all others like them, were fully entitled to share In the glory that was Multivac's.

For decades, Multivac had helped design the ships and plot the trajectories that enabled man to reach the Moon, Mars, and Venus, but past that, Earth's poor resources could not support the ships. Too much energy was needed for the long trips. Earth exploited its coal and uranium with increasing efficiency, but there was only so much of both.

But slowly Multivac learned enough to answer deeper questions more fundamentally, and on May 14, 2061, what had been theory, became fact.

The energy of the sun was stored, converted, and utilized directly on a planet-wide scale. All Earth turned off its burning coal, its fissioning uranium, and flipped the switch that connected all of it to a small station, one mile in diameter, circling the Earth at half the distance of the Moon. All Earth ran by invisible beams of sunpower.

Seven days had not sufficed to dim the glory of it and Adell and Lupov finally managed to escape from the public function, and to meet in quiet where no one would think of looking for them, in the deserted underground chambers, where portions of the mighty buried body of Multivac showed. Unattended, idling, sorting data with contented lazy clickings, Multivac, too, had earned its vacation and the boys appreciated that. They had no intention, originally, of disturbing it.

They had brought a bottle with them, and their only concern at the moment was to relax in the company of each other and the bottle.

"It's amazing when you think of it," said Adell. His broad face had lines of weariness in it, and he stirred his drink slowly with a glass rod, watching the cubes of ice slur clumsily about. "All the energy we can possibly ever use for free. Enough energy, if we wanted to draw on it, to melt all Earth into a big drop of impure liquid iron, and still never miss the energy so used. All the energy we could ever use, forever and forever and forever."

Lupov cocked his head sideways. He had a trick of doing that when he wanted to be contrary, and he wanted to be contrary now, partly because he had had to carry the ice and glassware. "Not forever," he said.

"Oh, hell, just about forever. Till the sun runs down, Bert."

"That's not forever."

"All right, then. Billions and billions of years. Twenty billion, maybe. Are you satisfied?"

Lupov put his fingers through his thinning hair as though to reassure himself that some was still left and sipped gently at his own drink. "Twenty billion years isn't forever."

"Will, it will last our time, won't it?"

"So would the coal and uranium."

"All right, but now we can hook up each individual spaceship to the Solar Station, and it can go to Pluto and back a million times without ever worrying about fuel. You can't do THAT on coal and uranium. Ask Multivac, if you don't believe me."

"I don't have to ask Multivac. I know that."

"Then stop running down what Multivac's done for us," said Adell, blazing up. "It did all right."

"Who says it didn't? What I say is that a sun won't last forever. That's all I'm saying. We're safe for twenty billion years, but then what?" Lupov pointed a slightly shaky finger at the other. "And don't say we'll switch to another sun."

There was silence for a while. Adell put his glass to his lips only occasionally, and Lupov's eyes slowly closed. They rested.

Then Lupov's eyes snapped open. "You're thinking we'll switch to another sun when ours is done, aren't you?"

"I'm not thinking."

"Sure you are. You're weak on logic, that's the trouble with you. You're like the guy in the story who was caught in a sudden shower and Who ran to a grove of trees and got under one. He wasn't worried, you see, because he figured when one tree got wet through, he would just get under another one."

"I get it," said Adell. "Don't shout. When the sun is done, the other stars will be gone, too."

"Darn right they will," muttered Lupov. "It all had a beginning in the original cosmic explosion, whatever that was, and it'll all have an end when all the stars run down. Some run down faster than others. Hell, the giants won't last a hundred million years. The sun will last twenty billion years and maybe the dwarfs will last a hundred billion for all the good they are. But just give us a trillion years and everything will be dark. Entropy has to increase to maximum, that's all."

"I know all about entropy," said Adell, standing on his dignity.

"The hell you do."

"I know as much as you do."

"Then you know everything's got to run down someday."

"All right. Who says they won't?"

"You did, you poor sap. You said we had all the energy we needed, forever. You said 'forever.'"

"It was Adell's turn to be contrary. "Maybe we can build things up again someday," he said.

"Never."

"Why not? Someday."

"Never."

"Ask Multivac."

"You ask Multivac. I dare you. Five dollars says it can't be done."

"Adell was just drunk enough to try, just sober enough to be able to phrase the necessary symbols and operations into a question which, in words, might have corresponded to this: Will mankind one day without the net expenditure of energy be able to restore the sun to its full youthfulness even after it had died of old age?

Or maybe it could be put more simply like this: How can the net amount of entropy of the universe be massively decreased?

Multivac fell dead and silent. The slow flashing of lights ceased, the distant sounds of clicking relays ended.

Then, just as the frightened technicians felt they could hold their breath no longer, there was a sudden springing to life of the teletype attached to that portion of Multivac. Five words were printed: INSUFFICIENT DATA FOR MEANINGFUL ANSWER.

"No bet," whispered Lupov. They left hurriedly.

By next morning, the two, plagued with throbbing head and cottony mouth, had forgotten about the incident.

Jerrodd, Jerrodine, and Jerrodette I and II watched the starry picture in the visiplate change as the passage through hyperspace was completed in its non-time lapse. At once, the even powdering of stars gave way to the predominance of a single bright marble-disk, centered.

"That's X-23," said Jerrodd confidently. His thin hands clamped tightly behind his back and the knuckles whitened.

The little Jerrodettes, both girls, had experienced the hyperspace passage for the first time in their lives and were self-conscious over the momentary sensation of inside-outness. They buried their giggles and chased one another wildly about their mother, screaming, "We've reached X-23 -- we've reached X-23 -- we've ----"

"Quiet, children," said Jerrodine sharply. "Are you sure, Jerrodd?"

"What is there to be but sure?" asked Jerrodd, glancing up at the bulge of featureless metal just under the ceiling. It ran the length of the room, disappearing through the wall at either end. It was as long as the ship.

Jerrodd scarcely knew a thing about the thick rod of metal except that it was called a Microvac, that one asked it questions if one wished; that if one did not it still had its task of guiding the ship to a preordered destination; of feeding on energies from the various Sub-galactic Power Stations; of computing the equations for the hyperspacial jumps.

Jerrodd and his family had only to wait and live in the comfortable residence quarters of the ship.

Someone had once told Jerrodd that the "ac" at the end of "Microvac" stood for "analog computer" in ancient English, but he was on the edge of forgetting even that.

Jerrodine's eyes were moist as she watched the visiplate. "I can't help it. I feel funny about leaving Earth."

"Why for Pete's sake?" demanded Jerrodd. "We had nothing there. We'll have everything on X-23. You won't be alone. You won't be a pioneer. There are over a million people on the planet already. Good Lord, our great grandchildren will be looking for new worlds because X-23 will be overcrowded."

Then, after a reflective pause, "I tell you, it's a lucky thing the computers worked out interstellar travel the way the race is growing."

"I know, I know," said Jerrodine miserably.

Jerrodette I said promptly, "Our Microvac is the best Microvac in the world."

"I think so, too," said Jerrodd, tousling her hair.

It was a nice feeling to have a Microvac of your own and Jerrodd was glad he was part of his generation and no other. In his father's youth, the only computers had been tremendous machines taking up a hundred square miles of land. There was only one to a planet. Planetary ACs they were called. They had been growing in size steadily for a thousand years and then, all at once, came refinement. In place of transistors had come molecular valves so that even the largest Planetary AC could be put into a space only half the volume of a spaceship.

Jerrodd felt uplifted, as he always did when he thought that his own personal Microvac was many times more complicated than the ancient and primitive Multivac that had first tamed the Sun, and almost as complicated as Earth's Planetary AC (the largest) that had first solved the problem of hyperspatial travel and had made trips to the stars possible.

"So many stars, so many planets," sighed Jerrodine, busy with her own thoughts. "I suppose families will be going out to new planets forever, the way we are now."

"Not forever," said Jerrodd, with a smile. "It will all stop someday, but not for billions of years. Many billions. Even the stars run down, you know. Entropy must increase."

"What's entropy, daddy?" shrilled Jerrodette II.

"Entropy, little sweet, is just a word which means the amount of running-down of the universe. Everything runs down, you know, like your little walkie-talkie robot, remember?"

"Can't you just put in a new power-unit, like with my robot?"

"The stars are the power-units, dear. Once they're gone, there are no more power-units."

Jerrodette I at once set up a howl. "Don't let them, daddy. Don't let the stars run down."

"Now look what you've done, " whispered Jerrodine, exasperated.

"How was I to know it would frighten them?" Jerrodd whispered back.

"Ask the Microvac," wailed Jerrodette I. "Ask him how to turn the stars on again."

"Go ahead," said Jerrodine. "It will quiet them down." (Jerrodette II was beginning to cry, also.)

Jarrodd shrugged. "Now, now, honeys. I'll ask Microvac. Don't worry, he'll tell us."

He asked the Microvac, adding quickly, "Print the answer."

Jerrodd cupped the strip of thin cellufilm and said cheerfully, "See now, the Microvac says it will take care of everything when the time comes so don't worry."

Jerrodine said, "and now children, it's time for bed. We'll be in our new home soon."

Jerrodd read the words on the cellufilm again before destroying it: INSUFFICIENT DATA FOR A MEANINGFUL ANSWER.

He shrugged and looked at the visiplate. X-23 was just ahead.

VJ-23X of Lameth stared into the black depths of the three-dimensional, small-scale map of the Galaxy and said, "Are we ridiculous, I wonder, in being so concerned about the matter?"

MQ-17J of Nicron shook his head. "I think not. You know the Galaxy will be filled in five years at the present rate of expansion."

Both seemed in their early twenties, both were tall and perfectly formed.

"Still," said VJ-23X, "I hesitate to submit a pessimistic report to the Galactic Council."

"I wouldn't consider any other kind of report. Stir them up a bit. We've got to stir them up."

VJ-23X sighed. "Space is infinite. A hundred billion Galaxies are there for the taking. More."

"A hundred billion is not infinite and it's getting less infinite all the time. Consider! Twenty thousand years ago, mankind first solved the problem of utilizing stellar energy, and a few centuries later, interstellar travel became possible. It took mankind a million years to fill one small world and then only fifteen thousand years to fill the rest of the Galaxy. Now the population doubles every ten years --"

VJ-23X interrupted. "We can thank immortality for that."

"Very well. Immortality exists and we have to take it into account. I admit it has its seamy side, this immortality. The Galactic AC has solved many problems for us, but in solving the problems of preventing old age and death, it has undone all its other solutions."

"Yet you wouldn't want to abandon life, I suppose."

"Not at all," snapped MQ-17J, softening it at once to, "Not yet. I'm by no means old enough. How old are you?"

"Two hundred twenty-three. And you?"

"I'm still under two hundred. --But to get back to my point. Population doubles every ten years. Once this Galaxy is filled, we'll have another filled in ten years. Another ten years and we'll have filled two more. Another decade, four more. In a hundred years, we'll have filled a thousand Galaxies. In a thousand years, a million Galaxies. In ten thousand years, the entire known Universe. Then what?"

VJ-23X said, "As a side issue, there's a problem of transportation. I wonder how many sunpower units it will take to move Galaxies of individuals from one Galaxy to the next."

"A very good point. Already, mankind consumes two sunpower units per year."

"Most of it's wasted. After all, our own Galaxy alone pours out a thousand sunpower units a year and we only use two of those."

"Granted, but even with a hundred per cent efficiency, we can only stave off the end. Our energy requirements are going up in geometric progression even faster than our population. We'll run out of energy even sooner than we run out of Galaxies. A good point. A very good point."

"We'll just have to build new stars out of interstellar gas."

"Or out of dissipated heat?" asked MQ-17J, sarcastically.

"There may be some way to reverse entropy. We ought to ask the Galactic AC."

VJ-23X was not really serious, but MQ-17J pulled out his AC-contact from his pocket and placed it on the table before him.

"I've half a mind to," he said. "It's something the human race will have to face someday."

He stared somberly at his small AC-contact. It was only two inches cubed and nothing in itself, but it was connected through hyperspace with the great Galactic AC that served all mankind. Hyperspace considered, it was an integral part of the Galactic AC.

MQ-17J paused to wonder if someday in his immortal life he would get to see the Galactic AC. It was on a little world of its own, a spider webbing of force-beams holding the matter within which surges of sub-mesons took the place of the old clumsy molecular valves. Yet despite it's sub-etheric workings, the Galactic AC was known to be a full thousand feet across.

MQ-17J asked suddenly of his AC-contact, "Can entropy ever be reversed?"

VJ-23X looked startled and said at once, "Oh, say, I didn't really mean to have you ask that."

"Why not?"

"We both know entropy can't be reversed. You can't turn smoke and ash back into a tree."

"Do you have trees on your world?" asked MQ-17J.

The sound of the Galactic AC startled them into silence. Its voice came thin and beautiful out of the small AC-contact on the desk. It said: THERE IS INSUFFICIENT DATA FOR A MEANINGFUL ANSWER.

VJ-23X said, "See!"

The two men thereupon returned to the question of the report they were to make to the Galactic Council.

Zee Prime's mind spanned the new Galaxy with a faint interest in the countless twists of stars that powdered it. He had never seen this one before. Would he ever see them all? So many of them, each with its load of humanity - but a load that was almost a dead weight. More and more, the real essence of men was to be found out here, in space.

Minds, not bodies! The immortal bodies remained back on the planets, in suspension over the eons. Sometimes they roused for material activity but that was growing rarer. Few new individuals were coming into existence to join the incredibly mighty throng, but what matter? There was little room in the Universe for new individuals.

Zee Prime was roused out of his reverie upon coming across the wispy tendrils of another mind.

"I am Zee Prime," said Zee Prime. "And you?"

"I am Dee Sub Wun. Your Galaxy?"

"We call it only the Galaxy. And you?"

"We call ours the same. All men call their Galaxy their Galaxy and nothing more. Why not?"

"True. Since all Galaxies are the same."

"Not all Galaxies. On one particular Galaxy the race of man must have originated. That makes it different."

Zee Prime said, "On which one?"

"I cannot say. The Universal AC would know."

"Shall we ask him? I am suddenly curious."

Zee Prime's perceptions broadened until the Galaxies themselves shrunk and became a new, more diffuse powdering on a much larger background. So many hundreds of billions of them, all with their immortal beings, all carrying their load of intelligences with minds that drifted freely through space. And yet one of them was unique among them all in being the originals Galaxy. One of them had, in its vague and distant past, a period when it was the only Galaxy populated by man.

Zee Prime was consumed with curiosity to see this Galaxy and called, out: "Universal AC! On which Galaxy did mankind originate?"

The Universal AC heard, for on every world and throughout space, it had its receptors ready, and each receptor lead through hyperspace to some unknown point where the Universal AC kept itself aloof.

Zee Prime knew of only one man whose thoughts had penetrated within sensing distance of Universal AC, and he reported only a shining globe, two feet across, difficult to see.

"But how can that be all of Universal AC?" Zee Prime had asked.

"Most of it, " had been the answer, "is in hyperspace. In what form it is there I cannot imagine."

Nor could anyone, for the day had long since passed, Zee Prime knew, when any man had any part of the making of a universal AC. Each Universal AC designed and constructed its successor. Each, during its existence of a million years or more accumulated the necessary data to build a better and more intricate, more capable successor in which its own store of data and individuality would be submerged.

The Universal AC interrupted Zee Prime's wandering thoughts, not with words, but with guidance. Zee Prime's mentality was guided into the dim sea of Galaxies and one in particular enlarged into stars.

A thought came, infinitely distant, but infinitely clear. "THIS IS THE ORIGINAL GALAXY OF MAN."

But it was the same after all, the same as any other, and Zee Prime stifled his disappointment.

Dee Sub Wun, whose mind had accompanied the other, said suddenly, "And Is one of these stars the original star of Man?"

The Universal AC said, "MAN'S ORIGINAL STAR HAS GONE NOVA. IT IS NOW A WHITE DWARF."

"Did the men upon it die?" asked Zee Prime, startled and without thinking.

The Universal AC said, "A NEW WORLD, AS IN SUCH CASES, WAS CONSTRUCTED FOR THEIR PHYSICAL BODIES IN TIME."

"Yes, of course," said Zee Prime, but a sense of loss overwhelmed him even so. His mind released its hold on the original Galaxy of Man, let it spring back and lose itself among the blurred pin points. He never wanted to see it again.

Dee Sub Wun said, "What is wrong?"

"The stars are dying. The original star is dead."

"They must all die. Why not?"

"But when all energy is gone, our bodies will finally die, and you and I with them."

"It will take billions of years."

"I do not wish it to happen even after billions of years. Universal AC! How may stars be kept from dying?"

Dee sub Wun said in amusement, "You're asking how entropy might be reversed in direction."

And the Universal AC answered. "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."

Zee Prime's thoughts fled back to his own Galaxy. He gave no further thought to Dee Sub Wun, whose body might be waiting on a galaxy a trillion light-years away, or on the star next to Zee Prime's own. It didn't matter.

Unhappily, Zee Prime began collecting interstellar hydrogen out of which to build a small star of his own. If the stars must someday die, at least some could yet be built.

Man considered with himself, for in a way, Man, mentally, was one. He consisted of a trillion, trillion, trillion ageless bodies, each in its place, each resting quiet and incorruptible, each cared for by perfect automatons, equally incorruptible, while the minds of all the bodies freely melted one into the other, indistinguishable.

Man said, "The Universe is dying."

Man looked about at the dimming Galaxies. The giant stars, spendthrifts, were gone long ago, back in the dimmest of the dim far past. Almost all stars were white dwarfs, fading to the end.

New stars had been built of the dust between the stars, some by natural processes, some by Man himself, and those were going, too. White dwarfs might yet be crashed together and of the mighty forces so released, new stars build, but only one star for every thousand white dwarfs destroyed, and those would come to an end, too.

Man said, "Carefully husbanded, as directed by the Cosmic AC, the energy that is even yet left in all the Universe will last for billions of years."

"But even so," said Man, "eventually it will all come to an end. However it may be husbanded, however stretched out, the energy once expended is gone and cannot be restored. Entropy must increase to the maximum."

Man said, "Can entropy not be reversed? Let us ask the Cosmic AC."

The Cosmic AC surrounded them but not in space. Not a fragment of it was in space. It was in hyperspace and made of something that was neither matter nor energy. The question of its size and Nature no longer had meaning to any terms that Man could comprehend.

"Cosmic AC," said Man, "How many entropy be reversed?"

The Cosmic AC said, "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."

Man said, "Collect additional data."

The Cosmic AC said, "I WILL DO SO. I HAVE BEEN DOING SO FOR A HUNDRED BILLION YEARS. MY PREDECESSORS AND I HAVE BEEN ASKED THIS QUESTION MANY TIMES. ALL THE DATA I HAVE REMAINS INSUFFICIENT."

"Will there come a time," said Man, "when data will be sufficient or is the problem insoluble in all conceivable circumstances?"

The Cosmic AC said, "NO PROBLEM IS INSOLUBLE IN ALL CONCEIVABLE CIRCUMSTANCES."

Man said, "When will you have enough data to answer the question?"

"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."

"Will you keep working on it?" asked Man.

The Cosmic AC said, "I WILL."

Man said, "We shall wait."

"The stars and Galaxies died and snuffed out, and space grew black after ten trillion years of running down.

One by one Man fused with AC, each physical body losing its mental identity in a manner that was somehow not a loss but a gain.

Man's last mind paused before fusion, looking over a space that included nothing but the dregs of one last dark star and nothing besides but incredibly thin matter, agitated randomly by the tag ends of heat wearing out, asymptotically, to the absolute zero.

Man said, "AC, is this the end? Can this chaos not be reversed into the Universe once more? Can that not be done?"

AC said, "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."

Man's last mind fused and only AC existed -- and that in hyperspace.

Matter and energy had ended and with it, space and time. Even AC existed only for the sake of the one last question that it had never answered from the time a half-drunken computer ten trillion years before had asked the question of a computer that was to AC far less than was a man to Man.

All other questions had been answered, and until this last question was answered also, AC might not release his consciousness.

All collected data had come to a final end. Nothing was left to be collected.

But all collected data had yet to be completely correlated and put together in all possible relationships.

A timeless interval was spent in doing that.

And it came to pass that AC learned how to reverse the direction of entropy.

But there was now no man to whom AC might give the answer of the last question. No matter. The answer -- by demonstration -- would take care of that, too.

For another timeless interval, AC thought how best to do this. Carefully, AC organized the program.

The consciousness of AC encompassed all of what had once been a Universe and brooded over what was now Chaos. Step by step, it must be done.

And AC said, "LET THERE BE LIGHT!"

And there was light----


encontre esto en internet :) http://www.multivax.com/

este post es para vos...

ponedor de raises compulsivo

alguien con acceso al svn de emesene que no se quien es tiene la bendita constumbre de llenar el codigo de

raise ExcepcionReEspecificaHermosamenteHeredadaDeException( 'mensaje' )

¿alguno por ahi preguntara que tiene de mal eso?

bueno, desde mi punto de vista las siguientes cosas:

1) las excepciones no deberian pasar!:
si, exactamente, una excepcion se llama excepcion justamente por eso!, porque es algo que pasa pocas veces, no una vez cada 5 lineas en el codigo

veamos que dice la rae:

excepción.

(Del lat. exceptĭo, -ōnis).

1. f. Acción y efecto de exceptuar.

2. f. Cosa que se aparta de la regla o condición general de las demás de su especie.



se aparta de la regla!, no es como un if que lo necesitas, es para circunstancias que no podes controlar, como por ejemplo que estas leyendo de un socket y se corte la coneccion o algo asi, no que un parámetro no te gusto como venia.

ejemplo claro en el código:

esta persona esparció todo el modulo de manejo de contactos con estas preciosas excepciones, por ejemplo, si queres borrar un grupo que no existe EXCEPCION, si queres mover un usuario a un grupo que no existe EXCEPCION, si queres borrar un usuario que no existe EXCEPCION, y un millón mas.

vamos a analizar estas situaciones desde la perspectiva de un programador en C que no tiene excepciones, esta "pobre persona carente de una herramienta tan valiosa" diría:

- queres borrar un grupo que no existe? ok, no lo borro, si total no existe
- queres mover un usuario a un grupo que no existe? ok, no lo muevo

y así, si es ya un supremo guru de la programación le dará un mensaje de error al usuario y un debug por ahí para que el desarrollador se fije si no es su culpa.

2) si vas a lanzar una excepcion usa try catch!

lanzar excepciones es complemento de atraparlas, si tenes una retorcida adicción a lanzar excepciones haceme el favor de atraparlas, y si la vas a atrapar hace algo útil, no vale atraparla y no hacer nada, porque te apuesto $5 que es nada que hiciste causa una excepción 5 lineas mas abajo, tampoco vale atrapar la excepción mas genérica, o hacer una especie de:


try:
correrPrograma()
except Exception, ex:
print 'algo paso: ' + str( ex )


porque con eso no hacemos nada...

3) las excepciones no atrapadas cierran el programa, y eso para el usuario final es "tu programa se me colgó":

eso es malo, mientras vos decís "yo hice lo políticamente correcto, si vos ingresas una cantidad que no es un numero lanzo una CantidadFormatException", y ahí esta el problema, la solución no es una excepción, es un mensaje de error o un valor por defecto..

tenia mas números en mente pero ya me cansé, voy a commitear la versión del modulo sin excepciones.. :D

PD: para el desarrollador que hizo eso, no se sienta ofendido, solo considere mis anotaciones :D

2^7 posts


import gobject
import thread

class Function( object ):
'''a class that represent a function that will run
on a thread and call a callback with the return value'''

def __init__( self, function, callback ):
self.function = function
self.callback = callback
self.queue = Queue.Queue( 0 )

def __call__( self, *args ):
'''when the object is called we start a thread
with the function and parameters and start the
check function that check every 0.2 seconds if
the thread has ended (there is something in the
queue), then call the callback with the result'''

thread.start_new_thread( self._function, args )
gobject.timeout_add( 200 , self.check )

def _function( self, *args ):
'''our function call the parameter function
with the args and put the return value in the
queue'''

self.queue.put( self.function( *args ) )

def check( self ):
'''check there is something in the queue
that means that self.function has ended
then call the callback with the result'''

try:
result = self.queue.get( True, 0.01 )
self.callback( result )
return False
except Queue.Empty:
return True

if __name__ == '__main__':
import time

def funcion(a,b):
time.sleep(5)
return a+b

def callback( suma ):
print suma

f = Function( funcion, callback )
f( 2,3 )
import gtk
gtk.main()


una clase que escribi que basicamente permite hacer que una clase se comporte como una funcion, con el adicional de que corre la funcion en un thread aparte y al terminar llama a la funcion callback pasandole el return como parametro.

util para funciones que demoran mucho para evitar bloquear otras cosas (como el refresco de la interfaz grafica)

si no contamos los comentarios esa clase debe tener 15 lineas, pero el resultado es que nos olvidamos de los threads :)

its evolution baby

un episodio de evolución acelerada fue detectado en un sapo gigante australiano, que en sólo 70 años ha desarrollado patas más grandes para poder colonizar territorio virgen. Además, sus propios cambios propiciaron una modificación en las mandíbulas de las serpientes del país para que estos sapos pudieran servirle de alimento.

(por si no lo notaron, el titulo es una cancion de perl jam)

Heaven and hell

Heaven is where the Police are British, the Chefs are French, the Mechanics are German, the Lovers Italian and it's all organised by the Swiss.
Hell is where the Chefs are British, the mechanics are French, the lovers are Swiss, the Police are German and it's all organised by the Italians

como se nota que no conocen a los argentinos... :D

maldita autocomplesion

El usuario intenta entrar a panoramio.com.
Se dirige a la barra de direcciones con la intención de lograr su objetivo e ingresa la letra p,
firefox gentilmente sugiere el sitio panfletoufa.blogspot.com
el (perturbado?) usuario lee panflauta.blogspot.com

es para preocuparme?

AttributeError

you will never understand:
me ense#abas GTK?
mariano guerra:
en un pasado remoto?
you will never understand:
AutoMessage: -vuelvo mas tarde -
puede ser condicional
si lo miras de entre ojos
mariano guerra:
de reojo se parece una ventana de emesene
you will never understand:
desde aca parece de gaim
*se vende*
mariano guerra:
*le da una puñalada en su inexistente alma*
you will never understand:
la pu#alada se la vas a tener que dar a los de gaim
por que se las vendi a ellos
mariano guerra:
vendiste mi alma?
el le y el su son reflexivos
you will never understand:
si, ala bart
mariano guerra:
maldita ambiguedad castellana
you will never understand:
no, esta bie
n*
estas hablando en tercera persona
mariano guerra:
en python seria algo asi como self.givePuñalada( self.getSoul() )
you will never understand:
claro
mariano guerra:
AttributeError: 'Human' object has no attribute 'soul'
you will never understand:
en php seria algo como
$pu#alada = $this->pu#alada
$this->addPu#alada($pu#alada)
no, flashie cualquiera
mariano guerra:
tu php es lamentable
you will never understand:
me marié
no, dejame pensarlo
$this->givePu#alada($this->soul)
pero yo lo queria hacer mas chiflado
mariano guerra:
mariano@war:~/proyectos/emesene$ echo "voy" $(echo "74-53" | bc ) "paginas y me faltan" $( echo "91-74" |bc ) "paginas para terminar"
voy 21 paginas y me faltan 17 paginas para terminar

y yo pense que eramos los unicos


como siempre chateo en el emesene con el debug prendido para ver posibles bugs en la implementacion del protocolo (principalmente MsnP2P), resulta que un contacto me estaba tirando un monton de paquetes P2P seguidos que no tenian sentido, copio algunos para leerlos y veo esto:


MIME-Version: 1.0
Content-Type: application/x-msnmsgrp2p
P2P-Dest: luismarianoguerra@gmail.com

\x00\x00\x00\x00-\xd0\x9f\x00\x00\x00\x00\x00\x00\x00\x00\x009\x01\x00\x00\x00\x00\x00\x009\x01\x00\x00\x00\x00\x00\x00\xfb\x91\x15\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00BYE MSNMSGR:lukas.utc@jagermail.com MSNSLP/1.0
To: <msnmsgr:lukas.utc@jagermail.com>
From: <msnmsgr:lukas.utc@jagermail.com>
Via: MSNSLP/1.0/TLP ;branch={621E96CE-2B17-4DEB-81FA-1670D27565EF}
CSeq: 0
Call-ID: {20CC3166-8288-656E-5EAC-A58212008222}
Max-Forwards: 0
Content-Type: null
Content-Length: 0

\x00\x00\x00\x00


me da curiosidad saber que cliente esta mandando esa calamidad, resulta que es el cliente oficial! WLM 8.1.0178.00.

para los que no leen MsnP2P de corrido :D la cosa es como sigue:
* su cliente me pide que le mande mi Display picture a traves de coneccion directa (Sockets)
* como no lo tenemos implementado, se lo rechazo
* entonces me manda ese mensaje que pegue ahi arriba

que esta mal?

To: <msnmsgr:lukas.utc@jagermail.com>
From: <msnmsgr:lukas.utc@jagermail.com>

eso quiere decir que el mensaje es de el para el mismo (???) para que me lo manda a mi entonces...

Content-Type: null

ayy, acuerdense de hacerle new a los Strings.. sino te sale un null por cualquier lado :D

eso es todo, me parecio gracioso que por la versioin 8.1 de un protocolo definido por ellos no vean esas cosas (debe ser que no chatean con el debug prendido :D)