Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
cinci zoo sniper
Mar 15, 2013




code:

n <- function(x) x / 2
o <- function() {
  n <- 10
  n(n)
}
o()
this evaluates to 5

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




is my post dead

e: twas

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
different namespaces for functions vs. other objects?

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

cinci zoo sniper posted:

what's the deal with multiple jvms (jdk implementations)

platform support, different implementations of parts, supportability

cinci zoo sniper
Mar 15, 2013




Jabor posted:

different namespaces for functions vs. other objects?

yes, but it seems to be context specific to function calls?

cinci zoo sniper fucked around with this message at 13:37 on Jul 17, 2017

cinci zoo sniper
Mar 15, 2013




carry on then posted:

platform support, different implementations of parts, supportability

oic. was reading some large discussion about using the right jdk for stuff to avoid angry oracle lawyers, which left me wondering a bit. looks tho like openjdk is the default one, supplied by oracle no less, and it's free of jrockit and whatever. other notable jvms seem to do just what you say - add fonts, dynamic heaps, different garbage collectors, aot, etc

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum
the azul jvm is pauseless and that is pretty neat

cinci zoo sniper
Mar 15, 2013




Sweeper posted:

the azul jvm is pauseless and that is pretty neat

that sounds like the azul dynamic heap one. they seem to have two, of which the other one is normal openjdk with freetype fonts and one other thing i forgot about

cinci zoo sniper
Mar 15, 2013




code:

h <- function(a = 1, b = d) {
  d <- (a + 1) ^ 2
  c(a, b)
}
:staredog:

Workaday Wizard
Oct 23, 2009

by Pragmatica

Sweeper posted:

the azul jvm is pauseless and that is pretty neat

i want their patent to expire so bad

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

Shinku ABOOKEN posted:

what's the thread opinion on "if(!test())" vs. "if(test() == false)"? i started liking the latter recently and i want to confirm if my opinion is correct(tm)

code:
if not test:
     do_butts()
most python IDEs will yell at your oafish style if you explicitly compare a condition to True or False.

cinci zoo sniper
Mar 15, 2013




i don't think pycharm has said a word to me about "if statement is False", and it's the only python ide that matters :colbert:

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news
PEP8 mothafuckaaaaa

http://legacy.python.org/dev/peps/pep-0008/#programming-recommendations

quote:

Don't compare boolean values to True or False using ==.
code:
Yes:   if greeting:
No:    if greeting == True:
Worse: if greeting is True:

cinci zoo sniper
Mar 15, 2013





odd, might be blind then. will check the code back home

Shaggar
Apr 26, 2006

cinci zoo sniper posted:

what's the deal with multiple jvms (jdk implementations)

java was originally going to have a large community around it where the language was common and then jvms were platform specific. then they kicked the largest jvm provider (Microsoft) out of java and that pretty much ended java on the desktop. it still thrived on the server tho so there are lots of JVMs that are designed to meet specific needs of other platforms, usually created by the platform owner. ex: IBM has their own jvm for their hardware.

there are still a number of non-sun/oracle jvms out there but they are almost universally server vms and you will never hear of them unless you have a specific need for them. the default java vm (hotspot) is extremely good tho

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news
flake8 + pylint are (mostly) good


(sometimes u get stupid arbitrary poo poo e.g. 80 column line limit and you have to do # noqa pylint-disable=max_line_lenth or some poo poo and its horrible)

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

cinci zoo sniper posted:

i don't think pycharm has said a word to me about "if statement is False", and it's the only python ide that matters :colbert:

I fired it up and pycharm only gives you an inspection warning if you use == to do the comparison.

Workaday Wizard
Oct 23, 2009

by Pragmatica
truthiness is bad

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?
embrace the falsity

Mao Zedong Thot
Oct 16, 2008


Mr SuperAwesome posted:

if ur unit tests fail simply delete the unit tests

im a 10x programmer

Unironically better than letting them fester forever

Course if you just broke it, go fix it. But if it's 'oh yeah that one has always been flaky/broken' :sever:

cinci zoo sniper
Mar 15, 2013




ultravoices posted:

I fired it up and pycharm only gives you an inspection warning if you use == to do the comparison.

booted up mine just now and ditto. pycharm community 2017.1.5, python 2.7.13

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news
python 2.7 :cmon:

akadajet
Sep 14, 2003

Mr SuperAwesome posted:

if ur unit tests fail simply delete the unit tests

im a 10x programmer

unit tests are a waste of time all of the time

cinci zoo sniper
Mar 15, 2013




i know, migration on 3 is planned now that 3 is worth something. wasnt the case when i started the project, and too buggy for a rational transition atm

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news
code:
(venv) yosposter@yosposter-macmini-ubuntu:~$ cat pylint_test.py
butts = False


def dumps():
    return False


if butts:
    print('fart')

if butts == False:
    print('poop')


if dumps() == False:
    print('running out of words for poo poo ehre')
(venv) yosposter@yosposter-macmini-ubuntu:~$ flake8 pylint_test.py
pylint_test.py:11:10: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
pylint_test.py:15:12: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
(venv) yosposter@yosposter-macmini-ubuntu:~$ pylint pylint_test.py
No config file found, using default configuration
************* Module pylint_test
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Invalid constant name "butts" (invalid-name)
C:  4, 0: Missing function docstring (missing-docstring)
C: 11, 3: Comparison to False should be 'not expr' or 'expr is False' (singleton-comparison)
C: 15, 3: Comparison to False should be 'not expr' or 'expr is False' (singleton-comparison)

------------------------------------------------------------------
Your code has been rated at 4.44/10 (previous run: 4.44/10, +0.00)

(venv) yosposter@yosposter-macmini-ubuntu:~$
weirdly although PEP8 explicitly says "if blah is False" is worse than ==, and the linters show warnings for ==, they don't show warnings for the "if boolean is False" case. wtf guido

tl;dr use pylint + flake8

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news

akadajet posted:

unit tests are a waste of time all of the time

thanks and god bless

cinci zoo sniper posted:

i know, migration on 3 is planned now that 3 is worth something. wasnt the case when i started the project, and too buggy for a rational transition atm

fwiw at $job we went from 2.7 to 3.x pretty easily and 3.x to 3.6 pretty easily

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


i went on holiday for 3 weeks and i have come back and catapulted straight back into the garbage pile

quote:


public class ButtExport
{
public ButtExport()
{
//literally a comment saying "todo:add constructor"
}
public ButtExport(DataRow row)
{
this.ButtId = row[0]
this. ....
//continues for like 15 properties
}

public ButtExport(DataRow row, bool ActuallyIAmAFart)
{
this.fartId = row[0]
//a load more poo poo referring to a different property set because we're now instancing a fart!

}

public ButtExport(DataRow row, bool ActuallyIAmAFart, bool ActuallyNoIAmInfactAPoop)
{
this.poopId= row[0]
//a load more poo poo referring to ANOTHER different property set because this is now a poop!

}

//massive loving list of private properties that apply to either a Butt, fart or poop

//massive list of public accessors for them that do nothing of value

}

so objects are all just a ButtExport but you don't know what that ButtExport might be, is it a butt a fart or a poop? Who knows! Are any of the variables named in a way that would describe it? No! everything is just an anonymous dataset or datarow with no comments! gently caress!

edit: 6 chained else ifs that handle conditions that pass datarows with zero comments on what they are testing for and whenever any of the conditions are met the same loving method is called so all 6 cases do the same thing and there is no fall through case so if one of those is not hit nothing happens

Powerful Two-Hander fucked around with this message at 17:08 on Jul 17, 2017

cinci zoo sniper
Mar 15, 2013




Mr SuperAwesome posted:

fwiw at $job we went from 2.7 to 3.x pretty easily and 3.x to 3.6 pretty easily
i doubt ill have many troubles. most of my stuff is python core and scipy stack, and all have full support of 3.x by now. there're two smaller libraries used on rare occasions that should be supporting 3.x, and some integer divisions running in the wild

cinci zoo sniper
Mar 15, 2013




mr superawesome, do you use bare flake8, or some plugins for it too?

VikingofRock
Aug 24, 2008




Mr SuperAwesome posted:

code:
Yes:   if greeting:
No:    if greeting == True:
Worse: if greeting is True:

The ordering here seems strange to me. All three of lines do slightly different things. The first is the most pythonic, and the last is useful if you want to see if something is strictly boolean False (and not some other false-y value). It seems extremely rare to me that you'd want the middle one though, e.g. to have greeting = 0 pass but have greeting = [] fail.

cinci zoo sniper
Mar 15, 2013




python 3 here we go lol. looks like my codebase only needed 10 changes, 3 print statements with () and 7 xrange() instead of range(). time to reboot to linux and check if nothing broke on the non-core library side of things

Mao Zedong Thot
Oct 16, 2008


omg (bounded) unemployment rules

Might work through that interpreter book this week or go hiking or something skies the limit

Mao Zedong Thot
Oct 16, 2008


VikingofRock posted:

The ordering here seems strange to me. All three of lines do slightly different things. The first is the most pythonic, and the last is useful if you want to see if something is strictly boolean False (and not some other false-y value). It seems extremely rare to me that you'd want the middle one though, e.g. to have greeting = 0 pass but have greeting = [] fail.

Yeah agree. I always used `is True/False` in Python since it's the least magic.

hifi
Jul 25, 2012

cinci zoo sniper posted:

just saw a repo issue "fix failing tests" :staredog:

i write that but usually i mean the other way around

Mao Zedong Thot
Oct 16, 2008


If youre intentionally truthing lists and maps and strings and poo poo you have probably hosed up, much earlier along.

hifi
Jul 25, 2012

cinci zoo sniper posted:

code:
n <- function(x) x / 2
o <- function() {
  n <- 10
  n(n)
}
o()
this evaluates to 5

this makes sense, you can resolve n the variable and n the function. of course why would you do that, but whatever

MononcQc
May 29, 2007

hifi posted:

this makes sense, you can resolve n the variable and n the function. of course why would you do that, but whatever

that's the crux of the lisp-1 vs lisp-2 debate

Shaggar
Apr 26, 2006

cinci zoo sniper posted:

code:
n <- function(x) x / 2
o <- function() {
  n <- 10
  n(n)
}
o()
this evaluates to 5



that's terrible

cinci zoo sniper
Mar 15, 2013




Shaggar posted:

that's terrible

wait until you see a "prank"

code:
`(` <- function(e1) {
  if (is.numeric(e1) && runif(1) < 0.1) {
    e1 + 1
  } else {
    e1
  }
}
replicate(50, (1 + 2))
code:
##  [1] 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 4 3 3 3 3 3 3 3 3 3
## [36] 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




python 3 transition done. tested all major parts of the module, and the one problem that 2to3 didn't account for was integer divisions used as intended, had to convert them all manually. otherwise everything works fine, maybe a bit faster, and i can do something fancier now with the code, which is nice.

  • Locked thread