Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
139 user(s) are online (100 user(s) are browsing Forums)

Members: 0
Guests: 139

more...

Headlines

 
  Register To Post  

Python: how to retrieve the current directory?
Just can't stay away
Just can't stay away


See User information
Hi,

How can I find the current directory from within a Python script?
I can run an AmigaDOS script that writes it into a file and read the file in Python but it's not so nice. Any better alternative?

Thanks

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: Python: how to retrieve the current directory?
Just can't stay away
Just can't stay away


See User information
Ok, found it thanks to Google and this file: http://www.python.org/download/releas ... .4/python1.4-amiga.README
You can use os.getcwd()

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: Python: how to retrieve the current directory?
Home away from home
Home away from home


See User information
@Elwood

http://docs.python.org/2.6/library/os ... ighlight=getcwd#os.getcwd

also you can do

8.AmigaOS4:> python
Python 2.5.6 
(r256:88840Jul  1 201323:31:00
[
GCC 4.2.4 (adtools build 20090118)] on ppc-amiga
Type 
"help""copyright""credits" or "license" for more information.
>>> 
import os
>>> help(os)
Help on module os:

NAME
    os 
OS routines for MacNT, or Posix depending on what system we're on.

FILE
    python:lib/os.py

DESCRIPTION
    This exports:
      - all functions from posix, nt, os2, mac, or ce, e.g. unlink, stat, etc.
      - os.path is one of the modules posixpath, ntpath, or macpath
      - os.name is '
posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
      - os.curdir is a string representing the current directory ('
.' or ':')
      - os.pardir is a string representing the parent directory ('
..' or '::')
Help on module os:

NAME
    os - OS routines for Mac, NT, or Posix depending on what system we'
re on....
...
...


Scrolling dowen through the quite large help file will get you what you want.

I might be then worth checking the function at the command line prompt, to make sure it works in AmigaOS (this does ofcourse).



Go to top
Re: Python: how to retrieve the current directory?
Home away from home
Home away from home


See User information
Also bear in mind that if you are writing an amiga specific script you may use "CURRDIR:"

eg


>>> f = open("CURRDIR:test","w")
>>> f.write("test")
>>> f.close()

Go to top
Re: Python: how to retrieve the current directory?
Just can't stay away
Just can't stay away


See User information
@broadblues

Thanks for the details. I'll test that too.

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project