#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Montana, USA
    Posts
    5
    Rep Power
    0

    Stdlib.h equivalent in Pyhton 2.7.3?


    Hello there! I am fairly new to Python and I was wondering if there is a stdlib.h equivalent in Python 2.7.3, which is the version I currently use.

    I searched the Documentation at the Python website, but I didn't see much there that answered my question.

    So I turn here, to ask you guys. Is there? Is there not? Did I miss a .py file that is buried somewhere? Any help would be appreciated.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,669
    Rep Power
    4273
    stdlib.h has several functions in it. Python has all of them implemented in different ways. What are you looking for specifically?
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Montana, USA
    Posts
    5
    Rep Power
    0
    Originally Posted by Scorpions4ever
    stdlib.h has several functions in it. Python has all of them implemented in different ways. What are you looking for specifically?
    Well, I'm attempting to convert lzss.c to lzss.py file, as a start. I think that io is the equivalent of stdio.h in Python, so I use that instead and I got a bit of it converted, mostly the error function. Bleh, I can't send a link through the posts... You can PM me if you want a sample of the code.
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,669
    Rep Power
    4273
    If you're talking about the encryption/decryption program (lzss.c), I just googled for the C source code and had a look. The only stdlib function used in the C code is exit(). In python, the equivalent is in the sys module.
    Code:
    import sys
    ...
    ...
    sys.exit(-1)
    Hope this helps.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Montana, USA
    Posts
    5
    Rep Power
    0
    Originally Posted by Scorpions4ever
    If you're talking about the encryption/decryption program (lzss.c), I just googled for the C source code and had a look. The only stdlib function used in the C code is exit(). In python, the equivalent is in the sys module.
    Code:
    import sys
    ...
    ...
    sys.exit(-1)
    Hope this helps.
    Oh, really? OK then, I'll just do that. ._. Thanks.
  10. #6
  11. Contributing User

    Join Date
    Aug 2011
    Posts
    5,115
    Rep Power
    482
    In python you can simply use

    #include <stdlib.h>
    #include "myIncludes.h" /* whatever */


    In fact, the python preprocessor (ppp) is free form. The # sign doesn't need to be in the first column.
    Last edited by b49P23TIvg; May 2nd, 2013 at 03:12 PM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,669
    Rep Power
    4273
    ^^^^
    For newbies to python, b49P23TIvg is actually kidding around

    HINT: # is the character used to comment lines in python.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Montana, USA
    Posts
    5
    Rep Power
    0
    Originally Posted by Scorpions4ever
    ^^^^
    For newbies to python, b49P23TIvg is actually kidding around

    HINT: # is the character used to comment lines in python.
    Well I know that # is used to comment. Silly guy above you.
  16. #9
  17. Contributing User

    Join Date
    Aug 2011
    Posts
    5,115
    Rep Power
    482

    Whoops, it's May first not April first.


    But Snivy, I'd be surprised if you understood what
    #include "a_header_file.h"
    is for,
    And I'd be surprised if you know anything about python modules.
    [code]Code tags[/code] are essential for python code and Makefiles!
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Montana, USA
    Posts
    5
    Rep Power
    0
    Originally Posted by b49P23TIvg
    But Snivy, I'd be surprised if you understood what
    #include "a_header_file.h"
    is for,
    And I'd be surprised if you know anything about python modules.
    Are you just being a troll?
  20. #11
  21. Contributing User

    Join Date
    Aug 2011
    Posts
    5,115
    Rep Power
    482
    Perhaps you've finished the project. Great.

    Unless you're translating from, say, matplot to matplotlib, a line-by-line translation of the code is, to me, nonsensical. I'd understand the algorithm on one side, then implement it in the new language.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo