Smal question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?Hans_M=FCller?=

    Smal question

    Hello group,

    I have some scripts sharing some common functions.
    So what I'd like to have is a modern include.
    Of course python does not have (with good reasons) no include statement.
    But I'm too lazy to create a module which has to be installed into the interpreter for some functions I need to share in a project.
    Is there any idea to do this ?

    Thanks a lot

    Hans
  • Nick Dumas

    #2
    Re: Smal question

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    This is easy. Simply create a .py file containing all the methods you
    want to share. Put this file in the same directory as the rest of your
    project files. In each of your project files that requires one of the
    methods, simply "import <name of method file>". Python supports
    impromptu module creation, which is great just for circumstances like this.

    Hans Müller wrote:
    Hello group,
    >
    I have some scripts sharing some common functions.
    So what I'd like to have is a modern include.
    Of course python does not have (with good reasons) no include statement.
    But I'm too lazy to create a module which has to be installed into the
    interpreter for some functions I need to share in a project.
    Is there any idea to do this ?
    >
    Thanks a lot
    >
    Hans
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.9 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iEYEARECAAYFAkh 2JOAACgkQLMI5fn dAv9gZiACeP3puv MknR2HQTOXKaNeB tC+h
    tyEAn3C6g9E5U5x XE4SQ7u368xdvkR x4
    =J6Sv
    -----END PGP SIGNATURE-----

    Comment

    • =?ISO-8859-1?Q?Hans_M=FCller?=

      #3
      Re: Smal question

      Thanks a lot,

      you made my day.

      As often in python, it's really simple and useful !

      Greetings

      Hans

      Comment

      • Bruno Desthuilliers

        #4
        Re: Smal question

        Hans Müller a écrit :
        Hello group,
        >
        I have some scripts sharing some common functions.
        So what I'd like to have is a modern include.
        Of course python does not have (with good reasons) no include statement.
        But I'm too lazy to create a module which has to be installed into the
        interpreter for some functions I need to share in a project.
        What do you mean "installed in the interpreter" ?

        Comment

        • Terry Reedy

          #5
          Re: Smal question



          Bruno Desthuilliers wrote:
          Hans Müller a écrit :
          >Hello group,
          >>
          >I have some scripts sharing some common functions.
          >So what I'd like to have is a modern include.
          >Of course python does not have (with good reasons) no include statement.
          >But I'm too lazy to create a module which has to be installed into the
          >interpreter for some functions I need to share in a project.
          >
          What do you mean "installed in the interpreter" ?
          He probably meant either compiled into the interpreter or installed in
          the interpreter directory, not knowing that one can import from the
          project directory, and that the project directory gets added to the
          front of sys.path (as '.').

          Comment

          • Aahz

            #6
            Re: Smal question

            [contextectomy]

            If we answer a small question, are we making smalltalk?
            --
            Aahz (aahz@pythoncra ft.com) <* http://www.pythoncraft.com/

            "as long as we like the same operating system, things are cool." --piranha

            Comment

            Working...