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

  • Thread starter Íéêüëáïò Êïýñáò
  • Start date
8

88888 Dihedral

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
 
T

Thomas Rachel

Am 12.06.2013 03:46 schrieb Rick Johnson:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top