this blog has moved
I got tired of blogger being so slow altow it now seams faster. Anyway is final,
this blog has moved to my website http://www.emilas.com/ where even if spead is only as fast as my DSL at least I have greater flexibility.
ByLog-PyMe
Never fight code: it'll always win - Dave Thomas
I got tired of blogger being so slow altow it now seams faster. Anyway is final,
this blog has moved to my website http://www.emilas.com/ where even if spead is only as fast as my DSL at least I have greater flexibility.
class fn:
def __init__(gen):
self.gen = gen
def __call__(*args):
fn.args = args
return self.gen.next()
f = fn(a+b+c for a,b,c in fn.args)
f(2,3,4)
f = lambda a,b,c: a+b+c
f(2,3,4)
__typecheck__: documentation, support for IDE, catch typo errors
I'm tired and sick, your finger is sticking into my eye. My
head is resting onto my fist. My ears are leaking connections
and the world is laying flat. Already the clocks are ticking
destructive demand and opposing is Homeric at best. The literature
has never been written, yet the breath is full of critical smoke.
A war is smiling at us.
It's dark and I'm ready to sleep.
Shame on me, if I bodered to read the help I could have long ago start subclasing wx controls "inside Boa GUI builder".
class wxFrame1(wxFrame):
_custom_classes = {'wxTreeCtrl': ['MyTreeCtrl', 'MyOtherTreeCtrl']}
def _init_utils(self):
pass
Glad to hear that. As for me, I'd love it if function arguments, only,
could bear an 'as' clause (making 'as' a keyword is long overdue):
def x(y as foo, z as bar):
body of x
translating into:
def x(y, z):
y = adapt(y, foo)
z = adapt(z, bar):
body of x
where builtin 'adapt' does protocol adaptation. On the other hand, if
the semantics of those 'as' clauses were something like:
def x(y, z):
if type(y) is not foo: raise TypeError, 'y must be foo'
if type(z) is not bar: raise TypeError, 'z must be bar'
body of x
then that's the day I move to Ruby, or any other language that remained
halfway sensible (if any).
@foo.when(x>10)
def foo(x):
...
@foo.when(x<5)
def foo(x):
...
Today I read this great article again and somehow I can't take this out of my mind:
So the abstractions save us time working, but they don't save us time learning
And all this means that paradoxically, even as we have higher and higher level programming tools with better and better abstractions, becoming a proficient programmer is getting harder and harder.
Evan Jones: http://evanjones.ca/
"Computers are useless. They can only give answers" - Pablo Picasso
Nice motto, however I guess they can make humans raise questions too. But the topic of what makes humans raise questions seams insanely hard to reason about. And what is a valid new question and what is a reformulation is another one.
It's just me being bored and having nothing better to do.
But is it ever different in such topics ever, anywhere?
The first think for me would be to implement a quick exists(txt) in a given huge collection of texts. rom there I can start searching.
Maybe the vector could be a "hash table" with indexes in the collection as values and provided that the hash functions, between themselves have very low collision ratio, the bits in the vector are now pointing to index in the collection instead of seen/not-seen and we could have a very fast search.
Also would make a nice implementation of "e-mail and beyond" black-list/white-list.
The only question is how do you come up with k different hashing mechanisms yet in a limited space like (1..m) and what is the best k,m to use for a given lenght of your collection?. I guess the answer is God bless the mathematicians.
UpdateNow that I think a little more about, this is all blabla (hash table), since m would probably need to be as big as the collection length, or somewhere near to allow for overlaping not to happend, and so cannot be fixed from the start, wich I beleve was the hole point of this, (where there are k different hashes to minimize the impact of a given relatively small m).
For push:
server sends Content-type: multipart/x-mixed-replace and then sends each part whenever it wants.
The browser will keep waiting for parts and present each part as a different page.
-in ASP do response.flush for each part and "sleep" until next part?
-is CGI ok since they will stay alive for so long?
-how is the server to cope with many of this such request, what is better separate processes (CGI, out of process ASP) or in-server-process scripts (pooled ASP)
-what about apache, is CGI or mod-python better
-what about third parties like webware?
How does someone do incremental updates of only one part of the page?
Maybe via JavaScript window.XMLHttpRequest and document.write or element.innerHTML ?
Maybe the MIME part is some javascript in a hidden (1 pixel) frame that updates the rest of the page (frames)?
It kind of starts to smell already, but I should give it a try and eventualy look for more info, for now i think I'll stay with pull via javascript XMLHttpRequest or HTML <meta refresh>.
Login once and then succesive calls must assume those credentials.
The following is nice but "login profiled behaviour" is still a question, (or not? can we configure SSH env. such that it will proxy to different rpc servers based on auth. profile? and if yes, isn't multiple rpc servers a complication?)
The default implementation uses HTTP as a transport, but that is
not a requirement. You just have to be able to serialise the request
and response parameters into an XML stream. The xmlrplic loads and
dumps functions will do that for you.
In one of my projects I actually use XML-RPC over SSH and deal with
the authentication etc at the SSH level. (I use the excellent pure
Python paramiko library for the SSH protocol part).
How to not enjoy a draft if Bush is re-elected.
www.enjoythedraft.com
Is there some how to enjoy taxes a la Europe more then rumor web presence?. Don't balance taxes at end of year, pay taxes included in the prices of things.
How would this be implemented? What would there be in this for small businesses, and what for big wolfs?
http://www.williamgibsonbooks.com/
read something from there (SF ?)
awarded + "Neuromancer" I heard but never went anywhere with it yet
http://compsoc.dur.ac.uk/whitespace/
how to code some language keywords as white space
=> bored people build boring stuff
http://www.worldwidewords.org/
good ???? for an english illiterate like myself
Pretty simple yet so powerfull:
ideas:
-name the class __metaclass__ so all we need is import
-keep track of the instances in a new key (A) of the class attributes dictionary
(use instance __init__ to add the new instances to A in the class)
-at module reload, check sys.modules for the old class and copy A from old class
to new class dictionary
-for each instance (a) in A replace a.__class__ from old class to new class
#----- autoupdate.py
'''metaclass for auto-update classes'''
class __metaclass__(type):
# automatically keeps tracks of instances
def __new__(cls, class_name, bases, class_dict):
import inspect
module_name = class_dict['__module__']
#we will update bellow the class_dict with a new key:
#instance_dict_name and value a list of instances
instance_dict_name = '_%s__instances' % class_name
# see if there is already an older class
import sys
old_instance_dict = None
if sys.modules.has_key(module_name):
module = sys.modules[module_name]
if hasattr(module, class_name):
old_instance_dict = getattr(getattr(module, class_name),
instance_dict_name)
# add instance list
import weakref
class_dict[instance_dict_name] = weakref.WeakValueDictionary()
# override the __init__
if class_dict.has_key('__init__'):
def new_init(self, *args, **kw):
instance_dict_name = '_%s__instances' % (
self.__class__.__name__)
getattr(self.__class__,
instance_dict_name)[id(self)] = self
self.__original_init__(*args, **kw)
class_dict['__original_init__'] = class_dict['__init__']
class_dict['__init__'] = new_init
else:
def new_init(self, *args, **kw):
instance_dict_name = '_%s__instances' % (
self.__class__.__name__)
getattr(self.__class__,
instance_dict_name)[id(self)] = self
class_dict['__init__'] = new_init
# build the class, with instance_dict
new_class = type.__new__(cls, class_name, bases, class_dict)
# copy over the instance dictionary, and update __class__
if old_instance_dict is not None:
for instance_id, instance in (
old_instance_dict.iteritems()):
getattr(new_class,
instance_dict_name)[instance_id] = instance
instance.__class__ = new_class
# return new class
return new_class
#----- Spam.py
from autoupdate import __metaclass__
class Egg:
'''Put here your class code'''
# def print(self):
# print 'Hello World!'
#----- from your Python console
import Spam
x = Spam.Egg()
# ... edit your Spam.py file and change code for Spam.Egg class,
# e.g.: add a print() method to Spam.Egg by uncommenting
# the corresponding lines. Save the file.
reload(Spam)
x.print() # prints 'Hello World!'
The "bester" coloring tool: color SynthAxis.
It actualy allows anti-designers pretend to be "ok" designers as far as "color schemes" go.
One aspect I cannot understand in TDD is how someone can assume that code is good if it's tested.Code that tests something is still code isn't it?
How do you know if you tested for everything that may go wrong?
If you can get the test correct then you can also get the main code correct.
The only help I see from TDD is that it may allow to see how fixing something here breaks something there. But that means the code is coupled and then how do you test for all this coupling?
-Your code should not be coupled.
-But how do I write GUI code that is uncoupled?
-Don't couple beforehand, instead use runtime registration of event handling.
-How is that uncoupling? How do you test for this chain of events and how do you know how are they going to happen?
-Test everything behind the GUI and leave GUI tests for later.
-What's the point?
-You should not write GUI code and start do some tests.
-Ha?
Ned Batchelder had problems mimicking Java's interfaces in Python and then he also had problems departing from that too.
The problem is that the implementer actually implements all the methods in the interfaces (via inheritance) regardless of whether it overwrites the behavior or not.
If there were real interfaces in Python's language, then this would not be a problem since it would only be implemented if it actually implements it.
He also explains how one does this in Java, which IMO is because Java forces you to implement all the methods in the implementer, so you must start creating hierarchies of interfaces to allow the implementer implement only one method, namely the child interfaces's method.
In python, thanks to the fact that everything is an object and dynamic nature of things you can declare that something does something other ways:
methodName.notYetImplemented = True even if there is code in the body of the method and then rely on this attribute of the method's object rather then on the fact that there is code in the body of the method or not like in Java.
def makeAbstract(f):
f.abstract=True
return f
class NotImplemented(Exception): pass
class Executable:
@makeAbstract
def oneWay(self):
raise NotImplemented
@makeAbstract
def secondWay(self):
raise NotImplemented
or for py2.3
oneWay = makeAbstract(oneWay)
secondWay = makeAbstract(secondWay)
class Statement(Executable):
def oneWay(self):
print "one way executed"
s = Statement()
if not hasattr(getattr(s, 'oneWay'), "abstract"):
s.oneWay()
else:
s.secondWay()
We can't really see what technology does because:
an exponential curve approximates a straight line when viewed for a brief duration (Ray Kurzweil)
So predictions are always in linear way (see below) because they are ideas applied to ideas.
The problem with "non-technological" fields of knowledge is that there is no reliable apparatus to effectively remembering and so to being able to quickly applying knowledge, rather a cycle of re-inventions and epiphanies (lousy memory triggers) represent the engine of evolution.
So really what technology does, it allows us to remember?.
Technology way, the exponential way (the anti-struggling way?)
Ideas build concrete objects. A
A and ideas build concrete objects. B
B and ideas build concrete objects. C
...
Gnoseology way, the linear way (the struggling way?)
Ideas build ideas. A
A builds ideas. A
A builds ideas. A
...
The equation to spin around Bill Joy:
linear + exponential = exponential
gnoseology + technology = technology
epistemology = gnoseology + technology
ontology = epistemology
ontology = technology
versus the old way
epistemology = gnoseology
ontology = epistemology
Thank you syllogism for being a friend again and probably still let me be with the ontology maped the old way.
Install XP in 5 hours or less
Install X-Chat in 5 hours or more
Sometimes you may find yourself taken over by the flow of things, when your brain is more in a "sensory like" state.
=> You may find this funny
Sometimes you may find yourself taken over by the critical you, when your brain is more in a "why, when, how" state.
=> You may find this sad
Again IMO is always about "my world" rather the "the world".
Via Ian Bicking
I realized I dislike Kerry because he isn't who I want him to be. But that's unfair -- he is who he is. He was selected for who he was.
The world does not exist, what exists is "my world" where the world is in the ways I got where I am know, with my frustrations, my happy moments, my knowledge and from there the inferred inevitable subjective opinions etc.
I strongly believe that even mathematics to a prety large degree is subjective, then what to talk about the less a priori wings of the world.
I didn't know about this
Nice
I've been inlining in emails, but for web I was always using a separate script to
give out images for which links should not be known like:
<img src="getImage?id=bla">
<img src="getImage?id=bla2">
where getImage only works if a user is signed in or something.
Now I can turn more round trips into one if images are not big using something like
<img
src="data:image/gif;base64,
R0lGODlhAwEgAPcAAP///87OzqWlpYSEhHNzc2tra1paWiEYGQv+E
AP/OGP/OAM7Oxr29xjEA/2MA/5wA/+8A/+dK79573ta8AGAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAIpHuDBABsMANrb8JqF0gFxG+XAAHeqe2S+
Rh//hEFwEiA8ENJPN8K6NawcWA50CCLMnw7kUa/p
Rdrpco7uOexAMKBLYPpNlxAZ6DAnJlm7WlavA4FANR0Kg9CEAC
BAQAOw==
" >