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

My 1st /prog/ram

Name: Anonymous 2009-03-11 19:52

So I took /prog/'s advice and started learning python:

Here is my first ever program that is not copypasted from the tutorial. (I went further by not ONLY having it say 'too high' or 'too low' or 'you guessed it')

Am I doing it right or is declaring 5 variables a waste of time?
Why cant I just say
if a < 5:
    print('way too low') #?
why does it have to be a variable?

Name: Anonymous 2009-03-11 20:02

Am I doing it right or is declaring 5 variables a waste of time?

Why cant I just say

if a < 5:

    print('way too low') #?

why does it have to be a variable?

It doesn't have to be a variable if a < 5: should be fine


And if declaring them on five lines is too annoying you could do

number,smallnumber,bignumber,hugenumber,belownumber = 23,5,50,150,22


Whats so bad about forced indentation (indention)?
Nothing, it's just the only thing we've been able to fault python for, so we mention it at every available moment

Name: Anonymous 2009-03-11 20:08

>>5
It never did?

Name: Anonymous 2009-03-11 20:11

>>8
They just stick with if elif elif .... else. I think there has been proposals but probably couldn't come up with anything pythonic enough for guido.

Name: Anonymous 2009-03-11 20:13

>>7
thanks

Name: Anonymous 2009-03-11 20:14

>>7-san has not read his SICP.

Name: Anonymous 2009-03-11 20:19

>>7
Ok you're right, I didn't have to make them variables... wierd..
How do i add colour when I'm pasting in my code?

Name: Anonymous 2009-03-11 20:34

I emulate switch statements with dicts and lambdas.
Seriously.

Name: Anonymous 2009-03-11 21:15

>>13
back to /pounce/, Leah

Name: Anonymous 2009-03-11 21:33

>>7
How about all the self() bullshit?
What about how retarded it is to save three characters and make the code less english like with elif instead of else if.
How about that it is slow as shit. Even ironpython is slow as shit.
How about that there exists no fully featured IDE for it?

Man thats 4 solid criticisms and I've never even coded in python.  The only time I've coded in python was to help a friend with his programming homework(because expert programmers can easily program in any non super gay language).

Name: Anonymous 2009-03-11 22:17

>>15
How about all the self() bullshit?
I don't know what language you think you're talking about, but it's not Python.

What about how retarded it is to save three characters and make the code less english like with elif instead of else if.
else: if: works just fine, if you're that confused by two-syllable keywords.

How about that it is slow as shit. Even ironpython is slow as shit.
It's an interpreted language. It compares very favorably to other scripting languages.

How about that there exists no fully featured IDE for it?
Vi and emacs are just as capable of editing Python code as they are any other language.

Man thats 4 solid criticisms and I've never even coded in python.
You don't say.

Name: Anonymous 2009-03-11 22:23

What about the distinction between statements and expressions?
How about the lack of distinction between variable assignment and variable binding? Forcing you to use shitty var[0] hacks etc.
How about the lack of several common control structures such as do..while loops, real for loops, multilevel break/continue, switches etc? Also the complete lack of ways to make your own control structures (no macros, no monads, nothing).1
How about the lack of proper tail calls?
How about Guido being a total retard?

1 At the ll2 workshop some python guy wanted to add a with syntax that automatically opens and closes handles, even in the presence of exceptions etc. A 10 second macro in any lisp, but the python guy needed a bunch of programmers hacking on CPython for a month to get it done.

Name: Anonymous 2009-03-11 22:27

>>17
Wah Python isn't exactly like Common Lisp. Only your last point has real merit.

Name: Anonymous 2009-03-11 22:30

It's an interpreted language.
It's only interpreted because of shitty implementations. lrn2futamura projections and read SICP.
One of the problems with python is that it's defined by CPython.

>>18
Python can be divided into two parts: the good parts and the original parts.

Name: Anonymous 2009-03-11 23:34

It compares very favorably to other scripting languages.
pretty much every other scripting language is faster.
the only scripting language it compares favorably to is ruby.
and with the way things are going (python getting slower and ruby getting faster), in about 10 years even ruby might be faster than python.

Name: Anonymous 2009-03-11 23:37

>>16
>How about all the self() bullshit?
>I don't know what language you think you're talking about, but it's not Python.

He was probably referring to things like:
class Name:
    def __init__ (self):
       self.x = 7

But that's ridiculously easy to understand, when you do:
foo = Name()
then
foo.x == 7

Name: Anonymous 2009-03-12 0:05

>>16
In Python, you have to declare "self" as a first parameter of all your methods.\
[quote]It's an interpreted language[/quote]
Doesn't change the fact that its slow as shit.
[quote]Vi and emacs are just as capable of editing Python code as they are any other language.[/quote]
*Rolls eyes* whatever makes you feel hardcore bro. Notepad is capable of editing python too.

Name: Anonymous 2009-03-12 0:05

>>22
BBCode fail

Name: Anonymous 2009-03-12 0:17

hax my anus

Name: Anonymous 2009-03-12 0:30

>>22
Hey now, Vim (not Vi) and Emacs implemented a shitload of "IDE" features long before bloatware like Eclipse got popular. And they're still small and fast like your tight, tight anus

Name: Anonymous 2009-03-12 0:52

Nothing, it's just the only thing we've been able to fault python for, so we mention it at every available moment

How about the fact that variable types don't seem to exist in the python world?

Name: Anonymous 2009-03-12 0:53

Python is fine as it does not endorse FOOP

Name: Anonymous 2009-03-12 0:56

>>25
Seconded.

He's probably one of those idiotic drones that keep calling Emacs and Vim 70's abandonware. But the latest stable version of Emacs was released in September 2008 and the latest stable release of Vim was released in August 2008. And Vim development is still very active, and Emacs won't go the way of the dodo even if RMS can't work on it anymore. Doesn't sound very "abandoned" to me.

Name: Anonymous 2009-03-12 1:00

>>28
Or probably, he thinks they're just updated versions of ed that have taken all this time to get even half of the bigs fuxed.

Name: Anonymous 2009-03-12 1:06

>>22
Yes, you declare "self" as the first parameter for (most) methods, but that allows you to reference them inside your function definitions and refer them to the actual outside variable.

note that:
class Name:
    def __init__ (bill):
       bill.x = 7

is also valid. "self" is just commonly used because it make sense. I don't see why any one would consider this stupid or in anyway a hassle. you might as well complain that __init__ has TWO underscores rather than 1.

As for speed:
yes, great. C is faster, WE KNOW. so don't use python to develop 3d engines. developing a small utility program which doesn't consume all your CPUs? who cares.

Name: Anonymous 2009-03-12 1:11

>>30
don't use python to develop 3d engines.
http://www.eve-online.com/

Name: Anonymous 2009-03-12 1:27

>>30
ok, write a python script that caculates 1000000! in less than 20 seconds.

Name: Anonymous 2009-03-12 1:31

>>31
I totally forgot about that! Though I don't know enough about the game to know whether that was an extraordinary feat or not. I am not an "expert programmer" (I don't even know how to do the bbcode or whatever to make it look all fancy).

Name: Anonymous 2009-03-12 1:33

>>32
x = 0
while x < 1000000:
   x = x + 1

total run time: <1sec

Name: Anonymous 2009-03-12 1:38

>>34
id is not factorial

Name: Anonymous 2009-03-12 1:44

>>32
write a C program that can calculate Pi to 1,000,000 digits in less than 3 years

Name: Anonymous 2009-03-12 2:02

>>35

Ah, I missed the "!".

My answer is: who cares. As I said in my original post, if all you're doing is writing small utility programs, speed really isn't a factor.

Name: Anonymous 2009-03-12 2:04

>>32

puts "8.2639312188778698163179091185559E+5565708"


Total runtime: 0 milliseconds

Name: Anonymous 2009-03-12 2:14

*** Exception: stack overflow

Name: Anonymous 2009-03-12 2:23

>>38
only the first 7 digits are correct.
unless you get all 5565709 digits right, you fail at factorial.

Name: Anonymous 2009-03-12 2:25

>>38
PYTHON DOES NOT WORK THAT WAY!

Name: Anonymous 2009-03-12 3:00

lol hey guys check out my C equivalent of factorial template metaprogramming in C++, it is alot more elegant


#include <stdio.h>

int factorial0() {
return 1;
}

int factorial1() {
return 1 * factorial0();
}

int factorial2() {
return 2 * factorial1();
}

int factorial3() {
return 3 * factorial2();
}

int factorial4() {
return 4 * factorial3();
}

int factorial5() {
return 5 * factorial4();
}

int factorial6() {
return 6 * factorial5();
}

int factorial7() {
return 7 * factorial6();
}

int factorial8() {
return 8 * factorial7();
}

int factorial9() {
return 9 * factorial8();
}

int factorial10() {
return 10 * factorial9();
}

int factorial11() {
return 11 * factorial10();
}

int factorial12() {
return 12 * factorial11();
}

int factorial13() {
return 13 * factorial12();
}

int factorial14() {
return 14 * factorial13();
}

int factorial15() {
return 15 * factorial14();
}

int factorial16() {
return 16 * factorial15();
}

int factorial17() {
return 17 * factorial16();
}

int factorial18() {
return 18 * factorial17();
}

int factorial19() {
return 19 * factorial18();
}

int factorial20() {
return 20 * factorial19();
}

int factorial21() {
return 21 * factorial20();
}

int factorial22() {
return 22 * factorial21();
}

int factorial23() {
return 23 * factorial22();
}

int factorial24() {
return 24 * factorial23();
}

int factorial25() {
return 25 * factorial24();
}

int factorial26() {
return 26 * factorial25();
}

int factorial27() {
return 27 * factorial26();
}

int factorial28() {
return 28 * factorial27();
}

int factorial29() {
return 29 * factorial28();
}

int factorial30() {
return 30 * factorial29();
}

int factorial31() {
return 31 * factorial30();
}

int factorial32() {
return 32 * factorial31();
}

int factorial33() {
return 33 * factorial32();
}

int factorial34() {
return 34 * factorial33();
}

int factorial35() {
return 35 * factorial34();
}

int factorial36() {
return 36 * factorial35();
}

int factorial37() {
return 37 * factorial36();
}

int factorial38() {
return 38 * factorial37();
}

int factorial39() {
return 39 * factorial38();
}

int factorial40() {
return 40 * factorial39();
}

int factorial41() {
return 41 * factorial40();
}

int factorial42() {
return 42 * factorial41();
}

int factorial43() {
return 43 * factorial42();
}

int factorial44() {
return 44 * factorial43();
}

int factorial45() {
return 45 * factorial44();
}

int factorial46() {
return 46 * factorial45();
}

int factorial47() {
return 47 * factorial46();
}

int factorial48() {
return 48 * factorial47();
}

int factorial49() {
return 49 * factorial48();
}

int factorial50() {
return 50 * factorial49();
}

int factorial51() {
return 51 * factorial50();
}

int factorial52() {
return 52 * factorial51();
}

int factorial53() {
return 53 * factorial52();
}

int factorial54() {
return 54 * factorial53();
}

int factorial55() {
return 55 * factorial54();
}

int factorial56() {
return 56 * factorial55();
}

int factorial57() {
return 57 * factorial56();
}

int factorial58() {
return 58 * factorial57();
}

int factorial59() {
return 59 * factorial58();
}

int factorial60() {
return 60 * factorial59();
}

int factorial61() {
return 61 * factorial60();
}

int factorial62() {
return 62 * factorial61();
}

int factorial63() {
return 63 * factorial62();
}

int factorial64() {
return 64 * factorial63();
}

int factorial65() {
return 65 * factorial64();
}

int factorial66() {
return 66 * factorial65();
}

int factorial67() {
return 67 * factorial66();
}

int factorial68() {
return 68 * factorial67();
}

int factorial69() {
return 69 * factorial68();
}

int factorial70() {
return 70 * factorial69();
}

int factorial71() {
return 71 * factorial70();
}

int factorial72() {
return 72 * factorial71();
}

int factorial73() {
return 73 * factorial72();
}

int factorial74() {
return 74 * factorial73();
}

int factorial75() {
return 75 * factorial74();
}

int factorial76() {
return 76 * factorial75();
}

int factorial77() {
return 77 * factorial76();
}

int factorial78() {
return 78 * factorial77();
}

int factorial79() {
return 79 * factorial78();
}

int factorial80() {
return 80 * factorial79();
}

int factorial81() {
return 81 * factorial80();
}

int factorial82() {
return 82 * factorial81();
}

int factorial83() {
return 83 * factorial82();
}

int factorial84() {
return 84 * factorial83();
}

int factorial85() {
return 85 * factorial84();
}

int factorial86() {
return 86 * factorial85();
}

int factorial87() {
return 87 * factorial86();
}

int factorial88() {
return 88 * factorial87();
}

int factorial89() {
return 89 * factorial88();
}

int factorial90() {
return 90 * factorial89();
}

int factorial91() {
return 91 * factorial90();
}

int factorial92() {
return 92 * factorial91();
}

int factorial93() {
return 93 * factorial92();
}

int factorial94() {
return 94 * factorial93();
}

int factorial95() {
return 95 * factorial94();
}

int factorial96() {
return 96 * factorial95();
}

int factorial97() {
return 97 * factorial96();
}

int factorial98() {
return 98 * factorial97();
}

int factorial99() {
return 99 * factorial98();
}

int factorial100() {
return 100 * factorial99();
}

int main(int argc, char* argv[])
{
    printf("%i", factorial100());
    getchar();
}

Name: Anonymous 2009-03-12 3:04

>>42

as opposed to


#include <iostream>

template<int I>
int factorial()
{
    return I * factorial<I-1>();
}

template<>
int factorial<0>()
{
    return 1;
}

int main()
{
    std::cout << factorial<100>();
    std::cin.get();
}

Name: Anonymous 2009-03-12 3:16

>>42-43
slow-ass fuck. also, lrn2<mp.h>.

Name: Anonymous 2009-03-12 3:54

>>43
C version compiles faster

Name: Anonymous 2009-03-12 4:21

>>45
both c and sepples versions are also fucking useless.
lrn2<mp.h>.
and then try doing 1000000! that way.

Name: Anonymous 2009-03-12 5:19

Considering you would need larger than a 131072 bit variable to store 1,000,000!, I'm guessing you'll be storing the number in a string or something, which will be SLOW AS FUCK.

Name: Anonymous 2009-03-12 5:29

>>47
bitches don't know 'bout my arbitrary precision integer library

Name: Anonymous 2009-03-12 5:34

>>1
Then you fail it, as /prog/'s advice is to learn Haskell

Name: Anonymous 2009-03-12 7:23

>>49
No, /prog/'s advice is to READ YOUR SICP.

Name: Anonymous 2009-03-12 13:15

>>7
[q]Nothing, it's just the only thing we've been able to fault python for, so we mention it at every available moment [/q]

Expert troll. 10/10.

Name: Anonymous 2009-03-12 13:28

def factorial(n):
     if n == 0:
         return 1
     else:
         return n * factorial(n-1)

Name: Anonymous 2009-03-12 13:33

[q]bitches don't know 'bout my arbitrary precision integer library[/q]
!

Name: Anonymous 2009-03-12 14:37

>>51
>>53
Read your BBCode Standards and Best Practices Vol. 1, please.

Name: Anonymous 2009-03-12 14:41

" > " is the standard

Name: Anonymous 2009-03-12 14:55

" > " is the standard

Name: Anonymous 2009-03-12 16:43

" > "

Name: Anonymous 2009-03-12 16:49

^ > ^

Name: Anonymous 2009-03-12 16:52

=(^___^)=

Name: Anonymous 2009-03-12 17:38

。  。
"
> "

Name: Anonymous 2010-12-24 19:40

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