Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results https://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

Don't shadow built-ins

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

Don't shadow built-ins

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: https://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

Don't shadow built-ins

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]
formatting
Source Link
Caridorc
  • 28k
  • 7
  • 54
  • 137

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

**Don't shadow built-ins`Don't shadow built-ins

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

**Don't shadow built-ins`

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

Don't shadow built-ins

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]
Source Link
Caridorc
  • 28k
  • 7
  • 54
  • 137

Use .format

Using % is considered old style, so:

print(" %5i | %6.3f | %s | %i".format(
 (num, time.time() - start, "ox"[ist == mod.SOLL], ist)))

Be generous with long variables names

For example ist is impossible to understand for me, solution is more natural

Don't abuse Code-Golf techniques

The line:

"ox"[ist == mod.SOLL]

is a well known Code-Golf trick that relies on implicit boolean to integer conversion that is equivalent to:

"x" if ist == mod.SOLL else "o"

please use the latter.

Use argparse

C-Style arguments such as sys.argv[1] should be avoided, I suggest argparse (help to get started here: http://stackoverflow.com/questions/7427101/dead-simple-argparse-example-wanted-1-argument-3-results)

**Don't shadow built-ins`

def run(file = "input/18.dat"):
 # Parse File
 with open(file) as fid:

file is a built-in, you should use file_ in your code.

Explode long lines

Divide the following lines in two please.

 tri = [[int(num) for num in line.split(' ')] for line in fid.read().split('\n')]
lang-py

AltStyle によって変換されたページ (->オリジナル) /