« first day (3255 days earlier)      last day (1708 days later) » 

12:05 AM
Hi everyone, new question about classes. I don't understand why the function I defined is considered as not define by Python.

class Justtotry:

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def Function_1(self):
        return self.a * self.b


A = Justtotry(2.0, 5.0)

print(Function_1(A))
I get:
NameError: name 'Function_1' is not defined
 
You need to call it on the instance A: A.Function_1()
class JustToTry:

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def method_1(self):
        return self.a * self.b


instance = JustToTry(2.0, 5.0)

print(instance.method_1())
Your function is actually a method of the class.
Naming of objects and typing conventions have their importance to understand python code.
 
Oh.. I don't know why I am still confused with that. Thank you
 
Maybe because you are not calling things by their proper name?
 
I do, I use Python for many years but I never learn OOP because it was not useful for me and now that I learnt little about it I want to do everything, perhaps too fast
I have reflex of usage but no deep understanding of the code on itself
 
 
2 hours later…
2:04 AM
@AndrasDeak Is the non-accepted answer by aleclara ok? If we all upvote it and downvote the accepted one, eventually that might trigger a change. Also, the title should say "getattr() with a chain of attributes 'attr1.attr2'" (not just "multiple attributes"). But it feels like encoding a Law of Demeter violation.
 
 
6 hours later…
8:10 AM
@smci gang voting the accepted answer is out of the question. We could try pinging OP to flip the accept, but I didn't check the other answer in detail. I guess the best solution is this:
 
8:24 AM
if user is None:
is it okay to check for none like that?
 
it is.
is is the right way to check against singletons.
 
also if user:?
okay
 
that goes for a "truthiness" check.
 
ahhh the famous my_module.py has the same name as import my_module! @ParitoshSingh
 
remember the discussion?
@ReblochonMasque hehe yeh, that's what im hedging my bets on anyways
 
8:26 AM
Cabbage!
 
cbg cbg!
 
suppose i want to create a function foo that updates a dictionary after going through several servers. example ssh server1 run foo ; print d gives{'s1':1}, then ssh server2 run foo ; print d gives {'s1':1,'s2':2}
i dont want to copy foo on all servers
all servers do have python installed
 
what is your question @pythonRcpp
 
no repro/solved. link
 
run a python script on many servers, but script is on my local machine,
and i dont want to copy it to all servers since its just a one time run
i think paramiko should help
 
8:30 AM
this reeks of overengineering if im being honest.
 
thank you
is 204 status code okay for a sign in? or maybe just 200?
 
@ParitoshSingh good call
 
8:52 AM
@pythonRcpp if python is available, you can call it via ssh and pass in the source of your script via the -c switch
something like ssh server1 python -c "$(cat foo)"
be mindful of escaping the code properly - a simple cat will not work in most cases
 
9:04 AM
@ReblochonMasque idjaw wrote a canonical for that.
 
9:22 AM
really? @PM2Ring
 
Yes, see the dupe target. :)
 
9:36 AM
is there actually any use-case where it is desirable for a module to import itself? I cannot think of a good reason not to throw an error in such a case.
 
@MisterMiyagi thanks, yours is a good way. Just that i was thinking if i could have multiple connections open to various servers and foo can be run on each , updating d local dict
 
cool, thanks @PM2Ring
 
9:51 AM
@MisterMiyagi Fair point. But raising an error on self-import will only work for some cases of that bug. It's more common for the desired module name to be shadowed by another of the OP's scripts, not the one that's currently running.
 
I've witnessed a self-import bug like that IRL
 
10:31 AM
Here's one I answered in my early days on SO: stackoverflow.com/q/32180949/4014959
 
11:08 AM
@Aurelius You probably aren't handling authentication well. See django-rest-framework.org/api-guide/authentication . Need more info on what you have currently, so that we can work out why it isn't working with docker. Also, I recommend you to take a look at any existing project templates for DRF with docker (github.com/yannikmesserli/django-rest-framework-docker/blob/…).
 
 
1 hour later…
12:35 PM
@shad0w_wa1k3r thank you very much, now everything is working even with docker, but I am not 100% sure it's the correct way to do it
 
1:02 PM
def fun(a, b = 1)

is this the correct way to have b as optional parameter with default 1?
 
Yes
 
Except PEP8 suggests not using spaces around the equals sign, so def fun(a, b=1) is the more usual way to write it.
The syntax is spot-on, though.
 
good point
 
And for assignments, spaces around the equals are definitely de rigeur
 
1:46 PM
@AndrasDeak closed
^^ this one too
 
 
1 hour later…
user10655999
3:01 PM
@AndrasDeak can you help me out how can we get coordinates of text in scanned image using python ? i tried tesseract.exe makebox it is just word coordinates
 
user10655999
Need boundingbox of words
 
No, sorry
 
user10655999
can anyone help me out
 
user10655999
how can we get coordinates of text in scanned image using python ?
 
By now you could've picked up the basics of OCR rather than waiting for someone to give you a full solution
 
user10655999
3:04 PM
what i tried microsoft vision and google cloud vision ocr services it worked
 
user10655999
but need open source solution
 
user10984358
3:15 PM
heya guys, do all (most) scrappers break if a webpage is changed or it doesn't if the scrapper is built good?
 
user10984358
by changed I mean a redesign from adding a button to a complete overhaul
 
of course changes tend to break things
which is one of the reasons why scraping < using the API
 
scrapper
 
4:08 PM
I have a question about github
I have a repo
and my local repo is totally different
yet pushes are going through
I tried "merge" in TortoiseGit, but no change made to what's shown on github
 
closing as unclear/no MCVE
If pushes work then perhaps you are confusing branches, or looking at the wrong repo
Merging locally won't affect github
Or perhaps you're pushing to the wrong place
 
4:27 PM
Hi people can you help me with this little code. I need output without space. I figure out how to remove '' but I can't remove space between characters. I get output like this A D G and I need ADG without space. If someone have some idea please share. This is code import itertools
somelists = [

['A', 'B', 'C'],
['D', 'E', 'F'],
['G', 'H', 'I']

]

for element in itertools.product(*somelists):

print(*element)
 
print(''.join(element))
or print(*element, sep='')
Touhou music remixes are both a blessing and a curse... half an hour ago I discovered a new song I liked, and now I have 7 versions of said song on my hard drive :/
 
Hello people

I am creating a customer renderer to adds admonition tags to Markdown. But for some reasone I am not able to call the parent (i.e `HtmlRenderer`) `paragraph()` method
0
Q: Misaka Python: 'super' object has no attribute 'paragraph'

CodyI am creating a customer renderer to adds admonition tags to Markdown. I am using misaka. Here is code. import misaka as m import re import houdini as h class CustomHTMLRenderer(m.HtmlRenderer): def paragraph(self, content): _prefix_re = re.compile(r'^\s*(!{1,4})\s+') CLAS...

 
4:43 PM
"That's odd", says Misaka #374 as she examines the situation
 
@Aran-Fey lol
@Aran-Fey can you help me?
 
Don't think so. I'm as stumped as Misaka #374
 
@Aran-Fey Thank you so much. I tried that but in wrong way. Thank you again
 
 
1 hour later…
Paz
6:06 PM
if self.stderr == subprocess.PIPE and (self.err != None or self.err != ''):
Do someone see a problem in that if statement?
the variable self.stderr equals to subprocess.PIPE though self.err equals '', but it still goes into that if statement
 
(self.err != None or self.err != '')
 
Paz
Thats what I wrote
 
the problem is there, but can you see the issue?
 
Paz
I cannot! I've been struggling for almost an hour
OH MY GOD
 
ah. well, that condition will always be True because when self.err is '', it will pass the first check
 
Paz
6:10 PM
THANK YOU
YES YES YES
WOW
You cannot believe how much frustration i've been through
 
It's all good. :) with negation, you have to be extra careful with writing conditions
also, you can use something called de morgan's law
 
Paz
yep, thanks
I guess I was just really tired
AM just really tired.
 
heh, it happens. coffee/break time? :P
 
@Aran-Fey Misaka is a CFFI Python interface for hoedown, which is forked from sundown, which is derived from upskirt (don't ask). misaka.BaseRenderer does indeed have a paragraph method. Most puzzling.
 
Paz
@ParitoshSingh i guess..
 
6:21 PM
oh and just a side note, use is and is not for checking against None
 
user10984358
i have three .py files (file1,py, file2.py, file3.py), file2.py uses a method from file1.py, and file3.py inherits a class from file2, i want to use an object of file3 in file1, as the user is only allowed access to file1
 
user10984358
when a user calls file1().getFile() it must return him an object of f3
 
user10984358
there are more files file4, file5 and 3 others that are inherited from file2
 
user10984358
based on a certain condition I want the corresponding file to be returned, file2 has many methods common to file3,...filen and each file has their own version of a certain method,
 
user10984358
I was asking a friend and they suggested this can be tackled in Java with interfaces, I am java illiterate what can be done here?
 
user10984358
6:30 PM
I can't even build the code if I use from file3 import File3Class, a sorta circular import situation is happening
 
I feel like you like making things complicated for yourself.
 
user10984358
well enlighten me, free me of my shackles
 
user10984358
what can be done
 
break the circular import, pull the method out of file 1 and file 2, making them both take from acommon resource
or make a file 0, one that can pull whatever is needed from any of the files. let that be the file exposed to the user.
bottom line should be, you should be able to freely import everything in one file, and then not have to worry about managing this
If that however does not solve your issue, it's mcve time.
 
user10984358
well actually there are more than one method being used, I just wanted to tell that a method is being used in file2, I didnt think the number of methods used would make a difference
 
6:36 PM
it shouldn't.
 
user10984358
I guess file0 is something I need to look
 
user10984358
so there isn't an interface equivalent here?
 
i have no idea what that even means. imports are how you "interface" between python files
 
user10984358
I was just made aware of that, I dont know what interface does in Java, they just said look for an equivalent to that in python
 
user10984358
anyways thanks for that design :)
 
6:40 PM
no worries.
 
7:02 PM
@TheNamesAlc an interface is the specification of what types provide - e.g. Iterable is the interface of types that support iteration in for loops
since Python does not have static typing, you generally need not declare, check or explicitly implement interfaces
in your case, just return whatever you want. Python won't stop you
 
the closest thing to a Java interface is probably an abstract base class from the abc module
 
hey y'all! Sorry I'm new and this may not be the right place to raise this issue but this seems important in my opinion. Searching for "python convert array of strings to string" in google the top answer was this "https://stackoverflow.com/questions/5618878/how-to-convert-list-to-string", which was marked as duplicate and lead to this "https://stackoverflow.com/questions/2906092/converting-a-list-to-a-string", and so forth.
This is from 8 years ago. Can't this be resolved somehow? It looks really bad an confusing.
 
do you actually want to convert the list or concatenate its elements?
 
are you referring to how the dupes bounce to one another or what are you referring to?
 
7:10 PM
How the dups are bound together.
 
the original question is so old that I can't edit the dupe target
 
I got my answer, but it looks bad.
 
we'd have to reopen and re-close it
 
It is actually good that similar questions and answers are linked together somehow but the presentation is not good.
 
what do you mean by "the presentation is not good"? that there is such a long chain of duplicate links?
 
7:12 PM
It may need some feature where you can remove all this dups marks (for really old questions) and just link them together somehow that people can look them up.
 
I'm just glad it makes more and more people realize that SO is a burning dumpster
 
Marking as duplicate makes sense when someone asks the question, but after 8 years it is just confusing and makes it look like a "dumpster". Removing the marks and adding something that links them together would be more helpful.
 
"something that links them together" isn't hat just the same as having the dupe link?
 
Not sure what kind of "something" you're imagining, if a link on the top of the question isn't good enough
 
The link is good but "marked as duplicate" is somehow demeaning and lessens the value of the answer.
 
7:18 PM
so you mean the wording should be different?
 
Yeah, people with less knowledge will get confused by that. "Marked as duplicate" has a meaning but it isn't working here. If it's a duplicate, does it mean that this answer is less authoritative then the other one that is linked to, etc...
 
bleh, I got tricked into cleaning up SO's mess again. Back to youtube I go
 
I don't quite understand why you think the wording is demeaning. The question is marked as a duplicate. It is not marked as inferior, lesser, or similar.
Though quite frankly, "convert array of strings to string" is so ridiculously broad that it may as well be marked as "people that asked this question actually wanted to ask <other question>"
 
yeah, the question is unclear. Could be asking for ''.join(lst) or just str(lst). Doesn't deserve the top spot on google or the thousands hundreds of upvotes
 
If you mean my search query, you missed "python" at the beginning of the question.
 
7:26 PM
maybe some people who still care about SO could delete it
 
@Alireza I mean the two duplicates along the chain
though see my question above in response to your initial message
 
On SO, when someone asks a question and it is marked as duplicate, it means that someone has already asked this very same question and received proper answers. The implication is that the original question has received more care, review, and scrutiny (through time and view) by capable eyes, which makes the assumption that it is more authoritative reasonable.
This implication may be true at the beginning (when the dup question is asked), but after 8 years it may have changed (like may be in this example).
The dup mark has lost its original meaning and is just used as a way to link these Q and As together.
 
7:42 PM
there, I improved it
 
since this doesn't seem to be about the questions or their content, I recommend taking up this issue on Meta
 
yeah, you both seem to be German speaking so Ich wuensche euch beiden einen shoenen Samstag Nacht.
 
@Alireza no
@Alireza the official policy is that we use English here
 
WoW, keep it cool, is that a robot? It's like the Speech Polizei
 
I think you don't realize that the question hasn't changed at all since '11 - it's been closed all that time, after all
it looked exactly like this when it was closed as duplicate
 
7:49 PM
surely we've gone a long way in converting lists of strings into strings
For instance there's that thing. Uuuh, you know. str.join.
best thing since sliced bread, and I'm pretty sure sliced bread wasn't here 8 years ago
 
I liked the comment that recommended json, actually
 
@AndrasDeak yeah, adding support for slices to bread.__getitem__ was fantastic
Hmm, well, I suppose the question did change a fair bit since its closure. Answers were edited, comments were posted, etc. Still, there's a better duplicate around.
 
Paz
Is there an option to TypeCast something in python?
 
define "typecast"
objects are strongly typed, but you can create new objects with different types from them
when you do x = 1; x += 0.5 you end up with a float, but that's really a different object than the original integer 1. Just the name is the same.
 
something something __class__
 
8:01 PM
@Aran-Fey I can't hear you lalalalala
 
@Paz what are you trying to do?
 
Paz
nevermind, I've got it covered another way. but I initially tried to cast an instance upwards
 
8:15 PM
cbg
 
Has SHA-256 been broken? The answer might surprise you (but it probably won't). crypto.stackexchange.com/questions/74251/…
 
"It is balderdash by scam artists trying to bamboozle people into buying fintech snake oil"
 
yeah, mostly linked it for that gem of an answer :D
 
it really is
 
I want to upvote it for effort alone, but I have no idea if it's actually correct, so I'll refrain
being a responsible voter is hard
 
8:19 PM
lol
 
@Aran-Fey the company is very clearly a scam project if you read the answer
none of that makes any sense
 
"overlapping into the quantum computing realm"
 
yeah ^
 
there's no proof that they could do it, as far as i know
 
I'm enjoying reading it, though, thanks :)
 
8:20 PM
let's just say the odds of a Nigerian prince wanting to give you all his money are higher
 
The HNQ I read about how the Nigerian Prince angle is deliberate did actually blow my mind slightly
 
In order to filter out conscious people?
(I didn't read that HNQ)
 
Yeah. I had just never taken the time to consider why these attacks exist
 
no way you bring that up, one just messaged me and he wants to make me his queen!
all I have to do is wire him 200k and then i'll have 10M
it's such a deal
 
well, always good to have a plan B in life
 
8:23 PM
That seems a little steep to lay down. Why don't you pay for them to come over in person first and see if it's genuine?
 
don't they spell words incorrectly as well?
 
also fake invoices and whatnot are very clearly doctored for the same purpose
 
The ingenuity of it all is frankly pretty amazing.
 
I think the cultural penetration of these scams has peaked so they can't really lose ground now
There will always be 0.0x% of people who take the bait. And the population online grows
 
well I mean if you're a scammer you only want to talk to people that want to believe it's all true
 
8:26 PM
@johnsmith Yeah, I somehow missed the context of what you were saying. That was my comprehension fail.
 
that's alright it happens
I use alot of sarcasm, which when written doesn't translate well.
 
You're in good company :P
 
I fell for one of those "send me your password plz" scams once :/ But in my defense, I was like 10 or something
 
@Aran-Fey they're getting really good at those the emails the scammers send you look exactly like the ones that the companies send
they'll have the same logos, font-type, and style it's crazy
 
In the UK they are rolling out "smart meters" so that your electricity usage can be monitored. Apparently, you need some meter to say "Oh yam, running my hair drier 24/7 costs money?!". I sit and wait for that network to be hacked and fake bills be generated
 
8:32 PM
@roganjosh it's probably extra-secure so the password is 54321
 
lol
 
ah, the good ol' "internet of (hackable) things"
 
in CHATLAB and Talktave, Jun 26 '18 at 10:59, by Dev-iL
Words of wisdom: The "S" in IoT stands for Security.
 
@AndrasDeak Add a 0, it's on the other end of the numerical keys, nobody will suspect that kind of trickery
 
when I was a teenager I had a data entry job and it amazed me how many people use password as the password
 
8:34 PM
@johnsmith in my case it wasn't anything fancy - just an in-game message from a self-proclaimed "developer"
 
@johnsmith the fact alone that you could have that realization is also telling
 
I'm sure "password" was the hash of their passwords /s
 
depending on john smith's age hashing might not have been invented yet //s
 
I might have dated myself
 
the web seriously needs to adopt a protocol that only sends pre-hashed passwords to servers
in other news, I seriously need to get some sleep but I can't stop listening to Strawberry Crisis
 
8:42 PM
that's fake news, you don't "need" sleep.
XD
 
On the media theme: if you were bored and got half enticed by The I-Land trailer on Netflix... I'll save you the pain. Diabolically bad. As a long-term despiser of Apple things, the clue was right before me.
 
have you seen the new dark crystal that Netflix put out?
 
I'm 6 episodes in. I actually quite like it but it's not enough to grip me
If I can't sleep, I throw another episode in
 
@roganjosh guessed as much from the trailer
 
@AndrasDeak The trailer reveals the plot anyway. I ended up watching the full first episode just to give my commentary to my best friend at work.
 
8:50 PM
@Aran-Fey Listened to it for a minute and forgot all about sleep.
 
sleep is for people that don't code
 
I don't code while I sleep*, and I don't sleep while I code. Close enough?
 
the blue light your computer puts off should keep you up for a good two days
have you ever had a dream about what line you messed up on?
 
(*falling asleep on the keyboard is not considered "coding")
I don't think I have had a dream like that, no
 
@johnsmith Not quite coding, but I did have a nightmare about some results I'd got in an Excel formula the day of a publication revision deadline. I got to uni at 5am and actually the nightmare was correct.
 
8:55 PM
wow
that's exactly impressive
 
Jun 6 at 7:29, by Andras Deak
I dreamt that it was the penultimate day of the semester and I accidentally learned from a student that we forgot to organise a mid-term resit, and there was no time left to rectify that. Weirdest "forgot to prepare for an exam" dream ever.
 
@johnsmith Turning the brain off and on again sometimes works :P
 
lol
 
@AndrasDeak I don't see the problem, just organize a surprise test on the last day :D
 
yeah, unfortunately we have regulations and whatnot :P
 
8:59 PM
you guys have to link your comments here? Do you guy not have something like caprica six, or Oak?
 
I don't see why using a bot would be superior
 
so instead of linking a comment, we would be doing... what?
 
saying "fetch me my message that said blah blah blah" and hope for the best
 
I guess it's not it's just a place to store important comments
 
meanwhile being annoyed at every other bored user playing with the bot
 
9:01 PM
that's fair
lol I do that(I spend quite some time in the sandbox)
 
9:12 PM
would it be appropriate to flag my own question to get it deleted and hopefully lift my questions ban?
 
deletion won't affect your question ban
 
that's a shame
 
Sep 1 at 14:54, by Andras Deak
85
A: Can self-censoring end up with a question ban?

Shog9Deleted posts are mostly irrelevant to the question ban. If someone tells you otherwise, tell them they're wrong; if you see a meta post that says otherwise, edit it. What matters are poorly-received posts. That is, questions that are downvoted, closed, or flagged as inappropriate in some way. ...

 
it's been more then a year
 
see that and my few subsequent messages
@johnsmith you should have a free question every 6 months
 
9:14 PM
nope
 
> If you're unable to improve your existing questions, you'll get the chance to ask one new one 6 months after your last question. If that question is positively received, you may be able to continue asking questions; if not, then the ban will be reinstated.
 
wait nevermind your right
I just didn't remember asking a question a couple of months ago sorry about that
 

« first day (3255 days earlier)      last day (1708 days later) »