« first day (4242 days earlier)      last day (697 days later) » 

12:21 AM
the goal is to run a Python script on the current interpreter, as a separate process? (i.e., the underlying problem really would not be better addressed by just `import`ing something?)

The `runpy` standard library module might be helpful here: https://docs.python.org/3/library/runpy.html
 
yeah I should checkout runpy
stackoverflow.com/questions/749711/… has part of the solution
 
12:39 AM
Worst case, I suppose you could read the file contents, create a new process with multiprocessing, and have it exec the code
I really do mean "worst case" though :)
 
the hack I posted works fine
 
 
2 hours later…
2:19 AM
https://stackoverflow.com/questions/72411595

this is a matter of general programming technique, yeah? Does it fit any existing duplicate mold?
 
 
2 hours later…
4:05 AM
https://stackoverflow.com/questions/72412738
Having quickly re-checked https://stackoverflow.com/questions/how-to-answer, I really don't think it's explicit enough about not answering dupes (and why). The existing wording comes across as a weak suggestion.
 
 
4 hours later…
7:41 AM
So apparently my linux install, which I haven't booted up in months, has self-destructed somehow. Just boots into a black screen. How the heck does that happen?
 
7:52 AM
Huh, no idea
Grub stuff broken?
Or is this after trying to boot into it? Probably this.
Can you boot in some safe mode?
 
8:17 AM
Not worth trying tbh, considering all the problems I had with it. I'll just reinstall
 
Now that you mention it, there was an update once that broke grub. But this is different, this is after grub
 
 
1 hour later…
9:34 AM
@Aran-Fey Used to happen on my VM, waiting for so long and rebooting for 10 times works :/
 
10:13 AM
I installed the new linux on a separate partition, which was a good idea because the fresh install doesn't boot and the old install suddenly works again (and better than before!) ¯\_(ツ)_/¯
With some luck I can become a linux user again... we'll see
 
How to share my code and ask some problem here ?
May I paste my code here ? Is it ok ?
print("hello world")
 
If it's longer than 10-15 lines, post it as a github gist or something
 
11:15 AM
I am unable to solve my problem for the last 7-8 days. I want help with this python program.
https://gist.github.com/M4MURARI/6915e291e0507dccc326f027824241b7#file-annotation-py
 
11:26 AM
@MurariMahaseth so you basically want what you have now, just without the empty dicts?
 
Just remove res1 = dict() etc, and then put newlist = [] at the top, and when you have res1 = [strt, ...], put newlist.append(res1) after that line. And then do the same with the other res* cases.
Which is not to say you couldn't refactor all that, but this seems like the most immediate solution.
looks like you could use a single loop over the three "constant" lists, because the loop bodies seem to be the same
 
I will update here the result after trying your suggestions
 
entities = {
    'CROP': ["rice", "wheat", "mango", "Potato", "onion"],
    'INSECT': ["Thrips", "stem borer" "pod borer","aphid"],
    'DISEASE': ["late blight","blight", "brown rust", "wilt", "Sheath blight", "False smut", "Yellowing"],
}

NER_data = []
for s in sentences:
    newlist = []
    for entity_type, names in entities.items():
        for w in names:
            x = re.search(...) # etc.
            if x:
                ...
                res = [strt, end, match.replace(match, entity_type)]
something like that ^
note that you have a comma missing between "stem borer" and "pod borer" which are implicitly joined into a single string (but this is probably just your small example)
 
comma is not missing between "stem borer" and "pod borer".
 
12:16 PM
For now, I am exhausted. I know your time is precise, but if possible, please share the full working solution to my problem. I have made my gist link public. So, there or here you may share your valuable effort. Otherwise, I will try to implement your suggestions in next sitting. For beginners of python like me, takes many hours to debug.
 
 
1 hour later…
1:43 PM
match.replace(match,"DISEASE") is a fun way to write "DISEASE" :D
 
 
2 hours later…
3:14 PM
Can someone please help me understand exactly what this line does. I am familiar with converting integers to/from hexadecimals, but this string formatting is mysterious to me
hex_color = "%02x%02x%02x" % (255,255,255)
 
% is the placeholder, x means hex, and 02 means "pad to a width of 2 by adding 0 characters if necessary"
 
Thank you :) It was the 'x' that was throwing me off in the string.
Then as far as the "%"... is the % just an operator that can replace format((255,255,255),("%02x%02x%02x"))?
 
Well that's not the right way to call format, but generally speaking yes, % is an alternative to format
Well. Sort of. format only takes a single value as input and turns it into a string. % takes a string and multiple values as input.
It's more of an alternative to str.format and f-strings
 
Whoops - I didn't realize that. Just typed that format code into the chat under the assumption that it would process an iterable object.
So something like this instead:
r, g, b = (255,255,255)
hex_color = f"{r:02x}{g:02x}{b:02x}"

For me at least, the f-string is easier to interpret than the modulus operatorg
Thanks @Aran-Fey !
 
3:34 PM
@JacobBumgarner yeah
 
 
2 hours later…
5:08 PM
@Aran-Fey It seems you are funny and have good sense of humour 🤣
But the replacement was due to match with any of DISEASE's list element. I will appreciate if you will reach to my goal ie. expected output.
 
5:23 PM
In India, now it is 10.55 P.M., time to say good night... 😍
 
You have a lot of repetitive code. Here's how I would do it.
 
missed opportunity for an assignment expression there
 
It took a bit of willpower, but I missed it on purpose :P
It's because I'm riding my bike today. Next time I'm driving my massive truck, I'll hit the walrus for sure
 
5:48 PM
Hello guys
What is difference in aiofiles, when used before for loop vs used inside for loop?
async with aiofiles.open("some", "a") as t:
         for s in arr:
              await t.write(s)
vs
for s in arr:
       async with aiofiles.open("some", "a") as t:
              await t.write(s)
second one imagining , it is already wrapped in async func
 
Well, the 2nd one opens and closes the file a bunch of times.
 
ok i also got same answer . i thought if asyncio do magic but ok
 
6:18 PM
@Aran-Fey xD one day for sure
 
6:56 PM
@Aran-Fey OMG!!! You became my Hero. Either God exists or you ! You inspired me a lot. You became my lifetime inspiration... No words can express my feelings...Lots of respect for you... I promise, I will also try to learn Python similar to your pythonic level...
 
make sure not to hit the walrus on your way
 

« first day (4242 days earlier)      last day (697 days later) »