Thread: Translate a C program to Pep8

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    23

    Talking Translate a C program to Pep8

    How would i go about converting a simple guessing game i made in C into a pep8 program?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    a google search for PEP8 came up with two major results for the definition of PEP8

    1. A code style standard for python.
    2. A CPU (possibly not a real one?) used in several assembly language courses.

    to which one are you referring?

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    23
    the first one

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    I would use a C compiler, if available and instruct it to output assembly code instead of object or executable code.

    failing that, I would break the program down into a set of very basic operations and implement each one, along with the logic that goes with it. do you know PEP/8 assembly language? if not, you'll likely need to learn it first, unless you have access to a C compiler that can generate PEP/8 code.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Eh, since by "pep8" you mean "A code style standard for python", then the right question to ask is:
    How would i go about converting a simple guessing game i made in C into a Python program?

    Styling your Python code according to the guidelines in PEP-8 is secondary to the task at hand.

    Anyway, the answer is: you translate what the C program does into Python. This does not necessarily mean line by line conversion, and sometimes it is easier to just write the Python program from scratch then use the C program to help verify the Python program's correctness.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    wow, I must have been really tired when I last posted. I gave the answer as if the OP had said "the second one," and for that I apologize.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. translate int_32 to 8-bit
    By quantt in forum C Programming
    Replies: 8
    Last Post: 01-26-2009, 04:47 PM
  2. Please translate
    By Ron in forum C Programming
    Replies: 24
    Last Post: 07-31-2008, 06:37 AM
  3. translate
    By limitmaster in forum C++ Programming
    Replies: 9
    Last Post: 08-13-2006, 01:55 AM
  4. just translate !
    By black in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 07-03-2002, 02:14 AM
  5. Can anyone translate this into C? from C++?
    By Wizard_D in forum C Programming
    Replies: 2
    Last Post: 12-19-2001, 02:44 PM