What does the snake say?

what does the snake say?

>>> 4 / 2
2
>>> 5 / 2
2

Other urls found in this thread:

pypy.org/
twitter.com/SFWRedditVideos

Sometimes I forget how much better Python 3 is.

are you retarded ?

put a .0 and see what happens

Wow, integer division yields an integer.
You can do 5/2.0 if you want float, amazing amirite?

>>> 4.0 / 2
2.0
>>> 5.0 / 2
2.5

I don't see the problem user, you are dividing integers, instead of decimals.
this.

I cannot tell if this is just a friendly nerd thread for python geeks or if it is a trolling thread to say why python is bad.

Python is pretty cool. Know what you are doing (Explicit before implicit).

>>> 4./2
2.0

Which is correct.

4/2=2
5/2=2.5

Only on python 2 kek

are you pretending to be retarded?

Everyone here is missing the point

>>> 4/2
2.0
>>> 5/2
2.5

> 2.0
> .0
> .0

Implying burgerstani """""""""programmers"""""""""" know difference between decimal and integer

> implying 2.0 != 2 in python

STOP USING PYTHON 2

> -1 % 5 is actually -1
Really Java?

F/IGHT ME NIGGER!!!

>forced indentation

>forcing conventions is a bad thing

You python 2.0 niggers are the reason we can't have nice things.

>getting cucked by a computer program

All programs do that though...

> implying that's not the best fucking thing about python.

If you want to make an argument from unnecessary syntax, you brought a dull knife to a gun fight.

Man it's like you have virtual stockholm syndrome.

but all programs restrict you in one way or another
I assume that's what you meant by "cucked" unless your memes have been evolving

int i = 5; i = ++i + ++i;
10, 11, 12, 13, 14 or 16?

language?

theres no pypy for python3

looks like C

Anything you wish. Try on C++ or C or C#.

>using curly brackets

fuckoff micropenis.

undefined behaviour

>I want my programming language to change the types of variables I am using withought telling me
Do you seriously not understand the dangers of not being able to control if a line of code is going to return a double or an integer?

Really in most cases it doesn't matter. Which is why Python 3 does it differently and you have to use a different operator to get integer division.

you can explicit tell which type you want.

but normally it doesn't matter anyway, the type it return will be compatible with your next function.

>>> L1 = [2, 3, 4]
>>> L2 = L1
>>> L1[0] = 24

>>> L1
[24, 3, 4]
>>> L2
[24, 3, 4]

DELETE THIS

> doesn't know how integers work

13

>>> 2.1 + 2.2
4.300000000000001

js?

Reminder that if you don't know why this happens you are officially a code monkey.

That's standard IEEE floating point behavior.

Inexplicable

im code monkey and even black but im knowing this

>math.floor(8.2-0.2)
7

Explain this

++i is pre-incrementation.
from left to right
>i = (++i) + (++i)
>i = (i += 1) + (i += 1)
>i = 6 + 7
>i = 13

>mfw Sup Forums still doesnt understand how floating point arithmetic works

>from left to right
no
>i = (++i) + (++i)
>i = (i += 1) + (i += 1)
>i = (i += 1) + 6
>i = 6 + 7
>i = 13

>mfw interpreter is forcing pass-by-reference behaviour
>irb(main):001:0> x1 = [1, 2, 3]
>=> [1, 2, 3]
>irb(main):002:0> x2 = x1
>=> [1, 2, 3]
>irb(main):003:0> x1[0] = 24
>=> 24
>irb(main):004:0> x1
>=> [24, 2, 3]
>irb(main):005:0> x2
>=> [24, 2, 3]

I think that kind of behaviour is more intuitive, even if we're dealing with primitives.

Honestly i'd blame the shitty way coding principles are taught nowadays. I've done code reviews for tons of college grads and they just arbitrarily force conversions between int/float/double wherever and have no idea what each of them should be used for or why, and then they wonder why they get 15.00000000000000000000000000001 as an answer.

I don't think it's more intuitive, but performance-wise it makes sense for it to be the default.

>mfw a pythocuck and a nodebabby get into an argument about performance

Holy shit, how incompetent can developers be?

what's wrong with that?
you guys seriously need to take a formal programming languages course so that you understand why some things work in a certain way in a certain language

This is something I hate of Python. In other languages you clearly know when something is a reference.

>configure your editor for this project or else

You would THINK python would be able to handle mixed tabs and spaces just fine. It's a simple thing to program. But no. It can't. It might mess up the alignment and trigger someone's autism.

Remember the 90s, when you could just put two vim and emacs lines at the bottom of the file and have indentation settings automatically applied? Things were better then.

(python 3.5.1)
> 0.2 + 0.1
0.30000000000000004
> 12345 / 54321
0.22726017562268735

(sbcl 1.3.1)
> (+ 0.2 0.1)
0.3
> (/ 12345 54321)
4115/18107

>mfw no "modern language handles numbers as well as lisp
>mfw lisp is still king

Gotta love that number tower.

True + True = 2

Everything in python is a reference.

>undefined behavior
It will probably just compile to a nop with optimization on

It probably rounds to 7.9999999999 and then rounds down with floor

Hence a pointer.

pypy.org/

>PyPy is a fast, compliant alternative implementation of the Python language (2.7.10 and 3.2.5). It has several advantages and distinct features:
>and 3.2.5

Does it implement tail call optimization?

No idea. I don't use pypy.

The post I was responding to said that it didn't exist. Now if the issue is that it doesn't perform as someone would like it to, that's different.

I'm getting 14 in C.

Ok this is getting far too serious for weekend Sup Forums, now what does the fox say?

This. This is the single reason why I don't use Python. Don't get me wrong, Python is terrible on so many levels I'd still not use it if it didn't have the indentation bug, but that alone is enough for me not to use it.

Because you never indent your codes?

>I'm gonna mix logic and styling, and when you say that's a bad idea, I'll accuse you of never styling

Didn't expect anything else from a pythonfag.

>I'll accuse you of never styling
Yes I never style my code. Neither did I sign them. It's useless, a signature is a stain in code. And my signature is the perfection of my code.

>what does the snake say?
what does the fox say?

this

Working with a team where someone has a different tab configuration completely fucks up a program, and python can't even say what line it happens on.

In C this is undefined behavior.

this

triggered

Because data types are mutable by default in Python, therefore it's not really useful in any serious (i.e. multithreaded) environments.

That's completely fine because Python is a scripting language -- it's not designed to create robust, scaleable, and performant software. But if I'm writing a script, then I'd rather use Bash. If I want an embedded scripting language, I'd rather use Scheme or Lua.

That basically leaves Python for a very small set of tasks that other languages can be used for just as successfully.

Python users have an identity crisis as they lack any real focus. Python tries to be a good task for everything, so it's great at nothing.

Just in case you actually believe what you wrote, the statement
>Because data types are mutable by default in Python, therefore it's not really useful in any serious (i.e. multithreaded) environments.
does not make sense at all, in any context.

Python does have a lot of problems (and by default can't multithread), but the mutability of data types has nothing to do with it.

Everything is essentially mutable on any practical language (functional languages are not practical).

Not in Clojure.

Mutable data types require the use of application-level data locks that are known to generally lose in performance compared to STM primitives and are more bug prone.

If I can't mutate an object, two threads can safely access it.

I'm getting 14 using g++, but clang fails with a linker error

if True + True then print("eat shit") endif
>eat shit

python

python 2 interprets 4 / 2 as floor division when both of the arguments are integers. if you wanted to treat them as floats, you should have cast them as floats.

if you want python to just magically make sense of this stuff, did you also complain when you said
someVariable="2"
print someVariable/2

and it gave you some error? did you want python to intuit that you meant to treat it as something it clearly wasn't?

...

>the indentation bug
>bug


Why do you tards insist on naming features you don't like "bugs"?

It's a bug when you're actually on a team, and someone's editor has a different indentation scheme and the code fails without any meaningful diagnostic information.

I keep forgetting the majority of posters on Sup Forums don't work on teams.

>without any meaningful diagnostic information
yeah it's so vague.

Anyone who mixes tabs and spaces in a file is a total PEBKAC. If they're hired by a company and can't even figure out indentation, they shouldn't be touching code to begin with.

and if you're talking about tabs

>It's a bug when you're actually on a team, and someone's editor has a different indentation scheme
Pre-commit hooks exist for a reason. Wrongly-indented code shouldn't even be getting checked in to begin with.

this. teams should have clear norms about how to code. i agree that a language shouldn't throw an error over this, but if you all aren't on the same page (or worse, if you're just LETTING everyone use their own preferred approaches), then you need to take a project management course or something.

standardizing code isn't just some OCD thing; it makes it easier (read possible) for arbitrary new members to join the team without feeling like they're walking around in in Eastern Europe in the 90s (like every 5 steps they take lands them in a different regime)

>wrongly indented
implying that the standard dictates whether to use tabs or spaces

Wow, one example of an informative error message. I have seen Python give complete garbage line numbers in the error message on files that are a few hundred lines long.

>increase the indentation standards
Or you could use a brace and save the time taken to setup the indentation and avoid the possibility of any unpleasant mistakes.

I really don't see why the brace is such a big deal. It makes everything explicit.

>implying that the standard dictates whether to use tabs or spaces
your team should have standards. whether you follow pip8 or not is up to you; you'll notice python won't scream at you for using tabs as long as you're consistent. that's because it was designed to meet autistic people halfway. but that means you have to meet it halfway.

i've never seen this, even in long codebases. generally error messages are within the right ballpark of the code. can you give an example, or do you just get to vaguely tell me that your codebase is some sort of fucking disaster and that's definitely python's fault and not yours?

>save time
having a standard format is time-saving. this is basically one line in documentation for on-boarding team members ("we use 4 spaces for indentation"). your on-boarding documentation should be comprehensive, meaning several pages worth of text, to avoid misunderstandings about literally every decision that could be left up to the programmer. even what sort of variable naming convention to use. you don't need to have a debate over this, either, just dictatorially say "we're using camel case for variables, but class methods get underscores and stay lowercase" or whatever. literally just pick something and write it down. then stop discussing the confusion of it all on Sup Forums.

this is basically a drop in the bucket.

>>wrongly indented
>implying that the standard dictates whether to use tabs or spaces
Actually, pep8 DOES say to use spaces instead of tabs, except when working on things that already use tabs.
But even if you don't give a shit about pep8, the correct style is always whichever one is already in the file.

>I really don't see why the brace is such a big deal. It makes everything explicit.
So does indentation.
Braces aren't infallible either. You can forget a closing parenthesis or brace somewhere and not notice. Much harder to do the equivalent in Python.

this. if someone on my team consistently committed code like
for whatever in someCollection {
foo();
bar();
etc();
}

(using not-really-java as an example relying on braces)

we would have a talk with them about indenting shit consistently. they wouldn't just get to do that and have nobody give them shit for it.

if we require everyone to keep indentations aligned, then it shouldn't be an issue that the braces are there or not. i can understand a mild preference to have them there, but this shouldn't be something that you object to the use of python for.

What did you expect? That's like the first thing you learn about programming.