@Kenshin I am not very good in python (or another coding language) but if you show me your code (or an example of the problem) in pastebin maybe I can find the error.
Sorry @Kenshin, I don't know about that subject (ctypes) and I get an error when I execute from referential_array import build_array so even I can't test your code. Sorry.
I don't know what you are doing but if I replace self.the_array2.append(self[i]) with self.the_array2 = [*self.the_array2, self[i]] it doesn't give an error. I hope that could be useful.
Oh k, I'll give it a try thanks, maybe need some clarification as to what that line means too
I'm trying to copy the_array onto the_array2, then with the extra size from the_array2, copy them back onto the_array again
Ok this worked for increasing an array from base size to double its size, but once that double size has been reached again, it no longer doubles it anymore, i need it to keep doubling when it gets full
question: let's say you have several lists that you want to incorporate into a big lists and change the the several lists as several sublists into the big list. Is there a way to automatize it with a loop or something else? I give you an example
a = ['a','b']
b = [''c,'f']
c = ['f','h']
...
z = ['a','1']
@Rawing it is not technical per se. More if I wanted to do something like, what should I do? yesterday when talking to DSM, I asked him what would be the best way to append two lists , making them sublists into a bigger list. His answer was to do that biglist = [[sublist1],[sublist2]]
I wanted to know if there was multiple sublists like in this case, is there a way to figure them out and to append them?
there shouldn't be. if you've stored each list in a separate variable, that would imply that they're not related - because if they were related, you'd have stored them in a dict or in another list to begin with. if you find yourself in a position where you have to combine a lot of variables into a list, it's likely that your code smells
if you're asking out of pure curiosity, then yes, you can probably use locals() to find all variables that hold lists... but again, that smells
def autoconcat():
a = [1, 2]
b = [3]
variables = locals()
c = [value for value in (variables[var] for var in sorted(variables)) if isinstance(value, list)]
print(c) # [[1, 2], [3]]
@Rawing out of pure curiosity, nothing else. But I'll bear in mind that it is definitely a bad method to apply if I have a big piece of code to write one day.
today's unexpected problem that wants to be fixed: I somehow managed to upload more than 2GB worth of files to my 2GB Dropbox drive, so now my backup program crashes because it can't deal with that situation
"Ah but this is just a 3d projection of a slice of a superellipsoid, which just happens to look like a sphere". And I'm a 4d projection of a slice of a superKevin which just happens to appear skeptical.
I'm wondering if I made my code too intelligent (trying to do too much in a single word - I tend to make that mistake and then later on can't decipher code anymore).
I tried to make a property "lazy" - it returns a list but only calculates on the first accessing
@Kevin How does one quickly read what a function does without knowing what types it works on? Especially if people don't put the type in the name of the function. I'm coming from a C background.
I usually depend on pluralization to indicate whether a value is scalar or not. widget is a Widget, widgets is a list. 'course, it becomes a problem if the word has identical singular and plural forms
This all sounds like a lot of work, which is why I only spend a couple days on a project so I can keep all the implementation details in my short-term memory instead of writing them down anywhere
Unrelated topic. The local police newsletter mentioned the thumping bass music that has been audible all throughout town. Their conclusion is "it's probably coming from the city, and the city cops are too busy investigating actual crimes to do anything about it, so oh well"
With an implication that, if we could narrow the location down farther than "probably the city", then maybe that would help.
Now I'm trying to figure out how hard it would be to triangulate the source of the noise to within the accuracy of, say, a 300 foot square.
Well probably easiest would be to use an aerial volume measurement - if you do it within the streets building reflections & absorption would make triangulation near impossible without extensive analysis of the accoustics.
I could position two* recording devices with synchronized clocks, far apart and roughly perpendicular to the approximate direction of the sound. Then I can determine the difference in time that the two devices recorded some distinguishable noise, and do math to it, yadda yadda speed of sound in air, yadda yadda intersection of the circle with the surface of the earth, and bob's your uncle
This is assuming that the sound is traveling in a straight line and not bouncing off of a lot of walls. There is only empty space between the city and me so I'm moderately optimistic
My back of the envelope indicates that I'd need timing accuracy to within 0.05 seconds to get a reliable position
ie at my room (10th floor) I hear sounds from the street louder than those at the first floor. - just because the sounds are bounced between the buildings and in some way converge on my window.
class A:
def __actual_foo (self):
print('The real foo!')
def foo (self):
return self.__actual_foo()
def bar (self):
# call the actual foo
self.__actual_foo()
class B (A):
def foo (self):
print('Haha! Overwritten!')
B().bar() # The real foo!
If the child class maker is following good design principles, then overriding a function shouldn't harm the execution of any other functions defined in the parent class, thanks to LSP. If they aren't following good design principles, then they're going to shoot themselves in the foot eventually no matter what you do, so you shouldn't worry too much about making the World's Safest Activity Box
Already tried to repin yesterday but it’s still marked as pinned for me in the transcript (probably because I was the one who pinned it last time?), and I can neither repin nor unpin.
This is unusual because I don't think I ever pinned it before, so the current working theory of "each RO can only pin a message once" doesn't fit the evidence
It’s displayed as pinned in the transcript, unpinning does just respond "ok" (but does not change anything), and trying to pin it (through the API call directly) says that "You have already voted, but the voting has been cleared by a moderator"
meta.stackoverflow.com/q/272383/953482 looks similar at first glance, but is actually "I'm not an RO and have never pinned this thing, but the transcript thinks I did pin it"
Which is different than "I am an RO and I actually tried pinning it and it said it pinned it but it's not actually pinned"
I'm also considering going into another room and asking the ROs there if they have had this problem and if they know a workaround. But that's kind of automatically off-topic in every room that cares about on-topic-ness
I'd say there's a positive correlation between on-topicness and the RO team being engaged and well-informed about the technical minutae of the chat system. So ironically the people most able to answer my question will be least willing
It’s displayed as pinned in the transcript, unpinning does just respond "ok" (but does not change anything), and trying to pin it (through the API call directly) says that "You have already voted, but the voting has been cleared by a moderator"
– which is btw. an interesting fact, that cleared votes are apparently still stored but just “disabled” by ROs?
In the Python chat room, we have a message that we like to keep pinned, because it is a useful reference for new users that are unfamiliar with the markup system.
An RO pinned the message, and it stayed on the sidebar star list for a few days before falling off automatically, as expected. Anothe...
I've read this answer to find out that pinned messages are being unpinned automatically after 14 days because "we found this feature to be abused too much". I fail to understand how a pinned message in someones chat room could abuse the site in any way.
However, I find pinning a message an extre...
I tested in another room with a message that was only pinned once and then expired: the problem exists there too. So the problem is probably not because there are too many pinholes in that poor message. — Andras Deak7 mins ago
If pin duration limitation is an intended feature, it would be really keen if trying to pin it said something like "sorry, you can't do that" instead of happily confirming that it did the thing it didn't actually do
Since there are people from all over the world here, but each of us is usually only in one timezone, the convention is to use the time that you actually know. ;-)
There are three cabbages. The Cabbage of the Morning, the Cabbage of Dusk, and the Cabbage of the Evening. Traditionally the Cabbage of Dusk is not used in conversation, for legend has it that it is forever beyond our reach, having been stuck in rush hour traffic since before man knew of cabbage at all.
Only at the foretold Sunset of Man will the Cabbage of Dusk finally arrive home and get a chance to crack open a cold one with the boys
@JonClements heh, I think that "move to/from trash" action messed up the chat. Clicking "load to my last message" takes me all the way back to July instead of last night.
//sometimes the main page crashes when it loads for the first time in a session, and we don't know why. So we'll just catch that here and reload the page and hopefully it will work the second time
This has been in the code base for many months. I am... Displeased.
To the original coder's credit, the duct tape solution works very well. The main page is perfectly stable, at least from the user's perspective.
... At least, I assume. It's possible that the users just don't report the problem. "Oh, yeah, the page always crashes once in the morning. It's always been that way. I just have to refresh the page"
Yesterday I found out about a task which runs on a server which occasionally explodes and consumes 100% of resources. The team responsible for maintaining that server doesn't monitor it, so they only find out when other people complain, which no one else can really notice until things have already failed. And their "solution" is to restart the task and mark the problem as "fixed".
hey I think it's a bit in vain to ask here: but is there a way to state (in type hints) that the return is "the same class as the input". For example:
def myFun(input: Sequence[BaseClass]) -> List[BaseClass] but if I would use ChildClass (which is a direct child of the base class and thus I can give it as argument) - the return would also be of List[ChildClass]
This actually happens in python by default - I'm just wondering how to make pycharm/type hinting understand this.
@Kevin I generally assume it's at my end, it does happen occasionally. I've a couple of other sites I regularly go to that crash/refuse to load first try or two.
File "C:\Python35\lib\typing.py", line 401, in __new__
raise TypeError("A single constraint is not allowed")
TypeError: A single constraint is not allowed
@Rawing Well "yes" apart from one thing: I could then give: def myFun(input: Sequence[T]) -> List[T] -- And then it is clear the type is the same (but can be any subtype of BaseClass).
Other valid reasons include "because the rules are more important than knowing how to get a monospace font and I don't want to imply they're equal" and "because the header is already ugly enough with just one unformatted url"
and "nobody reads the header anyway so it's futile no matter what I do"