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

Pages: 1-

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 10:52

python is totally forced gay

Name: Anonymous 2010-08-12 10:54

[code] tags, fuckface.

Name: Anonymous 2010-08-12 10:55

ya pro gay

Name: Anonymous 2010-08-12 10:56

#!/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()


happy?

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:03

>>6
considering the code fragment was so small, your nitpick was ridiculous from the first.  also next time don't bother posting your emotions all over my thread; keep that shit on your worthless twitter

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.

Name: Anonymous 2010-08-12 11:19

>>8
if that is the way you feel about it, then I apologize for not using the [code] tags.

Name: Anonymous 2010-08-12 11:24

>>6,8
Xarn! Contain yourself!

Name: Anonymous 2010-08-12 11:28

Well it works on my computer.

Name: Anonymous 2010-08-12 11:38

>>11
FFFUUUUUU

Name: Anonymous 2010-08-12 13:15

/prog/ in 2010 Now too dumb even to figure out Python.

Name: Anonymous 2010-08-12 16:26

>>13
actually, /prog/ in 2010 trying to ignore shit threads, as should you

Name: Anonymous 2010-08-12 21:32

>>14
I wrote a Greasemonkey script to hide the worst of it, and now the front page is empty. Please advise.

Name: Anonymous 2010-08-12 22:38

>>15
If you can't beat em...

Name: Anonymous 2010-08-12 22:47

>>16
If you can't beat em [sic], wait until September and try again?

Name: Anonymous 2010-08-13 0:45

>>17
F. See me after class.

Name: Anonymous 2010-12-06 9:44

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2011-02-04 16:19

Name: Anonymous 2011-02-04 17:37

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