Re: How to import other modules from my own code?



I found out the problem, it was me. I threw in some Python 3 specific idiom into the original source and that prevented it from being loaded correctly. My fault. Now it is solved as soon as I tried the original one.

Thank you very much Steffen, for your detailed help.


On Sun, Jun 30, 2013 at 6:58 AM, Steffen Macke <dia diagramr biz> wrote:
Hi Bao,


On 30.06.2013 03:56, Bao Niu wrote:
dia_rotate.py is located in Home/.dia/python . The code doesn't work. If I
try importing from the python console, it simply gives me an ImportError,
simply can't find them. What should I do to import it?

That's strange. Have you checked that your dia_rotate.py is the original one from [1]?

[1] https://git.gnome.org/browse/dia/tree/plug-ins/python/dia_rotate.py

Below is a Python Dia Console log that shows a successful import.
Do other scripts get loaded from your Home/.dia/python ?

Steffen

>>> import dia_rotate
>>> dia_rotate
<module 'dia_rotate' from '/home/user/.dia/python/dia_rotate.pyc'>
>>> help(dia_rotate)
Help on module dia_rotate:

NAME
    dia_rotate

FILE
    /home/user/.dia/python/dia_rotate.py

DESCRIPTION
    # PyDia Rotation
    # Copyright (c) 2003, Hans Breuer <hans breuer org>
    # Copyright (c) 2009, 2011  Steffen Macke <sdteffen sdteffen de
    #
    #  This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

CLASSES
    CRotateDialog

    class CRotateDialog
     |  Methods defined here:
     |
     |  __init__(self, d, data)
     |
     |  on_delete(self, *args)
     |
     |  on_rotate(self, *args)

FUNCTIONS
    SimpleRotate(data, angle)

    rotate_cb(data, flags)

_______________________________________________
dia-list mailing list
dia-list gnome org
https://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]