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.
 
  • Post
  • Reply
Soricidus
Oct 21, 2010
freedom-hating statist shill

Progressive JPEG posted:

does python still have that thing where input written by a foreigner suddenly triggers a requirement to blindly add .decode("utf8") to everything until the errors go away?

it's so type safe that some strings are differently typed from other strings

the whole point of python 3 was to fix this. the main controversy over python 3 was that it forced everyone to fix it, even people who had not yet encountered any input written by foreigners and did not believe they ever would.

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




Progressive JPEG posted:

does python still have that thing where input written by a foreigner suddenly triggers a requirement to blindly add .decode("utf8") to everything until the errors go away?

it's so type safe that some strings are differently typed from other strings

that’s a python 2 relic

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Nomnom Cookie posted:

you can also multiply lists by numbers

I’ve done this in production code

it made me feel dirty

lol yeah the first time i saw [0]*40 for initializing a 40 element list with 0 in each position i was like wtf

Soricidus
Oct 21, 2010
freedom-hating statist shill

Krankenstyle posted:

lol yeah the first time i saw [0]*40 for initializing a 40 element list with 0 in each position i was like wtf

it’s always fun the first time someone learns about this and then immediately does [[]]*10 to initialise a list of lists

Xarn
Jun 26, 2015
Yeah, that syntax does not work well with mutable types...

Xarn
Jun 26, 2015

Share Bear posted:

OK so what is the preferred way to transform another class or dict or other list into a new list? I thought this was pretty snappy.

I also think there are levels of syntactic sugar that are appreciable, like this as opposed to f-strings

I generally also don’t see the fault in writing comments assuming that someone might look at your code and not understand it on its face. I am usually this person, dealing with other people’s code, and would love more comments about someones wild Java streams chain or Scala nonsense or python garbage

Maybe I should stick to the terrible programmer thread

List comprehensions are good. Comments like these are not:

Python code:
# This is a list comprehension
[ butt.poop() for butt in butts ]
because they very much fall into the pattern of beginners who are told "you should write comments" and they write down what (which is what you already know from the code), but not the why...

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



wait f-strings own bones (when you stick to vars and don't get weird with arbitrary code)

Soricidus
Oct 21, 2010
freedom-hating statist shill

Krankenstyle posted:

wait f-strings own bones (when you stick to vars and don't get weird with arbitrary code)

handing guns to programmers and telling them not to point them at their feet has not, historically, tended to end well

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Soricidus posted:

handing guns to programmers and telling them not to point them at their feet has not, historically, tended to end well

fair

Cybernetic Vermin
Apr 18, 2005

Soricidus posted:

handing guns to programmers and telling them not to point them at their feet has not, historically, tended to end well

pretending that things that are troublesome don't need to be done has tended to yield a mix of terrible code and irrelevance though (will see whether go doesn't manage both within a decade). removing string formatting facilities entirely would of course prevent abuse, but every program doing string formatting would then be a horrific bug-ridden mess.

not sure that f-strings is the best idea ever, but unless we're going to constrain ourselves out of Turing-completeness the programmers have plenty of guns already.

feedmegin
Jul 30, 2008

Progressive JPEG posted:

python in production? oof

Mate one of the products I worked on shipped its own copy of the Python interpreter as part of its runtime, even

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


Progressive JPEG posted:

python in production? oof

its more common than you think

I would guess it's because it's an easy sell to management: "see? quick and easy to make programs"

Cybernetic Vermin
Apr 18, 2005

feedmegin posted:

Mate one of the products I worked on shipped its own copy of the Python interpreter as part of its runtime, even

well, obviously. you'd be stupid to set yourself up for someone just running the thing on whatever, at least if they have your contact details.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

Boiled Water posted:

its more common than you think

I would guess it's because it's an easy sell to management: "see? quick and easy to make programs"

"So, here is our first-pass, narrow vertical slice, skunkworks proof-of-concept prototy-"
"Ship it! Ship it real good!"

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


ynohtna posted:

"So, here is our first-pass, narrow vertical slice, skunkworks proof-of-concept prototy-"
"Ship it! Ship it real good!"

I see we work in the same place.

"Proof of concept proofs concept? SHIP! IT!"

cinci zoo sniper
Mar 15, 2013




Boiled Water posted:

I see we work in the same place.

"Proof of concept proofs concept? SHIP! IT!"

“ah you made an r shiny app with some graphs?”
“yeah it’s a rough mock of some of our key analytics for quant dev team to have easier time until bi team is fully formed”
“great, c-suite will love to use it”

Qtotonibudinibudet
Nov 7, 2011



Omich poluyobok, skazhi ty narkoman? ya prosto tozhe gde to tam zhivu, mogli by vmeste uyobyvat' narkotiki
implement feature for exactly one customer, with no thought as to how usage may differ for other customers

immediately release the feature to all customers with no documentation beyond a list of config settings with minimal explanations

cinci zoo sniper
Mar 15, 2013




florida lan posted:

implement feature for exactly one customer, with no thought as to how usage may differ for other customers

immediately release the feature to all customers with no documentation beyond a list of config settings with minimal explanations

yeah i had to maintain that pile of poo poo for 7 months. “architecturally” it was a daily cron’d bash script that would execute a python script which executes pile of SQL scripts, running against a dozen undocumented databases with bi-weekly uncommunicated structure changes, into csv files. then it stops shiny app, moves old csvs into archive, new csvs into data dir, and restarts shiny

Sapozhnik
Jan 2, 2005

Nap Ghost

Soricidus posted:

handing guns to programmers and telling them not to point them at their feet has not, historically, tended to end well

agreed, which is why we should all program in go

Plank Walker
Aug 11, 2005

florida lan posted:

implement feature for exactly one customer, with no thought as to how usage may differ for other customers

immediately release the feature to all customers with no documentation beyond a list of config settings with minimal explanations

that's agile!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Sapozhnik posted:

agreed, which is why we should all program in go

making people use go is like preventative foot amputation on the basis that you can’t shoot what you don’t have

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


Progressive JPEG posted:

does python still have that thing where input written by a foreigner suddenly triggers a requirement to blindly add .decode("utf8") to everything until the errors go away?

it's so type safe that some strings are differently typed from other strings

cinci zoo sniper posted:

that’s a python 2 relic

also a relic found in loads of lovely software that for some arcane reason needs to be both python 2.7 and python 3 compatible.

Like say most of the AWS library

Vomik
Jul 29, 2003

This post is dedicated to the brave Mujahideen fighters of Afghanistan
type safety guarantees once it’s compiled everyone will be forced to use my improperly optimized, logically incorrect code forever

Nomnom Cookie
Aug 30, 2009



Soricidus posted:

the whole point of python 3 was to fix this. the main controversy over python 3 was that it forced everyone to fix it, even people who had not yet encountered any input written by foreigners and did not believe they ever would.

i know of at least one person who got super butthurt about python 3 using str for filenames. passing arbitrary garbage to open() was apparently mission-critical. as linux allows anything but \0 in a filename and they were making full use of that capability. i went and checked--for my entire career i've been passing string filenames to the JVM, I have no idea what encoding the JVM uses when making the system call, and it's been an issue exactly 0 times

give a programmer tools to build things with and instead they'll dig a giant pit full of garbage. try to fill in the pit, maybe turn it into a nice park or something, and they'll bitch at you for breaking their poo poo

mystes
May 31, 2006

Progressive JPEG posted:

does python still have that thing where input written by a foreigner suddenly triggers a requirement to blindly add .decode("utf8") to everything until the errors go away?

it's so type safe that some strings are differently typed from other strings
The problem with python 2 was that like most legacy languages it wasn't type safe because bytes and "characters" were the same type.

VikingofRock
Aug 24, 2008




Nomnom Cookie posted:

i know of at least one person who got super butthurt about python 3 using str for filenames. passing arbitrary garbage to open() was apparently mission-critical. as linux allows anything but \0 in a filename and they were making full use of that capability. i went and checked--for my entire career i've been passing string filenames to the JVM, I have no idea what encoding the JVM uses when making the system call, and it's been an issue exactly 0 times

give a programmer tools to build things with and instead they'll dig a giant pit full of garbage. try to fill in the pit, maybe turn it into a nice park or something, and they'll bitch at you for breaking their poo poo

Nowadays open() takes anything implementing os.PathLike so this person is in luck!

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Nomnom Cookie posted:

i went and checked--for my entire career i've been passing string filenames to the JVM, I have no idea what encoding the JVM uses when making the system call, and it's been an issue exactly 0 times

It's because it's an abstraction, and depending on the JVM implementation and platform, it's different

on linux it defers to java.io.UnixFileSystem, i'm sure there's one for windows as well

EDIT: here's the windows NT impl https://github.com/stain/jdk8u/blob/master/src/windows/classes/java/io/WinNTFileSystem.java

CRIP EATIN BREAD fucked around with this message at 19:14 on Jul 12, 2019

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The sensible thing for Unix is to use a UTF-8 string that preserves invalid code point sequences and just presents them as that replacement character if you interrogate it as a string. But that doesn’t really work on Windows because IIRC native paths use 16-bit code points, and it also doesn’t really work in languages that expose the use of UTF-16.

rjmccall fucked around with this message at 19:19 on Jul 12, 2019

Nomnom Cookie
Aug 30, 2009



CRIP EATIN BREAD posted:

It's because it's an abstraction, and depending on the JVM implementation and platform, it's different

on linux it defers to java.io.UnixFileSystem, i'm sure there's one for windows as well

EDIT: here's the windows NT impl https://github.com/stain/jdk8u/blob/master/src/windows/classes/java/io/WinNTFileSystem.java

sure it's platform-specific. what i meant is that it has never once mattered how the UTF-16 turns into bytes for the kernel, nor have I have needed to answer the question "what if I want to open a file with a name that has no unicode representation". I don't think the stdlib supports that, or ever has. it's never been anyone's criticism of java that it doesn't support opening garbage filenames. and yet for some people that's a big issue with python 3.

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Nomnom Cookie posted:

sure it's platform-specific. what i meant is that it has never once mattered how the UTF-16 turns into bytes for the kernel, nor have I have needed to answer the question "what if I want to open a file with a name that has no unicode representation". I don't think the stdlib supports that, or ever has. it's never been anyone's criticism of java that it doesn't support opening garbage filenames. and yet for some people that's a big issue with python 3.

well python is for idiots

Bloody
Mar 3, 2013

list comprehensions are bad because they read in a completely random order. linq is much better than this because linq reads very clearly from left to right.

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

rjmccall posted:

The sensible thing for Unix is to use a UTF-8 string that preserves invalid code point sequences and just presents them as that replacement character if you interrogate it as a string. But that doesn’t really work on Windows because IIRC native paths use 16-bit code points, and it also doesn’t really work in languages that expose the use of UTF-16.

are you counting macos as a unix? if so, what about unicode decomposition?

feedmegin
Jul 30, 2008

Nomnom Cookie posted:

sure it's platform-specific. what i meant is that it has never once mattered how the UTF-16 turns into bytes for the kernel, nor have I have needed to answer the question "what if I want to open a file with a name that has no unicode representation". I don't think the stdlib supports that, or ever has. it's never been anyone's criticism of java that it doesn't support opening garbage filenames. and yet for some people that's a big issue with python 3.

What if you're opening files on, for example, a commercial Unix with a legacy encoding like EUCJP for Japanese? 'If it's not Unicode it's garbage' is not a practical approach in the real world.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

feedmegin posted:

What if you're opening files on, for example, a commercial Unix with a legacy encoding like EUCJP for Japanese? 'If it's not Unicode it's garbage' is not a practical approach in the real world.

Sure, but outputting to a well-known encoding scheme isn't that big a deal, and in the java example would be easily handled by just setting the default character encoding for the environment to EUCJP (if it wasn't already).

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Fiedler posted:

are you counting macos as a unix? if so, what about unicode decomposition?

the filesystem is almost certainly going to use different unicode normalization than user-level libraries want to. among other things, the filesystem has forward/backward compatibility restrictions that might put it in an impossible position: it probably doesn’t want to ban characters that weren’t in unicode when it was compiled, but new characters can come with arbitrary new normalization rules. and in fact, different filesystems are not unlikely to use different unicode normalizations from each other. so you can have things like strings that compare equal in the language but name different files on one filesystem but not another. the most sensible way for intermediate levels to handle this — whether the programming language or the kernel — is to propagate string data through unmolested as much as possible, and then at least basic functionality (opening files, reading directories) will generally work, which means it’s at least possible to work around these problems in user code. the only issue is if you’re doing things like renormalizing filenames or sticking them in hashtables

Vomik
Jul 29, 2003

This post is dedicated to the brave Mujahideen fighters of Afghanistan
*chris Farley voice* you can take a poo poo in a rust box and all you’ve got is a type safe piece of poo poo

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
fabrice bellard's new dependency-free embeddable js interpreter kinda owns

wonder how long it'll be before somebody uses it to build a javascript bootloader and begin the js apocalypse, as the legends foretold

luchadornado
Oct 7, 2004

A boombox is not a toy!

i normally work almost exclusively in kotlin, but have stood up half a dozen or so bottle+gunicorn APIs that front some keras/tensorflow poo poo. that kind of python in production is extremely non-problematic, but i can imagine some monolithic django app could be a huge pain to deal with

edit: i also have co-workers who have to be forced to use "that newfangled" python 3. the thing that's been available for 11+ years. so gently caress python.

luchadornado fucked around with this message at 01:44 on Jul 13, 2019

redleader
Aug 18, 2005

Engage according to operational parameters

Internet Janitor posted:

fabrice bellard's new dependency-free embeddable js interpreter kinda owns

wonder how long it'll be before somebody uses it to build a javascript bootloader and begin the js apocalypse, as the legends foretold

in 20 years there will only be js

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Honestly, having read both codebases, I like Duktape better

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply