Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-15 Thread Alex
On Mar 15, 5:42 am, Carl Banks [EMAIL PROTECTED] wrote: On Mar 14, 6:37 pm, Alex [EMAIL PROTECTED] wrote: On Mar 13, 6:21 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 13, 7:02 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Alex a écrit : (sni) First of all

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-14 Thread Alex
On Mar 13, 6:21 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 13, 7:02 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Alex a écrit : (sni) First of all thanks all for answering! I have some environment check and setup in the beginning of the code. I would like to move

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-14 Thread Arnaud Delobelle
On Mar 14, 10:37 pm, Alex [EMAIL PROTECTED] wrote: On Mar 13, 6:21 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 13, 7:02 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Alex a écrit : (sni) First of all thanks all for answering! I have some environment check and

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-14 Thread Carl Banks
On Mar 14, 6:37 pm, Alex [EMAIL PROTECTED] wrote: On Mar 13, 6:21 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 13, 7:02 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Alex a écrit : (sni) First of all thanks all for answering! I have some environment check and

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Alex
On Mar 12, 8:48 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 12, 2:19 pm, Alex [EMAIL PROTECTED] wrote: Hi all, The subject says pretty much all, i would very appreciate an answer. I tried to search the various forums and groups, but didn't find any specific answer... Python

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Bruno Desthuilliers
Alex a écrit : (sni) First of all thanks all for answering! I have some environment check and setup in the beginning of the code. I would like to move it to the end of the script. Why ? (if I may ask...) But I want it to execute first, so the script will exit if the environment is not

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Carl Banks
On Mar 13, 7:02 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Alex a écrit : (sni) First of all thanks all for answering! I have some environment check and setup in the beginning of the code. I would like to move it to the end of the script. Why ? (if I may ask...) But I

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Jonathan Gardner
On Mar 12, 6:37 pm, Carl Banks [EMAIL PROTECTED] wrote: On Mar 12, 8:11 pm, Justus Schwabedal [EMAIL PROTECTED] wrote: What do you need it for anyway? I just read about it and I think it's useless in python. Perl, like Python, has a separate compilation and run times.  One day, someone

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Paddy
On Mar 13, 7:03 pm, Jonathan Gardner [EMAIL PROTECTED] wrote: On Mar 12, 6:37 pm, Carl Banks [EMAIL PROTECTED] wrote: Snip And leave out the magical -p and -n. If you want to iterate through a file, for line in sys.stdin:. Or better still: import fileinput for line in

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Jeff Schwab
Paddy wrote: On Mar 13, 7:03 pm, Jonathan Gardner [EMAIL PROTECTED] wrote: On Mar 12, 6:37 pm, Carl Banks [EMAIL PROTECTED] wrote: Snip And leave out the magical -p and -n. If you want to iterate through a file, for line in sys.stdin:. Or better still: import fileinput for

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Aahz
In article [EMAIL PROTECTED], Jeff Schwab [EMAIL PROTECTED] wrote: I write maybe a dozen one-liners a day. It's not practical to do this with Python, or at least it's not nearly as convenient as Perl. That is a defensible position, but my take is that writing the one-liners in Python is

Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Alex
Hi all, The subject says pretty much all, i would very appreciate an answer. I tried to search the various forums and groups, but didn't find any specific answer... Thanks, Alex. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Paddy
On Mar 12, 6:19 pm, Alex [EMAIL PROTECTED] wrote: Hi all, The subject says pretty much all, i would very appreciate an answer. I tried to search the various forums and groups, but didn't find any specific answer... Thanks, Alex. No not really. There are lots of other ways to structure a

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Carl Banks
On Mar 12, 2:19 pm, Alex [EMAIL PROTECTED] wrote: Hi all, The subject says pretty much all, i would very appreciate an answer. I tried to search the various forums and groups, but didn't find any specific answer... Python technically has no equivalent: you can't run code at compile time.

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Tim Chase
The subject says pretty much all, Given what I understand about the BEGIN block[1], this is how Python works automatically: bash$ cat a.py print 'a1' import b print 'a2' bash$ cat b.py print 'b' bash$ python a.py a1 b a2 However, the first import does win and

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2008 11:19:05 -0700, Alex wrote: Hi all, The subject says pretty much all Only to people who know what the Perl BEGIN{} block means. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Justus Schwabedal
What do you need it for anyway? I just read about it and I think it's useless in python. On Mar 13, 2008, at 1:03 AM, Steven D'Aprano wrote: On Wed, 12 Mar 2008 11:19:05 -0700, Alex wrote: Hi all, The subject says pretty much all Only to people who know what the Perl BEGIN{} block

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Carl Banks
On Mar 12, 8:11 pm, Justus Schwabedal [EMAIL PROTECTED] wrote: What do you need it for anyway? I just read about it and I think it's useless in python. Perl, like Python, has a separate compilation and run times. One day, someone who was trying to use Perl for something asked, You know,

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Jeff Schwab
Alex wrote: The subject says pretty much all, i would very appreciate an answer. I tried to search the various forums and groups, but didn't find any specific answer... I'd like an answer to this, too. In Perl, I mostly used it for one-liners, when a variable needed to be initialized to

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-12 Thread Paddy
On Mar 13, 1:37 am, Carl Banks [EMAIL PROTECTED] wrote: On Mar 12, 8:11 pm, Justus Schwabedal [EMAIL PROTECTED] wrote: What do you need it for anyway? I just read about it and I think it's useless in python. Perl, like Python, has a separate compilation and run times. One day, someone