Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Python ➜ nick help... about import

nick help... about import

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Pkerr   (3 posts)  Bio
Date Fri 04 Oct 2013 01:05 AM (UTC)

Amended on Fri 04 Oct 2013 01:07 AM (UTC) by Pkerr

Message
my english is poor. please understand....

tt.py

def test():
  world.Note('Hello Mushclient')

>> import tt
>> tt.test()

脚本错误
游戏: pkuxkx
执行 1 行 0 列
立即执行
Traceback (most recent call last):
File "<Script Block 4>", line 1, in <module>
tt.test()
File "D:\MUSHclient\tt.py", line 2, in test
world.Note('Hello Mushclient')
NameError: global name 'world' is not defined

出错行:
tt.test()

>> execfile('tt.py')
>> tt.test()

Hello Mushclient


please tell me about import wrong .....thank you

Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 04 Oct 2013 02:30 AM (UTC)
Message
I am not a Python expert. Maybe someone else can help you?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Pkerr   (3 posts)  Bio
Date Reply #2 on Fri 04 Oct 2013 02:53 AM (UTC)
Message
Nick Gammon said:

I am not a Python expert. Maybe someone else can help you?



ok..
thank you
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Sat 05 Oct 2013 02:34 AM (UTC)
Message
Quote:
world.Note('Hello Mushclient')

The function name is case sensitive. It is supposed to be world.note, not world.Note.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 05 Oct 2013 03:00 AM (UTC)
Message
However "Note" is the correct capitalization.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #5 on Sat 05 Oct 2013 05:20 AM (UTC)
Message
That's not what the note doc says for python. *shrug*

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Pkerr   (3 posts)  Bio
Date Reply #6 on Sat 05 Oct 2013 09:09 AM (UTC)
Message
I find a solution...

#filename test.py

Quote:

world = object

def test():
world.Note('Hello Mushclient.')


Input in the game:

>> import test
>> test.world = world #pass namespace 'world'
>> test.test()
Quote:
Hello Mushclient.



My english is poor..... sorry

Thank every body
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


23,627 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.