Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

FFS Python

Name: Anonymous 2010-08-12 10:49

I don't know if I fucked up adding python libs or what, but I get NameError's when trying to use python's built in function 'sorted()' in my own function. 

#!/usr/bin/python -tt

import sys

def Cat(filename):
  f = open(filename, 'rU')
  text = f.readlines()
  print sorted(text)
  print text
  f.close()
def main():
  Cat(sys.argv[1])


        
if __name__ == '__main__':
  main()



All it should do is read from a text file with every line being an element and sort through them.  I simplified my sorted parameters.  The error I get is:


Traceback (most recent call last):
  File "./test.py", line 17, in ?
    main()
  File "./test.py", line 12, in main
    Cat(sys.argv[1])
  File "./test.py", line 8, in Cat
    print sorted(text)
NameError: global name 'sorted' is not defined


fkn python
also version is 2.7, and when i "python -c 'print sorted'"
it tells me:
<built-in function sorted>

Am i fucking up on python's scope or smth maybe?

Name: Anonymous 2010-08-12 11:00

>>5
Why should I be? You reluctantly accepted what is, much to your surprise, a standard and made a snide remark about it. You are a cretin and I feel uncomfortable even posting in the same thread as you.

Name: Anonymous 2010-08-12 11:11

>>7
considering the code fragment was so small,
It was multi-line. It included indentation. It was hardly too small.
your nitpick was ridiculous from the first.
Your reasoning is ridiculous. Why exactly should you not post small code snippets in a proper font? To make it painful to read? Perhaps you are too lazy to type these tags. As expected of someone who can't be bothered to use the shift key.
also next time don't bother posting your emotions all over my thread;
;)
keep that shit on your worthless twitter
You must be thinking I am someone I am not.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List