Module directory

M

m

Hello ,How are you I write a module as you see :

# Fibonacci numbers module
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
def fib2(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a+b
return result

the tutorials tells me to insert this module in the current
directory I couldn't find the current directory ,where we should put
our modules?
Sincerely yours Mohsena
 
A

Alex Martelli

m said:
Hello ,How are you I write a module as you see :

# Fibonacci numbers module
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
def fib2(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a+b
return result

Some mutant space-eating nanovirus has eaten all the leading whitespace
on each line. Make sure you put the spaces back (and don't use tabs,
use real spaces).

the tutorials tells me to insert this module in the current
directory I couldn't find the current directory ,where we should put
our modules?

How you find out the current directory depends on your platform. For
example, in all Unix-like shells, the command to use for the purpose is
pwd. If you are using a Python interactive session, either at a
commandline or via IDLE or other IDE, try os.getcwd -- e.g.:

If you don't tell us what platform you're using, we can't guess.

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top