WTF Bites
-
But python is actually not straight-up interpreted.
Most practical dynamic languages aren't. But Python's “special” if it is also trying to do early binding.
-
But Python's “special” if it is also trying to do early binding.
Yes, Python is . In anything else an undefined variable is either runtime error or autovivifies to undefined. But in python it is a load-time error.
However the specific case of type annotation has more problems with circular module dependencies than this, because the type annotations are part of function signatures, so they would still be needed at load time even if the check was not done inside function bodies.
-
@Bulb All the pitfalls of compilation, but none of the benefits. Yay.
-
@dkf Well, there is some advantage—it does catch large fraction of typos. And the disadvantage is not like compiled languages: e.g. Java or C# handle circular imports/uses just fine.
-
Java or C# handle circular imports/uses just fine.
Their declaration semantics were designed specifically to cope with it, and are a reaction to the older style used by C and C++ (which are… complicated).
-
The only content I can see on this site is the article's title. AND I ALREADY KNEW THAT... But thanks for letting me know what software to use if I want to run a blog, I know those are pretty unique systems
-
Modern news site experience:
- Open the site.
- Start reading an article.
- Suddenly, a wild "This site uses cookies!" popup appears. Click OK to dismiss. Continue reading article.
- Suddenly, a wild "This site would like to send you notifications" browser alert appears. Click on "Hell no go away" and return to reading article.
- Finish visible part of article, scroll down to continue, suddenly a full-screen advertisement pops up.
- Decide being ignorant and uninformed is the better option and close the web browser in frustration.
-
@mott555 On mobile you can add several instances of jellypotato as images load above and below, the page decides you really need to see the header again, or the comments suddenly become super interesting
-
if I stop hovering over "8 agents", the whole dialog box goes away.
So how the fuck am I supposed to click "More..." to see the other three agents?
-
@Yamikuronue Connect a second mouse.
-
@Yamikuronue keyboard navigation
Actually, you might be able to spoof the mouse over event in the console, then it should stay up as long as you don't go in and out of the hitbox
-
The only content I can see on this site is the article's title. AND I ALREADY KNEW THAT... But thanks for letting me know what software to use if I want to run a blog, I know those are pretty unique systems
A typical example of what you might call CVware - software specifically written to serve as a public portfolio for the more obscure buzzwords in your CV. Want to get hired to use technology X, but you don't have any "official" experience in that tech? This is how you do it. Having the buzzword list on the home page makes it that much easier for the HR to checkmark.
-
@cartman82 I am tempted to mention that imports can be done conditionally (which I assume you already know, anyway), but I realize that that would be apologism; really, it shouldn't be necessary in such a commonplace use case as type hinting.
I am not entirely clear on what 'weak importing' would be, though. My understanding is that it would be a) just importing the names of elements and the arities of any functions rather than the actual code, and/or b) not following any imports inside an imported module. Is this even remotely correct, or is it something different from either of those?
-
@ScholRLEA said in WTF Bites:
I am not entirely clear on what 'weak importing' would be, though. My understanding is that it would be a) just importing the names of elements and the arities of any functions rather than the actual code, and/or b) not following any imports inside an imported module. Is this even remotely correct, or is it something different from either of those?
I'm not a programming language designer. Don't know whats feasible.
But since these modules will only be needed for runtime checks, why not wait for the runtime to resolve them? Or some kind of second pass.
Eg.
from a.b import Class1 from c.d soft import Class2 class Class3(Class1): def method(self, arg: Class2): pass
So you don't really need class2 for anything at compile time, so you can just ignore it, and then have another pass later. Or something.
-
@Yamikuronue Connect a second mouse.
Just make sure it is the same sex as the first one. You don't want them to mate.
-
the very fact that GNOME3 dumbwits stole this idea, makes it a bad idea.
They partly unfucked the idea by letting you just type your password in. The curtain lifts up automatically.
-
@cartman82 said in WTF Bites:
So you don't really need class2 for anything at compile time
Wait, are the types of the parameters to a function used or not? Because it seems kind of strange to resolve them at runtime if there's a compile step.
-
PS R:\> gc .\quicky.py #! -*- coding: utf-8 -*- def testfunc(arg1: int, arg2: str) -> None: print( "Type of arg1 is " + type(arg1).__name__ ) print( "Type of arg2 is " + type(arg2).__name__ ) testfunc('A string', 42) PS R:\> python .\quicky.py Type of arg1 is str Type of arg2 is int PS R:\>
AFAIK Python's type hinting isn't really used by Python itself. It's more of a documentation/lint thing.
While these annotations are available at runtime through the usual
__annotations__
attribute, no type checking happens at runtime. Instead, the proposal assumes the existence of a separate off-line type checker which users can run over their source code voluntarily.
-
Python's type hinting isn't really used by Python itself
The more I learn of Python, the less I like what I hear.
-
>>> 5 + '5' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> '5' + 5 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't convert 'int' object to str implicitly >>>
See? It's not all bad.
>>> 0 == False True
Shit.
-
>>> 0 == False True
Shit.
Apparently Python needs the PHP '===' operator. And while they're at it they can also add '!==' (or '!!=' for bigger bang) and all related greater/less than variants.
See how from:
>>> a >== 3 False
I know that a is greater or equal than 3, and/or is not the same type. Sooo much information from just one test!
-
>>> 0 == False True
Shit.
You expect integer to add, compare etc. to longs, floats etc., don't you? Well,
bool
is a numeric type in python. It is in most other languages that have it too.Apparently Python needs the PHP '===' operator.
Python has
is
. It is slightly different as it tests for reference equality for objects, but for primitive types it does exactly what you'd use===
for.>>> 1 is True False >>> 0 is False False
and the usual style is to always use it when comparing to
None
, i.e. the tests are always writtenx is None
, notx == None
.That said,
None
does not auto-convert to standard types and does not compare equal to any of them:>>> False == None False >>> 1 + None Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
so it is not really that critical.
-
@Bulb
I was trying to laugh at the '===' operator. While Python's 'is' does one clearly defined comparison, PHP's '===' does something like:a == b and type(a) == type(b)
'is' also neatly says what it does right there, in the operator name.
I don't know what '===' is supposed to mean as an extension of '=='. 'equaler than'?
-
-
@ben_lubar said in WTF Bites:
Wait, are the types of the parameters to a function used or not? Because it seems kind of strange to resolve them at runtime if there's a compile step.
I'm only using these types for my IDE's auto-complete and type checking. As others have said, there's no type checking during runtime, although I imagine one could bolt on a type checking system using decorators.
The whole thing seems just poorly thought out.
-
@Yamikuronue Still gonna keep my mouth shut, here.
-
Well, bool is a numeric type in python. It is in most other languages that have it too.
But why?? Because of C?
In any case, in all other cases I remember, values of different types are considered different by the equality operator1 regardless of what value they take when you explicitly cast; except in this one case that sticks out like a sore thumb. Even
False
andNone
are seen as different.1 Unless you implement the rights metamethods, that is.
-
-
In any case, in all other cases I remember, values of different types are considered different by the equality operator1 regardless of what value they take when you explicitly cast
No. Values of all numeric types are considered equal when they convert to each other:
>>> 2 == 2.0 True
and in python 2, values of
str
andunicode
were also considered the same if they converted to each other:>>> "foo" == u"foo" True
In python3, byte strings are not considered equal to strings any more though:
>>> "foo" == b"foo" False
Also in python3 different types except numeric ones are not comparable for ordering while in python2 total ordering of all things existed and values of different types sorted by type.
-
Values of all numeric types are considered equal when they convert to each other
and in python 2, values of str and unicode were also considered the same if they converted to each other
You are the best kind of correct.
Also, this post submitted when I was trying to quote you the second time. õ_õ
-
From our own Front Page…
That's… great if you want to do Shift+Enter I guess.
-
From our own Front Page…
We have one of those now?
Also, here's the context blurb from TFA:
Cynthia wrote, "Received new XPS 15 laptop from Dell which attempted to mash a US keyboard into a UK chassis."
-
-
Three guesses as to what's wrong with the code. First two don't count.
-
@Maciejasjmj The naming would suggest TryOpenFile returns
false
when it works?Ewww
-
The naming would suggest TryOpenFile returns false when it works?
The opposite.
TryOpenFile
returnstrue
when it works, that is, when no error "occured".The best thing is that there are like 30 places where there's a variable named
errorOccured
, and sometimes it being true means there wasn't an error, and sometimes it means there was. But it's always named the same.
-
@Maciejasjmj said in WTF Bites:
sometimes it being true means there wasn't an error, and sometimes it means there was. But it's always named the same
nice. Reminds me of the database that used tinyint columns for booleans with 0=false and 1=true in every instance except one
-
@Maciejasjmj said in WTF Bites:
But it's always named the same.
Wait, no, sorry. That's at the top level:
// I do not care about "starting" and closing files etc, its Provider resposibility bool successed = controller.Process(); if(!successed) { // Errors whatsoever it would be }
Because obviously if no error occured, we must have successed.
-
@cartman82 said in WTF Bites:
@ben_lubar said in WTF Bites:
Wait, are the types of the parameters to a function used or not? Because it seems kind of strange to resolve them at runtime if there's a compile step.
I'm only using these types for my IDE's auto-complete and type checking. As others have said, there's no type checking during runtime, although I imagine one could bolt on a type checking system using decorators.
The whole thing seems just poorly thought out.
Why not just use comments like Closure does?
-
Apparently
blockquote > ,
is not only valid LESS syntax, but it's not caught by the linter.And no, it doesn't do anything useful. It just ignores the
>
, even if you nest selectors.
-
Fucking moronic "web marketing" idiots.
(one of our customers) Lorne can you put this Google Adsense script on the order confirmation page?
{click click} done{time passes}
Lorne you did it wrong because it doesn't work and I have no data in my campaign tracking bullshit fuckthing (paraphrased by me)
I dunno, the script you gave me is right there. {screenshot of order conf page}
Well, I have an email from my idiot monkey goober dumbfuck market person who says it's in the wrong place. (paraphrased again)
OOK OOK MUST BE RIGHT UNDER<body>
TAG ME GOOD MONKEY FOLLOW WORDS OOK! {sends link to Google documentation}
I don't think that needs to be done. Look {quotes from the link he sent me} it says it has to be within the<body></body>
block not first.
I dunno, Lorne, poop-eating monkey knows what he's doing.
OOK OOK MUST BE FIRST BECUASE PAGE LOADS SCRIPTS TOP TO BOTTOM AND USER MIGHT NOT LOAD SCRIPT BEFORE THEY LEAVE PAGE! HAHAHAH POOP!
No. Here's the web dev tools-- showing the script loading-- showing the HTTP calls to the google ad servers, sending the data you gave me.
OOK PEOPLE LEAVE PAGE FIRST MUST BE FIRST BELOW BODY!{grr}
... no. That is only true if you're in 1997 and using a dial-up modem. That page loads so fast a user would be hard pressed to INTENTIONALLY navigate away before the script loads. Even if someone got stuck on a very slow connection, there's the fact that this is the order confirmation page. People will wait for it to load to ensure their order was placed. And EVEN IF someone happened to leave, intentionally or accidentally, that'd be so rare that 1 in 10,000 would be common. It's literally impossible that every single on of the hundreds of people who placed an order in the week since this went live would have done that. And, if you'll look at my screenshot, you'll see that script IS firing and IS making the web calls as expected. Either you gave me the wrong script, or you put the wrong campaign/ID numbers in that script, or you forgot to whitelist the subdomain shop.example.com, or in some other way the MARKETING tool is set up wrong. I suggest you review that before we look any further at the otherwise perfectly functional code.
ok
-
@Lorne-Kates said in WTF Bites:
Fucking moronic "web marketing" idiots.
Unnecessarily repetitive and redundant. "Marketing" already implies "fucking moronic idiots."
-
Suddenly, a wild "This site uses cookies!" popup appears. Click OK to dismiss.
Fuck them and their assumed consent. I use F12 dev tools to delete the offensive elements!
-
@Yamikuronue said in WTF Bites:
So how the fuck am I supposed to click "More..." to see the other three agents?
You kids today who don't know keyboard navigation. Try tab, see if that works.
I mean, I bet it doesn't because some fucking nimrod captured the keypress, but that's how it's SUPPOSED to work.
-
Connect a second mouse.
Cute. I wonder. I bet a touchscreen would work. Touch the thing that makes the mouseover, then touch the more. No intervening movement.
-
Connect a second mouse.
Cute. I wonder. I bet a touchscreen would work. Touch the thing that makes the mouseover, then touch the more. No intervening movement.
Everything is a phone.
-
@FrostCat It actually did, after I had a laugh and posted here. But that wasn't really the point of the story :)
-
@Yamikuronue I found a t-shirt that looks like it was made specifically for you!
-
@HardwareGeek said in WTF Bites:
Everything is a phone.
Stop triggering me. Even with skype, your desktop's still not a phone.
-