Re: [BangPypers] How to run a block of code just before the interpreter is being exited like END{} in perl ??

2013-09-09 Thread Anand B Pillai
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sunday 08 September 2013 10:43 PM, Saager Mhatre wrote: With a verb name like *register* I'd much prefer to call the function as opposed to using it as a decorator. The more idiomatic decorators have noun names, viz- property, classmethod,

[BangPypers] Favorite tips/techniques

2013-09-09 Thread CsquaredinOmaha
  For a while I had thought it would be interesting to hear tips/techniques you  find yourself often using  - or perhaps found useful at one point (and thus would be valuable to newbies). It could be simple snippet, or some description of  logic, technique or steps. From simple to sophisticated

Re: [BangPypers] Appropriate list conduct (was Re: Fwd: Fw: Fwd: https://github.com/pythonhacker/ladies.py)

2013-09-09 Thread CsquaredinOmaha
Bibhas, You should be able to rest easy.  In the 10+yrs I have been on this mailing seldom/never have I seen someone bring in discord  and  in-your-face as was done recently... I rather expect to go another 10yrs before seeing it here again. Now, to Bibhas'  point about desiring to see

[BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/ With api responses after you have parsed the json, you start doing things like: api_response[attribute] I would much prefer to do api_response.attribute Which the bunch pattern can enable. I don't

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Shabda Raaj sha...@agiliq.com writes: http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/ With api responses after you have parsed the json, you start doing things like: api_response[attribute] I would much prefer to do api_response.attribute I

[BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
I generally like to use attributes instead of keys. If you are parsing json, aren't you limited to using keys? The bunch pattern can fix this, but its not widely known/used, so I don't use it as frequently as I would like. -- Thanks, Shabda Agiliq.com - Building Amazing Apps agiliq.com/blog/

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Shabda Raaj sha...@agiliq.com writes: I generally like to use attributes instead of keys. If you are parsing json, aren't you limited to using keys? Of course. I was making a general statement about attributes vs. keys. The bunch pattern can fix this, but its not widely known/used, so I

[BangPypers] Python Wats

2013-09-09 Thread Shabda Raaj
This is a popular talk on quircks of ruby/js https://www.destroyallsoftware.com/talks/wat What are the quircks/unexpected behavior you find in Python? (Aka Python wats). -- Thanks, Shabda Agiliq.com - Building Amazing Apps agiliq.com/blog/ | github.com/agiliq US: +13152854388 | IN:

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:09 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Shabda Raaj sha...@agiliq.com writes: I generally like to use attributes instead of keys. If you are parsing json, aren't you limited to using keys? Of course. I was making a general statement about attributes

Re: [BangPypers] Python Wats

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj sha...@agiliq.com wrote: This is a popular talk on quircks of ruby/js https://www.destroyallsoftware.com/talks/wat What are the quircks/unexpected behavior you find in Python? (Aka Python wats). x = 10 class Foo: print x x = 0

Re: [BangPypers] Python Wats

2013-09-09 Thread Ramchandra Apte
On 10 September 2013 10:21, Anand Chitipothu anandol...@gmail.com wrote: On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj sha...@agiliq.com wrote: This is a popular talk on quircks of ruby/js https://www.destroyallsoftware.com/talks/wat What are the quircks/unexpected behavior you find

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
https://github.com/webpy/webpy/blob/master/web/utils.py#L52 Wow, thats better than the bare bunch impl. Gonna use it now. Unrelated tip: Here is a one liner I use to generate passwords and other random strings. ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))

Re: [BangPypers] Python Wats

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:37 AM, Ramchandra Apte maniandra...@gmail.comwrote: On 10 September 2013 10:21, Anand Chitipothu anandol...@gmail.com wrote: On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj sha...@agiliq.com wrote: This is a popular talk on quircks of ruby/js

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj sha...@agiliq.com wrote: https://github.com/webpy/webpy/blob/master/web/utils.py#L52 Wow, thats better than the bare bunch impl. Gonna use it now. Unrelated tip: Here is a one liner I use to generate passwords and other random strings.

Re: [BangPypers] Python Wats

2013-09-09 Thread Ramchandra Apte
I get UnboundLocalError: local variable 'x' referenced before assignment. That's strange, I'd expect the first print statement to print 10, not generate an exception. On 10 September 2013 10:39, Anand Chitipothu anandol...@gmail.com wrote: On Tue, Sep 10, 2013 at 10:37 AM, Ramchandra Apte

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Anand Chitipothu anandol...@gmail.com writes: [...] I use it very often. Here is my random-password script. [...] I use mkpasswd(1) :) -- Cordially, Noufal http://nibrahim.net.in ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Anand Chitipothu anandol...@gmail.com writes: [...] I use it very often. Here is my random-password script. [...] I use mkpasswd(1) :) $ sudo apt-cache search mkpasswd libstring-mkpasswd-perl - Perl module

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
Real programmers pipe /dev/urandom :) Let me preempt the xkcd: http://xkcd.com/378/ On Tue, Sep 10, 2013 at 10:47 AM, Anand Chitipothu anandol...@gmail.comwrote: On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Anand Chitipothu anandol...@gmail.com writes:

Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Anand Chitipothu anandol...@gmail.com writes: [...] $ sudo apt-cache search mkpasswd libstring-mkpasswd-perl - Perl module implementing a random password generator I think that's something else. noufal@sanitarium% dpkg -S =mkpasswd whois: /usr/bin/mkpasswd noufal@sanitarium% file

Re: [BangPypers] Python Wats

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:46 AM, Ramchandra Apte maniandra...@gmail.comwrote: I get UnboundLocalError: local variable 'x' referenced before assignment. That's strange, I'd expect the first print statement to print 10, not generate an exception. A variable is either local or global. It is

Re: [BangPypers] Python Wats

2013-09-09 Thread Shabda Raaj
A variable is either local or global. It is decided at the compile time. Erm, compile? Python's scoping rules are , erm, interesting: http://me.veekun.com/blog/2011/04/24/gotcha-python-scoping-closures/ The mnemonic for scoping is LEGB:

Re: [BangPypers] Python Wats

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:57 AM, Shabda Raaj sha...@agiliq.com wrote: A variable is either local or global. It is decided at the compile time. Erm, compile? well, you may call it module/script load time. But python compiles the code and generates bytecode before executing it. $ file a.pyc

[BangPypers] Should equality (__eq__) be dependent on the typeof object?

2013-09-09 Thread Shabda Raaj
Eg: See this: http://nbviewer.ipython.org/5151306 I was expecting datetime.date.today() == datetime.datetime.today() to give me a True. (It is false). For example this works as I expect: http://nbviewer.ipython.org/5151398 However looks like __eq__ is doing a isinstance check - I would

Re: [BangPypers] Should equality (__eq__) be dependent on the typeof object?

2013-09-09 Thread Noufal Ibrahim
Shabda Raaj sha...@agiliq.com writes: Eg: See this: http://nbviewer.ipython.org/5151306 I was expecting datetime.date.today() == datetime.datetime.today() to give me a True. (It is false). I'd expect it to be False. There will be a small amount of time between the two invocations and the

Re: [BangPypers] Python Wats

2013-09-09 Thread Bibhas
Anand Chitipothu anandol...@gmail.com wrote: On Tue, Sep 10, 2013 at 10:57 AM, Shabda Raaj sha...@agiliq.com wrote: A variable is either local or global. It is decided at the compile time. Erm, compile? well, you may call it module/script load time. But python compiles the code and

[BangPypers] Short term contract - Flask developer

2013-09-09 Thread Tej Pochiraju
Hi all, I am looking for a reasonably experienced Flask developer to help us put finishing touches on a product. Experience of remote configuration management tools such as Salt Stack would be greatly appreciated. Please get in touch if interested and feel free to pass my details onto anyone you

Re: [BangPypers] Should equality (__eq__) be dependent on the typeof object?

2013-09-09 Thread Shabda Raaj
I'd expect it to be False. There will be a small amount of time between the two invocations and the time will change Ok, that makes sense. Should have written a better test case. What about this. datetime.datetime(2013, 1, 1) == datetime.date(2013, 1, 1) False datetime.datetime.today() ==