Ctypes example won't work :(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sara J
    New Member
    • Feb 2012
    • 2

    Ctypes example won't work :(

    Hi

    I currently use python 2.7 and i have a snippet of code that comes out different in two interpreters.
    Edit: Would help to post my code ^^
    Code:
    from ctypes import *
    msvcrt = cdll.msvcrt
    message_string = "hello world!\n"
    
    msvcrt.printf("Testing ctypes printf: {0}".format(message_string))
    print ("Python Idle: {0}".format(message_string))


    First one is python idle. Win7

    >>>
    Python Idle: hello world!

    >>>

    As we can see it completely skips the line with the ctype command.

    Now the second interpreter is eclipse. And while using the exact same code I get this:

    Python Idle: hello world!

    Testing ctypes printf: hello world!


    If we compare this to the code it writes the python idle line before it write ctype. But in the code ctype is written before the print command.

    This make my head want to explode. I know some python but I really can't wrap my head around this. Please help out, virtual cookies in return! ^^ -o
  • warnet
    New Member
    • Jul 2012
    • 1

    #2
    I came across the same problem when using python ver3.2. Then I thought maybe there's something wrong with the python version for it works well with ver2.5. You may try.

    Comment

    Working...