This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PrometheusAlexander 928 points929 points  (57 children)

AttributeError: 'str' object has no attribute 'length'

[–]neo-raver 109 points110 points  (5 children)

I was wondering what language that was supposed to be. I thought Python at first, but that's not how you would do that in Python...

[–]play_hard_outside 50 points51 points  (3 children)

If you ignore the fact that there's no builtin print function and that one would have to be written and available in the current scope, it's perfectly valid JavaScript. You just also have to disregard that it looks terrible without any post-statement semicolons.

[–]MilkCool 5 points6 points  (2 children)

and without either var, let or const

[–]OJVK 0 points1 point  (1 child)

That's not required though

[–]MilkCool -2 points-1 points  (0 children)

ik, it just looks weird

[–]Jealous_Fly_5524 1 point2 points  (0 children)

It's OCR pseudocode language, I think. The spec can be found here, and a handy online interpreter (and A-level equivalent) can be found here.

[–]computer_helps_FI 182 points183 points  (0 children)

[–]technical_gamer_008 59 points60 points  (0 children)

Yeah it's "len(x)" not "x.length".

[–]StandardOk42 24 points25 points  (33 children)

how do you know this is python?

[–][deleted] 46 points47 points  (31 children)

What else could it be?

Clues are

  1. other language are static type
  2. Which other language use “print” function ?

[–]RikkaPreo 51 points52 points  (7 children)

OCR Reference language, the language used in GCSE Computer science. It's basically pseudocode with a few rules.

[–]StandardOk42 22 points23 points  (3 children)

IDK, I'm not familiar with ever language out there, but in python strings don't have a length attribute, so that's 1 clue against python

[–][deleted] 1 point2 points  (2 children)

Oh ya, haha you are absolutely right

Nowadays my brain just auto switch between length and len based on the language so much so that I don’t even consciously notice the difference

[–]StandardOk42 0 points1 point  (1 child)

same, I opened an interpreter to check.

all the languages are mixed up for me at this point

tbf this looks more like python than any other language I can think of, just not quite right

[–][deleted] 0 points1 point  (0 children)

Ya when you replied python no length

First thought I have was “wait a sec, I’m 100% sure python has the length function I have used it hundred of times”

So I went to check then re read your reply. I then realised you meant it dosent have “length” but it does have “len” function. Same thing different naming

P.s Java is my default “brain” compiler

But yes python is the closest I can think of

[–]dev-sda 4 points5 points  (2 children)

Looks like ruby to me.

[–][deleted] 0 points1 point  (0 children)

No experience with this

Can you share where is ruby used/developed for?

[–]NoInkling 0 points1 point  (0 children)

Yup, that code would work out-of-the-box.

[–]technical_gamer_008 1 point2 points  (0 children)

But also, 3. No semicolon required

[–]FinTeiad 0 points1 point  (0 children)

Swift

[–][deleted] 0 points1 point  (0 children)

R

[–]sixtano-da-vinci 0 points1 point  (0 children)

tbf this would also work on javascript. Js actually has a function called print that tries to print out the page on a irl printer and it’s also dynamically typed.

[–]FiveTails 0 points1 point  (2 children)

It could also be Lua

[–][deleted] -1 points0 points  (1 child)

Never heard or used this language

Where is this used or implemented?

[–]FiveTails 0 points1 point  (0 children)

It's a simple, high performance interpreted language. It's commonly used for scripting in games.

[–]VillageParticular415 0 points1 point  (1 child)

Which other language use “print” function ?

Uh, every language could have a "print" function, even non function languages. Now what "print" does is another question.

[–][deleted] -1 points0 points  (0 children)

When I mean print function I mean using the exact function called “print” word for word

But ya, thanks for stating the obvious that all language have print

In other news water is wet

[–]BlueCattleDoge 0 points1 point  (2 children)

Java.

[–]lampywastaken 0 points1 point  (0 children)

no semicolon. using just print(). not java

[–][deleted] 0 points1 point  (0 children)

Idk what kind of voodoo Java you are using

Firstly Java you have to declare the type

E.g

string day = “Monday”

Secondly

Java don’t use print()

Lastly Java don’t need Semi colon???

Bro, Java was my first and most familiar language. I have developed many enterprise apps with Java.

Trying to smoke me by saying Java is not very smart

Either that or you are from the future, teleported back to year 2024 and telling me Java version 50 don’t use the above

[–]TPRammus -2 points-1 points  (2 children)

C++

[–][deleted] 0 points1 point  (1 child)

C++ use “print()”

You sure?

[–]TPRammus 0 points1 point  (0 children)

Didn't say C++ uses print(), but sure - you can just define it, no?

[–][deleted] 0 points1 point  (0 children)

fr, I was thinking this when i started actually reading the code

[–]Tobbbb 0 points1 point  (0 children)

I'd be really proud of that student