Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: A question about encoding
Post: A question about encoding

I had to add .encode('utf-8') to the end of a string containing vowels with macrons (ā and ē) to prevent my Kivy app from crashing, but these characters are not rendered properly in the app now. ē ap...
Exsul1 GUI 1 1,458 Mar-18-2020, 12:40 AM
    Thread: Two Linked Kivy Windows?
Post: Two Linked Kivy Windows?

Would it be possible to have Kivy launch two windows in Windows 10 that are linked to each other in some way? I have in mind to make a game that would make use of my monitor (which my students can't ...
Exsul1 GUI 0 1,281 Mar-04-2020, 07:32 PM
    Thread: How do I reference a method in another class?
Post: RE: How do I reference a method in another class?

Solved: I had to pass self.root into ConjugationGame.change_game_state().
Exsul1 GUI 3 4,221 Mar-02-2020, 07:32 PM
    Thread: How do I reference a method in another class?
Post: RE: How do I reference a method in another class?

(Feb-29-2020, 08:00 PM)ndc85430 Wrote: On line 18, you need to call the method on an instance of the ConjugationGame class. You could of course just add the parens to that line to call ConjugationGa...
Exsul1 GUI 3 4,221 Feb-29-2020, 08:11 PM
    Thread: How do I reference a method in another class?
Post: How do I reference a method in another class?

How do I reference a method in my BoxLayout class from my App class? class ConjugationGame(BoxLayout): round = 1 game_state = 0 def change_game_state(self): if self.game_state >...
Exsul1 GUI 3 4,221 Feb-29-2020, 07:44 PM
    Thread: A function for correctly using "a/an" before a word
Post: A function for correctly using "a/an" before a wor...

I want to make a function that, when passed a string containing a single word, returns that word preceded by the indefinite article "a" or "an," depending on which is correct. This would be easy enou...
Exsul1 General Coding Help 2 4,657 Oct-07-2019, 05:51 PM
    Thread: In linear time, find the maximum sum of all possible contiguous subarrays
Post: RE: In linear time, find the maximum sum of all po...

(Oct-02-2019, 09:04 PM)Gribouillis Wrote: It seems easy if you define s[j] = sum(arr[i] for i in range(j)) because if the maximum sum of contiguous subarrays is reached for a the range(a, b) of indi...
Exsul1 General Coding Help 29 9,029 Oct-03-2019, 10:06 PM
    Thread: In linear time, find the maximum sum of all possible contiguous subarrays
Post: RE: In linear time, find the maximum sum of all po...

It works. I tested the function that runs in linear time against my quadratic-time solution 10,000 times, and both give the same result, no matter what integers are in the array: import random # Gi...
Exsul1 General Coding Help 29 9,029 Oct-02-2019, 09:02 PM
    Thread: In linear time, find the maximum sum of all possible contiguous subarrays
Post: RE: In linear time, find the maximum sum of all po...

(Oct-02-2019, 01:05 AM)ichabod801 Wrote: I'm confused. The array as a whole is a subarray of the array, right? So the sum of all the positive numbers in the array is the maximum possible sum of all ...
Exsul1 General Coding Help 29 9,029 Oct-02-2019, 03:51 AM
    Thread: In linear time, find the maximum sum of all possible contiguous subarrays
Post: RE: In linear time, find the maximum sum of all po...

(Oct-01-2019, 11:37 PM)Gribouillis Wrote: False idea removed. I don't understand your answer. Can you elaborate? Update: Oh, wait. You gave an answer and then deleted it. Sorry, I'm dense someti...
Exsul1 General Coding Help 29 9,029 Oct-01-2019, 11:48 PM
    Thread: In linear time, find the maximum sum of all possible contiguous subarrays
Post: In linear time, find the maximum sum of all possib...

Per an interview question offered as a "question of the day," how would you find, given an array of integers, the maximum sum of all possible contiguous subarrays in linear time. I'm pretty sure my s...
Exsul1 General Coding Help 29 9,029 Oct-01-2019, 11:18 PM
    Thread: How to serialize custom class objects in JSON?
Post: RE: How to serialize custom class objects in JSON?

(Sep-22-2019, 06:26 PM)ndc85430 Wrote: In essence, it just boils down to making a JSON object where the keys are the field names (and so the values are, well, the field values). If you can make a di...
Exsul1 General Coding Help 4 3,432 Sep-22-2019, 06:53 PM
    Thread: How to serialize custom class objects in JSON?
Post: How to serialize custom class objects in JSON?

The Python documentation on JSON reads, "This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. The re...
Exsul1 General Coding Help 4 3,432 Sep-19-2019, 07:46 PM
    Thread: How do I write class objects to a file in binary mode?
Post: RE: How do I write class objects to a file in bina...

After talking with some folks in another forum, best practice might be not to store the class object at all, but rather to store the attributes of those objects to a list or dictionary and then recrea...
Exsul1 General Coding Help 7 5,649 Sep-14-2019, 05:41 PM
    Thread: How do I write class objects to a file in binary mode?
Post: RE: How do I write class objects to a file in bina...

(Sep-14-2019, 03:11 AM)ndc85430 Wrote: It's difficult to suggest an appropriate solution when you've given very little context. What is the application for? What kind of data does it need to store a...
Exsul1 General Coding Help 7 5,649 Sep-14-2019, 03:18 AM
    Thread: How do I write class objects to a file in binary mode?
Post: RE: How do I write class objects to a file in bina...

This seems unnecessarily complicated for something seemingly as simple as storing data. How do people usually do it?
Exsul1 General Coding Help 7 5,649 Sep-14-2019, 01:04 AM
    Thread: How do I write class objects to a file in binary mode?
Post: How do I write class objects to a file in binary m...

How do I write class instances to a file in binary mode? When I try to run this code, from npc_gen import NPC n1 = NPC() a = open("workfile", "wb") a.write(n1) a.close()I'm told: Output:Unexpe...
Exsul1 General Coding Help 7 5,649 Sep-13-2019, 03:39 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020