file in a current directory

This is the place for queries that don't fit in any of the other categories.

file in a current directory

Postby szostakowicz » Sat Aug 09, 2014 1:18 pm

Hi, quick question.

I was reading about modules and came across this:
"Use your favorite text editor to create a file called fibo.py in the current directory [...]. Now enter the Python interpreter and import this module with the following command: import fibo."
It probably has nothing to do with Python itself but how can I create the file 'in the current directory'? What does it even mean? :shock:
szostakowicz
 
Posts: 6
Joined: Tue Aug 05, 2014 5:40 pm

Re: file in a current directory

Postby metulburr » Sat Aug 09, 2014 2:29 pm

directories are folders. If your using Windows an example path would be:
Code: Select all
C:\Users\metulburr\Downloads

The same path in linux would be:
Code: Select all
/home/metulburr/Downloads

This would differ from yours only in repsect to 'metulburr' would be whatever your username is on your computer. The downloads directory is just an arbitrary one.
Creating a file without specifying the directory normally creates it in what ever directory you are in at the moment (ie. the current directory). So if you were in Downloads and created a file called filbo.py, the fullpath of the file would then be:
Code: Select all
C:\Users\metulburr\Downloads\fibo.py

At this point they are saying open the python interpreter in the directory
Code: Select all
C:\Users\metulburr\Downloads

In windows when you open a command prompt, they normally start you off in C\Windows\system32 unless you changed the default directory. So you will need to change to your directory Downloads
Code: Select all
cd C:\Users\metulburr\Downloads

Once here you can open a python interpreter. By just being in the directory Downloads when you open the interpreter, your current directory in the interpreter will be:
Code: Select all
C:\Users\metulburr\Downloads

If you have problems opening the python interpreter or the command prompt...check the tutorial here

Hopefully that explained well enough, instead of confusing you.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1512
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Coding Help

Who is online

Users browsing this forum: l_mono and 4 guests