User Profile

Collapse

Profile Sidebar

Collapse
ChrisWang
ChrisWang
Last Activity: Apr 28 '09, 10:19 AM
Joined: Nov 20 '08
Location: Beijing, China
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ChrisWang
    replied to Questions about the import ordering
    Ok. Thank you very much.

    Have a great holiday!
    See more | Go to post

    Leave a comment:


  • ChrisWang
    replied to Questions about the import ordering
    Thanks BV. Could you please show me detailed explanation about the consistency?
    I've read the description about imports in PEP08, but I think I am still puzzled about that....
    See more | Go to post

    Leave a comment:


  • ChrisWang
    replied to Creating folder browse dialogue gui
    Hi,

    I think wxPython can help you to develop GUI function, including the input/output.

    You can use wx.TextCtrl to get the input from the user, and then use os.listdir('PAT H') to enumerate the files.
    Note: PATH is the input got from user.

    I can give you a sample to use wxPython
    wxpython TextCtrl Basic Formatting - Python

    and the help for TextCtrl
    wx.TextCtrl
    See more | Go to post

    Leave a comment:


  • ChrisWang
    started a topic Questions about the import ordering

    Questions about the import ordering

    Dear all,

    I am reading the book "Core Python Programming". In the chapter talking about modules, it says the modules should follow this ordering:

    Code:
    import Python Standard Library modules
    
    import Python third party modules
    
    import Application-specific modules
    I am not sure whether the ordering will impact the module's loading or search efficiency. For example, a common...
    See more | Go to post

  • Thank you. I've got the answer why the error happened.

    "Since the name of the main module is always "__main__", modules intended for use as the main module of a Python application should always use absolute imports."

    So I made another main module with absolute imports, and also imports this test module. Everything is fine.

    Thanks again for your help:)
    Have a nice day!
    See more | Go to post

    Leave a comment:


  • ChrisWang
    started a topic A question about "Intra-package References"

    A question about "Intra-package References"

    Hi all,

    I have a simple question about "Intra-package References"
    There are two source files and __init__.py in package MyPkg shown below:

    |-MyPkg
    -__init__.py
    -example.py
    -test.py

    example.py is like this:
    Code:
    a = 5
    and test.py is like this:
    Code:
    from . import example
    
    print example.a
    While I executed test.py, python...
    See more | Go to post

  • ChrisWang
    replied to Question about "global" statement
    I found another solution to this problem.

    I can use a name space for the scoping.

    __main__.a will be referenced to a global variable.

    Anyway, I think container is better.
    See more | Go to post

    Leave a comment:


  • ChrisWang
    replied to Question about "global" statement
    Good suggestion! Thanks!
    See more | Go to post

    Leave a comment:


  • ChrisWang
    started a topic Question about "global" statement

    Question about "global" statement

    Hi,

    I am having trouble understanding the use of 'global' variables I want to use a global variable with the same name as a parameter of a function. But I don't know how to use them at the same time. Here is a snippet of example code:

    Code:
    def foo (a):
        global p
        global a
        p = a + 3  #here "a" will be reference to the global one
        
    a = 1
    p = 0
    foo (a)
    ...
    See more | Go to post
No activity results to display
Show More
Working...