l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2003 Jul 30 15:35

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] python: slicing extensions from file names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] python: slicing extensions from file names

Norm Matloff wrote:

> <snip>
> By the way, I can't resist urging all you Perl users out there to switch
> to Python. :-)  It's much cleaner and elegant than Perl, and a joy to
> program in.

Python is a joy because its structure encourages the construction of
classes, thereby increasing readability and reusability. Also, its syntax
allows you to put simple "driver" code at the bottom of classes
to easily test your work.

For example, lets say you have a "person" class having the "move" operation.

class person:
    # Instantiation
    # -------------
    def __init__( self, first_name, last_name ):
        self.first_name = first_name
        self.last_name = last_name
        self.street_address = ''
        self.city = ''
        self.state = ''
        self.zip_code = ''

    def move(   self,
                zip_code ):
        self.street_address = street_address
        self.city = city
        self.state = state
        self.zip_code = zip_code

# Test driver
# -----------
if ( __name__ == "__main__" ):
    fred = person( 'Fred', 'Jones' )
    fred.move( '555 Elm St.', 'Davis', 'CA', '95822' )

I've seen examples of Perl showing class creation, but does it have
this ability to easily test them?

>  I have a tutorial at
> http://heather.cs.ucdavis.edu/~matloff/python.html
> Norm
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.