« first day (3488 days earlier)      last day (1459 days later) » 

4:17 AM
@PaulMcG Can I add a scroll bar in the showerror() message box function.
 
4:34 AM
No, that's not really the purpose for these MessageBox windows. But I'm fairly sure that if you insert \n characters, you can show long messages in your message box and they will wrap to multiple lines. If you need to show something more complicated, then you'll need to construct your own Dialog subclass.
You could also subclass from MessageBox, to inherit some of the default button behavior. And maybe even add a scrollbar. But if you have something that requires that much text, maybe subclass from MessageBox and add a [Details...] button that would then show a dialog containing a textbox with your long text.
For text wrapping help, instead of writing this code yourself, look into using the textwrap module, provided in Python's stdlib.
 
5:37 AM
so I have been staring at this since last night... I can't even think of an approach to solve this....
i tried to solve this on paper, but i haven't got any result yet. makes me feel dumber every time I try :p
 
at least you have an O(n*m!) solution where n is the number of words and m is the number of distinct letters
 
5:55 AM
what type of problem is it exactly?
or atleast tell me pseudo code to solve it
 
1. gather every possible letter
2. generate every possible letter order
3. for each possibel letter order check if it's compatible with your list, stop if one's correct
it's definitely not the smart (nor right) solution, but it's very early in the morning and I'm not good with CS problems :)
I'm wondering if a topological sort could somehow help but that's all I've got. You have to reconstruct a directed acyclic graph from parts.
 
6:22 AM
Note: This is related to the MRO ordering. Python may have a builtin tool for it. Look for topological sorting.
 
6:42 AM
Hello all, can i ask a question here?
 
@vevekseetharaman within our rules, sure
 
I have a function which modifies a global variable, and it works just as expected when called using its name. However, when i call the function using .apply() to run it for every instance of a table, the changes made in the function doesnt reflect in the global variable anymore. Any thoughts/comments?
 
Do you have an MCVE?
 
Let me create a MCVE.
 
thanks
 
6:58 AM
thanks @AndrasDeak @MisterMiyagi
 
7:13 AM
It's Monday morning, 9AM. The SO forecast for this week: high chance of RTFM.
 
^^
I have to say, questions about Hello World Syntax Errors are a new low that I haven't seen before.
 
Is there an easy way to create a callable that I can make return a specific value, and that is pickleable? Basically like return lambda: self, except pickleable
The only two solutions I can think of are 1) creating a class with a __call__ and 2) creating an def id(arg): return arg function and wrapping it in a partial (both of which seem kind of... needlessly verbose)
 
Can't think of any. Many of my projects do have an identity function/class for such problems.
 
ok, guess my class is no longer pickleable
You know that feeling when you finally finish something that took way longer than it should have? Well, I'm finally at the point where my library can create a tkinter window without crashing when the window is closed.
Y'all may now applaud my superior programming abilities
 
7:35 AM
\o/
 
thanks for your support, Andras
 
8:02 AM
@Aran-Fey :claps:
 
*bows*
 
 
2 hours later…
9:44 AM
Good morning
 
 
1 hour later…
11:05 AM
Hello
 
hello
 
How are yoo, Jon Clements?
 
guess I'm fine... how's you?
 
I'm also fine. I am the new person in chat stackoverflow. Do I know what Python is talking about here?
 
well... there's general chit-chat as it were along with people asking Python stuff
welcome to the room
 
11:13 AM
Sorry I found out what is being discussed here? I'm actually new here so how can I help with COVID19 here? It would be nice to say please.
Jon Clements, thanks for your Greeting.
 
C19 isn't discussed here per se - there's a separate room where you might want to introduce yourself which is at chat.stackoverflow.com/rooms/210400/python-covid-help - you may want to say hello there
 
kevin'd :|
 
Hello
 
Hello, @ChrisP
 
I have a question.
If i save a file without an extension (example 123 instead of 123.php) how python can learn the appropriate extension?
I want to edit that file with python, but to do this i want to learn the file type...
 
11:29 AM
in general, you can't
 
From python manual:

mimetypes.guess_all_extensions(type, strict=True)

Guess the extensions for a file based on its MIME type, given by type. The return value is a list of strings giving all possible filename extensions, including the leading dot ('.'). The extensions are not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type type by guess_type().

The optional strict argument has the same meaning as with the guess_type() function.
 
@ChrisP Do you know exactly what a MIME type is?
 
The file is downloaded from the internet --> playlist.asx --> users.sch.gr/apappas/index.php?file=22 --> content-type video/x-ms-asf
Now i want from video/x-ms-asf to extract .asx extension
(Look the url above there is no .asx in it)
 
just store it with that extension, then
I'm not quite seeing the problem here
 
The problem is that url.com/file=22 is a valid url but has no information about the file extension (except content-type in headers)
 
11:35 AM
so use the headers!?
 
>>> mimetypes.guess_all_extensions('video/x-ms-asf')
['.asf', '.asx']
 
Xmm, ok i will try that way, but i don't really suggest
 
if you don't suggest it, you obviously know better and so I'm confused why you're asking advice here
 
I will make a manual relation (content-type,desired_extension)
If map fails then what?
 
see y'al in a bit
 
11:48 AM
@ChrisP Can you please clearly describe your problem? It's difficult to help when it's not clear what you need help with.
@ChrisP In general, you must know how to deal with unexpected data. A default "safe" action is to ignore/report it, since it is obviously not something you know how to handle (since it would be expected, otherwise).
 
 
2 hours later…
1:26 PM
Cbg
 
Not specifically a Python question, but anyway: too broad, too subjective and also off-topic for SO stackoverflow.com/questions/61593199/…
 
1:48 PM
@smci closed
 
 
1 hour later…
user10984358
3:07 PM
heya guys, been a while hope everyone is good, I am trying to solve this codewars.com/kata/5519a584a73e70fa570005f5/train/python but seem to run into time limit errors, is there a better way to do this? my code pastebin.com/0029yG5T
 
user10984358
I can see hits in the cache then shouldn't it work fine?
 
Could someone explain why when using PILLOW in python 3 if I was to do font.getsize('a') I get differing values each time the program is run? (for a font size of 32 using NotoSans-Thin.ttf I get either the dimensions (19, 34) or (17, 38).
 
why is today's xkcd so big?
or maybe it's Friday's...either way, I have to scroll for miles both vertically and horizontally. Is that just me or is that part of the joke?
 
my bad... It wasn't always getting the same font and was defaulting facepalm
 
@TheNamesAlc A streaming version of Sieve of Eratosthenes. (We discussed that last year, let me dig up the link). Suggestions: a) int(num\**0.5) may be expensive, if it calls floating-point sqrt. It's probably cheaper to square integers: replace for i in range(2,int(num**0.5)+1): with while i**2 <= num:
b) You don't need step=1, all primes are odd except 2, you can use step=2, once you've passed 2. Maybe a generator that yields 2,3,... your existing primes.
 
user10984358
3:19 PM
thanks for pointing it out, point b sounds obvious once you mentioned it, will look into Sieve of Eratosthenes
 
c) The usual speedup concept in Sieve of Eratosthenes is to use a set or hash of known multiples of primes, and once you discover a new largest prime q, you then either:
c.1) add 2*q, 3*q, 5*q, ..., p_i*q to known composites (wastes a quadratic amount of memory, not scaleable, don't do it), or else (the leaner version):
c.2) store the quantity q*q (it's pseudoprime, i.e. composite but not divisible by smaller primes, so it's quite expensive to test for primality) in your hash/set. Then you look up that hash/set before testing a number num, and if num is in it, you know to return False and skip primality-testing.
Here was a very fast but cryptic version by @PM2Ring from 2018:
 
user10984358
I have to manually generate a series to understand this
 
Aug 9 '18 at 11:17, by PM 2Ring
Check out this awesome prime number sieve using extended slice assignment. Some ideas came from a SO answer, but I already had a slice based sieve of my own, and I've made a few improvements to Robert William Hanks' version. I don't think you'll find a faster prime number sieve in plain Python.
and see our May 2019 discussion on prime sieving. But don't bother with wheel factorization.
@TheNamesAlc Also, can you use profiling to see where your cputime's going? See if num**0.5 is actually calling floating-point sqrt or not. Any tell us where the runtime is going.
 
wim
@Code-Apprentice I saw it earlier and it was normal size .. if it's part of the joke, I don't get it .
 
user10984358
@smci "See if num**0.5 is actually calling floating-point sqrt or not" -> when I didn't do the int conversion the loop failed, so I am guessing it returns a float, or do you mean something else?
 
3:33 PM
@wim So it's rendered ginormous for you now?
 
wim
yes
 
Actually you never want to loop over all smaller integers <= (num**0.5), not even just the odd ones. You only need to check your existing list of known primes {p_i} as candidate divisors. Otherwise you can see why doing that on every (odd) integer would be worse than O(N**2).
 
@Code-Apprentice the Turtle Sandwich Standard Model?
 
yes, that one
@wim ok, thanks for confirming it isn't just me. And I don't see anything in the joke why it would be a non-standard sized graphic. Maybe some CSS is foobar.
 
@TheNamesAlc: useful to measure your runtime for num=1,000, 1e4, 1e5, 1e6, 1e7... then you can tell how much you're improving it
 
user10984358
3:39 PM
ok sure, but I am sure if there is some other algorithm then the challenge requires me to do that and not this, I was under the assumption that this was a memorization/ generator problem
 
And here are some existing implementations:
60
Q: How to implement an efficient infinite generator of prime numbers in Python?

Hamish GrubijanThis is not a homework, I am just curious. INFINITE is the key word here. I wish to use it as for p in primes(). I believe that this is a built-in function in Haskell. So, the answer cannot be as naive as "Just do a Sieve". First of all, you do not know how many consecutive primes will be con...

@TheNamesAlc Okay but just because you're using memoization, doesn't mean your implementation is fast or performant or its memory requirements are scaleable. Consider the technique of storing large pseudoprimes q**2 to be complementary to memoization - it remembers for you the numbers you shouldn't test for primality, because they're composite but increasingly expensive to test.
Anyway good luck, get back to us with performance numbers on your speedup, I'm curious...
 
user10984358
will do, I will @ you once I run with mine and again with the Sieve implementation, thanks again!
 
Oh, also look at the cache size you used and at what value of num you blow out your cache, that's when your algorithm runs out of steam. (That's why storing only the q**2 pseudoprimes is scaleable and storing all multiples of primes totally isn't)
 
@Code-Apprentice I think something changed. The onebox of the same comic in chat also expanded a few days ago
firefox says "Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content." (warning)
 
wim
seems bug
 
3:59 PM
I'm viewing with FF. What are you using, wim?
oh...same result in Chrome, too
 
Looks fine to me on Safari/FF
 
fixed now
and now that I've reloaded a chat page, the onebox went back to the original size
 
quick question guys, if i wanted to add a duplicate key to a bst in python what would i need to do for the addReference() and removeReference() functions? more info stackoverflow.com/q/61573442/11302234
 
That question is already answered, and the code isn't properly formatted.
What exactly do you want to do with it?
Anyways, the most straightforward way to support multiple values per key is to stores lists of values instead of plain values.
 
4:18 PM
cbg
 
@MisterMiyagi yeah the question answer i was talking in general but using the programe function to add a duplicate
@MisterMiyagi what adjustment would i need to make for addReference() and removeReference() functions to accept duplicate keys
@MisterMiyagi or do i even need to to adjust anything?
 
well, you can directly test whether you need to adjust anything by adding a duplicate key
if that gives the desired behaviour, you're all good.
 
4:47 PM
Hello Anyone Give me list of Largest Project done by Python
 
user13287699
Is there any chance of Julia overtaking Python in the near future?
 
near future? no.
 
5:07 PM
@DomadiyaBhautik one of the biggest that are mostly python are instagram and dropbox
 
Training company TComp needs to hold information about the courses it offers, and which courses are pre-requisites for each other. Course X having pre-requisites A, B and C means that in order to do course X you should have completed courses A, B and C. Those pre-requisite courses may also have their own pre-requisites, and a course may be a pre-requisite for more than one other course.

When a customer applies for a place on a course, they complete an online application form, which is sent to a processing centre that processes applications in the order that they arrive. Courses have a limi
anyone can help me with this puzzle?
 
is that your homework?
 
No just trying to get a better understanding
and comparing my answer to other people
 
So you expect people to write one more essay so that you can compare it to other people's essays? This doesn't seem particularly Python related, by the way.
 
everyone thinks differently so this is useful for me to understand and look at things differently
 
5:14 PM
@Hassan it's not useful to us
 
ok sorry guys
 
@Hassan it's alright, this is just not the right place for such questions
@MisterMiyagi
 
@Hassan Please be aware that this question is weird in a Python context because you need exactly zero abstract data types.
@AndrasDeak done
 
im using a python to implement it
 
5:17 PM
@MisterMiyagi sent back from whence it came. I think...dupes might be exceptions
 
ok can i get your views of this
how would you guy rewrite this function to be more effective
 
are these questions related at all? It was Binary Search Trees, then Abstract Types and topological sort, now graph connectedness?
 
no im just looking for a topic we can discuss so i can learn
@MisterMiyagi are you good at working out complexities
 
5:39 PM
@Hassan What do you mean by "complexities"? Do you mean run-time complexity? Like Big-O notation?
 
@Code-Apprentice yes exactly that
i need help understanding it
 
Feel free to post your question rather than pinging anyone directly.
 
thank you mate
i need to know the complexity of the assignment of the above code
 
Please format for fixed font.
 
@PaulMcG all done mate
 
5:49 PM
Indentation matters in Python, @Hassan. That code is not runnable Python. But I wouldn't waste your time with reformatting it. This topic of complexity is usually covered over several weeks in a college undergrad CS class. I don't know if anyone here is inclined to coach you through that over chat, with very little effort shown on your part so far.
 
i understand i new to this im going to be starting college in September and i been looking at pass test documents to get a understanding as im in lockdown
maybe im to eagar
just by looking at that code could you work the complexity of the assignment?
would it be O(1)
 
@Hassan please see our code formatting guide for chat and practice in the sandbox if necessary
 
:49288658 is that right
 
6:20 PM
@Hassan that's exactly the kind of questions you've been told not to ask, and anyway a direct violation of our rules
Stack Overflow is not the right place for such "discussions".
 
@Hassan - I commend your desire to get an early start on your studies, but just starting with homework problems is not a good approach. Usually homework is assigned after having gone over some instructional reading or lecture.
Since you are in self-study mode, look for some general CS instruction material on the net. Several US colleges have offered their CS curriculum materials online for free.
 

« first day (3488 days earlier)      last day (1459 days later) »