« first day (4094 days earlier)      last day (1079 days later) » 

01:14
@roganjosh is now a Lead Data Scientist - Congrats!
Anyone here install Python3.10 on Linux? and successfully run pip afterward? I got this bug issue back in October (stackoverflow.com/questions/69512672/…) and just assumed that installing an update for setuptools would take care of things. It didn't click with me that since pip was broken, installing the setuptools update would be, um, a challenge.
(I have downloaded the release source package for setuptools and used python3.10 setup.py install, but that is not working either.)
01:59
cabbage
02:31
@PaulMcG Thank you kindly :)
 
3 hours later…
05:07
@PaulMcG Yeah, I have arch on my work computer and... things definitely happened (:
Not sure if I used get-pip or what
Yes, I tried get-pip also - will probably give it another run tomorrow.
should link to the issue in that post... maybe (:
05:28
I was waiting for independent verification that this was the actual problem before proclaiming it so.
06:22
Hi I need help in Python Tabula. I am trying to convert PDF into CSV using code
#!/usr/bin/env python3
import tabula
import pandas as pd
import csv

pdf_file='/pdf2xls/split_pdf/Input-page1.pdf'
column_names=['Product','Batch No','Machin No','Time','Date','Drum/Bag No','Tare Wt.kg','Gross Wt.kg',
'Net Wt.kg','Blender','Remarks','Operator']

# Page 1 processing
df1 = tabula.read_pdf(pdf_file, pages=1,area=(95,20, 800, 840),columns=[93,180,220,252,310,315,333,367,
410,450,470,520]
,pandas_options={'header': None}) #(top,left,bottom,right)

df1[0]=df1[0].drop(columns=5)
df1[0].columns=column_names
However the output CSV's 11th column is spilling into next column. How can I fix it?
"Spilling" is only going to happen when you have a rogue delimiter, e.g. a comma outside of quotes
I am very new to python can you please help with modifying the code to fix the issue
I can't fix the issue because I don't have anything to test. The best I can do is direct you to a solution, which is what I tried to do
Is this anything to do with Page Area or Columns = and mention in script
I don't know what any of that means, sorry
06:56
@roganjosh Pineapple!
Melon :)
Can anybody please help me to fix the issue as mentioned in above chats
No, because there is no repeatable example
Please do not treat the chat room as a helpdesk
I've looked over your problem and there's nothing I can do about a column "spilling over". I have nothing to test and I already answered you
Avv
Avv
07:41
Hello Guys,

Does wrapping a C++ code is literally writing same functionality in Python or is literally running C++ in Python? Does that mean we need C++ compiler to run wrapped C++ code that in Python please?
I would assume it's the latter where we simply run actual C++ in Python through some Python libraries that will warp the code. So this means we need C++ compiler for that to work anyway. Is the running cost of C++ code in Python will increase a lot or the difference is barely noticed please?
You can call into C/C++ with Cython
As to whether it's going to increase your run time, you'd need to explain what you're doing. Most likely, no, but you need to be clearer
Out of interest, how do you think that numpy works @Avv? Or CPython, for that matter
08:11
@Avv Who is "we"? Someone needs a C++ compiler, but it can be either the user or the maintainer. You can publish your code with pre-compiled C++ dlls included, or you can compile it on the user's PC.
08:53
Can someone on linux confirm that my code here works? I want to put a bounty on it, but not if the code is b0rked
09:11
I guess I'll just add a disclaimer
@Aran-Fey I can try later today
Neat, thanks
 
2 hours later…
10:58
@Aran-Fey I can't put gstreamer into a venv without building from source, right?
Pretty sure you can, sort of. AFAIK you only install the python bindings into the venv, gstreamer itself is installed from your system's package manager (if you don't have it yet)
Tbh I'm not really sure because it's always preinstalled on my OS
that's reassuring, thanks
@Aran-Fey So what's the python binding called?
PyGObject
ah, of course :P
before -> after button press
Wait what!
11:10
second button press does nothing
debian testing, python 3.9
The left side is a still image and the right side is animated?
no, only the static is animated
Yeah ok, that's normal
and it always prints the same "handle" (for a given session) when I press the button
so, rereading your question now that I know what it should be doing, I think it does the same thing as Windows
@AndrasDeak That's by design. There wasn't a point in writing code to switch back to the original canvas since it didn't work anyway
Could you also test this for me? You'll need to add those 2 functions to the VideoPlayer class and replace the player._video_overlay.set_window_handle(handle) with player.change_window_handle(handle)
11:14
sure
animation freezes on button press, nothing else happens in the window
Setting handle: 71303799
State of the new sink: (<enum GST_STATE_CHANGE_ASYNC of type Gst.StateChangeReturn>, state=<enum GST_STATE_READY of type Gst.State>, pending=<enum GST_STATE_PLAYING of type Gst.State>)
State of the pipeline: (<enum GST_STATE_CHANGE_ASYNC of type Gst.StateChangeReturn>, state=<enum GST_STATE_PAUSED of type Gst.State>, pending=<enum GST_STATE_PAUSED of type Gst.State>)
same handle with each button press
So at least that is the same on Windows. Thanks so much
anytime
11:32
recbg
Gst, my nemesis
 
7 hours later…
user17656212
18:41
Hi everyone. Excuse me, could anyone help me with this question? It is a bit long because I wrote at length and explaining well, but the question is quite easy. Thank you stackoverflow.com/questions/70544652/…
user17656212
0
Q: Count back through the database and count the fields to extract the data and create a condition

BobbyI have a game where robots fight. Robot wars scores are recorded. A robot fights on its own island, or out on the island of other opposing robots. I would like to browse the database table, counting backwards among the records, because I want to retrieve the previous data and use it to create a c...

18:52
Happy New Year To All Of You ❄️❄️
@AnkitTiwari Happy New Year y'all
@Bobby I don't understand the question for multiple reasons. Firstly, you keep saying you want to "count back", but I don't think there's any actual counting involved here. As far as I can tell, you want to load the robot's last 2 wars from the database and then run some if checks on those. There's no counting here. And secondly, I don't understand the problem. You load 2 rows from the db and then you check if they were wins or losses. Where's the difficulty?
user17656212
@Aran-Fey Yes, perhaps no count is involved. Sorry, I'm new to Python. I would simply like to count what is prior to the last robot war, but with the disputed island home and island away war. The difficulty is that I'm new to Python. I can check if there is a win or a defeat, as I showed in the code. What I don't know how to do and what question in the question is to control and maintain a grip, for example "Victory Away AFTER Victory Home"
user17656212
@Aran-Fey How can I create a condition with AFTER that checks "Victory Away AFTER Victory Home"? Can you help me please?
As far as I can tell, all you need is a SELECT * FROM war WHERE ? IN (robot_on_her_island, robot_on_island_away) LIMIT 2 followed by if is_home_victory_for(rows[0], 'Optimus') and is_away_victory_for(rows[1], 'Optimus')
user17656212
19:03
And with "SE"? In creating the condition what can I do? I am referring to running if Victory_away AFTER Victory_home:
print ("OK")
I don't understand. What is "SE"?
user17656212
I wanted to write IF, no SE. Sorry.
if is_home_victory_for(rows[0], 'Optimus') and is_away_victory_for(rows[1], 'Optimus')? Do you need help implementing those 2 functions?
That's basically just return row.points_robot_home > row.points_robot_away and row.robot_home == 'Optimus'
user17656212
@Aran-Fey First of all, thanks for your kindness. Theoretically I understand, but in practice not so much. With your answer it's a little clearer, but I'm still a little confused. Can you answer my question in the link please? So do more order code please? thank you
user17656212
You wrote me that SQL, but I didn't understand how to change my code, so how and where to add your code. With a neat answer on my question link, it would be more complicit for me. I thank you so much. You are really kind. I appreciate your help
19:23
Does this do what you want?
19:45
I don't think that will work
Looking at the example data, though, there doesn't appear to be any timestamp with which to do the ordering?
Oh right, my indices are off by one because I overlooked the id column
user17656212
@Aran-Fey Whats? I was unable to apply your SQL to my question code. I don't know how and where to apply your SQL. Can you answer my question on the site please? So order the code and show me. Here in the chat I did not understand very well. thank you
Sorry, but that's the best I can do
Is this your own code you're starting with @Bobby?
user17656212
@Aran-Fey Ok, don't worry, thanks anyway. Happy New Year Wishes :)
user17656212
19:58
@roganjosh Yes, this is it. I select the name of a robot from the combobox, then I search if this robot played the last war on his island or on an opponent's island. Then I print the dots. Thereafter there is a condition that prints "Victory Away" to me if the robot's last war is on an opponent's away island. This all works fine with the code I posted in the question.
user17656212
Now I would like to keep a condition in the condition, for example if Victory_away AFTER Victory_home: print ("OK"), then search for the previous war only if it was played on the home island and if it was a victory.
user17656212
I determine the time related to these data by counting the last time, the penultimate, the third last time (and so on ...) that the name of the robot appears in island home or island away.
user17656212
@roganjosh Can you help me please?
I ask because the suggestion from Aray-Fey didn't involve anything more complicated than what you have presented in the question, so it seemed unusual to me that you would have struggled to implement it
In any case, we ask that questions from main be left for 48 hours without an answer before being brought to the chatroom in our room rules. I would additionally ask you not to ping people to help you (as you just did to me) because I, and everyone else, are quite aware of your problem and will help if we can and feel inclined to put the time in
user17656212
@roganjosh Because I'm new to Python
user17656212
20:04
@roganjosh Ok. Sorry. I didn't know this. I apologize! Then I'll wait some time. Sorry again. Thanks for the kindness
No problem. Good luck
user17656212
@roganjosh Thank you. Happy new year wishes :)
And the same to you :)
I think tonight, I'll celebrate by finally untangling this stupid Java interface I have to deal with. I swear, every class can be cast to like 10 different objects and only one of them gives me what I actually need. Why did we think OOP was such a good idea? :/
I've been getting a lot of anti-OOP propaganda on my youtube feed recently. Lots of video essays explaining why procedural or functional are better. Don't know why they've been so heavily recommended to me but it's almost got me convinced
20:20
I like it to some extent and it'd be a push to make it get out of control in the way that Java can in Python. So we have that
Done properly OOP is a very useful tool... the problem is not everyone does it properly and it ends up a mess...
It doesn't help that the library is vast and almost entirely undocumented
keeps it fun though :p
Ah, "fun". Is that the word I was looking for? :P
Are there even any serious languages that don't have OOP?
20:23
Suddenly a wild Julia appears
(I've never used it and don't really intend to)
There's C of course, but that evolved into C++ which has OOP. And there's also stuff like the GLib, where devs went "You won't give us OOP? Fine, we'll do it ourselves"
To be fair, I just wanted to be a bit edgy by calling out OOP. In this case, it's entirely this library's fault for not being documented so it's tough going
Anyway folks... I'm not going to be staying up until midnight so I'll wish you all a fantastic new year now...
Most people who hate on OOP will then sit down and write a heavily OOP-based library that lets them write more functional code
And the same to you, Jon :)
20:27
Happy New Years to you as well, jon
So, I have a question tangentially related to a SO question I posted yesterday. I already found the solution to that question, but there's still one part of the puzzle that's bugging me. Since the main question has already been answered, I doubt that anyone will offer anything to answer the tangential question. Can I ask it here without penalty? Please forgive the confusing wording.
If it's not directly related to the question you asked then it's fine to ask here, just make sure we have enough context :)
rbrb for a little
20:43
Okay, here's the original question for context: stackoverflow.com/questions/70526966/…
My new question is, why do the standard python environment and ipython behave differently with this import? Could it have something to do with their path variables?
@Catyre you could check by printing the value of sys.path for both?
Their sys.path's are different, but I don't know what to make of that. When you import a python file that exists in the same folder that you're importing from, where is that represented in sys.path? The empty string in the list?
20:59
Happy New Years, Jon! And to everyone else, too!
@Catyre The empty string stands for the current working directory, yeah
Okay, well they both have that empty string, so they would both know to check the CWD
in the same position in the list?
No, it's the first in the regular python environment and the fifth in ipython's
21:07
sys.path is definitely different, but the first entry in the list is still the CWD for me - just the absolute path instead of the empty string
@Catyre that'd be why then... it searches in order...
I see. I was getting confused by the fact that the CWD was still in ipy's sys.path, so it still should have found my secrets.py. But it saw python's secrets.py first and stopped there. I understand now.
Thanks for the help!
21:59
@Catyre in future, make sure you add the tag to your posts, not just Python 3.x. Otherwise most people will never see it
22:34
Ah, okay. Will do. Thanks for the heads up
Avv
Avv
23:16
If we would like to initialize 10 variables to 0 in a class, one way to do that is to use vars in Python and then pass self keyword if we are to define the variables inside Python body. Is there a name for this syntax please vars(self)[f'x_{i}'] = 0?
 class Test:
        def __init__(self):
            for i in range(10):
                vars(self)[f'x{i}'] = 0
Most people refer to that as "you should've used a list instead"
Avv
Avv
you don't prefer this Aran?
I have never saw this syntax before
Nope. If you have a bunch of variables with numbers at the end, that's just a stupid way to make a list.
Avv
Avv
This is very confusing to me
So Aran how Python process vars(self)[f'x_{i}'] = 0 please? First, vars(self) will return dictionary of object variables, then we will use [f'x_{i}'] = 0 to add variable, but I am not sure how the last part works?
I see that in string literal, we can use that to add a value to a string f'x_{i}' % 0, but this is different from [f'x_{i}'] = 0?
What are you trying to do here... that's very anti-pythonic...
umm... you appear to be mixing up quite a few different things here...
23:20
All* variables/attributes in python are stored in some kind of dictionary. When you do self.foo, for example, that's just syntactic sugar for accessing the 'foo' key in self's dictionary. vars lets you access this dictionary.
Avv
Avv
I see Jon, I never saw this, but it works!
(*except attributes of classes implemented in C and __slots__)
I'd probably also use setattr instead of vars if something like this was actually needed
Avv
Avv
Thanks Aran, I see but can we compare f'x_{i}' % 0 to [f'x_{i}'] = 0 please or they are different?
Of course they're different, since when is modulo the same as an assignment?
I think you may be confused because you've never seen [] used in combination with a function call before. It may help to split it into 2 lines:
attr_dict = vars(self)
attr_dict[f'x_{i}'] = 0
Avv
Avv
23:24
Sorry Aran, I meant to say can we compare f'x_%i' % 0 to [f'x_{i}'] = 0?
Still no. 'x_%i' % 0 is string formatting, [f'x_{i}'] = 0 is an string formatting plus (half of) an assignment
Avv
Avv
So, how 0 get mapped to i? According to my information, this can be done in string literal f'x_%i' % 0. If we are to initialize a dictionary, one way is to use dictionary['key'] = value, so this is why dictionary[f'x_{i}'] = 0 is confusing to me?
'x_%i' % 0 creates a string that contains 0. attr_dict[f'x_{i}'] = 0 creates a string that contains i and then assigns 0 to that dict key.
Stop saying [f'x_{i}'] = 0, that's invalid syntax.
Avv
Avv
I corrected it.
So what you said is a feature added newly to Python or it's with Python since its launch ?
@Avv 0 doesn't get mapped to i. i is used to create the name of an attribute, like 'x_3'. The 0 is assigned as a value to that attribute
Well, I'm not sure if it's been this way since launch, but it's certainly been this way for at least a decade or two
Does this code confuse you?
my_dict = {}

for i in range(10):
    my_dict[f'x_{i}'] = 0
No? Then why does it confuse you when my_dict is replaced with vars(self)? It's exactly the same thing
Avv
Avv
23:32
I understand the my_dict part, but how [f'x_{i}'] = 0 gets executed is the confusing part
Never saw this before as a way to populate a dictionary in Python
populate*. I don't think we'll see dictionaries walking the red carpet soon, or be on the front of big magazines :)
Avv
Avv
:/
Corrected
I was only being light-hearted btw, no worries
Honestly, dicts are underrated. Dealing with GStreamer, I was reading the documentation for a class, only to realize it was essentially a glorified, overcomplicated dictionary. Those C programmers have it rough.
Avv
Avv
Happy new year guys
23:42
Looks like the folks outside my window have calmed down, so good night
Good night @Aran-Fey and Happy New Year
@Avv Happy new year to you also :)
Umm... I have no idea who this guy is on BBC1 right now
23:57
Can't help you, sorry
I've just loaded the live feed and it was 30 secs of confusion. Kylie and now.. this?
Ahh... Olly Alexander - first time I've heard of 'em...
Kylie never seems to age much...

« first day (4094 days earlier)      last day (1079 days later) »