« first day (3615 days earlier)      last day (1547 days later) » 
10:00 - 18:0018:00 - 23:00

10:41
Ah gotta love people who write documentation. "To see the available options, check out the code". Wow like, yeah why even write that in the doc xD
10:55
That's generally a "do not use" sign to me outside alpha releases.
Well I'm the first person to test the python bindings, it's written in C++
@Hakaishin There are some docs that I wish were this honest...
hi.. needed help here. i tried to import another .py file to my main pyhton file, but somehow it didn't work anymore. can anyone help? So I tried like this before:
`from . import lowerCasee`
and it worked before, but now it's not working anymore. I tried various step suggested by internet:
`from a.py import lowerCasee`
`from directory.a import lowerCasee`
`from directory.a.py import lowerCasee`
`import lowerCasee`
none of them work
11:16
@JackZakiZakiulFahmiJailani Please have a look at the code formatting guide
By "it's not working anymore" I assume you get an ImportError?
Did you change the environment, e.g. are you using a different interpreter or virtual environment?
@MisterMiyagi i use Spyder. I have downloaded previous Python for a case before, and now I'm back to the newest Python version. After that, I cannot import anymore any function from another file
11:31
What is your directory structure? Also, did you ever test the "working" version outside of Spyder? And have you gone from Spyder 3 to Spyder 4?
I made a lot of fuss about Spyder wonkiness to to the guy running the project and certain default settings about namespace and imports got changed going from 3 --> 4
11:44
@roganjosh the main python file and the file that I want to import are in the same directory. Soo I tried from . import lowerCasee. Somehow it worked in the past. But now it doesn't work anymore
You're not really helping us to pin down the issue. I asked multiple questions
That can't possibly have ever worked
If you have two python scripts in the same directory and you execute one like python3 path/to/main.py, then import lowerCasee should work
Something that's really bugging me is that the module looks like it should be called lowerCase.py, without the extra e. We have ruled out a typo from this, right?
@roganjosh I am trying to update my spyder right now. nice suggestion btw. For the typo, I deliberately name the file like that
Spyder 3's imports were more broken than Spyder 4 so I'm not sure it's going to fix anything. Then again, the Spyder version is at least loosely tied to your version of Anaconda and, therefore, Python. And thanks for clarifying on the typo; seemed a long-shot but something that should be ruled out regardless
11:57
wait, is lowerCase the name of a python file or a function/class/whatever inside that file?
^. What is a.py? And if a is the name of the file, and lowerCasee is the object inside it, then from a.py import lowerCasee would be from a import lowerCasee. Your imports jump between different setups
@Aran-Fey initially the file name is LowerCase as well as the function inside it and by only calling it from . import lowerCase it worked. now it doesn't work anymore, I tried to differentiate it by simply change the filename to a.py and the function name to lowerCasee and it still doesn't work
Ok. Can you confirm that from a import lowerCasee works if you run python3 path/to/main.py?
Does somebody know a good library ala CV2 for working with pointclouds? Something like pcl but for python?
12:16
@JackZakiZakiulFahmiJailani Surely from . import xxx requires the importing module to be a component of a package? Maybe that's it ...
@Aran-Fey it says there is no module 'a'
Then a.py and main.py aren't in the same directory
@Aran-Fey it is in the same directory
Then your computer is possessed by demons
Not again :'( Attacks are getting more prevalent
12:23
This is what happens if you don't regularly bathe your rubber duck in holy water
i think something went wrong after I downgrade my python version and upgrade it again
the no module a is solved now as the updated spyder recognize it now. i tried from .a import lowerCasee and now it says ImportError: attempted relative import with no known parent package
so it recognizes .a as the module, but there is something about relative import
So remove the leading . on .a
In any case, I think we're going to struggle to get to the bottom of this for you. Spyder 3 actually supported more magic on imports than was actually sane, so like I said, upgrading from 3 to 4 should make it harder to have borked imports work. I think you might just have a series of coincidences and you're mis-attributing observations to the actual mechanism behind them
@roganjosh if i remove . then it says no module named a. And my python version is 3.7. do u think it's okay?
12:42
I don't feel confident that I've got a footing on what you've actually set up so I'm not going to be able to help you sorry. Python 3.7 itself should be fine
i guess i will restart my computer first haha. thanks anyway @roganjosh :)
@JackZakiZakiulFahmiJailani A good idea to learn a little more about Python's import mechanism, since that may well allow you to better understand any oddities that Spyder introduces.
does that mean u don't use spyder @holdenweb? what do use then?
13:01
Pycharm is quite nice
with quite nice meaning, freaking amazing and I wouldn't touch any other IDE with a 10ft stick
I use PyCharm, but have also heard VSCode is comparably nice
@PaulMcG Meh I didn't like it, but it's still leagues better than eclipse, spyder
...almost anything except Spyder. I started with Spyder when I began learning, and had lots of problems associated with it.
Thanks for the hammer :)
13:05
... in the mornin', in the evenin', all over this land
The only similar issue I've had with PyCharm is that (even in it's inbuilt terminal) will find imports even when you don't have a complete path to them, which would lead to unexpected bugs for a beginner when my code didn't work outside of PyCharm (but at least PyCharm currently can warn that this is happening and let you chose how you format your imports).
downloading PyCharm now :)
At least that raised another quirk of numpy to my attention. I can actually see a 25% reduction in solver time just by switching out np.copy() in my code... that translates to 30 seconds shaved off runtime
@JackZakiZakiulFahmiJailani I use PyCharm for projects, IDLE+Debugger for competitive and sublime for small additions and modifications to code and of course text editing.
Thonny, Atom are both nice light end IDEs for Python.
13:10
Actually, I might be being too generous. Array copies are heavy but the outer loop is probably disproportionately heavy on runtime
@toonarmycaptain I've decided a few times to give Atom a try. But that doesn't seem to be happening any soon. How it actually is for projects OR competitive ?
raf
raf
Hi, I want to know if there exist any dedicated python modules so that it can convert all the location names into their country names! I have searched on Google but didn't find anything useful.
Relevant post:
4
Q: Converting location names into country names in pandas dataframe

rafI have a dataframe df such that: print(df['user_location'].value_counts()) India 3741 United States 2455 New Delhi, India 1721 Mumbai, India 1401 Washington, DC 1354 ... ...

@raf My initial guess is no, unless someone knows one ?
@PSSolanki I don't really use it often. It integrates well with git/GitHub, and I occasionally use it to do a quick edit. Depends on your preferences really...it's advantage for me is quickly getting a repo/finding a file in it's GUI, editing and saving/pushing, without slow starting or being resource heavy.
@raf you can try a wrapper around Nominatim to reverse-geocode the addresses
Or geocode. I forget which way is forwards :P But still, nominatim is the important part of my comment
13:20
@toonarmycaptain hmmm.. I actually use sublime now for quick edits, as it also allows to run the scripts and of course resources' friendly. But I will try Atom. Does it have code inspection and language interjection?
Honestly, Notepad++(Win)/Notepadqq(*nix) is what I use most when I'm not using PyCharm/nano.
@raf You might find more help if you google for "gazetteer", which will deal with place names. You can also download name lists from geonames.org
I use a subset of the US geonames list for littletable demos
@toonarmycaptain I use IDLE (just 'cause it also has a debugger :)) for those purposes.
@PSSolanki It's been awhile. I don't remember fully. I think it has some completions?
The only thing for me which notepadd++ can do which sublime can't is show line endings. Otherwise sublime all the way
13:23
@toonarmycaptain Got that. i'ma give it a go.
For quick scripting, SciTE is nice (and free), and has one-button 'Run' with side-by-side code edit and console output panes. A very fast alternative to Notepad on Windows (loads megabyte text files super quick), but no IDE features like autocomplete or projects. I used it for about 10 years before switching to PyCharm.
@PaulMcG interestin' ...never heard of it. Sounds good as an alternate of IDLE for me
most things are good as an alternative of IDLE
It is the text editor from the Scintilla project (SciTE = Scintilla Text Editor) scintilla.org
@AndrasDeak hehe true that. I don't even know why I use IDLE (maybe just 'cause it has a debugger or I am out of space on my notebook (i actually am :/))
13:31
Yes, I'm a long-term Wing user, and I believe it too uses Scintilla editing windows. Even the free version is good enough for many purposes.
Anything based on Scintilla has zoom-using-ctrl-scrollwheel support
I actually like that feature. Code::Blocks had this feature as well (but no dark theme built-in :/)
raf
raf
13:47
@roganjosh thank you.
Is it relatively stable? I've tried a few different wrappers before and it's hit-n-miss whether they actually do a decent job
raf
raf
@PaulMcG Thank you. geonames.org seems interesting!
Argh. Writing a simple website and PyCharm tells me I can't use align I have to learn CSS!
VSCode does the same. I ignore it
[Which is fine, and planned, but really, simple HTML tags are depreciated?]
13:56
Same with <center> and <font>
Styling should go in CSS sheets, not directly into the HTML
@Aran-Fey I do get this. I just didn't expect my IDE to complain so loudly about it lol
There's plenty that I'll put in CSS but if I want to render an error message, I don't see what difference it makes whether I return "<font color='red'>error</font>" or go to the effort of making some specific error font class in CSS
Inline CSS is a pain to customize with userstyles
I suppose it's more centralised but I haven't really bought into the html/css argument enough
Eh, my only defense is laziness on this. So yeah, you'll need to learn some CSS, toon :)
14:03
The worst offender I've found is actually SOpython, all the code highlighting is done with inline CSS there >_>
Were you working on a dark theme? :D
yeah
I was gonna start playing around with sopython code soon and had noticed that there wasn't really much going on with the CSS. I'll have a look at the inline CSS while I'm at it. I don't know about theme switching, though, so what's the important bit in your own site to flip themes?
I implemented global colours in my website, which means that it just won't work with IE users off the bat. But I'm not sure how you ended up being able to switch themes and store a user's preference
Javascript uses localStorage (if I remember correctly) to save the last active theme, and the themes simply set correspinding dark-theme/light-theme classes on the <body> element. The CSS then simply defines some variables based on a body.X-theme selector, and everything else uses those variables
(I'm not gonna implement a dark theme myself if I do start poking around with the code, but maybe I can move it towards a system better-suited to PRs for such)
@Aran-Fey that's the one; localStorage. Thanks
14:16
this is the JS code and here's the relevant styling (written in Stylus), if you want to have a look
14:37
I had my project packaged and installed, I then uninstalled it realizing I installed my own package in the same environment. Now whenever I try to run my project it says no module found named myprojectname.module and I guess it is because my project directory is trying to look for the installed project instead of executing imports from my local directory.
14:56
The import system iterates over sys.path in order, and "" is usually the first entry of sys.path, so it should look in the local directory before looking anywhere else
Why isn't his working now when it worked earlier : pastebin.com/pn21R0u9
@Kevin exactly but I am still getting that error
(disclaimer: creating packages has always been a terrific headache for me so any advice I give might just be flat-out wrong)
I wouldn't expect either of those directories to be importable, because neither of them are packages
i.e. neither one contains __init__.py
You should never execute a file from inside a package, that messes with your imports
Either place executable files outside or let pip create relevant console commands for everything (it's console_scripts in setup.py, I think)
@Kevin I forgot to add init.py , I'll update a second pastebin
@Aran-Fey That's after packaging is correct, but while I am using the raw project it should import I guess? or I am completely wrong here.
Even if both directories were packages, I wouldn't expect python1.py to be able to import either one, because neither of them are in sys.path. (assuming you haven't pip installed either one)
15:03
Packaging has nothing to do with it; the project structure before and after packaging (and then installing) is the same after all
Here is the updated paste : pastebin.com/Mi54AFSA
Which file are you executing?
@Kevin It did and i am working on it for so long now, only If I hadn;t installed that package
If you had a file python3.py in the same directory as setup.py, then that file would be able to import the inner dir1, because the inner dir1 is in python3.py's sys.path (in particular, the "" entry representing the current directory)
@Aran-Fey python1
@Kevin So should I move all .py to outer directory?
15:05
(reminder that I am often wrong about package minutae and you should test and verify any claims I make before depending on them in a production environment)
@Kevin Packaging is challenging, tip: never install your package in the environment that you are coding the project unpackaged
@AshwinPhadke That seems consistent with Aran-Fey's advice to move executable files outside the package.
Incidentally I vaguely recall that pip has a flag that lets you install packages in a debug mode that makes development easier
Okay, so it's still a bad idea to execute a file from inside a package, but it's not what's causing the import problem here. It's simply a matter of dir1 not being on your sys.path, like Kevin said. This is completely expected, and can be solved by installing your own package
I believe it's pip install --editable dir1
Or was it --symlink?
15:08
--editable looks familiar to me
pip.pypa.io/en/stable/reference/pip_install/#editable-installs. TLDR: in editable mode, you can modify the files of a package, and those changes will be applied immediately to the package, without you having to run pip install again.
(unless you're editing C extensions or other such files that have to be compiled)
So turns out all I had to do was remove the reference from dir1 from everywhere and it works fine
Greetings
@TanishSarmah hello tanish
Although most puzzling part is that everythin worked fine when I had not installed my own package and had from dir1 everywhere
15:12
That'll stop working after your project is installed if your project is imported rather than executed
@Kevin Ah TIL, I will surely check, it will solve a lot of problems
@Aran-Fey That is what I just realized
Why is python importing so messy
It's probably my least favorite part of the language
@AshwinPhadke I don't find it messy though :P
@Kevin I'm very tempted to ask where have you been :-) ?
Oh, here and there.
15:14
@TanishSarmah It is, imagine you did from dir1 import something for all this while and you then accidentally install the project you packaged realized that and uninstalled it and now nothing works because it cannot find module named dir1, but what>
The import system isn't actually hard to understand, it's just... not intuitive
@Kevin lol
Honestly, I don't see how installing and uninstalling could break anything. The project must've already been installed, probably in editable mode
@Aran-Fey No it wasn't but all these problems started after I uninstalled the project
@Kevin I've been waiting to tell you what I have concluded on that variance vs unfairness sum, It turned out to be unexpected (thanks to the guys at math.stackexchange)
15:17
@AshwinPhadke That's why I never name any of my file as the name of any python package :-)
Ah, the old "I reverted my project to the last known good configuration, but it still doesn't run"
My old nemesis
If the project really wasn't installed then your IDE must've performed some magic to make your imports work
@PSSolanki Cool. I'm glad some mathy guys were able to step in, because I couldn't come up with anything after thinking about it for the rest of the day
But it hardly gets to the 'same, old configuration' ever again. there is usually some broken links
@Aran-Fey Lol
15:19
And how did I found it was referring to the installed package is because while debugging I found out that the error I was having was coming from site-packages, why should it even go to site packages when all the imports should run from local directory, then I realzied I installed it so it is directly referring to installed package instead of local directory so I uninstalled it and then I am chatting here with you guys now
@Kevin lol
I think venvs are supposed to make this kind of problem easier to manage. You can't irreversibly mangle your site-packages if you always have the option to nuke it completely and spin up a new one
@Kevin here is what he did to prove they are not perfectly related :: HERE
@Kevin Wait, is the current directory really added to sys.path? I thought it's only the directory where the script is located. (Don't have access to python right now, so can't test for myself)
@Kevin I am not a fan of venvs, I almost always use global envs available
@ashwin me neither.
15:23
I, too, almost always use the global environment. But a lot of people tell me that venvs are one honking great idea
@Aran-Fey IIRC if a package is installed then first imports are done from packages
@Kevin That is the most stupidest thing ever
venvs are a comlete mess on top of actual pip install mess
@Kevin Namespace Packages called again. They feel neglected.
@Aran-Fey On my machine at least, "" is the first entry of sys.path, which means the current working directory is always searched first... I think.
The stupidest thing ever?
@roganjosh i might have gone overboard , but I really dont like venvs
15:25
@Kevin How did you start python, though? Just python or python file.py? Is that entry still there if you do python some/directories/file.py?
pip should have a banner saying never install your project where you code it
Umm, you kinda have to, though. Disregarding IDE magic and PYTHONPATH messiness.
I started python with python. Let's see what happens if I run python file.py... The first entry of path is not "", but rather "C:\\Users\\Kevin\\Desktop", which is the absolute path of the file.
@Aran-Fey I see this as a cache issue of pip more than IDE, as if pip mightve cached the install and still kept the temporary files then even if I uninstalled it it is still looking at those temporary files and trying to import originals throwing a module not found error
@Kevin You use windows?
Hmm. Trying to work out whether this changes any of the claims I made about the CWD being in the path. I don't think it matters whether the path is relative or absolute. (Provided you don't change the CWD in the middle of the program)
15:28
@Kevin @Aran-Fey the sys.path docs say when sys.path[0] is "" versus the script path.
@AshwinPhadke Yeah.
basically if there is a script, its path is sys.path[0]
@MisterMiyagi Oh, thanks
@MisterMiyagi They should be, I've crammed them into the dustiest corner of my crawlspace, next to the Halloween decorations.
Ah, here's a scenario where the CWD isn't in the path: if I'm in c:/users/kevin and execute python desktop/file.py, then the CWD is C:/users/kevin, but the first element of sys.path is "'C:\\Users\\Kevin\\desktop'".
@Kevin The thing is that python doesn't add the CWD to sys.path, only the location of the file you're executing. Sometimes those two coincide, for example if you do python file.py, but sometimes they don't, for example if you do python some_dir/file.py
15:32
Ok. I think we're on the same page, then.
So for the last ten pages of chat, everywhere I said "current directory", I should have said, "directory of the script being executed". I think the conclusions I drew were still valid though
python2.py still can't see the package it lives in, etc etc
I'm not sure whether I should be sad that I was flat-out wrong about the minutiae of packages, or whether I should be happy that I correctly predicted that I would be flat-out wrong about the minutiae of packages
everyone please have a look [HERE](https://stackoverflow.com/q/63774153/10145519)

This has taken an interesting turn, and i can't seem to figure out the math behind these dynamic programming concepts. (although it already has answers but first answer doesn't work for bigger test cases, and i'm unable to implement the second approach.)
I hv no idea why this markdown is not working :/
Almost all* markdown features don't work in multiline messages. No, I don't know why. Yes, it's dumb.
(*Or maybe just all? I forget if quote boxes still work)
I see. I tried that twice actually. had to delete previous msg.
@PSSolanki I saw that question earlier. It's borderline illegible on a phone - please layoff the CAPS plus bolding
@PSSolanki 1. I find the abundant formatting in your question atrocious. 2. we ask that you don't ask for help here with fresh questions on the main site.
(assuming you're asking for help; I'm still under shock from skimming the question)
15:44
Hmm, I could have sworn the question was asked on Thursdayish. Maybe it's a follow-up.
I didn't get as far as the timestamp. It's an assault on my visual senses
It is a follow up of the same question we were discussing 3 days ago.
@AndrasDeak my bad, Doin' it now :(
I'll take abundant formatting over no formatting any day :-P
If you discussed here first it's OK to link a subsequent fresh question here
@AndrasDeak It is. kevin, and I guess, MisterMiyagi were with me in discussion.
15:51
I think Attersson is on to something when he suggests in step 3 that you can get the unfairness calculation down to O(n) from O(n*k). Basically he's proposing a window sliding algorithm that lets you calculate sums-of-slices with one fewer loop than usual.
@PSSolanki FWIW, I don't feel like this new question is appropriate for SO main. For once, I still don't even know what the question is after scanning it twice.
I'm assuming it's something like "I have this algorithm that produces correct output, but it's too slow. How can I optimize it? Or, is there a completely different approach that's faster?"
The ransom note formatting is more of a barrier than an aid to understanding
Yeah, i got that 'snake' analogy he is trying to imply. calculating the MUS for first sublist, then just sliding over the rest to get the rest of 'em. but it doesn't seem to be implied for me .
@Kevin You got that :)
@PaulMcG heh
15:56
Of course I came to that conclusion based on both the post and the conversations we've had in here. I don't know if an average reader can figure out what the question is just by reading the question.
@Kevin that seems strange to me
@Kevin I get that, but "how to optimise wall of code" usually tends to be to be to broad. "Make a table of all I/O pairs", "Throw Cython/C++/Rust at it". I'm not trigger happy enough to mind, though.
@AshwinPhadke Well, keep in mind that python2.py could see the package it lives in if you had imported the package prior to executing python2.py. Then the package would already be in the module cache, and it will be importable from anywhere in the program.
@Kevin looks like importing is somewhat confusing.
@MisterMiyagi Hmm, true. "how do I make this program run faster?" is quite broad. But perhaps "how do I improve the big O complexity of my program?" is more narrow. Then "try implementing it in a faster language" isn't a valid answer, because O(N*k) in Python is still O(N*k) in Rust.
16:02
@PaulMcG they'll start by cutting off the least significant bits
"Make a big lookup table" may still be valid though
umm.. never mind. i'ma delete that post. Thank you for your inputs.
@Kevin Thank you :)
I don't know if I did anything truly substantive, but I hope I was useful somehow >_>
Can anyone tell me what are the coolest modules in python for automation of tasks?
@AshwinPhadke It's certainly confusing for me :-P
16:08
@Kevin You weren't the rubber duck they deserved, but you were the rubber duck they needed.
@Kevin Oh of course you were :) You were amazing tbf
@TanishSarmah requests, BeautifulSoup, Selenium, pywin32 if you need to interface with Windows stuff
@Kevin Seems interesting :P
adding pyautogui to kevin's answer..
@Kevin :-P
16:10
Honestly Python can do quite a lot of automation without any third party libs at all. It can emulate command line commands via subprocess, which gives you a good deal of power
@PaulMcG true that
Ah! How could I have forgotten pyautogui.
@Kevin subprocess is good at what it does.
Is pywinauto still a thing? I used that once to auto-play a browser-based gravity game.
Thanks guys, full workflow now works without using from, I hope it does after packaging too lol
16:13
pywinauto's last pypi release was Oct of last year, so it's active-ish.
@Kevin i got kevin'd here :)
It's not dead, it's resting stable and feature-complete
Coincidentally I also used automation to play a browser-based gravity game. I wonder if it's the same one PaulMcG was playing.
It was a basketball game where the goal was to sink as many shots as possible in thirty seconds. My program was able to make a perfect shot every time with lightning speed, so I was at the top of the global high score list for a day or two until I had a crisis of conscience.
I have heard most people saying to not go for DS Algo in python. Is it true that doing DS algo in other language such as Java or C++ more efficient?
Refresh my memory, what's DS again?
How did you remove yourself from the high score?
16:23
i guess data structures
The game I was playing, you had a field of planets/stars, and a body (asteroid?) you could drop in anywhere, with optional initial velocity vector, and then watch it meander through this minefield of gravity wells. If your asteroid survived for 'n' seconds without crashing into a star, you won that level. I was interested in the chaos of the whole system, where minimal changes in initial position/velocity had huge difference in outcome.
Scores rotated out of the high score list after 24 hours, so I just let it decay naturally
@Aran-Fey good question
@Kevin fair game
@Kevin Data structures
@TanishSarmah Use whatever language you can to understand the underlying data structure which is the main goal, language is just a medium
16:24
Lame. I was expecting either "I deleted my account" or maybe even "I hacked the high scores"
I wish I was leet enough to hack the high scores :-)
@AshwinPhadke And what about the pointers which are only in C++?
@Aran-Fey or told them hey look I did this
@TanishSarmah, oh, ok. I don't agree that Python is any worse at data structures than Java or C++. They're all fully capable of the same kind of OOP-based programming.
Pointers can be simulated in Python too.
16:26
Some games have such bad security, they practically invite you to hack them
And more cleanly, since you don't do sketchy stuff like math with them.
Mind you, there are lots of data structures that you don't need to implement in Python because they already exist. You almost never need to code up your own linked list or hash table, for example.
@TanishSarmah pointers can be added to python, you must understand that python itself is c and it's variant based
I guess you can still do passby value and passby reference in python
@Aran-Fey I am reminded of Super Meat Boy, which permitted arbitrary CRUD commands to its global high score data from semi-trustworthy client connections.
Focus should be understanding DS not language, I have used C++ and still never knew until recently that C++ too has tuples, so it is a matter of knowing DS more than language
16:30
@AshwinPhadke there is no need to dive that deep to implement a linked list in Python. To @Kevin's point, Python's list builtin usually makes that unnecessary, but to study things like singly and doubly-linked lists (and my favorite, the doubly-linked list with null header), a simple Python Node class is sufficient.
@TanishSarmah Pointers are still just a data structure. Literally they're a bit of memory with an address to other memory in them.
@AshwinPhadke Oh ,Okay.
Hence, pointers
Gray hat hackers politely informed the dev that bad guys could twiddle data coming out of their game and completely overwrite the global data. The dev replied, "no, that's impossible actually". The hackers executed a small easily reversible proof of concept attack. The dev got real salty and took down the high scores permanently.
@Kevin oops
16:31
(recalling this story from memory, I may have gotten some or all of it wrong)
Well, that's certainly the easiest way to close a security hole
@PaulMcG That is also a good point. However many a times people attribute certain data structures to certain languages which shouldn't be the case.
@dataclass
class Node:
    label: str
    prev: Node
    next: Node
@Kevin that's some story
Understanding arrays vs. linked lists is helpful in understanding Python lists vs. deques, for instance.
16:32
TBH I never knew DLL or even LL existed with null header , how does it even work?
@AshwinPhadke passby value and passby reference in python...what's that?
"so I was playing Super Meat Boy today and it segfaulted". This at least verifies the details up to the dev replying that it isn't a problem.
@PaulMcG I guess python lists and deques are more or a representation for a beginner to quickly understand arrays and LLs, like going higher to lower
I still don't get why Py doesn't use the globally accepted names for arrays and linked lists.
calling an array a list is confusing.
Because it's not
16:36
A DLL with null header starts with an empty Node that points to itself in both prev and next. Test for empty is header.next is header, all inserts are simply prev.next, newnode.next = newnode, prev.next; and similar for the prev pointers. The beauty is that the null header allows you to write this code without ever checking if node.next is None.
@TanishSarmah that;s a whole interesting topic, but essentially there are two ways you’re passing the reference to the original variable, and thus modifications will be reflected in the original variable. Passing by value results in a copy of the original variable, and modifications are not reflected in the original. , link here : realpython.com/pointers-in-python
@Cthulchu Maybe python wants to be a bit different from other languages. :-D
yeah well, that's not a bit
@Cthulchu An array looks like this: [1,2,3,3,4,2,1]. An array does not look like [1, 'hello', 4.2, (1,2), {'this': 'works}]
@AshwinPhadke Okay
16:37
@WayneWerner that's just an array of objects
In CPython, A list is implemented as an array of pointers to PyObjects, but I don't believe this implementation is a requirement of the language. Other implementations could make it a linked list, or something altogether stranger.
it's fine, it's still has O(1) speed of access
@WayneWerner Oh that's the difference!
@Cthulchu It is not exactly the same
Calling it a linked list in the documentation would restrain other implementations in a way the devs may find undesirable
16:38
@AshwinPhadke but it's the meaning of it all. We call data structures by their complexities. The rest is not important.
@PaulMcG You would still need to know the prev and next locations right?
Oh wait I get it
@Cthulchu Well, sure, why don't we just call everything electrons?
You're electrons and I'm electrons
@WayneWerner because we don't care about electrons, but we care about data structures.
but when you call everything an object
occam's razor, basically
16:39
@Cthulchu the meaning is different hence it is called different
@WayneWerner Lol ! looks like the python room has turned into physics room XD
I'm made of dark matter, and you would not believe how hard it is to manipulate a keyboard when the only observable effect I have on conventional matter is weak gravitational interaction
@TanishSarmah Everything is on topic here, except for Python ;)
because distinction on the data structure level is not important, from its perspective it's all objects
@WayneWerner lol, I guess it makes python all inclusive
16:40
@WayneWerner :-D
@Cthulchu but an array cares what type is in the thing
Python doesn't
if you're saying "oh it's all objects"\
@Cthulchu that is just not understanding what DS is and putting a tag on it
@WayneWerner +1
then by definition you can't care about the type of each element
so you can't do something like data[1] + 1
@WayneWerner ok, I see your point. but do you see mine? It looks like Python tries to appease new devs rather than make itself comfy to those who know data structures
you have to unbox your object into int(data[1]) + 1
16:42
which is not good or bad, too
Python tries to be precise
precision in this case is subjective
Python was mean to ease stuff, it was not meant to write 5 functions just to manipulate values
instead of saying "oh, my list looks like an array and behaves in most instances like an array, so we should call it an array instead of a list"
Its seems like I have the least knowledge of python in this room or even in this UNIVERSE lol!
16:43
sure, and so it added the unneeded colon. to ease stuff, @AshwinPhadke
@Cthulchu so you're arguing that Python isn't subjective in your subjectivity so it's wrong?
I don't think Python is trying to appease new devs specifically by avoiding the term "array" when talking about lists. I think it's trying to adhere to a higher level of abstraction compared to languages that use the term "array". Certainly a higher level of abstraction can be beneficial to newbies because it smoothes over implementation details, but it's also beneficial to seasoned devs too.
@WayneWerner if you didn't get the gist of it at this point, that's fine
@TanishSarmah don't worry I recently learned from this group itself that you can have a tuple as a value in a dictionary so we are all learning
@Kevin but you can't abstract from data structures. Unless you don't care about performace
16:44
@AshwinPhadke Yeah ! That's right.
I care about performance, but I care about it less than ease of design and maintainability
calling it a list is more correct from a generally defined/accepted terms perspective - en.wikipedia.org/wiki/List_(abstract_data_type)
@Cthulchu It also removed a ton of semicolons, you cannot call a language feature unneeded
@AshwinPhadke why?
@AshwinPhadke I asked the IRC community to explain the need of the colon. They couldn't. Turns out, Python, allegedly, made a test and determined that users liked the colon
All developers are willing to trade off some amount of speed for some amount of readability, or else 100% of us would be programming in assembly
16:47
@Cthulchu That's the apocryphal claim. I don't know if it would be possible to verify.
I'm 85% sure that the colon is necessary in order for Python's grammar to be unambiguous
It's not entirely necessary
and if you look at the new PEG parser and Guido's somewhat serious proposal about re-introducing the print statement
@Cthulchu If something was unneeded it wouldn't be there, sure there are some things that a wide audiene who have used other languages may think that this particular thing was not needed, however even public static void main string args looks unneede instead of main or void main
16:49
@AshwinPhadke no, there's need for public static void main string args. Every one means something important to the language
@WayneWerner that transition from print to making print a function call , I still remember the discussions over it lol
I actually respect Java's syntax more than Py's
oddly enough
@Cthulchu That surprises me exactly zero
why?
Every feature of every programming language is unneeded except for the features found in machine code
16:50
@WayneWerner +1
Is this discussion going to amount to anything other than that, @Cthulchu
yeah, fair enough @roganjosh. Sorry for hijacking the chan. Cheerio
@Kevin Machine code is arbitrary based on chipset. It's still built on leptons and quarks.
The concept of private/public classes, the concept of static methods, the concept of functions having return values, the concept of functions having arguments, are all unnecessary and can be safely disposed of, while still retaining a useful language. So public static void main(string[] args){ could indeed just be function main{
Contrived, unconvincing example where a colon is necessary to disambiguate the grammar: if "foo": "bar" "baz" is legal syntax, and if "foo" "bar": "baz" is legal syntax. If you eliminated the colon, you wouldn't know what if "foo" "bar" "baz" should be interpreted as.
I'm currently trying to convince myself one way or the other whether "require a colon for single line if cond: simple_statement conditionals, make it optional for if cond: newline indent statement_block conditionals" is unambiguous
I think it might be, unless you can do something truly wacky with line continuations
there are various blog posts by Guido clarifying that the block-ending-: is for readability: It is a familiar way of listing sub-expressions. Such as a list after a heading.
17:07
Which is better Visual studio code or Pycharm?
Hmm, trying to decide whether I should continue to take Guido's testimony as word-of-god, or if his abdication as BDFL should retroactively cancel his historic insights
(I kid, I kid -- clearly questions like "what were you intending when you wrote feature XYZ?" have the same answer whether he's currently BDFL or the janitor)
raf
raf
I want to make a function Function() that will take a location name from the user and search the name on the geonames database and print out the country name. For example:
```
x = 'New Delhi'
y = Function(x)
print(y)
```
```
India
```
Didn't I give you a suggestion on this earlier?
raf
raf
@roganjosh Sorry, I forget. Someone told me about the geonames website
Hint; I did. Did you try implement a nominatim wrapper library?
raf
raf
17:12
ohh sorry, I haven't tried it yet.
If the database has an API, use that. If the database has a website, use requests. If the website needs dynamic JS to operate, use Selenium.
Time for lunch
The nominatim wrappers im thinking of can be installed locally. Please don't scrape anything related to OpenStreetMap
their systems are used in things like natural disasters. Don't put load on their servers
raf
raf
I am looking at these now:
https://github.com/geopy/geopy
https://github.com/dsoprea/GeonamesRdf
Geopy was forefront of my mind. If it fails on a reasonable address, we can try another. Let me know how it goes
raf
raf
@roganjosh okay
17:30
cbg all
@Kevin Lol here's the time of sleeping :)
raf
raf
```
```
>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
>>> location = geolocator.geocode("175 5th Avenue NYC")
>>> print(location.address)
```
what do I need to put in user_agent?
17:54
@Cthulchu Surely the most obvious comment is that lists are not called arrays because arrays can commonly be multidimensional, and lists aren't and can't.
@WayneWerner I believe it's claimed that modern, optimised C or JITted code is faster than handwritten assembly, but treat that as apocryphal unless you find proof.
10:00 - 18:0018:00 - 23:00

« first day (3615 days earlier)      last day (1547 days later) »