In cpython' in ordre to be callable, an object must have __call__ in dict. Where __call__is an instance. If there's no code object, CPython jump to ob_type->tp_call and use the python arguments as the parameters. That's it.
@PeterVaro The problem is setting ->ob_type->tp_call.
@PM2Ring the guy I complained about yesterday, who hasn't given any feedback on my answer to his question since February? Well, finally, after my nth comment (n~6) he responded:D I managed to be annoying enough that it was simpler to stop ignoring me.
@AndrasDeak It's an expression as in : you see ? And I talked a lot with tristan about Microsoft's Douchebaggery and its weird tendency to poke its own eye out. I was happy I made my first non-Apple non-Microsoft os workd and I thought I'd share it with him
Should I flag: http://stackoverflow.com/q/39312609/179081 to be migrated to cross validated? As I got to the end of answering it, it became very clear that it is a question about Stats/Machine learning. Not a question about programming.
I'm a programmer, with a bit of a specialty in machine learning. People on Cross Validated tend to be Staticians (/machine learners) with a bit of an ability to program
@idjaw oh come on - you're not even tempted to throw in newlist = [dict(zip(['Name', 'City', 'email'], el)) for el in zip(*[iter(lst)] * 3)] for that one? :p
I have a n*n list. x=[1, 2, 3, 4, 5, 6, 7, 8, 9] given that i know n, how can i create a n*n matrix out of this looking like: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] I know numpy should make it easy but I'm not too familiar with numpy yet
Would there ever be a case where shutil.copy2 would fail with TypeError: Embedded NUL character when passed to os.path.join(directoryA, directoryB, 'filename' + '.ext')?
I'm only getting the TypeError with two particular files; outputting the path passed to shutil.copy2 shows that there are 21 spaces being inserted at the end of the filename and directoryA, which occur after being passed to os.path.join but not before.
Give me a minute or two to copy those files into a different directory and test them with repr; I'm doing a batch operation on a bigger set at the moment.
Yeah, it looks like the assignment was made for a more statically typed language and ported to python where duck typing works with minimal effort
Hmmm, it looks like the data is being given a whole lot of null characters. The difference between those files and the ones that work is that they don't have an album artist tag (so my code draws from the artist section)
The weird thing is that both values appear to be 'Kalafina' in file browsers (so it shouldn't make a difference), but when the artist is goes through a sanitization function, it gets a whole lot of \x00 values appended. The same string, coming from the album artist field doesn't have this issue...
Thanks for the help! Your keys are in your winter coat IIRC ;) It turns out I tried the correct solution, but forgot that `strip` ignores null characters unless specified
@user1107049 it does almost what you want. Instead of creating a function object, it creates a bytearray object with desired attributes, then uses (the stupidly named) read_dword to get a reference to a fake object. There is no stack protection that can help with this, it is all data-only operations well within allocated objects on heap.
@Karin Though it's the expectation that SO is a 'do your homework' website that is a problem. But by the time a user has a little bit of experience/rep with SO, their attitude improves and they seek help with their homework
@idjaw Ah. That Project Euler problem again. I see DSM answered the OP's immediate question, and gave a hint that their algorithm is hopelessly inefficient. I'm tempted to link them to this question, but I guess it's better if the OP figures it out for themself. :)
@NinjaPuppy If you're talking about the phone diagnosis stuff, it could be, but it's not. The code is invariable a horrible twisty maze of nested if... else. (Sorry about the triple ping)
@AnttiHaapala I don't know which is worse, those "elementary school homework " questions, or those "I just started using Python and some huge complicated framework, and I don't know how to do some really elementary operation in Python".
Eg, they're using OpenCV to do some fancy image recognition, or NLTK to do deep text analysis, but they don't know what a tuple is.
@user2284570 I am not sure if the code above will work for this: it does access array out of bounds, yes, but the target is another valid C object there. It still has undefined behaviour according to C standards, but would work on all compilers and all options that I've seen.
@PM2Ring or the string interpolation question from that Vietnamese guy yesterday
I am working on python with piece of about date-time.Its purpose is to list the files from specific date in the past util today. Unfortunately, I get this error:
I cannot figure out how to interpret `someday' as a date or time
Code:
import os
import datetime
day = 3
hour = day * 24
today =date...
in Helsinki... must be the stupidest architects ever. I was looking at that tram platform thing, and it sure looked odd but couldn't realize why... until it occurred to me that not only it is less safe to walk onto the platform island in the middle, but now also they would need to modify all the trams to have doors on the left side as well... :D
didn't it occur to them when they were doing that animation...
@AnttiHaapala I understand newbies getting confused by stuff like that. And it looks like he realises that he needs to use some special syntax to tell find to use the contents of someday rather than its name. But they way he asked the question does make him look pretty clueless.
My dad upgraded from Win 7 to Win 10 on his laptop, and he hates Win 10, but he waited too long before he asked me how to roll it back to Win 7, so now he's stuck with Win 10. He's still running XP on his desktop, and hoping that Norton will be enough to protect him...
@AnttiHaapala He's grudgingly coming to accept that Linux might be ok. I've used it a couple of times to recover his desktop machine when it became unbootable. I wrote a simple Bash script to manipulate restore point files so you can easily roll back to earlier configs than "Last known good configuration".
@AnttiHaapala No. Not many private individuals here have a flag & flagpole. Lots of people fly "toy" flags on Australia Day (26th of January), but apart from that we're not really a big flag-flying nation.
In the cities, many large commercial building do have flagpoles, and of course all government buildings do, but police stations generally don't. And organizations for people from the armed services, eg the RSL are rather keen on flying the flag.
Our next-door neighbour has a flagpole, but they mostly fly the Boxing Kangaroo flag; they only fly the national flag on special occasions.
A lot of people here would like us to have a new flag that doesn't contain the British Union Jack, but that idea is not popular with the RSL: they say that we should keep the flag that our servicemen fought & died under.
Afrikaans is a daughter language of Dutch and—unlike Netherlands Dutch, Belgian Dutch and Surinamese Dutch—a separate standard language rather than a national variety. As an estimated 90 to 95% of Afrikaans vocabulary is ultimately of Dutch origin, there are few lexical differences between the two languages; however, Afrikaans has a considerably more regular morphology, grammar, and spelling. There is a degree of mutual intelligibility between the two languages, particularly in written form.
Afrikaans acquired some lexical and syntactical borrowings from other languages such as Malay, Khoi and...
somehow I got to here :P
it is so fun to realize that I can understand Afrikaans, reading the first column there:
"Hy het op die lughawe aangekom" yeap, he has to the airport arrived.
yeah, I can pretty much get most of the Norwegian that the politicians talk, yet I only have studied Swedish in school. But then...
I need to triangulate Afrikaans with Swedish/German/English
Though, English is not really useful at all, too many false friends.
so "Hy het op die lughawe aangekom"
is quite close to the German "Er hat am Flughafen angekommen", though one notices that it is not the word flight but air in Dutch (luft in Swedish / German)... and the person pronoun is closer to English he.
naturally it should be much easier for Poke, (and Martijn, which goes without saying)
@AnttiHaapala Then it shouldn't work. It's not whether it write to a region which is allocated or not. It's about writing between the lower and the upper limit of a buffet. The aim is security in order to prevent attackers corrupting data of other memory regions. And there's a 15000$ bounty for anyone who can bypass it.
Though recently I have been able to perform arbitrary out of bound reads. It might works if there's a bug, but it's very unlikely
And due to a patch refusal i can still read arbitrary memory address in python but i can't perform writing since the object is created with a bug in the buffer() python function
@AndrasDeak Being able to edit self-deleted answers is a very handy feature. Say you just posted an answer, then moments later you notice a major flaw that's worthy of downvotes. You still want to answer the question, but you need time to repair your answer. So you self-delete, fix your post, and undelete.
Unrelated: I need >=1 times 2 cents, please. I posted a meta bug-report about semi-transparent images potentially breaking with certain sizes. Now I bumped into it and realized that imgur itself does the conversion, so it's their bug. Still, others might run into the same issue later on SO...
so do you think I should delete it (since it's not an SO bug), or answer it (to have some trail of information to the problem)?
@user2284570 Python doesn't have unsigned ints, so if you want values greater than 0x7fffffff to be represented as positive integers then you're going to get a long on 32 bit Python 2.
General question. If you have some data and you are deriving additional columns from it, would you say it's best practice to derive the ones you need as per the requirement, or append the actual data with a whole bunch to reduce on computation?
:facepalm: The OP of this question just self-hammered to an incorrect dupe target. I siuppose I should've searched for an applicable target, but I'd already decided to be a Nice Guy & fix their code for them. So I un-hammered it. :)
user6568562
13:59
@AndrasDeak I just got aware of this little gem : D This is genius Thank you !