Python anyone?

Any other programming language that is not covered in the Web Scripting category.

Python anyone?

Postby trick on Thu Sep 28, 2006 8:39 pm

Is there anyone around here who likes Python? I'm using it for school and I really like the language. It's OOP aproach is just awesome, but one of the things it was missing was a good way to take input from the command line and make objects out of them. The input() function is just bad, and raw_input() will only give you a string object which you have to deal with on your own. So I've written a package called cliutils, and I'm wondering if there are people who want to looks at it and provide feedback.

I'll post the code as soon as I get a shell account. Till then post if your interested or PM me.
'The military don't start wars. Politicians start wars' - William Westmoreland
Image
trick
Contributer
Contributer
 
Posts: 74
Joined: Mon Aug 07, 2006 6:07 am

Postby slashfoo on Fri Sep 29, 2006 11:15 am

Well, that sounds nice, although I have not had any problems with the functions/methods (however you want to call them) you mentioned.

I look forward to seeing the code and maybe get some ideas and new ways to do stuff.

trick wrote:I'll post the code as soon as I get a shell account. Till then post if your interested or PM me.


Just being curious, what does posting the code and getting a shell account have to do with each other?
Slashfoo
"Hello my friend, stay a while and listen..."
--- Deckard Cain (Diablo game)
slashfoo
Contributer
Contributer
 
Posts: 70
Joined: Tue Sep 05, 2006 12:44 pm

Re: Python anyone?

Postby al_tyranny on Sun Oct 01, 2006 1:47 am

trick wrote:one of the things it was missing was a good way to take input from the command line and make objects out of them. The input() function is just bad, and raw_input() will only give you a string object which you have to deal with on your own.


I don't get it. input() is made for numbers and raw_input() is made for strings. How is this a bad system?
mm_freak wrote:Slackware users are dreamers. Sorry to say.
al_tyranny
Phoenix Veteran
Phoenix Veteran
 
Posts: 294
Joined: Tue May 17, 2005 3:18 am
Location: Greater Boston Area

Postby trick on Mon Oct 02, 2006 3:47 pm

not really. what raw_input() does is gets the input and puts it into a string. input() is the same as eval(raw_input()) which is ugly, and exhibits all sorts of weird behaviour if the user types in the wrong thing. raw_input isn't bad if all you want is strings, but that's often not good enough. Here's an example

Code: Select all
from cliutils import io

speed=io.input_object('What is the air speed of an unladen swallow?: ',float)

It will prompt the use with that question, and make sure they input something that python can convert to a float, and store the float in speed. If the user types in something like 'is that an African or European swallow?' then it will output a nice error message telling the user the input must be a number, and give them another chance.

Here's some other examples
Code: Select all
n=io.input_object('Integer to factor: ',int)

That will make n an integer.
Code: Select all
a=io.input_object('Are you sure you want to do that? ',io.casts.yes_no)

That uses a function that makes sure the user types in either 'y', 'yes', 'n', or 'no' and gives you True for the yes response and False for the no response.

As for the shell thing, I actually meant hosting. But aren't they the same here?
'The military don't start wars. Politicians start wars' - William Westmoreland
Image
trick
Contributer
Contributer
 
Posts: 74
Joined: Mon Aug 07, 2006 6:07 am

Postby if on Fri Oct 06, 2006 2:36 pm

I do like Python.
wxPython is very cool and Python's syntax is easy readable Smile
if
Newbie
Newbie
 
Posts: 2
Joined: Fri Sep 22, 2006 4:23 pm

Postby Gratemyl on Thu Dec 14, 2006 1:43 pm

I love python and in fact have it on my mobile phone (that's how addicted I am). If anybody needs help with python, I am always here.

And yes, I do think that "Python" should have been an option in the programming language poll.
Gratemyl
Newbie
Newbie
 
Posts: 6
Joined: Wed Dec 13, 2006 11:41 pm
Location: Germany

Postby fishpoo222 on Tue Jan 16, 2007 9:31 pm

I love python too, its simple and clean
Image
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
fishpoo222
Regular
Regular
 
Posts: 104
Joined: Tue Oct 04, 2005 5:12 pm
Location: reigate,surrey,england

Postby oscuro on Mon Jan 29, 2007 2:39 am

Well I've read something about python, once in it's site, they explain at as a very practical languge, that actually gets to the point, without having to read, or understand many things, that you must learn while learning others.
"Pay no mind to those who talk behind your back, it simply means you are two steps ahead."
-website

Image
oscuro
Regular
Regular
 
Posts: 88
Joined: Thu Apr 27, 2006 4:59 pm

Re: Python anyone?

Postby zxwysh on Sat Aug 11, 2007 3:13 am

Python is very wide spread now, and it seems to be the "new" perl - can do some nice stuff with it in the web environment too check out http://www.djangoproject.com for a nice framework for website dev.
zxwysh
Newbie
Newbie
 
Posts: 4
Joined: Fri Aug 10, 2007 3:47 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron