Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing expected output

Tags:

python

I am trying to run this file from the ebook Learning Python The Hard Way with the "python ex18.py" command, but it is not outputting anything. What's wrong?

# this one is like your scripts with argv
def print_two(*args):
    arg1, arg2 = args
    print "arg1: %r, arg2: %r" % (arg1, arg2)

# ok, that *args is actually pointless, we can just do this
def print_two_again(arg1, arg2):
    print "arg1: %r, arg2: %r" % (arg1, arg2)

# this takes just one argument
def print_one(arg1):
    print "arg1: %r" % arg1

# this one takes no arguments
def print_none():
    print "I got nothin'."  
like image 541
pdenlinger Avatar asked Apr 20 '26 11:04

pdenlinger


1 Answers

Because that file doesn't actually call any functions, there's nothing to output.

That file just defines four functions and then does nothing with them. :)

Try adding calls to print_none, print_one, and so forth:

print_none()
print_one("hello")
print_two("hello", "world")
print_two_again("hello", "world")
like image 168
sarnold Avatar answered Apr 23 '26 01:04

sarnold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!