« first day (3420 days earlier)      last day (1511 days later) » 
00:00 - 18:0018:00 - 23:00

12:00 AM
Yeah, that's the world of tanks version. But he may have linked that here.
 
wim
pretty sure it was a gif , not a video
 
It was a gif
 
 
1 hour later…
1:33 AM
I DID IT @@@@@@@@@@@@@@@@@@@@@@@@@@
just finished my first django application, a website and a blog <3333333333333
but honestly, back to pandas hahaha
 
hey guys
I need help with something, can you please visit my question about my python calendar program?
 
2:14 AM
FYI last few hours to take StackOverflow's 2020 Developer Survey. Make your response count - even if you believe management are destroying the community.
I changed my mind and agree with @roganjosh that the survey is worth completing, even if it's just self-reported user demographics and comments, without tying it to (gasp!) looking at user handles to try to semi-objectively measure a user's credentials, experience and SO contribution. Badly-implemented as the survey is, it's one of the few feedback channels SO management listen to with half an ear. Also, a good place to mention Codidact as an an SO replacement.
 
please, I would appreciate if someone helped!
 
@navodithshankar Hi, please obey the room rules, you're not allowed post here soliciting answers on a question <48hrs old. Also, please edit your question to fix the code formatting, otherwise it's really hard to read and less likely to get answers. Please see Meta for much good advice on formatting questions.
 
wim
3:01 AM
I think that's not a "feedback channel", it's market research.
Codidact looks promising, if it ever gets off the ground I will migrate my content there
 
3:29 AM
In 2001, no school in Miami-Dade county got an F, whether it was elementary, middle or high school.
 
3:40 AM
Hey Guys I need help
I am having a excel sheet containing some names in 1st column and organizations in 3rd column I wrote a script for getting the organizations which contains "university of minnoseta" in their sentence and their names in the 1st column
my code is this https://gist.github.com/glakshmi-nyros/c6a8cc1eda6110eb5200198f1ab1961a
o/p example: Medicinal Chemistry, University of Minnesota
Austin Westberg
Now in this url https://myaccount.umn.edu/lookup?SET_INSTITUTION=UMNTC&type=name&campus=a&role=any&CN= when I search for Austin Westberg I will get details from that email should b
 
3:51 AM
can anyone help me ?
 
Dude like cant you read?
for rhubarbs sake....
Even I know I need to research for 2 hours before asking a question (thanks @JonClements)
 
 
1 hour later…
5:20 AM
cbg guys o/
@JonClements :)
 
 
1 hour later…
6:26 AM
Hello I am trying to scrap the email based on name from this url : search.rutgers.edu using selenium code is pastebin.com/5Gh0QRtF when I run this everything working fine I want to print the email for that name but it is not printing anything even I wrote the print statement can anyone help me
 
6:45 AM
@JossieCalderon We like to keep the room clear of profanity.
 
@smci <gasp> I've just woken up; there's actually (the tiniest bit of) snow on the ground and you're agreeing with me. It's a Christmas miracle!
Oh, crap, no. Its 7am and I've gotta get out of bed for work :/
 
@roganjosh adulting is hard :-p
 
user10984358
waking up at 7 for a 9 - 5 for work is way too early?
 
cbgg guys
 
@TheNamesAlc I start anywhere between 7:30 and 9
 
user10984358
6:52 AM
I am usually tardy so I took a studio flat next to my intern workplace, that way I dont have to worry about traffic, you better get ready :)
 
@shad0w_wa1k3r why haven't we automated this yet?
I guess Skynet taught some lessons
 
Glitch in the matrix
 
If you dont mind can you people see my last message and can help me?
 
@shad0w_wa1k3r Thanks for yesterday. Do you a good book on Django you can recommend? I have finished the tutorial in the documentation, watched some videos on udemy and now reading two scoops of Django, a good book but I think it just scratched the surfaces. Any idea?
 
@superv No, don't have any book recommendations, I never read any. Just the official documentation + lots of work / projects. I think these should be good though - realpython.com/tutorials/django
 
7:03 AM
@stack your message has been seen, don't worry. We're also real people that are helping for free and have our own priorities. Please don't presume that we'll drop everything to work on your problem; give it time
 
Ok Thankyou @roganjosh
 
7:21 AM
@shad0w_wa1k3r Thanks. Just a quick question, when I do context['contract']= Contract.objects.filter(pk=self.kwargs.('pk')), the contract list disappear but when I do context['contract']= Contract.objects.all(). I get all the list in the model. What I actually wanted is the single object for that view. Line 43 here: dpaste.com/3Z8GCR3. Thanks
 
@superv That's inside a DetailView, which will have the pk belonging to the model attribute of the class i.e. RentalProperty. So, you need to fetch your contract on the basis of the RentalProperty object, not some random kwarg.
 
7:36 AM
@wim I see. back to square 1 then! So, if the value of the Enum doesn't matter, why even bother with having values? Make them all None or something?
Er no wait, they can't all be None, the values do have to be different for different items. Scrap(e. couldn't resist) the last part.
 
7:58 AM
Does it makes any sense that people are suggesting for edits to write 'the' as 'The' or anyother stuff that are not improving any answer at all
 
@shad0w_wa1k3r I don't fully understand you. Do you mean I should do something like this? filter(rental_property__created_by=self.request.user).order_by('created_at')
 
@Codewizard If there's an edit with just that then no. There's a reject reason based exactly on that
 
@PabitraRoy Please see the room rules. You should wait a minimum of 48 hours before posting a question from main here
 
okay . I respect the rules. I will take care about that from next time. But I have to meet the deadline too. @roganjosh
 
We all have deadlines. Unfortunately, other people's deadlines are of no concern to anyone else
 
hmmm...
 
Hello I am trying to scrap the email based on name from this url : search.rutgers.edu using selenium code is pastebin.com/5Gh0QRtF when I run this everything working fine I want to print the email for that name but it is not printing anything even I wrote the print statement can anyone help me if you are free?
 
8:33 AM
@stack This is the second time you've asked the same question. I've already said that people will have seen your question
 
Yes but sorry @roganjosh I thought that my question does not reach the people
 
2 hours ago, by roganjosh
@stack your message has been seen, don't worry. We're also real people that are helping for free and have our own priorities. Please don't presume that we'll drop everything to work on your problem; give it time
 
@superv yes, I suppose. I'm not aware of the relations, but you seems to be on the right track with that ...__created_by=request.user
 
@stack It's literally the first sentence of my reply
 
Yes Ok sorry @roganjosh
 
8:54 AM
@shad0w_wa1k3r I will try that out. I have one solution, here: dpaste.com/39BT0G4, this display the single objects multiple times in the template with the contract objects while the second solution here: dpaste.com/0RGC9Z9, display a single object of the rentalcontract but muliple objects of the contract object. Which one of the two is a better solution that I should to to fix? Thanks.
 
9:37 AM
@JossieCalderon please dial back on the cocaine in your messages, and please use child-friendly language here
@JossieCalderon also drop the snark at others
 
Has anyone had this error? It's from matplotlib on Python 2 (don't ask me why I use the old version, there is no other option for me :( )
I am not sure how to "install Python as a framework on Mac OS X"
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends.
 
@codinggirl why do you use the old version?
 
"If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information."
@AndrasDeak I am investigating on a code from Rutgers University. It uses the weave module which is a standalone package, separated from scipy and available on Python 2.x only
 
@codinggirl boo :( Are you learning the weave part? Or the python part? Because you really don't have to compile embedded C code.
 
cbg all, bugrit
 
9:49 AM
http://www.physics.rutgers.edu/~haule/681/src_MC/python_codes/ising.py
This is the complete code. Seems to be a problem to run matplotlib on python 2 :/
 
Yes, all sane libraries have dropped python 2 support by now.
@codinggirl And that link is not an answer to my question
 
that sucks -.-
I am investigating the python part so the weave part is not that relevant to my work
 
Unfortunately Python 2 has reached the end of its life, and many developers are starting to support Python 3 only. I'd recommend porting to weave Python 3, but that would be an ambitious project for someone whose major interest is getting the results of a computation. It does kind of suck, but 2.7 was released fifteen years ago ...
 
@codinggirl so you might want to find a non-ancient tutorial
 
Have you looked at scipy.weave?
 
9:53 AM
I was trying to find an alternative for weave in Python 3 but I guess I have to learn how to convert C into Python code...
 
The only reason weave is there is to speed up the tight simulation loop. Numba could do most of that for you.
 
@holdenweb weave in not supported by scipy anymore, as far as I know
 
@codinggirl I can help with that if you're in no rush
 
@AndrasDeak that would be amazing, how much time would it take for you?
 
15 minutes plus making sure it works, but I have a busy day or two ahead of me :)
 
9:56 AM
@codinggirl Sadly correct. Apologies.
 
@superv dpaste.com/39BT0G4 is better or rather, correct (I still think you don't understand what you're doing with the template data). Also, you no longer need lines 25, 30 & 35, since you're fetching the contract from the rentalproperty contracts.
 
@AndrasDeak that should work for me!
 
@codinggirl alright :)
Incidentally this simulation is right up my alley. I work in computational solid state physics.
 
@shad0w_wa1k3r Do you mean I still don't understand how it works or what I am doing? I will be glad if you can expanciate. Thanks
 
@superv Like I said, only things that you explicitly pass to the template's context are available for use within the template (unless you're using DetailView or ListView, where only the implemented variables are available given that you've set it up correctly), so contract variable in your template is not the same as the contract variable in your view. The one in the template gets defined in your template's forloop block.
Basically, your new_rental view is not related to your template in dpaste.com/39BT0G4
it's only related to the DetailView which only passes property variable to the template's context
 
10:12 AM
@AndrasDeak haha, what a coincidence!:) Will you post the code here? Lmk if you prefer using a different platform for this.
 
@codinggirl I'll post it to a github gist and ping you here
 
@AndrasDeak cool
 
recbg o/
I wonder if the method send_file(in Flask) is appropriate for sending an audio file or should we use streaming api?
The thing is audio file will be played by the client and not downloaded.
 
That sounds like something that can easily be tested
 
Uhm? tested as in which one is faster?
 
10:24 AM
more like which one is better to hear
(no stutters, etc.)
 
or which one works at all
 
@TheLittleNaruto which one works?
 
I'm supposing the normal one would work, but that's a bit stronger assumption than I'd like to make. I've done it for videos, so I guess audios aren't that different.
 
I tested send_file for now and it's working
@shad0w_wa1k3r normal one means send_file?
 
10:26 AM
I'm wondering if it might be browser-dependent
 
If it's good enough, I don't think you should venture into streaming (unless you're really interested) since it may take a good chunk of time to implement, should be fun though.
@AndrasDeak Negative. At least for most modern browsers.
 
neat, thanks
 
@shad0w_wa1k3r Do you mean no data is coming from the new_rental view to the template? and am i suppose to pass it as a context to the detailview? I try iterating through "contract" in the templates, nothing happens
 
For our case, the clients are iPhone/Android apps
 
@TheLittleNaruto If that's a very important feature, streaming might be worth the implementation (if it's not your regular 3-4 MB MP3s or the likes)
 
10:29 AM
It can go beyond that
Okay so I should try streaming implementation too.
 
I'm not that experienced, but I think streaming would help. You should research more.
@superv The template you've mentioned in the dpaste is used with the DetailView & not the new_rental view.
 
Hey a small help which tool is easy to learn and best for web scrapping with python??
 
I'll. Melon Andras, Sha, Arne!
 
@superv Hence you can't interact with the contract variable since it's not present. Django templates just silently ignore errors like that (not defined, etc.)
I'm not sure of what is *easier*, since that's contextual, but I can say you may try
1. https://scrapy.org/
2. https://www.crummy.com/software/BeautifulSoup/bs4/doc/ with https://requests.readthedocs.io/en/master/
 
@shad0w_wa1k3r Now I got your point. Does it mean I either create a new template for the new_rental view, or pass the context to the detail view or remove the detail view?
 
10:35 AM
Also, it's called scraping, with a single p.
 
@shad0w_wa1k3r is selenium a tool or not for web scraping?
 
@superv Create a new template for the new_rental view.
@stack 3. Selenium :-p
 
Scraping -> scray-ping. Scrapping -> sk-rap-ping.
 
I followed the documenatation tutorial and they did something similar to this, but that doesn't look complicated :)
 
Ok Thankyou
 
10:36 AM
@stack yes, it can be used, but it's not meant for that I suppose.
 
So you are saying its not for scraping
 
It is not made for web scraping, it is meant for automation & testing primarily, but can be used for scraping.
 
ok fine
 
I imagine selenium has too much overhead when you don't need it
 
10:38 AM
Simply put, scraping, if done at scale, can / should not be done with selenium.
^^
 
@shad0w_wa1k3r Thanks for all the help.
 
you're welcome. I would suggest taking a look at some existing Django projects so that you get a better idea of how things are.
 
I tried one with selenium could you people once see my last message and help me?
 
github.com/django/djangoproject.com should be a good example I think, there may be others out there. Shouldn't be hard to search for.
@stack I saw that message but for some reason I'm unable to open your pastebin link.
Kindly use a different paste service & I might take a look once I get time.
 
Ok I will @shad0w_wa1k3r
@shad0w_wa1k3r dpaste.com/15ZTBJE I had pasted the code in this once see is it opening?
 
10:44 AM
It works for me
 
@AndrasDeak Can you help me ?
 
Nope
 
Ok
 
@stack Looks good to me. Code should theoretically work. I would suggest printing out the variables and checking. Or better yet, do this inside an interactive session instead of simply running / executing the script.
 
Yes I tried printing out the variables but not worked so I am asking is the code correct or not?
 
10:49 AM
@shad0w_wa1k3r I got it fixed by using the first solution. I did property.contracts.all to iterate on the contract and it work now. I really appreciate man.
 
@stack If it doesn't print then isn't it incorrect by definition? I checked your xpaths, they seemed correct, but I'm not aware of your setup, so there maybe some other issues. Did you try the interactive approach I mentioned in the earlier comment?
@superv good going
 
what does this interactive approach I dont know @shad0w_wa1k3r
 
How are you currently executing your script?
 
by running the python script in the terminal
 
Can you mention the exact command?
 
10:53 AM
python3 script.py
 
Okay, then you can start an interactive session with just python3 command. See here for more info - en.wikibooks.org/wiki/Python_Programming/Interactive_mode
shad0w_wa1k3r@Proness-Aura:~/my_cwd$ python3
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
>>>
 
@AndrasDeak - why was I banned when I have asked genuine question I am faced with?
 
@variable you have been told plenty of times. And please don't rude-flag messages that aren't offensive. If you object to how you're being moderated here raise a custom moderator flag. That's possible to do in chat but it's easier to flag one of your own posts on main. I'll gladly explain to any moderator why you're the subject of hard moderation.
 
@shad0w_wa1k3r I am able to open the search results page of "Taraq" and but not printing the email of him in the search results
even with both interactive and normal approach
 
@stack If you are in the interactive mode, then see what you get when you try accessing the email elements. You can print things & see what's going wrong. I think there's an issue doing a .text with the element, it may not give what you want.
 
11:06 AM
then what should I try now in .text place
 
I recommend using the interactive session because you can keep trying different things with the same variables until you have all the right data, which you can then put inside your script.
@stack That would depend on what element you're getting. You can check all attributes associated with a particular variable by doing dir(my_variable). Sometimes you may also find help(my_variable) useful.
 
here varaible means what you are taking the element in the html or var in script
 
@stack Variable would mean something like your items, or items[0].
The one in your python code.
 
cbg
 
@shad0w_wa1k3r in reactive session should I need to execute every line seperately
 
11:21 AM
@stack Not necessary. But you should execute each code block / line separately if you are debugging after each & every step (since we want to find out where exactly things go wrong)
 
dpaste.com/15ZTBJE so in this code I need to paste all from def(name) to print statement once right?
 
@stack No, you should do it line by line. Once you get to line items = driver.find_elements_by_xpath('//*[@id="content"]/div/div/dl[3]/dd[1]/a'), execute it & then see what is the content of items by doing print(items). If there's nothing there, then you need to try other xpaths.
Since the interactive console automatically prints the output to the console, you can simply do driver.find_elements_by_xpath('//*[@id="content"]/div/div/dl[3]/dd[1]/a') and you can see what you got in return. If that's not what you want then change the xpath or other stuff till you have the right code / line.
@stack example interactive session for debugging purposes - dpaste.com/3KF2TE1
 
11:44 AM
from the interactive session I am not able find my chromedriver
Ok sorry @shad0w_wa1k3r I got it
Now getting error as selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@type="text"]"}
 
12:08 PM
I am getting this error: UnboundLocalError: local variable 'seq_name' referenced before assignment, with the following code: paste.ofcode.org/33MWXjsszEdisn5PmEDgv4V
As far as i can see seq_nameis being assigued within the function and thus within scope?
 
@Lamma Because if if 'Identified secondary metabolite regions using strictness' in line: is not True, it doesn't get defined
 
ah so an else continue would help here?
 
No, because you would still be doing if seq_name in line so it will still have to do a name lookup. continue would not break out of the function, but else: return would if you had no further reason to continue in the function. Otherwise, you'll need to define seq_name as some default value in the else:
 
okay I will give that a try. That is odd though as there is no situation where if 'Identified secondary metabolite regions using strictness'should not return true
 
@stack There you go, you found the root cause, now try and see why that happens when you execute the script (or use the interactive console), but doesn't happen in actual browser. Also, note that you can interact with the selenium browser that is active from the interactive session. That way you can check the xpath in the browser console (find element or using javascript) as well the interactive console session (python code)
 
12:16 PM
Yes but actually I had copied the right x-path from the website
 
Like I said, test that xpath in the selenium chrome launched because of your interactive session.
Or try different xpaths (or css selectors) till you get the right one (which works in the interactive session as well as the browser)
 
Ok I will try like that Thank you @shad0w_wa1k3r will ask If got further doubts
 
sure, good luck
 
1:13 PM
I nominate @shad0w_wa1k3r for Patron Saint of Web Scrappers
and cbg
 
@PaulMcG haha
cbg
 
You have way more patience than I
 
Sometimes, yes :)
 
2:07 PM
fwiw, I like him, and appreciate his moderating
6
 
I want to use pytest to test the output file generated by running popen on an executable. I need a pointer on how to proceed. I can test the return code of popen but I want to also test that the command and file generated are as desired
def copy(self, myfile):
        temp_copy = subprocess.Popen(['executable', '-c', self.myfile, '-out', self.tempfile])
        return self.tempfile
 
that code doesn't look right. You are ignoring all parameters and variables.
 
yes its not the complete code. its just a folow up to my question here: stackoverflow.com/questions/60145401/…
I just need a pointer on how to proceed
 
2:53 PM
Presuming that executable creates some file, then your test should just open it and verify its contents are what were expected. It looks like you know the file path, so using pathlib.Path, you can get the contents with contents = pathlib.Path(self.tempfile).read_text()
 
awesome, i did not think about opening and reading the file. How do I ensure that the args passed to the executable remains the same. This is cos the executable can have many args that generate multiple files
 
It looks like you are in control of that too - isn't the output file path in self.tempfile?
 
for example exec -f may give txt file and exec -c may give binary file.
yes so if someone goes into my code and changes -c to -f, a file will be generated
so it will not fail if I am checking for file output assuming -f and -c generates txt file
 
You will have to make your code smart enough to handle the two cases. If -f and binary is created, then you would call read_bytes() instead of read_text().
You could open a text file with read_bytes() also. This would be a good time for you to do some hands-on experimentation.
 
sure @PaulMcG Thanks for the pointers.
 
3:01 PM
@Starter wouldn't you detect that because the content of the file would fail the test?
 
@MisterMiyagi if the 2 options generate the same file format with different values, I wont be able to detect that
it will be nice to know when the options have been changed by someone else e.g from -c to -f but the result is still a text file
 
This doesn't seem like a task for unit tests. If someone can change your code, they usually can also change the code of your tests.
Unittests should verify output, not implementation.
 
3:30 PM
@Arne <3
 
3:41 PM
Just read a question where the asker says "how do I do a thing with library X" and the answer is "not sure have you considered library Y instead, it's simple". To me, that is not the answer and should never be accepted or upvoted. This is akin to suggesting another language as a solution in my opinion. Apparently the community disagrees with my opinion here
 
user11585758
Guys
 
user11585758
I was importing , how to import other folders .py files in my directory but it is not importing as in google.com/…
 
user11585758
Can we import variables from another .py files
 
@Dodge it depends on the problem and X and Y. Often the answer is Y.
X might just be due to misconceptions of OP.
 
@Dodge "How do I turn an png into a bitmap with requests?" should probably be referred to an image library though? At least in the same breath as some absurd answer that actually manages it.
 
3:45 PM
@AndrasDeak I agree but this instance is np vs sklearn so really a preference, I'd say
 
@toonarmycaptain or more realistically, "how to scrape a full-JS website with requests?"
@Dodge maybe, yeah
 
user11585758
I am using colab.
 
Always find it creepy to get emails from linkedin saying: "... people are looking at your profile"... You'd have thought of all that's available they'd have better things to do :)
 
@Dodge Remember that you are part of the community. Upvotes and downvotes are subjective, if you feel an answer is inadequate or another is better, vote.
 
3:48 PM
I have done this with np but have been doing more with sklearn. Just thought it was strange that the accepted answer is numpy
 
user11585758
I think to use polynomial regression
 
@Dodge borderline. Sklearn builds on np so it'd make sense to use np. But the general alternative would be scipy...
 
@MisterMiyagi you know that's actually a really good point
@AndrasDeak Ah, interesting
 
@Dodge accepts are irrelevant. They are as reliable as the asker. Look at votes.
 
This is a bug in my brain, though. Need to fix my tenancy to overemphasize the importance of accepts
 
user11585758
3:51 PM
This might may help towardsdatascience.com/…
 
user11585758
I switched problem its working
 
4:22 PM
if you want to inherit from a list of objects can you do:
class subClass([objectList])
?
 
No, but you can unpack a list as the base classes such as class subClass(*objectList) - but if you're going down that route you better know what you're doing or doing some weird stuff with meta programming...
 
I think @Permian wants to inherit from list and contain a bunch of objects
 
@PaulMcG yeah
 
@PaulMcG ahh... seems you're right... guess I took that far too literally :p
 
And I assume that the purpose for this is so that you can define some extra methods for this list?
 
4:25 PM
(me jumping thinking about type factories and all that :p)
 
Sometimes it doesn't pay to be too smart
/me waiting for response from @Permian
 
no its just class needs to inherit from a list of the same objects
 
So what is the purpose of this class, that you can't just use the builtin list class?
 
i cant remember now lol
it was in an interview
 
One does not typically define special classes for all the lists of various objects they might contain.
 
4:29 PM
look i cant remember
 
Inasmuch that you don't have anything further to go on, the answer to your question then is "you don't do that".
 
ok haha
i have another question
set A = {10, 20, 30, 40, 80}
set B = {100, 30, 80, 40, 60}

set A - set B = {10, 20}
how is the "set minus" there implemented?
 
@Permian look up "set difference". It's math (i.e. not programming).
 
Compare with set B - set A. Stare at the results until you discern the answer.
 
the implementation is surely programming
becuase you have to search the arrays
 
4:33 PM
@Permian yes, but it's implemented such that it does math.
 
which would be O(n^2)
 
@Permian ah, so you really did want to ask about the implementation, sorry. With you I never know.
 
@AndrasDeak why?
"with you i never know"
 
new_set = {each item in A if it is not in B}
 
@Permian because sometimes you ask focussed questions and sometimes you do that
 
4:35 PM
This is O(len(A)) since "if it is not in B" is O(1).
 
I remember a few weeks ago you surprised me by misunderstanding something very simple, considering the kind of things you usuallly ask here
 
@AndrasDeak lol
 
It's pretty cool, might work as a lightning talk if it's rejected.
It's something I've got in the back of mind for something I'll be working on eventually, as I imagine I might be able to use it to parse student answers to algebra questions.
 
this morning I stumbled over this mess of a question, now I've just seen this almost as messy question which has practically the same code, plus a few useless lines extras.
is that a dupe? sock? plagiarism? course assignment?
 
The second one cites a GitHub repo as the origin, I'm guessing this is owned by a classmate of the two questioners.
 
4:48 PM
@MisterMiyagi both users registered 16 days apart 1.5 years ago. First user has two downvoted questions, newest 17 hours ago. Other user has two questions, older 6 hours ago. Huge chance of socks, worth a flag.
 
ok so it looks like set is a hashmap, so it just a case or iterates through one of them
 
I have class of name OPEN which is supposed store some unexplored nodes of a graph, I created this class because I wanted to create a priority queue over a list and override some function like minimum which finds the minimum of the nodes according to some parameters. In this class I have defined a method with the following code:
def __min__(self):
    return min(self.cont, key = lambda x:x.f)
But when I am using I am getting error that OPEN is not an iterable.
Here self.cont has been definited under the __init__ method, and I have initialized it with a list, which is an iterable.
Is this description sufficient, or I need to provide an MCVE?
 
I don't think __min__ is an existing dunder method, and it's usually frowned upon to define your own ones
@AjayMishra MCVE, please
 
there is no special method corresponding to min. It uses __iter__.
 
class OPEN:
    def __init__(self, cont):
        self.cont = cont
    def __min__(self):
        return min(self.cont)

op = OPEN([1,2,3])
print(min(op))
 
5:03 PM
yeah, min(op) tries to iterate OPEN
def __iter__(self):
    return iter(self.cont)
perhaps ^
 
Thanks! :)
 
and then min(op) and list(op) and for val in op will iterate over the underlying list
 
@AjayMishra Do you just want to be able to get the "minimum" element of a container, or do you want the container to define what the minimum element is?
 
I want to define what the minimum element is.
Basically I am trying to solve a maze by implementing A* algorithm.
I wanted to get the element( or node) with lowest value of f. Where f = distance from start + ~distance from end
 
you need to implement your own helper or method for that. The builtin min does not allow the iterable to override the sorting of its elements.
You can implement the ordering in the elements, though. min use the element's __lt__ special method.
 
5:14 PM
So @codinggirl that ising simulation is a mess in terms of programming style. Are you trying to learn python from it, or Ising simulations? I suggest that you don't use it for the former, and it's quetionable to use for the latter... Anyway I've updates the code to python 3 here. I fixed a bunch of style sins but there are still a lot left. I added numba as a "dependency" to compile a version of the simulation function.
Compare the runtimes of SamplePython and SamplePython_jitted (change commented lines here). The point is that you don't need the weave-y function: that just implements a similar simulation just using C++ (we can use numba for that nowadays). I did change the implementation of the pure python function to reflect the functionality of the C++ one.
Let me know if you have any questions, and again, beware of that code, it's not nice at all.
 
@AjayMishra I believe what miyagi mentioned is what you're looking for without realising it. if you want a custom class to understand max or min or sorting, you just define it's comparison and equality operators and let python figure out the rest. also, take a look at this
though then again, you are defining all elements inside open. So it's a bit weird that way compared to how i'd have imagined this setup
 
You can also define a regular op.get_min (or just .min) method that uses min(self.cont, key=...) to compute the min. That would be consistent with composition.
 
^ would keep it simple too
 
5:42 PM
@AndrasDeak, What did you mean by "drop the cocaine in my messages?"
 
@JossieCalderon that you should strip down the excessive nature of your communication as exemplified by these messages, among others. It comes across as off-putting and doesn't put you in a good light. If you look around everyone is calm and balanced here, there's no need to be overly excited and bounce off the walls.
 
Thanks for your reply, but how am I supposed to celebrate completing a task?
 
You can dab all you want in front of your computer :) Just filter between the keyboard and your hands.
 
Well, that's fair.
 
thanks for understanding
 
5:54 PM
Andras, what should I use this room for?
 
00:00 - 18:0018:00 - 23:00

« first day (3420 days earlier)      last day (1511 days later) »