How to call function which is in one program ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shahriar Shamil Uulu

    #1

    How to call function which is in one program ...

    Dear All,
    i got another questions. For example i have two programs in python
    like: first.py, second.py.
    In first.py i have a function test() like:
    # first.py
    ....
    def test(name):
    print name

    ..... so other functions
    =============== ==========

    #second.py

    Question is how i can include first.py into second.py and use function
    test.py.
    Thank you ...

  • Fredrik Lundh

    #2
    Re: How to call function which is in one program ...

    "Shahriar Shamil Uulu" wrote:
    [color=blue]
    > i got another questions. For example i have two programs in python
    > like: first.py, second.py.
    > In first.py i have a function test() like:
    > # first.py
    > ...
    > def test(name):
    > print name
    >
    > .... so other functions
    > =============== ==========
    >
    > #second.py
    >
    > Question is how i can include first.py into second.py and use function
    > test.py.[/color]

    # File: second.py
    import first
    first.test()

    tips: read a Python tutorial *before* you post your next question. start here:



    </F>



    Comment

    • Shahriar Shamil Uulu

      #3
      Re: How to call function which is in one program ...

      Thank you Fredrik Lundh
      for your help ...
      it worked ...
      the problem was in saving of file first.py
      Fredrik Lundh wrote:[color=blue]
      > "Shahriar Shamil Uulu" wrote:
      >[color=green]
      > > i got another questions. For example i have two programs in python
      > > like: first.py, second.py.
      > > In first.py i have a function test() like:
      > > # first.py
      > > ...
      > > def test(name):
      > > print name
      > >
      > > .... so other functions
      > > =============== ==========
      > >
      > > #second.py
      > >
      > > Question is how i can include first.py into second.py and use function
      > > test.py.[/color]
      >
      > # File: second.py
      > import first
      > first.test()
      >
      > tips: read a Python tutorial *before* you post your next question. start here:
      >
      > http://www.python.org/doc/Intros.html
      >
      > </F>[/color]

      Comment

      Working...