« first day (3472 days earlier)      last day (1469 days later) » 

1:57 AM
Is python as powerful as JS for development purposes? I think of using python in Data Science related tasks and JS for development tasks. Can anyone guide me if I am right in thinking so?
 
 
1 hour later…
AMC
3:01 AM
@paradoxlover Is python as powerful as JS for development purposes? That depends entirely on what you mean by powerful.
 
3:33 AM
@paradoxlover Yes, Pythons are far more powerful than coffee soaked move scripts, although play scripts are a closer-run thing.
 
@AMC powerful as in - The required tools are available and more can be done in few lines of code. Take machine learning for eg. you've got sklearn, keras, tensorflow and what not. TBH I haven't heard of any ML library in JS. Even if it exists, python prevails.
 
4:14 AM
can't find the best dupe for aliasing when assigning to list of sublists Changing member of list impacting copy of the list
...aliasing when making shallow copy of nested list
Actually here's a target: How to clone or copy a list?
Btw, the tag wiki says it refers to "Distortion caused in analog-to-digital conversion by a too low rate of data sampling." But most of its 154 uses, in C/C++/Java/Python refer to pointer or variable aliasing, and then there's also SQL aliasing.
 
AMC
5:03 AM
@smci Unless I’m misunderstanding what you’re looking for, would List of lists changes reflected across sublists unexpectedly do the trick?
 
@AMC Well I already cast my close-vote using the above target. That one you mention is alright not great, but the example it uses [[1] * 4] * 3 which newbies are likely to misunderstand as being due to that syntax, not just all nested lists in general. So I prefer the target I mentioned. But either way, please help voting to close those three.
 
5:41 AM
Hello. What is the best way to search the api of module in the interpreter?
ok never mind, I think I figured this out...
 
6:25 AM
@smci signal processing should always take precedence :)
 
 
4 hours later…
10:28 AM
cbg
 
sigh fell for another "best practice" trick question...
grumbles back into the shadows
"What's the best way to do X?" "Well, it's x because of this, that and these" "Oh that's good, but actually I wanted to do not-X as well."
 
@MisterMiyagi heh... so is it best practice to answer such questions and why? :p
 
11:18 AM
hi fam
can u help me on how to inline increment a value?
like
(ord(iv[m+=1]) << 24) | (ord(iv[m+=1]) << 16) | (ord(iv[m+=1]) << 8) | ord(iv[m+=1])
            cbcleft = (ord(iv[m+=1]) << 24) | (ord(iv[m+=1]) << 16) | (ord(iv[m+=1]) << 8) | ord(iv[m+=1])
 
Step 1: Don't.
 
i try to convert the js code to python
but im stuck
for exmaple
right = (message.charCodeAt(m++) << 24) | (message.charCodeAt(m++) << 16) | (message.charCodeAt(m++) << 8) | message.charCodeAt(m++);
do you have another appraoch there Aran?
 
Yeah, just add 4 in the next line.
 
?
 
right = (message.charCodeAt(m) << 24) | (message.charCodeAt(m+1) << 16) | (message.charCodeAt(m+2) << 8) | message.charCodeAt(m+3)
m += 4
 
11:22 AM
oh
ty
ill give it a shot
 
@0x45 out of curiosity what does that code actually do... looks like a JS-ish way of trying to do something that might have a more straightforward way of doing it in python rather than shifting things
 
11:40 AM
@bad_coder Hah.
 
How can I check if the given perimeter is a pythagorean/right-angle triangle?
 
@JonClements decompiling a game file
 
@X4748-IR check the Pithagorean theorem? Just watch out for floating-point errors.
 
@AndrasDeak Yes. By the given perimeter. Hmmm
 
@X4748-IR if you just have a perimeter then you can't
Closing as unclear
you can scale any given right-angle triangle with a factor to achieve an arbitrary perimeter length
there are continuous infinity^2 solutions
 
11:53 AM
I thought the same thing. You're right. Somebody was asked to answer this question.

Doesn't this equation work? 3x + 4x + 5x = perimeter?
 
@X4748-IR close them as unclear
x = perimeter/12. You're welcome.
 
:D X can be anything anyways... thanks. I barely remember geometry from the highschool. I thought maybe there is something to do
 
@0x45 still looks like there might be a simpler way... have you sample input/output?
 
its a game file as I said
which needs DES decryption
let me link you
@JonClements
 
@0x45 thanks... a quick look at that and err yeah... I think I'll crack on with trying to have a day off :)
(trying to not do too much thinking today!)
 
12:05 PM
u could hit me on discord if u need the gamefile or sth to test
breezko#0088
@JonClements
I'm off bbq now, cya later :)
 
rbrb
 
Am I fine with Python 3.6.9 or should I upgrade to 3.8?
 
@JossieCalderon you can look at the release schedule of 3.6 to see if that's OK with you
Seems that it's supported until 2021 December but it'll only get security bugfixes. If you want new features it's a good idea to upgrade.
 
Hi to all,
I am trying to change the title in ubuntu bar (panel).
How can i do this?
I tried: `import Tkinter as tk
win = tk.Tk()
w, h = win.winfo_screenwidth(), win.winfo_screenheight()
win.geometry("%dx%d+0+0" % (w, h))
win.title("Papinhio player")
win.tk.call('wm', 'iconphoto', win._w, tk.PhotoImage(file='images/epalxeis.png'))
win.mainloop()`

But the title is only changed in window.
In the panel i can see the favicon but next to it, it displays Tk.

What i am doing wrong
?
 
using python 2 ;)
I can't repro on debian so I'm afraid I can't help try debug that :(
Are you on gnome?
 
12:21 PM
so you suggest me to use python 3 instead?
i think so...
 
@ChrisP that's just the default guidance because python 2 is no longer supported :) It won't help your issue, I'm pretty sure.
you'd have to change your current code to import tkinter as tk for it to run and there might be other subtle differences
 
Ok thanks
Happy Easter to all!!!
 
thanks, you too
@ChrisP although I can't get a favicon to work and in the window switcher (alt+tab) I still see "Tk"
however if I construct it as win = tk.Tk(className='asdf') I see a default title of 'asdf' and in the window switcher I see 'Asdf'. Might just work for you too.
I don't actually know what className is for so perhaps this is a bad workaround :D
 
12:42 PM
def answer(perimeter):
    if(perimeter % 12): return "It's not a right-angle triangle."
    x = perimeter/12
    abc = [3,4,5]
    for index,val in enumerate(abc):
        abc[index] = int(abc[index]*x)
    return abc
 
Updated to python3.
Your code works!
 
* I think this would be the answer.
 
@ChrisP neat!
@X4748-IR I offer you a triangle with sides 6, 8 and 10
 
@AndrasDeak The sum of that is 24. It will return what you offered! But for some number like 13 it would return an error.
 
@X4748-IR ah, no, that's not what I meant. Triangle with sides 4, 4, 4*sqrt(2)
or triangle with sides 1.5, 2, 2.5
 
12:49 PM
@AndrasDeak Is that a right-angle triangle?
 
@X4748-IR yes
 
Hmmm. I thought maybe I shouldn't conder the float number
 
>>> 4**2 + 4**2 - (4*2**0.5)**2
-7.105427357601002e-15
 
If the result is going to be a float number it returns an error.
 
Most right triangles don't have a 3:4:5 side ratio
 
1:20 PM
@Andras apparently the tycho monolith on the moon does though...
 
1:50 PM
How do I create a room like Ouroborous? I didn't suppose I'd need one for the COVID chat room but someone has decided to move on from this room and take stuff there
 
You can set the access to "gallery" in the room's settings
plus there are plenty of trash rooms already on chat.SO if you don't feel like maintaining a separate one
 
Ah, perfect, thanks
 
there's also one called the "friendly bin" when you want to take out the trash with a silk glove, but I prefer the former
 
Yeah, I think we're way past the silk glove approach. The puppy did some vacuuming up, though, thanks :)
 
2:11 PM
@AndrasDeak 5, 12, 13 and 7, 24, 25 jump to mind from high school algebra
 
I never remember any others :)
 
9, 40, 41   ->   odd_number_x, (x**2-1)/2, (x**2+1)/2
 
I'm pretty sure I've coded a Pythagorean triple search for project Euler...
 
3:11 PM
You can generate all primitive Pythagorean triads using (u²-v², 2uv, u²+v²), where u & v are coprime, with one of u or v being even & the other being odd. If u=v+1 the 1st term simplifies to u+v and the difference between the other 2 terms is 1. Eg, v=5, u=6 -> (11, 60, 61)
@ChrisP You should always save a PhotoImage to stop it getting garbage collected. Otherwise, your image may mysteriously become blank. See the note at the bottom of effbot.org/tkinterbook/photoimage.gym
 
Is it not weird that the objects photos are passed to don't hold references?
 
Not all arguments converted during string formatting? This error is driving me nuts.
 
@JossieCalderon What do you get from print(len(row))?
Why is it even mentioning string formatting? Something is missing
Is this postgres btw?
 
@AndrasDeak I suppose it is weird. It's definitely annoying, but you get used to it, eventually. ;) I guess there may be a logical explanation, if you know Tcl/Tk.
 
It's MySQL
csv_data is a csv.reader object
 
3:27 PM
FWIW, from a Pythagorean triad you can easily construct a solution set for a²+b²=2c², see math.stackexchange.com/a/1250949/207316 for details.
 
so when I tried print(len(csv_data[0])) it said it's not subscriptable
But it didn't throw that error when I tried

for row in csv_data
 
One sec, I'm working on it
 
yeah, csv readers are iterable, but not subscriptable
 
@JossieCalderon dpaste.com/27JYR7D
IIRC the MySQL placeholders don't require quotation marks and you can get rid of the outer loop to execute in a single transaction
 
The problem is that the Tkinter/Tk interface doesn’t handle references to Image objects properly; the Tk widget will hold a reference to the internal object, but Tkinter does not. When Python’s garbage collector discards the Tkinter object, Tkinter tells Tk to release the image. But since the image is in use by a widget, Tk doesn’t destroy it. Not completely. It just blanks the image, making it completely transparent…
 
3:32 PM
@JossieCalderon you'll also need to call list() on your csv.reader
 
@roganjosh in the loop header?
Ah, you've replaced the loop. OK.
 
@AndrasDeak that's one of the things that makes me grumpy about different SQL flavours. executemany for psycopg2 is just a wrapper around around a for loop so it ends up doing it in multiple transactions anyway :/
I think for MySQL it actually does get submitted as a single transaction
 
3:51 PM
I am wondering how we can use background gradient (like in css) in python3 tkinter menu (instead of bg)
 
I think you're overestimating tkinter there
 
Is there any other gui in python that i can use for this porpose?
 
QT and WX are popular but not part of the standard library
 
@ChrisP I suppose you could create a gradient background image, and then overlay it with stuff that uses a transparent background. However, transparency support is a little flakey in Tkinter, and can do different stuff depending on the OS (ironically, transparency support is better on Windows than Linux, despite Tcl/Tk's Unix roots).
 
4:07 PM
One Tkinter object that does support transparency is the somewhat neglected BitmapImage
 
that's a good solution i think
 
@ChrisP Right. FWIW, Bryan is our top Tkinter expert, and was coding in Tcl/Tk before Tkinter was invented. So his Tkinter answers are generally of high quality.
 
Reminds me of when for rounded borders and gradients in web pages, you use to have various corner piece images and a background and then float them around your div etc... oh the fun days :p
@PM2 is that oakes or somthing?
 
I've got an answer somewhere that lets you create 4 way gradients in Tkinter...
 
Who is Brayn?
 
4:11 PM
Oakley the guy that answered the question you just linked, @ChrisP :P
 
@JonClements Or something. ;) Oakley.
 
@PM2Ring was on the right line at least :p
at least I didn't say Adams :)
 
:D
Oh, BTW, I forgot to mention earlier, I'm glad you decided to return to modding, @Jon
 
@PM2Ring I appreciate the thanks
 
I wonder what would happen if Shog got nominated to be a mod... :)
 
4:20 PM
@JonClements I mean, you never know. With our fabulous technology these days, we could probably re-modulate his voice, spin some dials on a nondescript machine, and find that Bryan Adams has been teaching us how to pack frames all this time.
 
@roganjosh sounds like something that'd be dangerous to play backwards in case it summons Cthulhu :)
 
@roganjosh like Brian May ;)
 
Exactly!
 
can never know with Br[iy]ans
 
4:24 PM
hi
 
please i have a question about a little problem i have in flask
 
shoot
 
i have a code like this: stackoverflow.com/questions/57722897/flask-404-not-found but when i run it and pass a path with '?' in it, it automatically appends a '/' before the '?' making the code not to function well, please how can i prevent it from appending '/' before the '?'.......i hope my question is not confusing
 
Another question: How can i put images left to text in tkinker menu?
 
Brian May is an awesome guitarist, but he's probably one of the least hip people on the planet. ;) I watched a YouTube clip of him last night playing a Beatles song, acoustically. But he doesn't have an acoustic guitar with him in his covid isolation, so he played an electric guitar acoustically. :)
 
4:31 PM
@IsraelObanijesu @app.route('/imagelookup/<string:img>/', methods=['GET']) --> @app.route('/imagelookup/<string:img>', methods=['GET'])? Note that I removed the final /. I'm not sure I follow what you're asking, though.
 
@ChrisP Sorry, I don't like menus much, and I've hardly ever used them in Tkinter. But from a brief look at the docs it shouldn't be too hard. effbot.org/tkinterbook/menu.htm
 
Great... time to put some Queen on :)
 
Hello Friends. Does anyone know how to make a HEAD only request in python? I was using Requests, but it seems to make a second request for the favicon. If I do it with curl it does 1 request. If I do it with requests it is making 3 requests
 
@ChrisP On 2nd thoughts, maybe it's not so easy. :) But take a look at stackoverflow.com/a/38571943/4014959
 
@Johnston err are you sure? requests won't decide to do that by itself - that's very much a browser thing
 
4:40 PM
I created a simple server with the example on the Flask page
@JonClements I will triple check. I usually only come here when I'm absolutely sure.
 
from PIL import Image
im = Image.open("images/radio.png")
editmenu.add_command(label="Αναπαραγωγή",font='Ubuntu 11', image=im, compound='left')

Error:

Traceback (most recent call last):
File "Papinhio player.py", line 35, in <module>
editmenu.add_command(label="Αναπαραγωγή",font='Ubuntu 11', image=im, compound='left')
File "/usr/lib/python3.6/tkinter/__init__.py", line 2887, in add_command
self.add('command', cnf or kw)
File "/usr/lib/python3.6/tkinter/__init__.py", line 2878, in add
self._options(cnf, kw))
 
@Johnston HEAD requests using the Requests lib are straightforward: requests.readthedocs.io/en/master/api/#requests.head
 
Is an absolute path needed?
 
@ChrisP Please see the code formatting guide for future
 
@roganjosh ok!
 
4:43 PM
@Johnston I think you're looking at the server logs that are serving static content, correct?
 
@roganjosh i am not sure if you get my question very well, although i can't test your change because the server is now complaining of too many requests.....anyway, just to explain further, the code is meant for taking imagepath and scanning them through google image search, so if i send an imagepath like: 'https://url.com/img', it works but if i send an imagepath like: 'https://url.com/img?query=0', it automatically turns to 'https://url.com/img/?query=0' which is a wrong path
 
@roganjosh yes.
 
@IsraelObanijesu which is why I removed the training / in the route
 
Same error trying with absolute path.
 
@Johnston I'm not sure that this is a thing that requests is actually doing, but rather something that the web server might do internally
 
4:45 PM
@roganjosh oh okay then, i will test it when the server cools down
 
@roganjosh let me test straight from a REPL and see what happens
 
@Johnston I'm not sure what that means in terms of a web server, but ok
 
`>>> from __future__ import print_function
>>> from PIL import Image
>>> im = Image.open("images/radio.png")
>>> print(im.format, im.size, im.mode)
PNG (256, 256) RGBA`
So the image opens well
 
Someone didn't read the formatting guide :/
 
I used `` with no luck
 
4:46 PM
Which the guide would have told you
 
>>> im.show()
Opens the image....
 
@ChrisP Ok, that's weird. BTW, since you're using Python 3, there's no need for that __future__ import, but it won't hurt anything.
@ChrisP Oh, hang on. A PIL Image isn't the same as a Tkinter PhotoImage.
 
Great
 
You can easily create a PhotoImage from an Image, though. And recent versions of Tkinter can open PNGs (older versions only recognized a few image formats, like GIF & PPM).
 
I fix the error
`from PIL import Image, ImageTk
image = Image.open("images/radio.png")
photo = ImageTk.PhotoImage(image)
...

editmenu.add_command(label="Αναπαραγωγή",font='Ubuntu 11', image=photo, compound='left')`
And works as i expected!
 
4:55 PM
@ChrisP Excellent
But you should be able to open it without PIL, eg photo = PhotoImage(file="some_image.png")
 
Can I save images from fontawesome.com as png images?
 
hey why does del my_list[-1:-1] dont deleate an item ? somehow I dont get it
 
@ChrisP Sorry, no idea. But fonts should be actual fonts, not images!
 
my_list = [1,2,3,4]
 
you must erase the last pointer.
That's from the theory
in high school
 
5:02 PM
@HoboCoder check my_list[-1:-1] first
 
@HoboCoder For the same reason that del my_list[2:2] doesn't delete anything: you specified a slice of zero length.
 
@PM2Ring ah okay got it
 
@HoboCoder Cool
 
So, I figured out what my error was....@roganjosh. It turns out I was missing a column. I only accounted for 17 columns but there were 18. So it threw the error "Not all arguments converted".
 
@JossieCalderon Glad you sorted it. That's one reason that I split the parameter names into a newline list because it's much easier to debug that way
 
5:10 PM
Well, it was from the .csv file itself. It totally did not occur to me that the first column, which contained the numbers should be accounted for. The first row has no text so I skipped accounting it. Human error for sure.
 
@HoboCoder You might be wondering "But why doesn't Python give me an error or warning when I create a zero length slice?" If so, see stackoverflow.com/q/9490058/4014959
 
columns = ['a', 'b', 'c']
sql = 'insert into table ({}) values({})'.format(', '.join(columns), ', '.join(['%s'] * len(columns)))
@roganjosh I tend to do ^^^
 
@JonClements noooooooo
 
whyyyyyyyy?
 
@JonClements sure, but that won't help if you have a mismatch of actual datapoints and what you account for in columns
 
5:14 PM
@JonClements oh, you're inserting the columns, not the values. False alarm :D
 
true but makes building the string much easier based on a single source
 
@JonClements yeeeeeeess
 
Hahaha. I think I'm partly responsible for putting Andras on edge for these things :P
 
that or the Deak needs to have more faith in puppies or something :p
 
Regards!
 
5:15 PM
hi Chris
 
Happy Easter to all!!!!
 
@JonClements you can never know :D
 
@AndrasDeak In this situation, a false positive is infinitely preferable to a false negative. :)
 
You see? PM said I'm right!
 
fine then... I'll go sit in the corner and put the cone of shame on :p
 
5:18 PM
I'll join you :P
 
You're more than welcome... but it's probably better to pick another corner what with this whole 2m rule and stuff :)
 
At least Andras didn't actually berate some poor newbie for an SQL injection vulnerability that doesn't actually exist. ;)
 
My program is working now PM. Cheers
 
@ChrisP Happy Easter! FWIW, I live in a part of Sydney that used to have a fairly large Greek immigrant community, although these days the Greeks are probably outnumbered by the Chinese.
 
Day 2,965. The bluff is still working - still no one expects I'm a newb... the experiment continues...
6
 
5:26 PM
We've all always known. This is our experiment; how long can we keep this up for? :P
 
 
4 hours later…
9:12 PM
What is the best AI book or website in your opinion?
 
 
1 hour later…
10:26 PM
@X4748-IR Star Wars
 
 
2 hours later…
11:59 PM
How can I pass ForeignKey in Django/DRF from Class based (generics.CreateAPIView) to my serializer such that ForeignKey is not visible in DRF form as I would like to pass that data manually from my views. Hence my serializer should not show that ForeignKey but should accept that field from user side. How should I do it? The problem is I can pass data only if I include that field and when I include it, its visible in DRF form.
 

« first day (3472 days earlier)      last day (1469 days later) »