Subroutines

Glyph Lefkowitz glyph at no.spam
Fri Oct 13 16:02:44 EDT 2000


Kalle Svensson <kalle at gnupung.net> writes:

> On Fri, 13 Oct 2000, j wrote:
> 
> > For example how would a perl subroutine below be in python.
> > sub myfunc {
> > print $_[0];
> > }
> 
> I'm not very good at perl, but I believe you want to print the first
> argument to the function. In this case
> 
> def myfunc(arg):
>     print arg
> 
> would be what you want. I suggest you Read The Fine Manual, starting with
> the tutorial, where functions are discussed in sections 4.6 and 4.7.

I believe the "literal" translation would be

def myfunc(*_):
  print _[0]

but such a function is bad style in python, and a design flaw in perl :)

-- 
Glyph Lefkowitz
Professional -- Software Engineer,  Origin Systems
Amateur      -- Computer Scientist, Twisted Matrix Enterprises
(My opinions are my own and do not reflect in any way on the policies
or practices of my employer, etcetera etcetera.)



More information about the Python-list mailing list