[Baypiggies] line error on no. 7

Martin Falatic martin at falatic.com
Wed Jul 29 00:00:04 CEST 2015


(Keeping replies on the mailing list.)

I'm referring to the list data structure and its methods, like append()
(but *not* including split()).

I'm sure lst.append isn't doing much either without an argument.

What's the goal of this exercise? That will help illuminate what you're
trying to accomplish. Based on the original pastebin
(http://tinyurl.com/oua9uqx) this is what's happening:

fname = raw_input("Enter file name: ")
fh = open(fname) # Open a file
lst = list()  # Create a new list
for line in fh: # For each line in the file...
    if fh == list: continue  # Eh??
    list.split()  # Illegal (can't do this to a list and it's on a type
anyway)
    list.append   # Not appending anything, and it's on a type not a var too
    sorted("fh")  # You've sorted the string "fh" and assigned result to
nothing
print line.rstrip() # Finally, we only print the very last line we read.

I don't think that's the plan, but that's how the code parses so far.

 - Marty



On Tue, July 28, 2015 14:25, ltc.hotspot at gmail.com wrote:
> Marty,
>
>
> Are you referring under 5.1. Using Lists as Queues?
>
>
>
> 1st.append produced a new error message.
>
>
>
> Hal
>
>
>
> Sent from Surface
>
>
>
>
>
>
> From: Martin Falatic
> Sent: ‎Tuesday‎, ‎July‎ ‎28‎, ‎2015 ‎1‎:‎55‎ ‎PM
> To: ltc.hotspot at gmail.com
> Cc: baypiggies at python.org
>
>
>
>
>
>
> First of all, you can't use split() on a list.
>
>
> Second, you have lots of typos... you're calling things like "append" on
> the data type, not the variable you created (list.append versus
> lst.append(something). Read the man pages... e.g.,
> https://docs.python.org/2/tutorial/datastructures.html
>
>
> - Marty




More information about the Baypiggies mailing list