"spir" wrote
I often use the else clause of try...except. This allows putting
only the
minimum problematic code lines inside the try block, which is good
both for
legibility andto avoid catching unexpected errors. The else will be
executed
only in case of no exception:
try:
problematic_inst
On Mon, 29 Dec 2008 13:18:55 -0700
"Eduardo Vieira" wrote:
> Hello, this weekend I had fun using Python for text processing. I
> needed to change a qif converted from a ofx, using the tool MT2OFX
> (http://www.xs4all.nl/~csmale/mt2ofx/en/index.htm)
> I wanted to change transactions like these:
>
Hello, this weekend I had fun using Python for text processing. I
needed to change a qif converted from a ofx, using the tool MT2OFX
(http://www.xs4all.nl/~csmale/mt2ofx/en/index.htm)
I wanted to change transactions like these:
D11/14/2008
MCHEQUE 102 17590807;Cheque or Preauth. Debit
T-500.00
N102
On Sun, Dec 28, 2008 at 8:49 PM, wormwood_3 wrote:
> Hello all,
>
> This might be trivially easy, but I was having a hard time searching on it
> since all the component terms are overloaded:-) I am wondering if there is a
> way to print out the code of a defined function.
If the source code is av
On Mon, 29 Dec 2008 09:18:43 -
"Alan Gauld" wrote:
>
> "wormwood_3" wrote
>
> > I am wondering if there is a way to print out the code of a defined
> > function.
>
> Its not reliable but I think you can use
>
> func.func_code.filename
> func.func_code.firstlineno
>
> To find the first
On Mon, 29 Dec 2008 09:10:45 -
"Alan Gauld" wrote:
>
> "bob gailer" wrote
>
> > Also IMHO it is bad design to put a lot of code inside a try block.
> > In this case the user might make a mistake on day and then is forced
> > to reenter the year and month!
>
> Obviously there is no absol
prasad rao wrote:
hello!
I am a novice looking up to the tutor as my Guide.
I got a problem while using optional parameter.
#! user/bin/env python
import os
def myfiles(directory,extension=None):
change that to def myfiles(directory,extension=""):
for x in [os.path.join(x,i) f
Dj Gilcrease wrote:
def myfiles(directory,extension=None):
for x in [os.path.join(x,i) for x,y,z in os.walk(directory)\
if extension: << SYNTAX ERROR!
for i in z if i.endswith(extension)]:print x
--
Bob Gailer
Chapel Hill NC
919-636-4239
__
def myfiles(directory,extension=None):
for x in [os.path.join(x,i) for x,y,z in os.walk(directory)\
if extension:
for i in z if i.endswith(extension)]:print x
Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com
___
Tutor maillist -
hello!I am a novice looking up to the tutor as my Guide.
I got a problem while using optional parameter.
#! user/bin/env python
import os
def myfiles(directory,extension=None):
for x in [os.path.join(x,i) for x,y,z in os.walk(directory)\
for i in z if i.endswith(extension)]:prin
"wormwood_3" wrote
I am wondering if there is a way to print out the code of a defined
function.
Its not reliable but I think you can use
func.func_code.filename
func.func_code.firstlineno
To find the first line of code in the original source file.
Its up to you to figure out the last line
"bob gailer" wrote
Also IMHO it is bad design to put a lot of code inside a try block.
In this case the user might make a mistake on day and then is forced
to reenter the year and month!
Obviously there is no absolute rule here but I disagree.
One of the biggest advantages of try/except err
"David" wrote
Is this the correct way to handle a ValueError exception and should
I get in the practice of catching them?
Yes and Yes.
Although I woulfd move the except clause up to just after the input
section
(which is where the errors will be raised). A couple of other comments
below:
13 matches
Mail list logo