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

2013-09-02 Thread Noufal Ibrahim
babmis  writes:

[...]

Really. Please use the body of the email for the message and the subject
line for the subject.

-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


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

2013-09-02 Thread Anand B Pillai
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 03 September 2013 06:27 AM, Anand Chitipothu wrote:
>> This is another version of this by mucking around directly with
>> sys.exitfunc using a with context.
>> 
>> from contextlib import contextmanager
>> 
>> @contextmanager def end_of_days(): def wrapper(): print
>> 'Goodbye.' yield wrapper
>> 
>> with end_of_days() as sys.exitfunc: print 3+4
>> 
> 
> How is this different from:
> 
> import sys def goodbye(): print "Goodbye"
> 
> sys.exitfunc = goodbye
> 
> I don't think we are really doing anything with the context in your
> example except initializing sys.exitfunc.


Well, nothing really except maybe,

@contextmanager
def end_of_days():
before_context()
def wrapper():
print 'Goodbye.'
yield wrapper
print after_context()

with end_of_days() as sys.exitfunc:
print 3+4

Just provides a context manager as well to do things
before entering context and after exiting (just before
sys.exit in this case), in a modular way.

> 
> Anand ___ BangPypers
> mailing list BangPypers@python.org 
> http://mail.python.org/mailman/listinfo/bangpypers
> 


- -- 
Regards,

- --Anand

-
--
Software Architect/Consultant
anandpil...@letterboxes.org

Please note my updated email address .
Kindly update your address books.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSJVS7AAoJEHKU2n17CpvDbdsIAJD8T8AJp49jmE5l/tEpUCKu
k5U0e3cTcy7rAevxhE40lFjvmTAENw6K85Eh1hTbVt0uRQDhdDs7Lv47WuVHEppH
28WlGkufwMHc5fIPb1XVbL7UbzPcqZd/6tUTXN+AAYZYtx2OB1rRiG6REhiFyY+Z
+8hPwMWcs6n3oV8hCJbdFITaRM9pm4RozBolFVe+r5LWBp1IO56fSt0IFDS9gceI
5NhLI9JZReoqYEfK8cPtNBjM9y1tLGJ8AZP60E0n3WGgVZMFK0Mw1xloefIZvaBC
xa5l81BVq+zov50WkXTQ/FVCGQpJM7l9A9XRfTznC5nnx2QVbitOPgFNNZpIYQc=
=V14p
-END PGP SIGNATURE-
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


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

2013-09-02 Thread Anand Chitipothu
> This is another version of this by mucking around directly
> with sys.exitfunc using a with context.
>
> from contextlib import contextmanager
>
> @contextmanager
> def end_of_days():
> def wrapper():
> print 'Goodbye.'
> yield wrapper
>
> with end_of_days() as sys.exitfunc:
> print 3+4
>

How is this different from:

import sys
def goodbye():
print "Goodbye"

sys.exitfunc = goodbye

I don't think we are really doing anything with the context in your example
except initializing sys.exitfunc.

Anand
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


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

2013-09-02 Thread Anand B Pillai
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Monday 02 September 2013 08:09 PM, venkatakrishnan g wrote:
> import atexit
> 
> def callback(): print "about to exit!"
> 
> atexit.register( callback )

Better use it as decorator.

import atexit

@atexit.register
def last_man_standing():
print "Hasta la vista, Baby."p


This is another version of this by mucking around directly
with sys.exitfunc using a with context.

from contextlib import contextmanager

@contextmanager
def end_of_days():
def wrapper():
print 'Goodbye.'
yield wrapper

with end_of_days() as sys.exitfunc:
print 3+4


> 
> 
> On 2 September 2013 20:00, babmis  wrote:
> 
>> 
>> __**_ BangPypers
>> mailing list BangPypers@python.org 
>> http://mail.python.org/**mailman/listinfo/bangpypers
>>
>
>> 
___
> BangPypers mailing list BangPypers@python.org 
> http://mail.python.org/mailman/listinfo/bangpypers
> 


- -- 
Regards,

- --Anand

-
--
Software Architect/Consultant
anandpil...@letterboxes.org

Please note my updated email address .
Kindly update your address books.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSJO29AAoJEHKU2n17CpvDSK4IALaLNb/tP3MjUE6EvQskn8EQ
SLg2BuUY0dy2f+QfHQ2bBZLj3unuHHPHlugfK8wGbNpB80rGm0lpoyqxiU7H2JnN
aSXGyAS435VemqohOr26ZN/5nsYdSkz87KnJNlZ8YagPd+RaDZd/dc6BNM3er7va
DioJnm+txAqIenv3xGeYNQfs7U7QljKcdrzqPjJuQp65ZmSUbcfmPls1I7B6Oxxe
1Xj+ax/N3wJeNKkWZKsvOJsHgQNMjNhTICfH8Ofsv0c04mlXI/Ej3+yIzQ/2tZwc
k9jQrlX/Wgv+Mza41RPCtJTJGkbfFVTCOiQQjvwA4ZnriuwmTAcH2axELbSr1aU=
=E2cM
-END PGP SIGNATURE-
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


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

2013-09-02 Thread venkatakrishnan g
import atexit

def callback():
  print "about to exit!"

atexit.register( callback )


On 2 September 2013 20:00, babmis  wrote:

>
> __**_
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/**mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


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

2013-09-02 Thread babmis


___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] [gsoc-india] Re: A BoF session about Google Summer of Code at PyConIndia tomorrow

2013-09-02 Thread Dhruv Baldawa
Hi,
It was awesome meeting everyone at PyCon. Sarup, can you make the
spreadsheet you created earlier public ? Everyone can add/update their
details accordingly.

--
Dhruv Baldawa
(http://www.dhruvb.com)


On Mon, Sep 2, 2013 at 5:09 PM, Anuj Deshpande wrote:

> Could we have the group photo posted here ?
>
>
> On Saturday, August 31, 2013 11:55:18 PM UTC+5:30, Amber Jain wrote:
>
>> Hello,
>>
>> I hope that everyone who was a PyCon India today enjoyed it a lot (like I
>> did).
>>
>> I'm a Google Summer of Code 2012 intern. I met over a dozen fellow
>> GSoCers at PyCon India today. I'm sure that there are other ex-GSoC interns
>> roaming around at PyConIndia's venue. Dhananjay (another ex-GSoCer)
>> suggested to do a BoF [1] session to talk about GSoC. All current/past GSoC
>> interns/mentors (as well as those who are interested in applying to GSoC in
>> future) are invited. I guess this will be the first time GSoC interns from
>> different years and from different states of India will be together at one
>> place.
>>
>> Please note, afaik, you can only attend PyCon India if you purchased a
>> ticket from http://in.pycon.org/2013/.  I'm sorry but we can't do
>> anything about this. Please make sure that you have a PyCon India ticket
>> before you plan to attend this event.
>>
>> Date: September 1, 2013
>> Time: 12:15pm
>> Venue: PyCon India Open Space (Auditorium 3 at NIMHANS Convention Center:
>> https://maps.google.com/maps?**q=NIMHANS+convention+centre+**
>> bangalore&t=m&z=13
>> ).
>>
>> See you there!
>>
>>
>> [0] 
>> http://www.google-melange.com/**gsoc/homepage/google/gsoc2013
>> [1] 
>> http://en.wikipedia.org/wiki/**Birds_of_a_feather_%**28computing%29
>>
>> --
>> Amber Jain
>> i.ambe...@gmail.com
>> http://amberj.devio.us/
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Google Summer of Code - Indian Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gsoc-india+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/gsoc-india.
> For more options, visit https://groups.google.com/groups/opt_out.
>
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers