[Tutor] Checking for file existence

Rick Pasotto rick@niof.net
Sat, 24 Feb 2001 14:45:26 -0500

On Sat, Feb 24, 2001 at 08:35:21AM -0900, Tim Johnson wrote:
> Hello:
> 	Python newbie here.... I'm checking documentation, but can't
> find anything like the C access() function.
> Is such a function available.

import os
if os.path.exists('/full/path/to/file'):
	print 'yes'
	print 'no'

"The fact that a man has no claim on others (i.e. that it is not their
moral duty to help him & that he cannot demand their help as his
right) does not preclude or prohibit good will among men & does not
make it immoral to offer or to accept voluntary, non-sacrificial
assistance.  It is altruism that has corrupted & perverted human
benevolence by regarding the giver as an object of immolation, & the
receiver as a helplessly miserable object of pity who holds a mortgage
on the lives of others... leaving men no choice but the roles of
sacrificial victim or moral cannibal...   one must begin by rejecting
altruism's terms & all of its ugly emotional after-taste, then take a
fresh look at human relationships.  It is morally proper to accept
help, when it is offered, not as a moral duty, but as an act of good
will & generosity, when the giver can afford it (i.e. when it does not
involve self-sacrifice on his part), & when it is offered in response
to the receiver's virtues, not in response to his flaws, weaknesses or
moral failures, & not on the ground of his need as such."
		-- Ayn Rand
		   Rick Pasotto email: rickp@telocity.com