100% of my programming is now in python

100% of my programming is now in python.

The language is fucking beautiful. Surely you guys can agree ?

Other urls found in this thread:

dev.metasploit.com/pipermail/framework/2006-October/001325.html
softwareengineering.stackexchange.com/a/122212
twitter.com/NSFWRedditVideo

Python is OK, but I have a hard time to grasp the Python logic:
Somtimes the methods are called with the object as parameter, sometimes you call an object-method. And it seems totally arbitrary which one it is:

"method([a,b,c])" vs. "[a,b,c].method"

Also why do you have to pass "self"? Would it hurt so much to provide "self" as (implicit) default object?

Last issue I have is this bad way they handle strings, constantly decoding/encoding bytes from/to unicode and you never really know which method to use, so it's mostly trial and error. This is unnecessary.

>"method([a,b,c])" vs. "[a,b,c].method"
This is a fucking good point. ";".join and len("str") is actually really dumb, never noticed.

>Also why do you have to pass "self"? Would it hurt so much to provide "self" as (implicit) default object?
I can see the logic in this. Its so class a can pass its own instance to another class.

>Last issue I have is this bad way they handle strings, constantly decoding/encoding bytes from/to unicode and you never really know which method to use, so it's mostly trial and error. This is unnecessary.

The "pythonic" way is to decode ASAP. You should always be working with unicode strings. 95% of the time you can just do
x = x.decode('utf-8') if type(x) == bytes else x


If you're working with web facing code you're best to do
try:
x = x.decode('utf-8') if type(x) == bytes else x
except:
return

fioc

Yes, python is beautiful.

I have never programmed with python.

I don't understand the shit people give Javascript, I think it is a beautiful language too. If you can point out the main differences, I'd be happy to get to know python a bit better.

I use it for everything except web (Django and flask are cancer compared to node or naked php) and mobile (can't really do it on mobile anyway).

The one problem I have with the language itself is that it's oop features are just garbage. Yes it has everything that a "java" or mature oop language has, but it's just off somehow.

It's not as arbritrary.

Most classes have these behaviours that are actually called when you, say, do a len of a list.

When you do the len(a_list) it's actually calling this value

a_list.__len__ == len(a_list)

It's an extra thing for operators and classmethods and is made to be overriden

Python is great except for "muh white space".

Thank you, I will try to do this "decode if bytes ASAP".

Python is pretty fantastic.
I use it to try some algorithm ideas or if I need to prototype something quickly.

Well, I don't want to turn this into a "dick length contest", but I found the object model of Ruby way more logical. In Ruby you ALWAYS ask the object to do something:
[1, 2, 3].length
[1, 2, 3].sort

..and so on. And yet you can override whatever you want.

So in my humble opinion Python claims to be beginner friendly but has a lot of pitfalls that make it overly complicated. As I said, Python is not a bad language and I like many of it's features. To me it's a close second to Ruby.

>Python is great except for "muh white space".
What exactly is your problem with it?

Nah, it's mediocre at best.

Not diverse enough

kek

How about "muh colorspace"?

>Django and flask are cancer compared to node and naked php

I like Lua because of the way you implement classes using metatables. It's pretty elegant, keeps the language lighter, and no OOP specific keywords.

But C++ needs to stop being shilled so hard. It's not that much harder, but especially for games which so many people wanna use it for, you can get your ideas down more quickly with a scripting language.

>get your ideas down
Confirmed for not being part of the cool kids club.
The cool kids of Sup Forums use Haskell or Assembly to not achieve anything of significance instead.

The IPython repl is pretty nice.

i've used python (2) a bit recently because of libraries.
It's an ok language. bytes/string encoding is annoying. Runtime exceptions on type errors are annoying. Passing self is annoying. Documentation could be better.

I'm not a fan of trying to make one language the language.
For me it's basically use the language in which a library i want to use is written in.
This way you actually learn a bunch of stuff.

I'd love to think that way, but it is hard to be proficient in so many languages and this makes me very uncomfortable.

None of that is arbitrary, you just haven't bothered to learn how any of it works.

something([a, b, c]) is not a method call, it's a function call. Methods operate on class instances, so you need to instantiate the class first. e.g.:
Class().method([a, b, c])
or
instance = Class()
instance.method([a, b, c])

If you understand that all of python's basic types are actually objects, the string and list methods like ''.join([a, b, c]) make sense. It's the same as doing
s = str() # I have instantiated the string class
s.join() # I am invoking the string's join method

len() is a function rather than a method because it operates on multiple types like lists, strings, tuples, etc. (it actually calls an internal method that allows each class to define how len is determined)

When defining methods, you explicitly pass self because there are situations where you might not want to do that. For class methods you pass cls, and you don't pass any context for static methods.

String encoding is simple. In python 3, strings are UTF-8. Sockets and other objects that operate on raw bytes take bytestrings. That's all there is to it, and those are the only times you have to convert.

>python 3

GET OUT

>I hate Python 3 because my favorite library has not been ported and I'm too incompetent to do the conversion myself

>implying i'm going to do a bunch of extra work just to use a slightly different version of the same language

Python 3 is considerably better

I prefer C#.

I for one prefer curly brackets.

most mainstream languages are the same anyway

Yes

Neckbeards will disagree

My only complain so far is the inconsistency across different versions with the Windows API.

while not hdl:
hdl = windll.kernel32.GetStdHandle(handle)
# prevents weird behaviour where Windows does not
# return anything and the loop freezes.
# It does not really wait any ammount of time except for the call
# ??????? Python 3.4 needs it / Pyhon 3.5 does not ???????
time.sleep(0.0001)


I just don't get it.

I've been using Python at work a lot and it's crept it's way to my side projects as well.

I still don't feel like I'm proficient writing Python and there is just something about the language which rubs me in the wrong way which makes me feel like learning something more "real", but I never pick up anything else

It's essentially the same with .length and .__len__ in python3. Just the old code that uses len() is numerous I reckon

Python is awesome OP !

Er, what?

You're giving him way too much credit. I doubt he's even a serious programmer. My guess is that he just like to have an edgy opinion on something, to fool others into thinking he's smart.

len() an is old convention that got preserved. You can access length as an attribute in python3.

Coming from Ruby I find Python3 to obsessions with brackets disturbing

Coming from C, I started tinkering with python because of the extensive modules available.
Onestly tho, I'm having an hard time using it because there's too much 'magic' for my taste.
And even if you try to look what the module you are using does, it will be pretty difficult to understand because of course they in turn use tons of others modules...
I'm just more proficent in C, because I know everything I code.
Also, indentation resulting in errors is bad.

>whitespace with syntactic meaning
it's shit

>Also, indentation resulting in errors is bad.
Just indent correctly.

What? There's no .length attribute in Python 3, and .__len__() has always existed.

I've never understood the whitespace issue. It's not that difficult to indent properly, is it?

>indentation resulting in errors is bad

I'm not a huge fan of this, but I never found this bad either..

I mean everybody uses indention, right?
It's just a convention to make it more readable by avoiding braces, see the pic.

No big deal.


Likewise. Ruby is such an distustingly cute language, it's hard to not rant about the small differences in Python, i.e. the braces or whitespace indention. But if you keep them seperated in your head, you can be a good Pythonista and a good Rubyist at the same time. I like Python for it's amazing libraries (i.e. numeric computation, GUIs) and Ruby for anything web related.

hating forced whitespace is a meme.

especially when you consider the autistic lengths these guys go to for "MUH CONSISTENCY" in other languages.

i respectfully disagree good sir

>hating forced whitespace is a meme.

"The Python programming language was also a language candidate. The reason the Metasploit staff opted for Ruby instead of python was for a few different reasons. The primary reason is a general distaste for some of the syntactical annoyances forced by python, such as block-indention. While many would argue the benefits of such an approach, some members of the Metasploit staff find it to be an unnecessary restriction. Other issues with Python center around limitations in parent class method calling and backward compatibility of interpreters."
>dev.metasploit.com/pipermail/framework/2006-October/001325.html

Python's forced indentation overloads the concept of whitespace with two non-wholly-overlapping definitions, leaving it up to the programmer to infer which meaning applies in a given context based on visual cues.

Yes, it's easy to use. No, it's not hard to indent. My objection is to the philosophy of the decision, not the practicality.

seriously, why python 3?

I prefer Ruby as a Java dev who hates Java. Python feels like something in between those two. A bit more annoying than Ruby and a bit less of a chore than Java.

because it's better in every way

PEP 3102

To be fair, wether you programm Python, Ruby, Bash or Lua you will always follow certain style conventions. (Let's not talk about Perl here..)

You could also argue that it enforces a proper formatting, which is not necessarily a bad thing.

I generally think that Pythons strengths is that they try to make code is more "idiomatic" (which not 100% true, but they try). So when you look at legacy code you can see what's going on pretty fast, unlike languages where you have more "freedoms". Show me 3 C++ programmers and I'll show you 4 differnt programming/formating styles.

Article is literally meme argument incarnate.

I want to like lua but it looks hideous.

I agree but i'm the only one at work who uses it..

I'm getting forced to use c# and powershell, because python is not default on windows platforms.

One could argue that, but I wanted to avoid that issue. I don't personally think that a language's spec should be in the business of enforcing formatting aesthetics, but I recognize that's a personal objection.

I don't personally think any benefits gained from enforcing formatting guidelines outweigh the negatives, but if I made that argument in the first place then we'd get in a big huff about whether it really does have a positive effect, and I thought that would be a less interesting discussion.

no multi-statement anonymous functions
into the trash it goes

Python is the most disgusting language that's actually being used and considered a serious languge (so PHP etc. don't count)

and I don't mean syntax, that's irrelevant. I mean semantics. like holy fuck name errors and type errors at runtime? who the fuck thought this was a good idea? Never mind the fact that they can't even get together a decent REPL

How people can willingly condemn themselves to cripplingly inefficient test-crash-fix loops on an error-by-error basis is beyond me

>holy fuck name errors and type errors at runtime? who the fuck thought this was a good idea?
That's the nature of an interpreted language with duck typing?

I don't think lack of a decent REPL should really count as a fault of the language.

>powershell
I feel for you. Such a powerful tool wrapped around the worst shit you could even think of.

>an interpreted language with duck typing

The question remains: who the fuck thought this was a good idea?

>How people can willingly condemn themselves to cripplingly inefficient test-crash-fix loops on an error-by-error basis is beyond me

My guess is that they don't know any better.

>Never mind the fact that they can't even get together a decent REPL
What is IPython?

softwareengineering.stackexchange.com/a/122212

Also, Python 3.5 introduces type hinting.

having to install something from a third party to get a decent repl doesnt put python in a good light

Because Python was born in the age of the internet and collaboration. Third party is an obsolete term when used with Python.

You accidentally said programming when you meant scripting.

I switched from C# .NET to Python best decision in my coding life

I like python for stuff that isn't performance critical. I've tried convincing my co-workers to use python. I immediately get shot down because it's open source and doesn't have an ISO standard. They insist on writing hundreds of lines of c++/Java instead.

The topic has been discussed to death. Most of the arguments that try to defent dynamic/weak typing boil down to
>it's more hackable! (easier to build something that barely works)
>you don't need to learn how to use the type system
>you can do that too... sorta (eg. classes)
>you should write tests anyway
It's clear, even from that answer alone, that static/strong typing is backed by the most solid and factual reasons.

And it's a pity that just when the C language started to be seen as a dangerous, unsafe language to avoid, the industry was flooded with webdevs and their shitty scripting languages that break whenever you're looking the other way, not to mention the fact that they are unavoidably slow as molasses even when they work. Thankfully C# and Java are still alive and Rust was born recently as a light at the end of this tunnel.

>Also why do you have to pass "self"?
class instances bind themselves to the instance methods, that's why.

>";".join
try:
str.join(';', [a, b, c])


instance = Class()
Class.method(instance, [a, b, c])

also works

JavaScript has problems because of its weak standard library which makes it extremely framework dependent and flavor of the month.

Python is beautiful but Rust is more beautiful

Ruby is more consistent, more expressive, and easier to use.

JavaScript is a botched language right down to its badly designed syntax. All those frameworks are attempts to mask the underlying mess which would be impossible to work with directly. The fact that most of them are webdev babbys' first code and that they're mostly used to bloat up websites contributes to the JS hate.

>s = str() # I have instantiated the string class
>s.join() # I am invoking the string's join method

And that's exactly the point..

You say to an STRING instance:
"dear string, copy yourself behind each list entry of the following list".. Basically the logic is that a string can somehow multiply and merges itself with a list. Uhm..

While in Ruby ("list.join") you say:
"dear list object, produce a string with the following delimiter."

Way better.

>len() is a function rather than a method because it operates on multiple types like lists, strings, tuples

And again you create another "dimension", you have to remeber wether an method is a function or part of the string class. And you create a overloaded function that takes an list/tuple/string and try to "count" it (which means differnt things for differnt objects). This is just bad design from the dark procedural ages..

Why not giving list/tuple/string the "length" method, since the object knows best what "length" means for itself?

Those are the sublte reasons why Ruby is way more well-designed than Python.


ECMA6 is pretty good, desu sempai.

Python doesn't like me much. If it try to do a mixture of tabs and spaces it just keeps throwing endless indentation errors and refuses to run.

> using tabs at all

is it possible to make a full featured game in python.

Yes, depeing on what you want to do.

Join as a string method is convenient because it allows any iterable to be joined.
len() calls obj.__len__() so again, it's for convenience

>Join as a string method is convenient because it allows any iterable to be joined.

I still prefer "join" as method of any iterable..


>len() calls obj.__len__() so again, it's for convenience

But if you call a function at the object anyway, why not just making it more readable??

But why not using "[1,2,3].len()" in the first place? It's not convenient if the result is not logical because it's actually just a short cut.

My only explanation is that "[1,2,3].__len__()" means "this is an method with two underscores, so stay away from it!", but this is quite a stretch. You introduce a (wierd) shortcut for an simple function, so people COULD add their own ".len()" function while the "__len__()" function would still be available..

I don't really think the end justifies the means here.

would like to agree but havent started the journey yet.
can you recommend any resources for beginners/retards?

>Because Python was born in the age of the internet and collaboration
what the fuck is that even supposed to mean?

disgusting. switch to go to find a beautiful language with 100% consistent grammar and style.

You can install arch on an usb key.

There is a e-book my friend recommended to me called
>Learning Python the hard way

Also get a python bible while you are at it.

I enjoy python, i just made rss downloader. I love using dictionary mapping as a switch work around.

Python is Ok honestly, but I've been dealing with some issues the past year that's worth mentioning:

Dependency management is a major headache. For instance, at work (government agency) I have a Linux PC that's pretty much secured down to the pip commands so I can't just install dependencies. I have to get the system admin to run pip for me which is extremely annoying when you are developing and want to test out libraries. I've thought of resorting to using virtualenv or a standalone Python distribution like PyPy, but good luck writing a procedure so that normies can get a standalone Python distribution installed on their machine.

Low-level programming is extremely frustrating. I have a header file in c++ with struct definitions and a helper Python script that generates packer/unpacker methods for it in c++. The generated files then are wrapped using SWIG and then imported in my main script. This works fine except when I'm reading bytes from a socket and trying to unpack them using the imported c++ library in real time. Good luck passing a ByteArray (or memoryview) object to C++ using SWIG. Also forget about doing bit manipulations on a ByteArray because you have to keep casting shit from char to int to string to BitArray back to int and then again to char. You end up writing 5 lines of Python while it would've been 1 line in C++.

Overall, Python is very good at doing high level stuff, but as soon as you start diving into low level shit it becomes a huge time sink..

" ".join(list)

string.split(" ")


U wot m8

it's extremely slow and doesn't deal with memory

Wait until you have to use it in a industry project. You'll change your mind then.

Dynamic typing combined with Strong typing is a mistake

python + string is fucked up.

OP is retarded and probably doesn't do anything really worthwhile

>python + string is fucked up.
In what way?

it's to allow any iterable to be joined. if it was a method on lists, then they would need to implement it on sets, tuples, etc... and anyone making their own iterable not inheriting from existing iterables would have to implement their own join method.

this is pretty clearly and concisely explained if you just look up "python why is join a string method" on google.

he's probably referencing the fact that python 2 dealt with strings in a stupid way, hence the (breaking) change in python 3. what's crazy is that people blame python 3 for the breaking change rather than python 2 for being broken in the first place.

but lazy developers in any language will bitch and moan about change, even if it's clearly for the better.

Python is a shit language for retards.

In what way?

why even engage with people like him, dude? the next 20 minutes trying to engage with him to give you concrete reasons that "python is for retards" is going to be like pulling teeth.