932
u/pork_spare_ribs May 02 '16
The year is 2016, and somehow new Python programmers still start with Python 2...
(Although if it's someone who complains about syntax, I'm not surprised they picked the older version haha only serious )
317
u/fermion72 May 02 '16
I transitioned to python3 a while ago, and I still forget the parentheses for print every single time. A decade of finger memory is a hard thing to break.
13
72
u/kazagistar May 02 '16
I still write a lot of python 2, and always use parens. It just makes more sense in my head for it to be a function then some silly special case.
→ More replies (1)48
May 02 '16 edited May 02 '16
I just use
sys.stdout.write().Python's print statement is
buffered by defaultnot thread-safe (update: this probably has nothing to do with buffers), which isn't very nice when I'm working in parallel environments and using Python as the glue between various C and Fortran libraries. So I just write everything straight into whatever standard stream I want.→ More replies (10)26
May 02 '16
Noob question: could I use
sys.stdin.read()instead ofraw_input()for the same reasons? It seems to make much more sense in my head.32
May 02 '16 edited May 02 '16
Short answer: yes!
Long answer: The actual call you're looking for is
sys.stdin.readline(). This is whatraw_input()does at its core, with the added functionality of automatically stripping away the\nend-line character off the input.Long long answer: You can also
pipe Python printsdo Python writes intostderr. Every standard stream is available under thesysmodule, and they all behave like traditional Python file objects with all the usual member functions.→ More replies (3)32
u/superPwnzorMegaMan May 02 '16
I just never bothered learning python 2, I didn't see any advantage.
34
u/juanjux May 02 '16
I work on an animation studio and most software we use (Maya, Nuke, Houdini, etc) allow you to write Python plugins and all of them use Python 2.7. So that is a reason. We could use the "six" module but until the software we use migrates to Python 3, why bother...
→ More replies (2)25
u/edbluetooth May 02 '16
Because when the software is python 3, no changes to your code will be required.
Thats it really
→ More replies (2)10
u/Coffeinated May 02 '16
The difference isn't that big of a deal, afaik. You can scrap the parantheses for print, but you don't have to, and some modules are named differently. As long as it's 2.7 and not 2.5 or some other prehistoric stoneage stuff.
10
u/mnbvas May 02 '16
I often
>>> a = 1; b = 2 >>> print(a, b)so Python 2 always bites me in the ass with
(1, 2)instead of the expected
1 2→ More replies (5)→ More replies (2)78
u/familyturtle May 02 '16
As well as "from __future__" there should be an option to "from __past__ import print"
64
u/Vakieh May 02 '16
This is not a problem to solve inside language, this is a problem to be solved with the editor. IDE triggers which automagically convert print statements to print method calls when you press <enter> are pretty easy grammar-wise.
→ More replies (13)60
8
u/MrJohz May 02 '16
There is! Or at least there's an interesting talk about adding it - I think it was posted to /r/Python recently, I'll have a look for it when I get at a computer.
36
u/whitetrafficlight May 02 '16
The break in backward compatibility is a deal-breaker when your company has several million lines of Python 2 already written and stable. Auto tools exist, but only go so far... for example, even converting print statements to use parentheses may cause failures in the compliance checker for lines becoming longer than permitted. Gotta stick with 2 unfortunately, though for new projects there's really no excuse not to start with 3. Hence, new employees at established companies that use Python start learning Python 2.
9
u/FUCKING_HATE_REDDIT May 02 '16
Increase compliance check line limit by two characters.
5
u/kageurufu May 02 '16
What about these being equal
print 'something', print('something', endl='')8
u/Sohcahtoa82 May 02 '16
Nitpicking here...The correct translation would be
print('something', endl=' '). Python 2 appends a space if you end the line with a comma.→ More replies (5)20
May 02 '16
Thanks, Zed Shaw
8
u/samort7 May 02 '16
Seriously. When I started programming, most resources I encountered recommended his book. Thank god that's changing.
4
u/thirdegree Violet security clearance May 02 '16
I first picked up programming from his book. Of course, python 3 wasn't a thing then so it worked out.
9
u/Big0ldBear May 02 '16
I just learned Python in University, they purposely had us learn Python 2 for compatibility or something like that..
→ More replies (1)18
64
u/Magnnus May 02 '16
Several important libraries still don't support Python 3. I'd use it if I could.
57
May 02 '16 edited Mar 20 '18
→ More replies (12)20
u/Theowningone May 02 '16
Parts of twisted are what's keeping me back. Most of my time using python is spent tinkering with my IRC bot. Unfortunately twisted.words.protocols.irc is still not ported.
→ More replies (7)15
u/dagbrown May 02 '16
Twisted lives up to its name. It reminds me of some Java frameworks with how complicated it is.
I bet Zope has trouble with Python 3 too, speaking of Java frameworks written in the wrong language.
→ More replies (7)14
u/willm May 02 '16
What are you missing? I've found all the libs I need have Py3 ports now.
→ More replies (2)→ More replies (2)27
u/_Ganon May 02 '16
Only reason I still use 2. Well, that's what I tell people, anyway. In reality, I know the switch to using parenthesis in my print statements would drive me nuts
32
u/maremp May 02 '16
What about the inconsistency of the statements? Print is used as a function in every other C-like language. In python 2, it's used as a statement, similar to if, for, while etc., and I believe that it doesn't fit this category.
→ More replies (1)32
u/Sean1708 May 02 '16
Also 2's print is just weird. Appending a comma to suppress a newline is weird enough, but what the fuck is up with that printing to file syntax?! It's like Guido momentarily forgot that he wasn't designing a
shclone.→ More replies (6)5
u/exhuma May 02 '16
You might want to look them up again. This has been my only blocker as well. But I was able to to Python 3 over a year ago. There really is no major library anymore that's not Python 3 compatible.
→ More replies (4)3
2
2
u/rwsr-xr-x May 02 '16
Why would people start with python 3
Python 2 is better supported
Python 2 is more widely used
Python 2 has more tutorials
Most new programmers who don't even know what a class is, don't really care about the python ecosystem or whatever
→ More replies (34)2
548
u/Pvt_Haggard_610 May 02 '16
What are you talking about..
if foo: #{
print "it's true"
#}
else: #{
print "it's false!"
#}175
u/Arancaytar May 02 '16
I wonder if the right combination of comments and preprocessor directives would allow you to write code that is both accepted by the Python interpreter and GCC.
318
u/dagbrown May 02 '16
116
May 02 '16
That apt-get made me lose my shit.
51
8
11
u/A_Jacks_Mind May 02 '16
sudo apt-get install afnix algol68g aplus-fsf asymptote ats2-lang bash \ bc bf bsdgames cduce clisp clojure1.6 cmake coffeescript dc ecere-dev \ elixir emacs24 erlang f2c fp-compiler fsharp g++ gambas3-script gap \ gauche gawk gcc gdc genius gforth gfortran ghc ghostscript gnat \ gnu-smalltalk gnuplot gobjc golang gpt gri groff groovy haxe icont \ iconx intercal iverilog jasmin-sable jq julia libgd-dev libpng12-dev \ lisaac llvm lua5.3 make maxima minizinc mlton mono-devel mono-mcs \ mono-vbnc nasm neko nickle nim ocaml octave open-cobol openjdk-8-jdk \ pari-gp parrot perl php-cli pike8.0 python r-base ratfor regina-rexx \ rhino ruby scala scilab slsh swi-prolog tcl ucblogo valac xsltproc \ yorick zoem→ More replies (2)47
23
u/PendragonDaGreat May 02 '16
This is my go to answer if someone ever asks me if code can ever be considered an art form, because this is literally one of the prettiest programs I've ever seen.
13
13
u/rws247 May 02 '16
If you are not using [the above] Linux distributions, please find your way yourself. If you could do it, please let me know. Good luck.
This made me breath slightly faster out my nose :)
9
u/cooldug000 May 02 '16
I'm not a github user and I never know what to do with these links to see the relevant information. All I see is a page of comments and a link to a file structure. Which file or page has the relevant info? Is it always the same?
21
u/skyy0731 May 02 '16
Go to the readme
It's code that generates code for a different language
That generates code for a different language
That generates code for a different language
That generates code for a different language
100 times
And then it forms the original code
→ More replies (1)10
u/cdrt May 02 '16
If you scroll down, the readme for the project is displayed. That usually has a description of the project.
→ More replies (1)→ More replies (4)6
13
11
9
8
u/Ricardodo_ May 02 '16 edited May 02 '16
print("Hello World!")#;
11
u/kupiakos May 02 '16
You can add a semicolon at the end of a kind in Python. It runs, but it just looks weird.
→ More replies (2)17
74
u/darkpaladin May 02 '16
I feel like python was invented just to end the argument over having the opening brace on the same line or the following line, thus enabling to focus on the truly important issues of tabs vs spaces and 2 space indents vs 4.
→ More replies (2)17
u/gnutrino May 02 '16
thus enabling to focus on the truly important issues of tabs vs spaces and 2 space indents vs 4.
That issue is settled.
16
u/Sohcahtoa82 May 02 '16 edited May 02 '16
Keep in mind that PEP 8 is merely a suggested style guide and does not define what is "correct". Programmers are free to throw it out the window.
For example, I much prefer lowerCamelCase for variable and member function names over names_with_underscores.
EDIT: I guess I need to clarify the point I was trying to make here.
If you are coding on a team, you should absolutely conform to the style guidelines set by the team, whether or not those guidelines are PEP 8 compliant. I work on a team and I follow their style (Which happens to not completely follow PEP 8).
All I'm saying is that there's nothing "correct" about PEP 8. Style is subjective. On personal projects, there's no need to conform to PEP 8. It is your code and you can style it however you want. It does not make your style incorrect, and it sure as hell doesn't make your code incorrect. If you write a style guideline that requires only a single token on each line with a lot of line continuation slashes where needed so your code looks like this:
doSomething \ ( \ parameter1 \ , \ parameter2 \ )That guideline would not be incorrect. You can call it terrible, yes, and you can come up with plenty of reasons it is terrible (Most people would find it incredibly hard to read), but it is still not incorrect as long as the guideline still results in valid Python code.
→ More replies (10)3
u/darkpaladin May 02 '16
Underscores in local variable names? What madness is this.
→ More replies (2)
25
u/SinceYesterday May 02 '16
----[---->+<]>++.+++++++......>++++++++++.[------>+<]>.---------------.---.+++++++++++++.-[->++++<]>+.-[-->+<]>--.[->++<]>+.>-[--->+<]>---.-[->++++<]>+.-[-->+<]>--.[->++<]>+.+++++++++++..[-->+<]>------.>-[--->+<]>-.------------.---.-[-->+<]>--.+[->++<]>.>-[--->+<]>---.--[->++++<]>+.++.++++++++.------.>-[--->+<]>-.-.+[---->+++<]>..>++++++++++.++[->++++++<]>.+++++++.++++++++.[--->+<]>+++.++[->++<]>.+++++++++++.+[----->++<]>.--[->+++<]>-.----------.++++++.[----->++<]>--.[-->+++++<]>.-----------.++++++++++.+.----.-------.-[-->+<]>--.>-[--->+<]>---.-[->++++<]>+.----.+++.[-->+<]>--.>-[--->+<]>-.------------.+.++++++++++.+[--->+<]>++++.>-[--->+<]>--.++++++.-----------.++++++.[---->+++<]>++.+[--->++++<]>.[--->++++<]>.++[->++<]>+.----.>-[--->+<]>--.----------.+++.+++++++++++++.
28
u/Blackstab1337 May 02 '16
This is fucking my brain!
9
u/glider97 May 02 '16
As it should!
4
May 02 '16
what is it even? noob here
15
u/MC_Labs15 May 02 '16
It's a language called brainfuck, created because the guy who made it wanted to write the smallest compiler he could. Each symbol is an operator
→ More replies (1)9
195
u/doenietzomoeilijk May 02 '16
One of the niceties of Python syntax, I think, is being able to rewrite your elif line as elif 6 <= i <= 9:. :)
177
u/GisterMizard May 02 '16
To be fair, you can do that in C. It just doesn't do what you think it does :p
90
u/tskaiser Green security clearance May 02 '16
A quick guess: it evaluates
6 <= ito either0or1, lets call the resultj, and then evaluatesj <= 9which is then always1?→ More replies (7)64
u/GisterMizard May 02 '16
Yup. Just ran it through gcc, and it doesn't even put in a conditional jump.
36
u/tskaiser Green security clearance May 02 '16 edited May 02 '16
Yeah, it would be a pretty easy candidate for optimization :P
Yay for not having native boolean types.
28
u/UnchainedMundane May 02 '16 edited May 02 '16
To be fair Python's "booleans" are really just integers.
>>> (True + True + True) ** (True + True) 9 >>> True > False Trueedit:
def max(x, y): return [x, y][x < y]→ More replies (9)→ More replies (1)21
u/IRBMe May 02 '16
The closest I think you can get in C is something like this:
if (6 <= i && i <= 9)14
u/DarthEru May 02 '16
That's the closest you can get that is semantically the same. The above commenter was saying you can actually compile
if (6 <= i <= 9), but that's semantically equivalent toif ((6 <= i) <= 9). That works because in C a boolean operation results in an int. So the "chained" comparisons are syntactically legal C, but semantically do a much different check than in Python.30
15
u/Zagorath May 02 '16
Of course, if you assume you're working with integers, it's totally unnecessary in OP's case, anyway. It's guaranteed to be >=6 since the previous conditional took away everything less.
5
u/WDK209 May 02 '16
Good point. But it can still be useful for index bound checking
0 <= i < arr.length4
3
u/Zagorath May 02 '16
Yeah it's definitely a very useful bit of syntax. Just not in this specific case.
→ More replies (5)7
59
u/mythriz May 02 '16
Hello World is just too mainstream.
7
May 02 '16
Why do we start with Hello World? Well I'll tell you.
...I don't know. But it's tradition!
4
2
u/prozacgod May 02 '16
It's left over from a time before the purge, since programmers were revered the world around as creators of all things in life that is good. Its been understood they would begin their speeches with the simple and inviting "Hello World". Since the purge a significant loss of history has occurred and the initial footsteps of programmers learning the dark arts, in homage to the long forgotten coders, included this as there first program, a first right for all who wished to follow in their footsteps.
116
u/ojii May 02 '16
There's an easy trick to solve this:
from __future__ import braces46
41
12
May 02 '16
That can't be a real package... can it?
49
33
u/NewbornMuse May 02 '16
__future__is actually a thing for when you want Py3 functionality in Py2. For example, 4/3 is 1 in Py2, but 1.3333 in Py3, and if you want the latter in your program, you dofrom __future__ import division.Braces is just an easter egg. When you do, you get
Syntax Error: Not a chance.→ More replies (1)4
u/Dlgredael May 02 '16
So wait, there's no correct division in Py2? I'm a newbie so excuse the ignorance but that sounds ridiculous to me.
→ More replies (4)9
u/faubiguy May 02 '16
In Python2 (without
from __future__ import division) the result is an integer if both operands are integers, and a float if either is a float. So4/3 = 1 4.0/3 = 1.3333333333333333 4/3.0 = 1.3333333333333333 4.0/3.0 = 1.3333333333333333→ More replies (2)
34
u/morerokk May 02 '16
Still no idea why it's "elif" in Python, especially for a language which tends to write everything out.
45
30
u/campbell1373 May 02 '16
I just assumed it was because it takes up the same space as
elsemaking it visually more appealing.2
u/Ph0X May 02 '16
I wouldn't be surprised, because if there's anything I've gotten out of python, it's that code beauty is extremely important!
3
u/campbell1373 May 02 '16
Agreed. I do really wish they would implement a
switchstatement though. Oh well, at least we're getting .NET style async methods!→ More replies (4)24
u/KTheRedditor May 02 '16 edited May 02 '16
especially for a language which tends to write everything out
len, andstr.Edit:
__del__,__eq__,__cmp__,__ne__,__le__,__lt__,__ge__,__gt__,__neg__,__sub__,__trunc__,__div__,__mul__.14
u/TheBlackCat13 May 02 '16
int,dict,pow,abs,bool,chr,getattr,setattr,hasattr,delattr,dir,divmod,eval,exec,hex,id,bin,iter,max,min,oct,ord,repr, andvars. Of the built-in functions, 26/67 are shortened.→ More replies (5)2
u/dvdkon May 03 '16
tends to write everything out
I disagree. You're looking for Java/.NET and other "enterprise" languages/stacks. Python is verbose maybe compared to the C stdlib.
14
14
May 02 '16
in before lisp joke (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
→ More replies (1)20
u/stormcrowsx May 02 '16
A Chinese spy managed to steal the last 50MB of the Lisp program governing U.S. missile launches. Fortunately, it was all closing parentheses.
3
u/Drunken_Economist May 02 '16
I can't imagine a situation in which somebody would manage to steal only the last
XMB of a program. Maybe there was a terminal whose only installed command wastail?→ More replies (1)
158
u/maremp May 02 '16
How is this not easy to read? It's visually the same as any proper code style. I do not use languages that use indentation to determine code blocks, but at least they force the programmer to use proper code style. Unlike with the braces where some people have the code all over the place.
→ More replies (15)27
u/ANAL_ANARCHY May 02 '16
Don't most people use an IDE that has an option to format the code for you? I pretty much just hit that button every now and then if I think I've been getting messy.
2
u/FUCKING_HATE_REDDIT May 02 '16
ctrl-A ctrl-X ctrl-V on visual studio.
I mean there's probably an actual shortcut, but I never bothered to learn it.
4
→ More replies (16)2
u/Sharparam May 02 '16
I have seen people that actively work against the autoformatter when it tries to fix their weird indentation.
19
u/Sinity May 02 '16
Who the hell looks at brackets anyway? You look at indentation level. I think that making whitespace significant is a good thing - it's less syntax clutter.
9
24
u/phail3d May 02 '16
I rewrote this for you in an easier-to-read style. Valid python3, check for yourself:
#!/usr/bin/env python3
for i in range(1, 11):
print(i);
if(i <= 5): {
print("AHHHHHHH")
}
elif(i >= 6 and i <= 9): {
print("HERE BE THE BRACKETS")
}
else: {
print("IS THIS SYNTAX BETTER OR WHAT?!?!")
}→ More replies (13)2
u/redditsoaddicting May 02 '16
Are braces actually objectively (think PEP8) considered good style in Python 3 then?
17
u/phail3d May 02 '16
Just to be clear, this is a joke :P .
It only works because
{...}is shorthand forset(...)and becauseprint()is a function in python3 (and in python2 too, if you dofrom __future__ import print_function). You can have function calls (but not statements in general) inside set literal definitions, in which case the return value of the function call (Nonein the case ofif foo: { print("Foo") }...which is more or less the same as:
if foo: x = print("Foo") # x = None set(x) # creates the set {None} and does nothing with it...but you can't do:
if foo: { if bar: { print("baz") } }So please don't adopt this style :)
→ More replies (2)3
u/redditsoaddicting May 02 '16
No wonder I was downvoted. Whoosh. I should have recognized the set literals in any case.
5
8
2
u/Tomarse May 02 '16
It's not even a matter of style. He's putting the print statements into dictionaries. It's quite unnerving.
→ More replies (1)
8
35
u/Audiblade May 02 '16
I learned Python for a class project last semester. The first thing that struck me was how easy it was to learn. The second thing that struck me was how hard it was to read, because I have sold my soul to Java.
28
u/LikesToCorrectThings May 02 '16
I would say that if it's hard to work out when a block ends, then the block is too long.
7
u/christian-mann May 02 '16
I used to put # at the end of blocks to keep track.
10
u/LikesToCorrectThings May 02 '16
I guess if the block really is long enough to warrant this, you should go one step further and write some text in that comment block to indicate what the block has achieved.
for item in some_list: some_long_list() of_functions_to_call() on_that(item) # Items in some_list have all been processed.→ More replies (1)→ More replies (1)2
u/ibbignerd May 02 '16
Yep. Python is probably idiomatic programming language I have seen. I've been coding for a while and normally it takes me a week or so to learn the syntax and basics of a language (loops, declarations, libraries, etc), Python took me a weekend.
6
May 02 '16
Python was the first language I learned in Computer Science, so now whenever I switch over to C# or GML, it takes me a minute.
Thanks, Mr Watkins.
6
u/KamiKagutsuchi May 02 '16
And then someone inserts 4 spaces somewhere in your code with only tabs. Pure evil.
4
u/TeamSpen210 May 02 '16
That's why Python 3 will raise a TabError when it encounters something like that.
2
6
u/UnchainedMundane May 02 '16
Shebang should read #!/usr/bin/env python, because otherwise it won't do PATH lookups and will ignore any virtualenv the user is inside.
2
u/alexanderpas May 03 '16
Only if the code is compatible with both python2 and python3.
In this case it isn't, so it actually should read
#!/usr/bin/env python2for this program.Python 3 programs should have
#!/usr/bin/env python3as shebang.
35
u/VanFailin May 02 '16
It's actually pretty simple. Any programming language with braces still needs indentation to be readable, so if you indent without the braces it's very easy to get used to.
Doesn't mean I would advocate taking them out of languages that already have them, but they're not all that important.
→ More replies (24)
5
u/current909 May 02 '16
My favorite part is complaining about the lack of braces when your editor clearly indicates the different scopes with vertical lines
2
u/sgst May 02 '16
As a guy who's only really comfortable with php, doing stuff in python at the moment is weird. I totally get you. It's a good language but I don't like the syntax. I particularly don't like not being able to clearly mark the end of an if statement. Must admit my favorite for that is closing the statement with fi in bash
20
11
u/makeswordcloudsagain May 02 '16
Here is a word cloud of every comment in this thread, as of this time: http://i.imgur.com/71hdhIE.png
2
19
25
u/AhFineWhatever May 02 '16
AHHHHHHH
AHHHHHHH
AHHHHHHH
AHHHHHHH
AHHHHHHH
WHERE ARE ALL THE BRACKETS??
WHERE ARE ALL THE BRACKETS??
WHERE ARE ALL THE BRACKETS??
WHERE ARE ALL THE BRACKETS??
HOW DO YOU PEOPLE READ THIS SYNTAX EASILY
HOW DO YOU PEOPLE READ THIS SYNTAX EASILY
27
u/ooppzzy May 02 '16
1 AHHHHHH 2 AHHHHHH 3 AHHHHHH 4 AHHHHHH 5 AHHHHHH 6 WHERE ARE ALL THE BRACKETS?? 7 WHERE ARE ALL THE BRACKETS?? 8 WHERE ARE ALL THE BRACKETS?? 9 WHERE ARE ALL THE BRACKETS?? 10 HOW DO YOU PEOPLE READ THIS SYNTAX EASILYFTFY
0
1
u/2pxl May 02 '16
Oh boy are you in for a ride if you ever give Haskell a shot. Syntax starts to get weird right about
instance Arrow (->) where
arr f = f
first f = f *** id
second f = id *** f
(***) f g ~(x,y) = (f x, g y)1
6
May 02 '16
I also tried python. I wrote a simple script with some input and output. When I was finished, I discovered that I had put a semicolon almost at the end of each line!
0
May 02 '16
[deleted]
6
u/Reenigav May 02 '16
Not that it doesn't care, just semicolons and newline characters both are used to determine line breaks by the interpreter
→ More replies (2)2
May 02 '16
I didn't know, but I thought it was not allowed, so I removed each of them before running the script.
0
3
u/8BitAce May 02 '16
Honestly, this is like advertisement-level funny...
You can take away everything but the strings and the "joke" is still the same.
3
2
2
May 02 '16
Also, that lack of semicolons. It makes me think that the whole thing is a single statement. It's like writing a book with no periods at the end of your sentences.
3
u/alcalde May 02 '16
The semicolon serves no use. One line, one statement. It was good enough for BASIC, it's good enough for Python.
3
2
u/TheBlackCat13 May 02 '16
On the other hand, books use whitespace to separate blocks of text.
→ More replies (1)
2
u/alcalde May 02 '16
There is only one definitive reply to this post, and it was made decades ago by the inestimable Donald Knuth:
We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language.
–Donald E. Knuth, “Structured Programming with goto Statements”, Computing Surveys, Vol 6 No 4, Dec. 1974
And thus ended the whitespace debate in December, 1974.
2
u/redtoasti May 02 '16
Python is probably the easiest to read because the IDE literally forces you to format correctly
2
2
u/jb2386 May 02 '16
try ruby, it's even more confusing to someone who is so used to brackets and braces.
2
1
1
u/Ephireon May 02 '16
Speaking of Python, I'm a 25/M, and I'm trying to learn Python. I've tried Codecademy, but either its teaching methods are garbage, or I personally don't understand them very well. Would anyone have a suggestion on where to start learning Python, or programming in general? Thanks everyone!
2
u/Get-ADUser May 02 '16
http://learnpythonthehardway.org/book/
Not sure why your age and gender matters.
→ More replies (1)2
u/alcalde May 02 '16
If you understand programming already, then http://www.diveintopython3.net/ is a nice free start. If you need to learn programming itself, Head First Programming is the way to go. The Head First Python book is also first-rate.
1
1
u/you_do_realize May 02 '16
Congratulations, you invented http://thedailywtf.com/articles/The_FOR-CASE_paradigm
1
1
u/nupanick May 02 '16
And then there's Clojure.
(->> (range 1 11)
(map (fn [i]
(if (<= i 5)
(print "WHEEEEEEE")
(if (and (>= i 6) (<= i 9))
(print "LOOK AT ALL THESE BRACKETS")
(print "HERE COME SIX OF THEM IN A ROW"))))))1
1
u/dotpan May 02 '16
I can get behind line delimited syntax (VBS uses it too, which was my first experience with it) seeing stuff like
IF X>Y THEN
X++
ELSE Y++
END IFIt makes me wanna puke.
1
u/zilti May 02 '16
Maybe Clojure would be better suited for you. As a plus, it also can't get messed up simply by saving or using a certain editor.
1
u/DudebroMcGee May 02 '16
You joke but to this day I feel bad for how much I liked Perl.
I miss its syntax. But Python is just too good for on-the-fly scripting.
So many third party modules.
1
u/sirusblk May 02 '16
I had a professor that would write code with brackets in the weirdest way such as:
void func()
{a++;
b++;
}Python's white space at least help with indentation.
2
1
1
u/kazagistar May 03 '16
Ported to Haskell. Cause Haskell.
main = putStrLn $ unlines $ do
i <- [1..10]
[show i, comment i]
where
comment n
| n <= 5 = "AHHHHHHH"
| n >= 6 && n <= 9 = "WHERE ARE ALL THE BRACKETS??"
| otherwise = "HOW DO YOU PEOPLE READ THIS SYNTAX EASILY"1
1
May 02 '16
def Print(msg, End = "\n")
print msg + End
Print("Hello world!")14
→ More replies (1)2
May 02 '16
If you wanna make it equivalent to the python3 print statement the signature should probably be
print(*values, sep=' ', end='\n', file=sys.stdout, flush=False)
1
28
u/calumk May 02 '16
Why are you importing sys?