Ask Your Question
1

os.path.isdir()

asked 2010-09-09 11:30:24 +0100

Mike Witt gravatar image

Should the following work, or am I doing something wrong?

[mike@Vector ~]$ export MIKES_DIR=/home/mike/
[mike@Vector ~]$ /usr/local/sage-4.5.2/sage
----------------------------------------------------------------------
| Sage Version 4.5.2, Release Date: 2010-08-05                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: os.system('echo $MIKES_DIR')
/home/mike/
0
sage: os.path.isdir('/home/mike/')
True
sage: os.path.isdir('$MIKES_DIR')
False

I ask this because isdir() appears to be used in one of the scripts for building ATLAS to test whether you're trying to use system-wide atlas libraries, and I'm having trouble getting that to work.

-Mike

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2010-09-09 11:42:53 +0100

mvngu gravatar image

You could try this:

[mvngu@sage sage-4.5.3]$ echo $DOT_SAGE
/dev/shm/mvngu/dot_sage
[mvngu@sage sage-4.5.3]$ ./sage
----------------------------------------------------------------------
| Sage Version 4.5.3, Release Date: 2010-09-04                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: os.path.isdir(os.getenv("DOT_SAGE"))
True
edit flag offensive delete link more

Comments

Or as in the ATLAS spkg, os.path.isdir(os.environ['$MIKES_DIR']).

John Palmieri gravatar imageJohn Palmieri ( 2010-09-09 11:46:32 +0100 )edit

OK, I see now. I missed the getenv() part. Duh.

Mike Witt gravatar imageMike Witt ( 2010-09-09 11:57:19 +0100 )edit
0

answered 2010-09-09 13:58:22 +0100

ccanonc gravatar image

updated 2010-09-09 13:59:01 +0100

sage: os.environ['MYVAR']
'/home'
sage: os.path.isdir(os.environ['MYVAR'])
True

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-09-09 11:30:24 +0100

Seen: 7,995 times

Last updated: Sep 09 '10