nouvelles du froid #2



Donc il est tombé 50 cm de neige. Soyons honnêtes, et tant pis pour ceux que ça a ennuyé, c'est fun. J'ai loupé toutes les photos dans la tempête mais de toute façon j'y voyais si peu qu'à un moment j'ai ouvert les yeux et j'étais au milieu de la route avec les voitures en train de foncer vers moi... huhu.  Donc si j'y voyais rien j'imagine que l'appareil ne voyait pas bezef non plus.

Après pas mal de passage de chasse neige en milieu d'après midi la rue ressemblait à ça (il pouvait y avoir des tas de neiges d'1m50 + par endroit) :


Sinon, un endroit ou je vais prendre mon café se trouve dans le quartier latin et la vue qui normalement ressemble à ça :

Ressemble à ca maintenant: 



Dans cet endroit, j'ai rencontré Nicolas, lui après 5 ans à passer ses vacances à Montréal où il avait rencontré sa mie, il a décidé de s'installer, et manque de bol, il a eu été un peu plaqué à son arrivée à Québec. Ça ne le démoralise pas trop, et muni d'un visa touristique il compte trouver son travail.


Là sur cette image il est heureux, il a profité des soldes d'hier matin et réussi à acheter sa literie à -70% (c'est les soldes en ce moment) et je suis jaloux. J'ai profité un peu des soldes mais juste pour un pull et un jean. Ben je me fais pas de soucis pour lui, je pense qu'il y arrivera.

J'ai pas encore regardé pour l'apparte, honte à moi :) je sais que c'est l'affaire de 3 semaines à trouver sans se fouler. Donc j'ai encore un peu de temps devant moi.

Sinon je m'amuse à faire capoter l'appareil photo en prenant des clichés où il y a des éclairages et des infrarouges, les résultats sont amusants.




Lettre à ma maman #1

Alors, hier alors que je pissais dans une ruelle, je me disais, faudrait que je rassure ma maman restée au pays quand au fait que Montréal est une ville où il fait beau vivre. C'est vrai, après 5 semaines ici, je sens bien mon expertise :)

Et alors, que ce projet me traversais l'esprit je me suis dit faut vraiment le faire et pour c'est ainsi que j'ai fait cette photo :


Hé bien, tu me croiras pas : c'est à ce moment précis que le flic qui était en train de me suivre pour vérifier si j'étais pas en train d'uriner illégalement est arrivé.

Il m'a vu en train de photographier, et il s'est excusé.

Et d'un coup, j'ai compris que c'était le Karma. On a une idée con en pissant, le genre de truc qu'on ne fera jamais, mais d'un coup, paf, on sait qu'on doit le faire parce que l'univers vous envoie un signe.

Donc voilà le projet c'est de t'envoyer parfois une ou deux photos avec une tranche de vie pour que tu comprennes que ton fils est pas malheureux à Montréal

On va commencer par Alex :

Nous nous connaissons de mon café concert favori du moment: L'Escogriffe.

Il vient de la région du lac Saint Jean comme une personne sur 6 ici. Ils ont des accents à couper au couteau (bien qu'ils prétendent qu'ici c'est moi qui aurait un accent...).

Il était freelance graphiste en informatique puis il en a eu marre de courir après l'argent, alors il a décidé de devenir un métallo. 

Là il va partir voir sa famille 2 semaines. Ensuite, il attend avec impatience de  reprendre les cours pour apprendre une méthode de soudure utilisée pour les pipelines ce qui lui permettrait d'aller sur les chantiers là où ça frette (caille des meules sévère en argot correct).

Il est content d'avoir changer de métier. Même si le graphisme ne lui manque pas, il s'est acheté un atelier de sérigraphie et ferait bien des T-Shirts pour lui et ses amis du travail.

Voilà ...

Tu t'inquiètes de ce que c'est sur internet?

Ahahah, tant que tu partages pas le lien, personne viendra le lire. Puis de toute façon, j'ai pas honte de rassurer ma pôôôvre mère épleurée dont le fils et si loin.

Auto documenting and validating named arguments

In real life there are companies were keywords (**kw) are prohibited, and others where positional arguments can stack up as high as seven. Let's state the obvious concerning arguments:

Human beings are flawed


The positional arguments are fixed arguments. Some are mandatory others are optional (and are being set at function definition). 

Named arguments is a way to give arguments which are known by their name not their positions. 

If we humans were not limited by our short term memory then positional arguments would be enough. Alas we are limited to 7 items in memory +- 2. I normally strongly advise to remember that even if you can go up to 9 because you are genius, when you are woken up at 3 am after a party for a critical bug your short term memory might drop to 5+-2 items. So be prepared for the worse and follow my advice and try to stick to 3 mandatory positional arguments the more you can. 

Then, you have the case against the named arguments.

Named arguments are great for writing readable calls to function especially when there are a lot of optional arguments or when calls can be augmented on the fly thanks to duck typing and all funky stuffs that makes programming fun.

However, the documentation of the function might seems complex because you have to do it by hand as you can see here :
https://github.com/kennethreitz/requests/blob/master/requests/api.py

Plus the signature of the function is quite ugly.

    
get(url, **kwargs)
        Sends a GET request. Returns :class:`Response` object.
        
        :param url: URL for the new :class:`Request` object.
        :param **kwargs: Optional arguments that ``request`` takes.

So, even if named arguments are great they are painful to document (thus a little less maintainable), and gives function a cryptic signature when used in the form **kwargs.


Having explicit named arguments with default values are therefore «more pythonic» since :

Explicit is better than implicit. 

Decorators for easing validation documentation 



Since I am an advocate of optional named arguments and I find them cool, I thought why not write code ... 

>>> @set_default_kw_value(port=1026,nawak=123)
... @must_have_key("name")
... @min_positional(2)
... @validate(name = naming_convention(), port = in_range(1024,1030 ))
... def toto(*a,**kw):
...     """useless fonction"""
...     return 1

... that would magically return a documentation looking like this:


toto(*a, **kw) useless fonction

keywords must validate the following rules:
  • key: <port> must belong to [ 1024, 1030 [,
  • key: <name> must begin with underscore
at_least_n_positional :2

keyword_must_contain_key :name

default_keyword_value :
  • params: port is 1026,
  • params: nawak is 123

The idea was just to make a class making decorator with reasonable defaults that would enhance the decorated function documentation based on functools.wrap code.


class Sentinel(object):
    pass
SENTINEL=Sentinel()

def default_doc_maker(a_func, *pos, **opt):
    doc = "\n\n%s:%s" % (a_func, a_func.__doc__)
    posd= "%s\n" % ",".join(map(str, pos))  if len(pos)  else ""
    named = "\n%s" % ",\n".join([ "* params: %s is %r"%(k,v) for k,v in opt.items() ]
        ) if len(opt) else ""
    return """
**%s** :%s
%s""" % ( 
        a_func.__name__,
        posd,
        named
    )


def valid_and_doc(
            pre_validate = SENTINEL,
            post_validate = SENTINEL,
            doc_maker = default_doc_maker
        ):
    def wraps(*pos, **named):
        additionnal_doc=""
        if pre_validate is not SENTINEL:
            additionnal_doc += doc_maker(pre_validate, *pos, **named)
        if post_validate is not SENTINEL:
            additionnal_doc += doc_maker(post_validate, *pos, **named)
        def wrap(func):
            def rewrapped(*a,**kw):
                if pre_validate is not SENTINEL:
                    pre_validate(*pos,**named)(*a,**kw)
                res = func(*a,**kw)
                if post_validate is not SENTINEL:
                    post_validate(*pos,**named)(*a,**kw)
                return res

            rewrapped.__module__ = func.__module__
            rewrapped.__doc__=func.__doc__  + additionnal_doc
            rewrapped.__name__ = func.__name__
            return rewrapped
        return wrap
    return wraps



That can be used this way :

def keyword_must_contain_key(*key):
    def keyword_must_contain_key(*a,**kw):
        if set(key) & set(kw) != set(key):
            raise Exception("missing key %s in %s" % (
                  set(key)^( set(kw)& set(key)),kw)
            )
    return keyword_must_contain_key


def at_least_n_positional(ceil):
    def at_least_n_positional(*a, **kw):
        if a is not None and len(a) < ceil:
            raise Exception("Expected at least %s argument got %s" % (ceil,len(a)))
    return at_least_n_positional

min_positional= valid_and_doc(at_least_n_positional)
must_have_key = valid_and_doc(keyword_must_contain_key) 

Okay, my code might not get an award for its beauty, but you can test it here https://github.com/jul/check_arg


And at least sphinx.automodule accepts the modified docs, and interactive help is working too. 

Of course, it relies on people correctly naming their functions and having sensibles parameters names :P

However, though it sound ridicule, I do think that most of our experience comes from knowing the importance of naming variables, modules, classes and functions correctly.


Conclusion



Since I am not satisfied by the complexity/beauty of the code I strictly have no idea if I will package it, or even work on it. But at least, I hope you got the point that what makes optional optional named arguments difficult to document is only some lack of imagination. :)



Cross dressing on the internet and gender issues

So the actual buzz is gender issues



http://www.kathrineswitzer.com/written_about.shtml
I dare say it is a non problem. But before let me tell you my story as a cross dresser ... on the internet.

Once upon a time I signed up for a famous dating site. And as advised by a friend, I was told to try with a fake feminine account. Well, let me tell you: it feels awkward. You are not at the right place. You directly notice it because communication is really different. Communication is sexualized.

At least it gave me tips on how to hit on girls: which techniques were working (thanks to fellow men), and which were not. After 3 hours, I stopped and analyzed on what I learned in the gender difference issues, and scripted a very efficient lightweight bot to help me improve my dating ratios.

Years later, I became a City of Heroes player. I had two very good reasons to cross dress again:
- if you ever played a MMORPG (meuporg as we say in my country), you may notice that in order to level up a support player needs to team with a party, and men prefer to team up with girls;
- the camera was always showing the player in subjective view, and feminine 3D model were awesome.

That's how I became half a man, and half woman. My damage dealers/tanks would be men (because they were accepted easily) and my support/controls were women. I was «love», «tainted love», «true love» and was having a perfect body I could enjoy watching... And even women would prefer my masculine looking damage dealers. Everyone is biased ...

Well, being proposed many times in global canals was disturbing. My chat was only feminized using huhu and hihi and nothing else, but talking like a men for the remaining turned them on. It was weired. So, I created a feminine only guild so that we wouldn't be bothered, and played with women. Needless to say the guild was 66% masculine IRL players (huhu). And I discovered women are not only common but good players. And we teamed up with feminine guilds too (that were knowing we were mainly men).

I then decided MMORPG were really enjoyable but taking too much of my time, so I get to a more fast paced game known as Urban Terror where my nick became [SF]Julie.  During pickups, I was favorised even though my level was lower (there are very good she players on Urt btw, I was even below their average).
I had of course troubles on public servers: people trying to hit on me or being sexists, but as I was an admin of our public server, they would get kicked/banned easily. And, I dare say that by being quite extreme, girls would enjoy playing on our server since they would not be annoyed.

Finally, nowadays on IRC I am an androgynous creature named Julie1 (julie + 1 pronounce as my real first name in french but people oddly enough just only read the feminine part). So I still am cross dressing in a way, and let me tell you, it has one advantage: on tech channels I get answers faster than «men».

Everybody is being pissed by the bad behaviors, and not the «unfair positive bias». And that bugs me; gender issues is like an auto reflexive feedback loop. How do we break it?

Speaking of women in free software



First I apologize for having crashed libroscope server. But as you can notice here, we libroscope were amongst the first to publicly speak of women in free software. Our method was to let them speak by themselves.

Since I am quite doubting everything, I was quite dubious to their claims they were discriminated. But, we let them speak. And I listened. Perline claimed for instance that the problem with men is that no project can be achieved in a mixed environment since men would take the lead, and not let women express themselves. And I thought to myself: «what a joke!» and then came the Q&A.

Well, for 15 minutes, an -he- anarchist, and very sensitive to women problems and utterly activist would explain to every one his problems as a women. The actual women present in the room were not even able to talk a single word. It was like a proof in example.

He was trying to shine in his white armor of protecting the women's pride. And all my years as a cross dresser came back: men talking on behalf of women on gender issues  is weired. Women being pushed in conference is also weired: it is like when I was accepted for partying only based on my gender. At my opinion it does not help women cause, it reinforces the bias.

So my message to men heralding women would be better understood in song I guess :

Do I have a solution?


Critic is easy. And I have a solution. One of our speaker the year before -Benjamin Mako Hill- made an awesome speech on the first freedom of free software (and that explained especially why non commercial use was bullshit), the freedom to use that in its term is radically non discriminative.

The ethic of free software/Open Source is based on action, and production. And I think that by being a regular free software user we should envision the deep implication is has:
- not a single discrimination, positive or negative is acceptable;
- when we install/use/modify a software do we already care if it is French, Black, Women Alien made? No we don't...

So Free/Libre/Open Source Software community is armed for accepting women... and all other minorities...

If Perline is right and women only communities are what it takes to empower feminine presence in Free Software: please do it. Production and quality is the only stuff that matters, whatever the means you have to use. You have my full support to exclude me from your workshop the time it will take for you to produce enough software in order to be respected. Even if it is kind of strange.


On internet though -dear women- you should try cross dressing. And if you want to fully understand men, maybe you should even try cross dressing on a dating site, in games, on IRC to understand the bias we all experience...

In fact, I praise everyone to walk in the other's shoes by cross dressing on internet. 


One of the stuff that bugs me though is: are we really aiming at the right issues. Behind the gender issues wouldn't we miss a broader issue? Why was free software shaped the way it was, and what is the invisible barrier that keeps not only women, but also a lot of other minorities out of free software? And shouldn't we measure in an objective way the diversity (economic, geographic) so that we can measure the impact of our actions?

I will make a wild guess however ... Free Software is probably regressing in terms of diversity since we are becoming more and more «experts». And, we might observe more and more people leaving the way pierre 303 left stack exchange.

But as I said before, without a survey we babble nonsense: we don't give ourself the means to measure the impact of our actions and to understand the real nature of the problem.