Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 5th, 2001, 10:35 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
python

I WANT MORE : things like executing commands from the script

Reply With Quote
  #2  
Old June 5th, 2001, 11:57 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Careful, the text talks (in an aside) about the print() function. This is _wrong_, there is a print _statement_, but no print() function.

Reply With Quote
  #3  
Old June 5th, 2001, 12:12 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Statements and expressions

Once more, a slight confusion over statements and expressions leads me to point out that, although the article says, "Well, comparison operators come in very useful when building conditional expressions - and conditional expressions come in very useful when adding control routines to your code," Python does not have conditional expressions, only conditional staements.

In this, Python is unlike Perl or C. Pythonistas claim this makes the resulting code more readable.

Reply With Quote
  #4  
Old June 5th, 2001, 01:52 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
switch/case

Very good tutorial. Just a comment on:

> Since Python does not support PHP-or
> JSP-style "switch/case" conditional
> statements, the "if-elif-else" construct
> is the only way to route program
> control to multiple code blocks.

Python provide simple enough function pointers to implement switch/case in a
more elegant way than a long if/else.
But maybe this is advanced code:

def work():
print "Ahiho"

def fun():
print "Yuk"

>>> tasks = {'monday':work,'tuesday':work,'sunday':fun}
>>> tasks['monday']()
AhiHo


Reply With Quote
  #5  
Old June 5th, 2001, 02:04 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Error with code

Why doesn't python allow wrapping around of text when there is an if block indented. It gives an error.

Reply With Quote
  #6  
Old June 6th, 2001, 03:41 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Error with code

whitespace is significant. try the line continuation \

Reply With Quote
  #7  
Old June 7th, 2001, 02:19 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thank you

Thank you for the inro to Python.
I enjoyed it. Please keep these type
of tutorials coming.

Abe Almonte

Reply With Quote
  #8  
Old July 7th, 2001, 10:58 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Good stuff

InktomiSearch uses python as its scripting language. I've been trying to hack that up a bit but not being familiar wtih python, I was breaking stuff constantly. This series is a great quick intro to the language. Much appreciated!

Reply With Quote
  #9  
Old August 15th, 2001, 04:22 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Python Who?

Python is like one of those languages that you don't hear of until you get deep into Geekdom. I've been working in the IT industry for a long time, and I've never actually seen it being used. Is this like a cult language (The Black Sabbath of 'puter languages)??

Reply With Quote
  #10  
Old January 28th, 2002, 06:52 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #11  
Old February 14th, 2002, 04:38 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
semi-colon

Vikram,

Presumably the semicolon at the end of:-

else:
print ("Finally! A user with active brain cells!");

is a mistake?


Reply With Quote
  #12  
Old February 14th, 2002, 05:13 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strange slices

So,

>>> str='hobgoblin'
>>> str[:7]
'hobgobl'

Since str[0] is 'h', either the second value of the slice is a counter or the slice means from the first value up to [but not including] the second.

>>> str[3:3]
''
>>> str[3:4]
'g'

Ok, so the slice is:-
[from:to but not including]

Not a problem, but it's certainly different from what I expected.

Reply With Quote
  #13  
Old February 22nd, 2002, 03:53 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #14  
Old May 27th, 2003, 10:35 AM
Ducani
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Python 101 (part 2): If Wishes Were Pythons

Python 101 \(part 2\): If Wishes Were Pythons

Begin your tour of Python with a look at its number and string types, together with examples of how they can be used in simple Python programs. Along the way, you'll also learn how to build conditional expressions, slice and dice strings, and accept user input from the command line.

Please discuss this article in this thread. You can read the article here .

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > Python 101 (part 2): If Wishes Were Pythons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT