Re: Check if variable is an instance of a File object

2006-09-15 Thread George Sakkis
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: > > #1 : should I start by checking that 'file' is indeed an instance of a > > File object ? > > Unless you have a *very* compelling reason to do so (and I can't imagine > one here), definitively, no. FWIW, it's pretty common in Python to pass

Re: Check if variable is an instance of a File object

2006-09-15 Thread Fuzzyman
[EMAIL PROTECTED] wrote: > Hi everyone, > > Maybe these questions will sound strange to you, but I sometime have a > hard time switching from Java to Python ;-) > > Let's say I have a function like this : > > def show_lines(file): > for next_line in file: > ... > > What can I d

Re: Check if variable is an instance of a File object

2006-09-15 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Marc 'BlackJack' Rintsch a ecrit : > >> And what do you do if you check for `file` and it isn't such an instance? >> Raise an exception? A no, that's something you don't like. So what else? >> ;-) > > Well, I prefer the idea of raising my *own* exception to the idea

Re: Check if variable is an instance of a File object

2006-09-15 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi everyone, > > Maybe these questions will sound strange to you, but I sometime have a > hard time switching from Java to Python ;-) > > Let's say I have a function like this : > > def show_lines(file): > for next_line in file: > ... OT : this wi

Re: Check if variable is an instance of a File object

2006-09-15 Thread sc_wizard29
Thanks for your help peter ! -- http://mail.python.org/mailman/listinfo/python-list

Re: Check if variable is an instance of a File object

2006-09-15 Thread Peter Otten
[EMAIL PROTECTED] wrote: > > Marc 'BlackJack' Rintsch a ecrit : > >> And what do you do if you check for `file` and it isn't such an instance? >> Raise an exception? A no, that's something you don't like. So what >> else? ;-) > > Well, I prefer the idea of raising my *own* exception to the i

Re: Check if variable is an instance of a File object

2006-09-15 Thread sc_wizard29
Marc 'BlackJack' Rintsch a ecrit : > And what do you do if you check for `file` and it isn't such an instance? > Raise an exception? A no, that's something you don't like. So what else? > ;-) Well, I prefer the idea of raising my *own* exception to the idea of having an unknown behavior occu

Re: Check if variable is an instance of a File object

2006-09-15 Thread Calvin Spealman
On 15 Sep 2006 00:18:14 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi everyone, > > Maybe these questions will sound strange to you, but I sometime have a > hard time switching from Java to Python ;-) > > Let's say I have a function like this : > > def show_lines(file): > for nex

Re: Check if variable is an instance of a File object

2006-09-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, sc_wizard29 wrote: > Maybe these questions will sound strange to you, but I sometime have a > hard time switching from Java to Python ;-) > > Let's say I have a function like this : > > def show_lines(file): > for next_line in file: > ... > > What can

Check if variable is an instance of a File object

2006-09-15 Thread sc_wizard29
Hi everyone, Maybe these questions will sound strange to you, but I sometime have a hard time switching from Java to Python ;-) Let's say I have a function like this : def show_lines(file): for next_line in file: ... What can I do to be sure that the input argument is in