Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > A certainl part of an if() structure never gets executed.

Reply
Thread Tools

A certainl part of an if() structure never gets executed.

 
 
88888 Dihedral
Guest
Posts: n/a
 
      06-26-2013
Michael Torrie於 2013年6月20日星期四UTC+8下午2時01分11秒 寫道:
>
> But since the LISP never really got a form beyond S-expressions,
>
> leaving us with lots of parenthesis everywhere, Python wins much as the
>
> Hitchhiker's Guide to the Galaxy wins.


Yep, a list is mutable even it's empty.
But constant integers, floats, strings, and None is immutable.

The variables in a function of python with default
parameters which could be mutable or immutable.

def fun1( x, alist=[]):
alist.append(x*x)
return alist ## valid

def fun2(x, alist=None):
if alist==None: alist=[]
alist.append(x*x)
return alist

# kind of boring to show the name binding mechanism of objects
# in Python in different usages





 
Reply With Quote
 
 
 
 
Thomas Rachel
Guest
Posts: n/a
 
      06-26-2013
Am 12.06.2013 03:46 schrieb Rick Johnson:
> On Tuesday, June 11, 2013 8:25:30 PM UTC-5, (E-Mail Removed) wrote:
>
>> is there a shorter and more clear way to write this?
>> i didnt understood what Rick trie to told me.

>
> My example included verbatim copies of interactive sessions within the Python command line. You might understand them better if you open the Python command line and type each command in one-by-one. Here is an algoritm that explains the process:
>
> open_command_window()
> whilst learning or debugging:
> type_command()
> press_enter()
> observe_output()
> if self.badder.is_full:
> take_potty_break()
> close_command_window()


with command_window():
whilst learning or debugging:
type_command()
press_enter()
observe_output()
if self.badder.is_full:
take_potty_break()

looks nicer.

SCNR


Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
semple code accept never executed fakessh C Programming 11 09-15-2012 05:46 AM
Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed Fabio Mastria ASP .Net 5 01-30-2008 09:07 PM
server event never/always executed phil ASP .Net Web Controls 1 06-06-2006 12:00 PM
ORIGINAL CODE GETS EXECUTED NOT THE NEW CODE - ASCX sk ASP .Net 1 04-19-2006 11:50 AM
Page_Unload gets executed twice chefo@bulgaria.com ASP .Net 0 01-21-2005 01:44 PM



Advertisments