« first day (3855 days earlier)      last day (1091 days later) » 
01:00 - 20:0020:00 - 00:00

1:17 AM
Hi, I am trying to calculate rank in a for loop in Python. It throws error of "unsupported operand type(s) for -: 'float' and 'method'". Is there any idea on how to solve?
 
did you forget parenthesis somewhere?
 
for t in res:
rank = [((t - res.min)/(res.max - res.min)) * (2.0 - (-2.0))] + (-2.0)
print(rank)
The code is above
 
res is numpy? add ()
 
Yes added ()
Now the error changed to can only concatenate list (not "float") to list
 
you can't add the float to the list
 
1:23 AM
I don't need to add
I need to print list of ranks
for each item in res
 
... - (-2.0))] + (-2.0)
 
Hmmmm
 
that is what you can't do
make the list a numpy array
 
It is the formula to calculate rank
 
why are you doing +(-2.0)
 
1:24 AM
Got it
Paranthesis missing
 
 
2 hours later…
3:13 AM
django.db.utils.OperationalError: no such column: blog_article.active
What does this error mean?
OperationalError at /blog/
Error during template rendering
 
 
3 hours later…
6:32 AM
hey guys which is the nicer method here
opts = list(map(lambda x: list(filter(lambda y: len(y) != 0, x )), opts))
or
end_opts = []
opts = list(map(lambda x: list(map(lambda y: end_opts.append(y) if len(y) != 0 else print(y), x)), opts))
just readability and all round better method?
 
6:57 AM
both are gross
but the 1st one is the nicer one
 
101
7:14 AM
@Kwsswart write it in more lines, it will be so much more readable
 
@Aran-Fey how would you do this then?
 
Depends. What's the goal here? The first snippet does something completely different than the 2nd one
 
7:30 AM
well essentially the goal was to sort through the internal lists within a list retreiving end results
 
I don't get why you do list+map+filter combinations. That's what list comprehensions are there for.
But the append six layers deep inside a partially lazy iteration is indeed... particularly unreadable.
As far as I can tell, the first should just be [[y for y in x if y] for x in opts]
 
With better variable names than x and y of course
But I can't say I see any "sorting" happening in that code, and "retrieving end results" means exactly nothing
 
essentially I have some empty fields within that I am wanting to remove from the lists to then flatten the lists and work based on the number of elements to figure the end result
 
If you want to flatten a nested list, you need
opts = [
    y
    for x in opts
    for y in x
    if y
]
 
7:45 AM
if you want to go for iterators, I think you need itertools.chain(filter(None, opts)) filter(None, itertools.chain(opts)).
Yam, why is the iterable the second argument to filter?!?
 
@Aran-Fey that might be the better option atm I have
opts = list(map(lambda x: list(filter(lambda y: len(y) != 0, x)), opts))
end_opts = [item for sublist in opts for item in sublist]
 
Ugh. Who writes these "programming" pages? Can't even make it through the first sentence without flinching...
hurries back to the cave of pedantry
 
8:44 AM
Hi guys,
I'm in python 3.8. I want to type hint the return value of a function. I want to return a List of tuples that contain two integers.
-> List[(int, int)] gives me E TypeError: 'type' object is not subscriptable
What is the correct syntax?
Best,
Michael
 
@Kwsswart ugh
That's atrocious
 
@AndrasDeak I would have gone for something a little stronger there... but... :p
 
@Kwsswart heads-up: I strongly suggest refactoring these monstrosities to match readable best practices, or stop asking us for opinions
 
@Michael_H List[Tuple[int, int]] ?
 
@Michael_H did you re-assign the name List? While the type hint is not correct (Jon's is) it should not throw that error.
 
8:59 AM
Thanks Jon. No i did not re-assign the name. It is assigned in
from typing import List
 
That's weird. It should throw TypeError: Too many parameters for typing.List; actual 2, expected 1
And when using a proper type like list, it should throw AttributeError: type object 'list' has no attribute '__class_getitem__' oO
 
@AndrasDeak already have I have used the example set forth by you
end_opts = [
    needed
    for current in opts
    for needed in current
    if len(needed) != 0
]
 
Hi everyone, this is not python specific, but any general tip for why streaming is better than triggering after each update to the database?
 
@Kwsswart excellent
 
@MisterMiyagi You are right. I mis-read the error message. I had deque[int] in the same line. I think that one caused the TypeErrror.
 
 
1 hour later…
10:32 AM
cbg
 
11:05 AM
cabbage
 
11:24 AM
Has anyone here used QML before?
mostly seems like JS and some CSS type
 
@jrh Yeah, it's not terribly efficient to put a "dense" type like an array into an essentially sparse collection like a table. I see this as a trade-off between efficiency and transparency. If you want tightly packed data, you can put the object in a BLOB or put it in the file system, but then the SQL engine can't easily query information about the object. If you want fine-grained query abilities, then you can put each piece of data in an individual row/column, but it will cost more memory
I understand your concern about "[a folder] filled with thousands (millions?) of unlabeled files that are completely impossible to link back to the relation without the help of the DB". From an academic standpoint it strikes me as inelegant. But from a practical standpoint, I'm not too worried about it. I don't consider it a high priority for the developer to be able to understand the data's relationships just by browsing through the directory.
If you disagree about that priority, that's valid, and I think you can take some inexpensive steps to make the data less opaque. You could choose filenames that aren't completely meaningless -- for example, {GUID}_{user_name}.png rather than just {GUID}.png could give you a quick-n-dirty way of seeing who's making the most out of your image upload feature.
You could also store metadata about the image in the database. For example, a filesize column would make it easy to identify who's been uploading 4 GB super high def images as a prank
 
AAB
12:07 PM
@roganjosh :p 2 table manufacturer, category 3rd table that has the relationship between the 2 the id from manufacturer and category together make a unique key. I need to retrieve manufacturers based on specific categories, so using that table to run group by as of now. @Aran-Fey is right I need to create a pid in Django for this no other way, or remove the 3rd table and add another column in manufacturer(which seems like a bad idea)
 
12:26 PM
@CoolCloud You probably don't mean Quantum Machine Learning, do you?
 
@MisterMiyagi Noo, I meant the language Qt QML
 
@Kevin Ugh. We have such a DB-only object store as one of our multi-PB storage backends. Very smooth for its main task, total nightmare when manual intervention is needed. If the file system permits, adding the vital information to files via xattrs (as backend #2 does) can be a lifesaver.
 
1:05 PM
@AAB Then it's just a many-to-many relationship as I suggested
 
jrh
1:20 PM
@Kevin From a theoretical perspective, you're right, storing an array in a column is technically using a hierarchical construct in an environment intended to be purely relational. That is a bit messy from a design perspective, however Postgre does have native support for Array columns. Though it would be a valid point that I should write DB neutral code just in case, or avoid designing against implementation details of the DB and stick with the common features every DB supports.
As an exercise I might do it without ArrayFields just to make sure I know how to do it, in case one day I use a DB that doesn't support array typed attributes
@Kevin so, to be fair, I have a lot of experience doing exactly this (storing giant amounts of files on disk), I've used all of the following strategies: 1) Using directories to store more information, 2) using file specific tags (e.g., TIFF tags) to store information about where it came from, 3) tacking on stuff to the file name as you suggested. (1) and (3) are only as good as your filesystem, (2) is file format specific and opaque without an app.
What I mean by "only as good as your filesystem" is, among other things, you always have to filter out characters the filesystem can't handle. Windows is especially annoying (to be fair I'm not targeting that), I had to write quite an elaborate routine to prevent people from getting an image named CON, etc... I have had customers say "we want to pull up with a USB stick and copy it to my computer and read it at my desk", I would have to replace that functionality in the web app
and for what's more do it so well they'd never want to look at the files, maybe I can.
That specific workflow might not be all that important to this new project too, to be fair. I have a feeling it'll come up though. I suppose another idea might be to use the DB to query all the filenames and allow somebody to bulk download files matching a query and automatically rename them, that might actually be more convenient than the USB stick. I am still (perhaps irrationally) worried about the DB going out of sync with the filesystem.
Also if I'm being silly (I'm not actually making this point seriously), strings are technically a hierarchical construct too (ordered array of char), I could make a fully relational "string" by making a single char table with indexes. I'd guess your objection against storing arrays in an attribute is more to do with not cluttering up query results, and sticking with types all DBs actually support
 
1:50 PM
cbg guys, is there a different way for [x] + foo() if condition else foo() + [x] basically instead of having to write foo() twice?
foo() returns a list so the output differs on the order
 
I'd summarize my thesis as "DBs have many tools for working with relational data, and few tools for working with hierarchical data". I won't go so far as to say "therefore, never use DBs to store hierarchical data". More like, "have a solid plan for replicating the tools you need, but which the DB doesn't natively have"
 
I don't think so. If you need it a lot, write a helper for it.
 
jrh
couldn't you do something like y = foo() then do if(condition) [x] + y else y + [x]?
 
@python_user you could use an assignment expression but I wouldn't complicate that, it would be less readable
alternative: lst = foo(); y = [x] + lst if condition else lst + [x]
 
yeah like jrh suggested then
 
1:53 PM
Ah, yes. Just with the ternary.
 
maybe Miyagi's helper seems good but its just this one line in a recursive call
 
Unless foo is actually some super-long name, I'd write it out then.
 
jrh
@Kevin That makes sense, thanks
 
But mind precedence – pretty sure you need parentheses there.
 
it works without that, context for those who are interested pastebin.com/3jKQq8Bc (13 LOC)
this is a now deleted answer for a question I was attempting on main
 
1:57 PM
Comedy option
>>> def foo(): return [1,2,3]
...
>>> x = 4
>>> cond = False; ([x] if cond else []) + foo() + ([] if cond else [x])
[1, 2, 3, 4]
>>> cond = True;  ([x] if cond else []) + foo() + ([] if cond else [x])
[4, 1, 2, 3]
 
@MisterMiyagi good point
 
I was expecting lists to have a __radd__ option so I could go crazy but they dont :/
 
@python_user with a deque you can appendleft
 
ahh that is a nice option, didnt occur to me
 
Comedy option 2
 
1:59 PM
I am listening :D
 
Copy-paste is borken, please hold...
>>> cond=False; list.__add__(*[[x], foo()][::None if cond else -1])
[1, 2, 3, 4]
>>> cond=True;  list.__add__(*[[x], foo()][::None if cond else -1])
[4, 1, 2, 3]
 
sum refuses to work on lists these days, right?
 
You have achieved komedi :p
 
@AndrasDeak I thought so too, but now that I try it:
>>> cond=True;  sum([[x], foo()][::None if cond else -1], start=[])
[4, 1, 2, 3]
>>> cond=False;  sum([[x], foo()][::None if cond else -1], start=[])
[1, 2, 3, 4]
 
@AndrasDeak where would you use it? foo() gets called only after the condition, so where can I assign it?
 
2:03 PM
@AndrasDeak Why?
 
I distinctly remember seeing an error message in the past saying "I know exactly what you're trying to do, but I don't care. Go use join or something"
(paraphrasing)
 
this works (the error) when using the start arg of sum sum([1, 2], start='a')
 
@python_user Something like this:
>>> cond = True; [x] + (y:=foo()) if cond else y + [x]
[4, 1, 2, 3]
>>> cond = False;[x] + (y:=foo()) if cond else y + [x]
[1, 2, 3, 4]
You may have misread "assignment expression" as "assignment statement". The magic of the walrus operator is that you can stick it in places where normal assignment can't go
 
I had this mental code in my mind, but I thought y would not be assigned if condition failed
 
@Kevin huh
@python_user good point, I got confused
 
2:07 PM
@python_user Hmm, maybe I have some stale variables in my REPL... I will test further
 
@Kevin I thought it would not work due to short-circuit
 
Andras has paraphrased it in a more technical way :D
 
def foo():
    return [1,2,3]

def troz(cond):
    x = 4
    return [x] + (y:=foo()) if cond else y + [x]

print(troz(True)) #[4, 1, 2, 3]
print(troz(False)) #UnboundLocalError: local variable 'y' referenced before assignment
 
Hello, long time user of information found on stack, but the first time I have started asking questions of my own and interacting with the community. I guess I'm a "Green Bean" lol.
 
Yep, my previous code only worked because y retained its old value.
@ChristopherBrown Welcome
 
2:09 PM
@Kevin thanks for confirming, this happens to me a lot in REPL and jupyter
@ChristopherBrown cabbage :)
 
@ChristopherBrown cbg
 
Ah, I see I should have started my message with cabbage lol.
 
Shun the outsider!
 
@ChristopherBrown salad is entirely optional
 
I rescind the shun proposal!
 
2:12 PM
Too late, we've already broadcast the shun on all frequencies
 
Well heck
 
I'm in the Python Discord channel, and those guys have been great helping me we I do something silly like save my file as tkinter.py and can't figure out why when I do from tkinter, nothing is working lol. Do you guys know of any other good communities I might want to join? Trying to find one on Selenium but haven't had much luck.
Kevin, you are sending me conflicting messages, first welcoming me then shunning me? lol
 
@ChristopherBrown Doesn't the python server already have a channel for selenium?
@ChristopherBrown Typical Kevin :p
 
What can I say, I contain multitudes. I've settled firmly on welcoming at this point, though.
 
@ChristopherBrown if you need help on selenium concepts rather than python selenium you can check the java selenium, that actually has more resources
 
2:15 PM
For a group as chronically online as programmers, I have a heck of a time finding communities for pursuits any more specific than a programming language
In other words, I haven't seen a hangout for Selenium enthusiasts
 
The Python Discord server doesn't have a channel for selenium. I've been asking in their "web-development" channel because I feel they would have the best understand of the structure of webpages and how I can go about getting to the info I want.
There is a selenium discord but it contains 95% questions, and few people providing answers. So essentially the blind leading the blind in there until someone with knowledge can get on lol.
 
Ah yes, the default state of all troubleshooting communities :-)
 
@Kevin I know what you mean, yesterday I was trying to find help with VS Code. I went to bed and woke up and Python wasn't working in VS Code anymore. I had to delete everything, Python/VS Code, from my computer and reinstall everything again to get it to function.
But I searched everywhere to find some sort of help on my issue. There were some forum posts on stack but nothing that helped.
 
Yeah, "this complicated tool stopped working for no apparent reason, help?" is just about the worst ghost town you can find yourself in
 
@ChristopherBrown Does not work means?
 
2:25 PM
I've tried to avoid such situations by honing a certain foresight for actions that may wreck my computer. If I can avoid taking the action, I do; otherwise, I write down what I'm doing in great detail.
 
I'm sorry, @CoolCloud, what do you mean? lol. Are you asking, what wasn't working in VS Code?
 
If I'm lucky, I can un-break the environment simply by going backwards through my list and doing the reverse of each step
 
what if the thing on which you write down breaks? ;) unless its an actual paper
 
@ChristopherBrown Yep, what was wrong with VSC
 
Usually Notepad++, since the environment at risk of breaking is most often a DB or my programming environment. Notepad++ doesn't care if Python or Oracle throw a sprocket. If the tech stack that Notepad++ depends on is at risk (OS, firmware, hardware, baseline reality), then I say my prayers and use paper.
"Step 4. Watch helplessly as motherboard melts into slag". Ok, so I just have to set the motherboard on nega-fire... I may need liquid nitrogen for this.
 
2:30 PM
Not a clue. I'm assuming it had something to do with the Code Runner extension. The night before I was playing around with tkinter in VSC, got frustrated, saved, put my pc to sleep, work up, opened VSC, ran my code again and instead of the error I got last night, I got something like "Can't find Python, install via the microsoft store". My Interpreter for VS code said Python in the bottom left corner and I had the Python extension installed. So I went to the terminal in VSC...
 
Did you play with system paths?
 
...typed in py and VSC looked at me like I was dumb. Went to my own CMD Prompt and typed in py and it worked just fine.
I didn't change anything in paths, and when I checked the environment variables and the PATH there everything was pointing to the right location.
 
I think the order of items in PATH is important. I remember having such errors at the beginning randomly. Don't remember how I got past it.
 
code.visualstudio.com/docs/python/… I tried doing this but couldn't find the settings.json file it was talking about.
 
Also try to hone a foresight for which kinds of applications may wreck your environment without your knowledge or permission
 
2:33 PM
@ChristopherBrown if you actually press ctrl+shift+p and type in settings, there is an option to open JSON of settings, that's what they are talking about
 
It may have been that and reinstalling python fixed the path. I deleted EVERYTHING from my appdata folder
ok, I was able to open that, but I couldn't edit it from vsc and couldn't figure out where it was saved. I assumed in my appdata folder somewhere but couldn't find it
 
It's exactly this kind of painful experience that most effectively strengthens your ability to avoid painful experiences :-)
 
@ChristopherBrown Hmmm I guess inside .VScode in APPDATA
 
lol painful it was
 
Reinstalling is such a pain, you lose all the installed libraries. Especially if you dont use a venv
 
2:38 PM
yep. I tried copying the lib folder from Python and just paste them into the new folder after the reinstall but that didn't work, or it is possible the VSC libs are stored separately when I do pip install from the VSC terminal.
but oh well, just run the code and if it says "I can't find this" just do a quick pip install and keep going down the list.
 
You could make your project installable and define its dependencies
 
I could if I have been doing Python for more than a couple weeks and knew what you meant lol. Sorry for the sass, but I do appreciate it. I can't think of new ways to do things if I don't know they exist.
From this: just run the code and if it says "I can't find this" just do a quick pip install and keep going down the list. I thought, maybe I could do a try: except:, and if the try throws the error, the except will run pip install. Never tried it, just a thought.
 
When I ask about a problem in here, 95% of the time Andras will say "have you tried [useful tool/module/algorithm that Kevin has never heard of]?". He is most skilled in the field of unknowns.
 
mostly because your problems these days are of a numerical nature :P
 
Could be, could be
@ChristopherBrown I've seen that approach before. But it's almost always easier to use a dependency manager tool, for example the ones described at packaging.python.org/tutorials/managing-dependencies.
 
2:53 PM
okay.Thank you
 
I don't have a whole lot of experience in that field, but I understand there are a variety of toolchains ranging from "single .txt file listing the modules you want pip to install" to "detailed breakdown of every salient detail of your computing environment"
 
setup.py can list install_requires, and I'm sure all other systems can specify dependencies
 
3:13 PM
Today I may have to do UI design, please pray for me
 
🙏
 
I feel my power growing
 
I have been struggling mightily on getting the UI right on a simple QGIS plugin for a couple weeks. I'm mostly running through layouts in my mind but nothing great has emerged. My current version of the plugin works but will probably confuse anyone who uses it. I feel your pain, Kevin.
 
3:31 PM
@Kevin pray or put you out of your misery before it starts? :p
 
am I wrong to want (i:+=1)
 
@piRSquared I'm going to say "yes" and point you to the naughty step... :p
 
I thought as much
nothing wrong with this at all:
k = 0
while (x:=(lambda i: i**2)((k:=k+1))) < 110:
    pass
print(x, k)
 
3:48 PM
I can easily put together a quick interface that 95% of users will understand, but I foresee the remaining 5% will put many support tickets on my plate
 
Proving the BOFH right once again. Users are the source of all problems
 
I just need to find the local maxima of the function total_man_hours = development_hours + user_cluelessness*num_users/development_hours so I can optimize my labor
 
@Kevin It follows the project effort equation
 
Gotta account for relativity because some users are dense enough to bend spacetime
 
4:15 PM
@Kevin No matter how hard someone try. There will be normies somewhere somehow
 
Truth
 
Those 5% either didn't read the ui carefully (or at all), or just don't want to do the work so they claim "IT" issues.
 
"normies"? is that the same as "muggles"?
 
@inspectorG4dget Correction: Isomorphic.
 
hahaha
 
4:26 PM
from tkinter import *, imports the entire tkinter library. github.com/python/cpython/tree/3.9/Lib/tkinter is that everything from here?
 
if you want to understand what a star import imports, look at the init file
init is the first file that gets run when a package is imported. If you do a star import, and if there's an __all__ present in an init file, then those are the parts that get imported. If not, everything in the globals of an init get imported.
 
ah ok... good, that was my question. I read the * imports everything form the library, but sometimes I also would go from tkinter import ttk, but that is on that same page, so I was trying to figure out why.
 
for what it's worth, just generally i'd avoid star imports
i grow increasingly annoyed at tkinter for trying to make star imports a thing for their package in the official docs. It's confusing at best
 
from https://tkdocs.com/tutorial/firstexample.html:
"Notice that we've imported everything (*) from the tkinter module... This is standard Tkinter practice."
lol
 
4:41 PM
Yes, its something that everyone does. And the people end up messing up the imports. They say:
from tkinter import *
from tkinter.ttk import *
Right now, the imports are messed up. A normal button, Button() would mean ttk.Button() and not tk.Button(). and people enter panik mode :p
Nonetheless, if you say:
from PIL import Image
from tkinter import *
It replaces the PIL.Image with tk.Image. Definitely not what we want.
So rule of thumb, don't use from x import *.
 
Does: from tkinter.ttk import * == from tkinter import ttk ?
 
@ChristopherBrown The items imported would be same. But in LHS, you just have to say Button() only but in RHS, you have to use ttk.Button().
 
ugh, stuff my tutor just brushed over.
 
@ChristopherBrown I wouldn't blame them, if it is online or recorded. But if it is a live class, then....
 
4:48 PM
Then there is "import x from y as z"... I just copy paste what is at the top and go from there. lol
It was paid 1 on 1 tutoring lol.
 
I also think you shouldn't do from tkinter import *. I have answered many tkinter questions, which either means I know what I'm doing, or I'm very persistent.
 
@ChristopherBrown That is wrong, I guess
Its always from y import x as z, IDT the first one is syntactically right.
@Kevin But while answering I prefer from tkinter import *, saves some time.
 
It was good, I learned a lot, I can read and understand most everything or where stuff comes from, and how manipulate code to get the output I want but I know there is some deeper level of understanding I don't have.
 
import tkinter as tk helps bypass a lot of the pitfalls of star imports, at the cost of tk., so 3 characters before your classes and functions
 
@CoolCloud my bad, I didn't have an example in front of me so I was just trying to recall what I saw that I was like, "yep, that does a thing"
 
4:52 PM
that's an easy tradeoff to make any day, honestly
 
@ChristopherBrown Well if you have anything, I would be happy to help(If I know :P)
 
from x import * is a fairly minor antipattern in my opinion, since it doesn't compromise your program design in a way that's hard to fix. It just makes it more likely that your variables will get bound to a value you don't expect.
 
@ParitoshSingh True
 
5:36 PM
@Kevin if it's guaranteed to have well named stuff like a settings file... I don't mind it...
 
has someone worked with importlib.resources? I'm trying to figure out whether I can get the modification of a resource (st_mtime), or whether I'll just get the metadata of a temporary file.
The source code is... not helping.
 
@bad_coder you already tried that one yesterday chat.stackoverflow.com/transcript/6?m=52134818#52134818
 
6:19 PM
is he bumping his own question? or is that something else?
 
@AndrasDeak I checked the Python room FAQ and found nothing against bumping, so I assumed the socvr rule (i.e. 1 bump is permissible). It also worked, since atm more folks were in the room.
 
New here, so not trying to call anyone out, just wondering what was going on :)
 
@ChristopherBrown see cv-pls policy also if you want visit SOCVR.
 
6:41 PM
@bad_coder it's not against the rules, just probably pointless. As I said few people here engage in close voting, so it's not too likely to gain more eyes with a repost. And if you repost at least say so so the few that do open it know what to expect.
Although in this case it worked so perhaps I stand corrected
@ChristopherBrown high-rep activity centered around closing unanswerable questions
 
6:53 PM
Hi Can somebody explain why this code does not work?
df.loc[:, ['B', 'A']] = df[['A', 'B']]
 
@PrathapKb hello. How does it not work?
 
i wanted to assign column B to A and vice versa. but this code does not work. the reason being column alignment is before value assignment. what does that mean when they say " column alignment is before value assignment ?
 
I see what you're trying to do, but you just repeated "it does not work". What I was looking for was "there's no error but the dataframe is unchanged". That tells me how it "does not work".
>>> import pandas as pd
>>> df = pd.DataFrame({'A': [0, 1, 2], 'B': [-4, -5, -6]})
>>> df
   A  B
0  0 -4
1  1 -5
2  2 -6
>>> df.loc[:, ['B', 'A']] = df[['A', 'B']]
>>> df
   A  B
0  0 -4
1  1 -5
2  2 -6
@PrathapKb here's an MCVE if next time someone asks for one ^
@PrathapKb who is "they" who says that?
 
This blog makes that statement
why the data frame is unchanged?
 
OK, so this is an explicit example from the official pandas documentation. That is promising. This is the kind of information you should start with.
@PrathapKb here's a broader quote for a bit more context:
> pandas aligns all AXES when setting Series and DataFrame from .loc, and .iloc.
This will not modify df because the column alignment is before value assignment.
This means that if you have two dataframes in an assignment, their columns will be paired up by name even if they are in the wrong order.
 
7:00 PM
@AndrasDeak yes, I noticed folks here aren't voting to close but I recall visiting the room a few months back and there was more activity and I also saw cv's. So it might depend entirely on who's in the room at a given moment. I do pay attention to your advice, so I'll take it slowly with the cv-pls and try to post them sparsly at opportune timings.
 
@bad_coder an I appreciate that
@PrathapKb what is the final dataframe you want to end up with?
 
Am just trying to understand the concept behind so as to why there is no change in the dataframe
 
OK :)
Then let me know if the explanation was satisfactory.
 
if the columns pairs up, then how the below code changes the column values? df[['B', 'A']] = df[['A', 'B']]
In the above code, A changes to B and vice versa but not with the code which has .loc
i feel it has something to do with .loc
 
The quote specifically mentions .loc and .iloc. See my quote a few messages above.
 
7:06 PM
@AndrasDeak Right here it says about loc and iloc. @PrathapKb
 
ok. you mean to say columns will be paired up even if they are in wrong order in case of loc and iloc. is my understanding correct?
 
@PrathapKb that's how I'm reading it and that seems to match the documentation's wording and the behaviour
 
@PrathapKb Hence they appear the same and no change is done to the dataframe :)
@AndrasDeak Saw txtspk for a moment there :p
 
Thanks @AndrasDeak and @CoolCloud... I understand now. :)
 
No problem :)
 
7:14 PM
What is a good way to store data to be used later by Python? Right now my program reads a PDF, extracts text, uses the text to go to other websites and fill out forms and bring back more text. This is then brought to a final website to fill out 1 more form and then the user has to wait for another human to check the form and send it back. Once the form comes back, the user then has to go to another website and fill out more stuff with information from the first process.
The information used in the final website is some of the same information from the 1st set of process, so I want to reuse it, without rerunning the program a second time, but a little bit different. make sense? Right now I'm saving everything to a text file, just wondering if there was another way.
 
@ChristopherBrown Locally or server based?
 
txt file, json files, or a local database like sqlite seem like decent options to explore
 
ok, and then just read the file. That's what I've been doing, but I'm new at this so 9/10 there is another, better way to do what I'm doing lol
 
IDT there is another method. You want to save the file somewhere. What better way would there be ?
 
7:20 PM
Well one could just keep the data in memory (either in some native python type, or an in-memory database or similar).
A lot depends on the use case, what kind of data we're talking about, what operations are done on it etc.
And even if we knew more I personally wouldn't be able to help :P
 
anyone here use pydeck? The documentation has many gaps, so I'm having some trouble getting my map to render exactly right
 
Let me step in for you for a moment: I only know py deque. :P
 
lol IDK what better way there would be. From my understanding Python keeps everything in memory until the code ends, once that happens it data dumps. Maybe there is a lib out there that I point all of my variables to and it saves the variables and information and later when I run the other program, I can use the lib to point to pull everything out in the same way I saved it.
 
@ChristopherBrown you said "without rerunning the program", so I thought this was all within the same interpreter session.
 
Gotcha. I'm trying to figure out a better way to explain without being so long winded lol.
 
7:34 PM
I personally always prefer long-winded and clear over short and vague.
 
I need to know if something is possible.
I have some mod files that people need to install
The files need to be in a specific directory
When people run the exe, is it possible to find the directory where the game is already installed ( without telling the person to give it to me?)
Asking because most people don't even know where the games files are installed not to talk of getting the location
Another option is can I provide a default path and check if the game exists there? So like the exe has to be looking for a specific file and if it does not find it then it shows a message to the user that file was not found in this location.
 
@Dave hello
 
@AndrasDeak Hi
 
@Dave I won't be able to answer but I suspect the target platform (windows/*nix) might matter.
from "exe" I presume windows
 
Yes windows
 
7:37 PM
Does the game have a default folder it is always installed on? Like the steamapps folder?
 
Yes the game is a steam game
Steam allows you to get a default path, but some people like me might sometimes even install to an external drive.
 
If you want to be a real tryhard, you can even look for shortcuts to that game on the user's Desktop, in the Task bar, and in the Start Menu
 
import os.path
from os import path

a = path.exists("C:\Program Files (x86)\Steam\steamapps\common\Valheim")
print(a)
That Prints true if Valheim is on their computer on that path. That's the default install dir for steam.
 
@Aran-Fey That makes sense. I guess I'll need a way to go about that.
 
From there it's just an if statement to check if a=="true" before executing. I'm assuming
 
7:43 PM
@ChristopherBrown Yes exactly what I was thinking, but can this be put in something like an installer? That's the challenge for me
Since the installer would be putting the mod files at the game location
 
i see zero problems why you can't go through a list of places to look at, definitely
 
Maybe like the installer lunches a script while installing and then get's the path from that script.
@ParitoshSingh Sounds interesting. I don't even know how to go about it though
 
I'm sure it can, I've just never used an installer so I don't know how it works. Is all your code in Python?
 
a list of pre-defined paths, and some pathlib paths for iterating on the folder. start by just say, giving it a path yourself and then writing just the part that verifies that the path is correct
for iterating over a directory, take a look at either os.listdir or, i'd recommend pathlib's Path.iterdir()
 
Are you using py2exe for your program?
 
7:49 PM
@ChristopherBrown Yes
@ChristopherBrown py installer
@ParitoshSingh ok so like when the installer lunches it also lunches a script to do that? Just to clarify, my installer is something like the direct X installer or the visual studio one
 
your installer isnt like a direct X installer because it's technically actually bundling an entire python interpreter and that runs.
anyways, implementation details of the installer aside, yes, you're running a python script/python code as normal.
So, it's just code. you just have to write the logic appropriately.
 
@ChristopherBrown tangential note: that would be True, and the test would be if a: ...
 
cbg all, bugrit
 
cbg
 
@ParitoshSingh I'm sorry I should have explained better. py installer gave me an exe. I then package it with NSIS (Nullsoft Scriptable Install System) to create an installer, which is why I came around to ask all these questions. Based on the responses though I'm guessing if I use the NSIS (Nullsoft Scriptable Install System) to create my package what I'm asking for would not be possible.
 
7:57 PM
@AndrasDeak Gotcha, I would have gone a=path.exists() if a =='True': install in the path, else: then launch some sort of gui for the user to navigate to the install folder and assign that as the new install dir.
 
@Dave not sure what is NSIS or how it interacts with a pyinstaller exe, but going on a certain "common sense" assumption, something must be firing the py code as usual, no? So, here's my recommendation then, instead of us having to guess and make assumptions, why dont you make a simpler py script and find out.
make a dead simple py script, say something that just prints out a message, or writes a message to a file perhaps. Bundle it up with whatever and see the result
 
Trial and error/brute force coding, my fav :)
 
I remember knowing about all that NSIS stuff [drools into beard] ...
 
@ChristopherBrown and a == 'True' would always give you False for a bool a.
 
Knowledge I am far happier without.
 
7:59 PM
And if you have if a == True then you're using an anti-pattern, just do if a. Which was my point.
 
Never mind "the right to be forgotten," fight for the right to be able to forget.
 
01:00 - 20:0020:00 - 00:00

« first day (3855 days earlier)      last day (1091 days later) »