#1
  1. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14

    Questions from a Python Virgin...


    Hi all...

    I'm looking to moving into offline app development, having build many web apps over the past 6 years in the industry. I've moved from newbie PHP hax0r to profficient OOP PHP applications developer very quickly, and feel that I need to move my skills to other platforms to help me grow.

    I've heard many things about python, but generally I don't know much about the language.

    So, I thought I'd ask a couple of questions on here - see whether the python community can make my mind up on whether to start playing with code.

    Firstly, I've noted from popping into the forum that Python can be compiled into EXEs.
    Is this true? Is it relatively easy? Is this just for windows?

    If I compile my code to an exe, would I be able to "hook in" to the windows platform and control aspects, such as volume levels?

    Can python scripts be compiled into DLLs for use with other apps?

    Can python scripts be compiles into .so files for use with apache?

    What are the main advantages of Python?

    I know thats quite a few questions, but please try to answer as many as you can - I'm really interested, and I might end up back in the future helping out!
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11
    Firstly, I've noted from popping into the forum that Python can be compiled into EXEs.
    Is this true? Is it relatively easy? Is this just for windows?
    -> Yes it is really easy in most cases .And No its not just limited to windows
    You might want to look at the following
    Py2exe - windows
    cx_freeze - *nix
    py2app - mac ( i just learnt this from mark's posting)

    (just google those and you'll find the links)



    If I compile my code to an exe, would I be able to "hook in" to the windows platform and control aspects, such as volume levels?


    Well there many things that can be done cross platform for system intraction. But if you are looking to do platform specific things then there are several platform specific add ons like win32all for windows
    Can python scripts be compiled into DLLs for use with other apps?

    I know there are ways to use c/C++ libraries as dll's in python program. But never really looked at other way round , but i am sure there are ways to do that.

    Can python scripts be compiles into .so files for use with apache?
    you might want to look at modpython for working apache.


    What are the main advantages of Python?

    Well there are too many to list. But its the speed of devlopment that makes me use it
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    wx covered nearly everything there, making this a pretty small post . Everyone can probably tell you something different but the one reason you will hear the most as you learn more about Python is:

    it's elegant design and easy to read syntax this is very important because it makes writing and maintaining your programs a lot easier! This is particularly important for larger programs .

    Anyway lets pass the ball here, someone else add something!

    You might also be interested in IronPython, a version of Python created for the .NET platform that can (correct me if I'm wrong here) be compiled to exe\DLL files.

    This also makes the entire .NET CLR (Common Language Runtime) & libraries available in Python .

    http://www.ironpython.org/

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Originally Posted by neobuddah
    What are the main advantages of Python?
    One of the basic principles in the design of Python was the a programming language is a user interface, so the principles and practices of good interface design were applied.

    The result is a language that is incredibly easy, efficient and fun to program in. It is simple enough for children to learn, but as powerful as any other mainstream language such as Perl or Java. For most tasks you can get a working program in Python in a fraction of the time it would take in other languages. It is also inherently very readable, unlike some other scripting languages.

    Here is an article by Open Source guru Eric S. Raymond about why he uses Python.

    Dave - The Developers' Coach
  8. #5
  9. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14
    Thanks for your comments.

    How would I find the transition then from PHP? I'm partial to PHP's build-in functions. Does python come with similar readily-available methods? Is there anything I should look out for in particular, or any "heads-up" items of note?

    And with regards to Apache modules... I'm thinking that I'd like to write a mod_whatever, in python, then compile it so it can just be included as a .so module for Apache distributions without python installed. Would that be possible?

    Also, I'm handy at manipulating XML with PHP, and use it as my primary data-storage when working with document-centric data. I'd like to be able to move that knowledge over if possible. How is python's integration with XML/XSL/X{whatever}?
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Python has it's own set of built-in functions but obviously they have different names & uses. Since everything in Python is an object with it's own methods, you'll probably find yourself using these more than the built-in functions. Particularly if you're working with strings .

    http://docs.python.org/lib/built-in-funcs.html

    On the subject of the Apache module, you CAN'T do it that way. If you want to write your own Apache module in this way then I would suggest that you learn C instead a good thing about this is that the syntax will be familiar to you and you will learn a lot about the computer system.

    Python's great for XML processing however I would hazard to guess that PHP's API (like it's MySQL API) is easier to get to grips with .

    http://pyxml.sourceforge.net/topics/
    http://www.python.org/sigs/xml-sig/
    http://www.xml.com/pub/at/24

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  12. #7
  13. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14
    Thanks for the speedy reply!

    Shame about Apache... Though, would it be possible to compile a binary python app and use it through apache? In the same way that you'd point to a html or php file?

    I've been led to understand you can compile PHP scripts together with the PHP environment into a stand-alone app, which I assume must then be able to be run by apache, though I've not tried it. If python can do this, it would be pretty useful.

    Also, I have an idea for an app which I'll probably code up in python to get my feet wet (i've decided to take the plunge). It'd be useful if it could run as a service. Is this possible with python?

    And, finally, when it comes to the UI - does python sort that out itself, or do you need to add another layer? I can create apps using PHPGTK, or use Mozilla/XUL connecting to a webservice... do i do the same with Python?

    Oh, one last thing... where's the best place to head to get started?

    Thanks for all your help!
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    35
    Originally Posted by neobuddah
    Hi all...
    Firstly, I've noted from popping into the forum that Python can be compiled into EXEs.
    Is this true? Is it relatively easy? Is this just for windows?
    It is just about true, but you:

    - Lose cross platform compatability
    - Don't get any speed advantage
    - Have another copy of the Python Interpreter in the EXE, so it's a bit redundant.

    If I compile my code to an exe, would I be able to "hook in" to the windows platform and control aspects, such as volume levels?
    The two are unrelated. If you have the Win32 extensions then you can do it whether it's an EXE or not.

    Can python scripts be compiled into DLLs for use with other apps?
    Not that I know of, but with the Win32 extensions you can build COM components that other apps can use.

    What are the main advantages of Python?
    That you don't have to compile it (makes development and bug-fixing much quicker)
    That it has an interactive shell (makes testing code much quicker), and
    That it has a pleasant construction (it's pleasant).

    I know thats quite a few questions, but please try to answer as many as you can - I'm really interested
    If you're interested, go download Python, load IDLE and start playing - http://www.ibiblio.org/obp/thinkCSpy/ (book/tutorial)

    Though, would it be possible to compile a binary python app and use it through apache?
    Binary Python app? There's no such thing - just the interpreter and Python script put together in one file.

    In the same way that you'd point to a html or php file?
    CGI?
    Python has lots of Apache supported frameworks (the sheer number of them means it's difficult to pick one), but I don't know about Apache modules.

    It'd be useful if it could run as a service. Is this possible with python?
    Chapter 18 of "Python programming for Win32"
    In the Win32 extensions, look for win32serviceutil.ServiceFramework examples.
    I have never tried using it, but the example in the book has three methods - init(), stop() and run().

    And, finally, when it comes to the UI - does python sort that out itself, or do you need to add another layer?
    You need to add other layers - e.g. wxPython, pyGTK, and so on.
    Last edited by sfb; March 18th, 2005 at 08:33 AM.
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Python can be compiled to an exe however I'm not sure if or how this can be run with Apache. You're best bet would simply be to configure Apache with CGI support so you can run Python programs.

    Python comes with an easy to learn GUI toolkit called Tkinter which can be found in Pythons documentation a long with nearly anything else you need to know .

    http://www.python.org/doc/2.4/

    There are also a whole bunch of other GUI toolkits to choose from i.e. wxPython.

    http://www.wxpython.org/

    Oh, Python should be able to be run as a service.

    Mark.
    programming language development: www.netytan.com Hula

  18. #10
  19. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14
    Binary Python app? There's no such thing - just the interpreter and Python script put together in one file.
    Thats fine. I'm thinking more about distribution - the apps I'll be developing would need to be simple "click and install" apps, and different versions for different environments would be acceptable.

    Thanks guys. I'll get coding!
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...

IMN logo majestic logo threadwatch logo seochat tools logo