파이써니스타 vs. 고퍼스 (Pythonistas vs. Gophers)

 

파이써니스타 vs. 고퍼스

Pythonistas vs. Gophers


파이썬 개발자 관점에서 살펴보는 Go 언어. 무엇이 비슷하고 무엇이 다른가?

원문: https://www.coderedcorp.com/blog/golang-for-python-devs/


Python

Golang

open source


Python Software Foundation (PSF)


Conventions

  • Functions and variables are snake case snake_case.

  • Classes are Pascal case PascalCase.

  • Globals or “constants” are often all caps CONSTANT.

  • Private members begin with an underscore _private.

open source


Google


Conventions

  • Anything that begins with a lowercase letter is private.

  • Anything that begins with a capital letter is public.

  • Depending on public or private, everything follows camelCase (private) or PascalCase (public).


Naming Conventions

Python

Golang

# A public "constant" that should not be changed.

MY_CONSTANT = "Apple"


# Public function.

def do_thing():

    return "Banana"


# "Private" function.

def _do_thing():

    return "Cherry"


# A public class.

class MyClass:

    pass

// A public constant that cannot be changed.

const MyConstant = "Apple"


// Public function.

func DoThing() string {

    return "Banana"

}


// Private function.

func doThing() string {

    return "Cherry"

}


// A public struct.

type MyStruct struct {}


Comments & Docstrings

Python

Golang

/* comments */


Variables

Python

Golang



String Formatting

Python

Golang

For Loops

Python

Golang

Lists

Python

Golang

Dictionaries

Python

Golang



Classes

Python

Golang


댓글

이 블로그의 인기 게시물

install tensorflow gpu version on macbook pro

Neural Machine Translation