« first day (3749 days earlier)      last day (1182 days later) » 

1:43 AM
Anybody remember how numpy stores arrays of custom objects internally? Does it store a reference counted version at each index? Or just the item without the reference count?
 
 
2 hours later…
3:27 AM
cbg, how can one find what are the possible kwargs from the boto3 doc? boto3.amazonaws.com/v1/documentation/api/latest/reference/core/…
I saw the source and its not documented there, is there a definite list where I can see what these kwargs are?
 
 
3 hours later…
6:23 AM
Is this relevant?
 
6:39 AM
I stumbled upon that thread, for now I am using a manual python based filtering to get what I want as some other thread said what I wanted was not possible
11
Q: How to list objects by extension from s3 api?

st78Can i somehow search objects in S3 by extension, not only by prefix? Here is what i have now: ListObjectsResponse r = s3Client.ListObjects(new Amazon.S3.Model.ListObjectsRequest() { BucketName = BucketName, Marker = marker, Prefix = folder, MaxKeys = 1000 }); So, I need to li...

 
7:12 AM
hello, I have a question: export MY_VARIABLE=100 in python context. How I can do that? then it goes to python3 preprocess.py train.txt.tmp \$MY_VARIABLE > train.txt like this.
 
Can you clarify your question a little more? As I read your question it has nothing to do with Python, but variable expansion inside bash
setting an environment variable sets it for your current bash session, so you can call for e.g. command $VARIABLE afterwards
alkasm:~$ export FOO=123
alkasm:~$ echo $FOO
123
this works if you're running any executable, whether or not its a python script. The expansion happens in bash, before it gets passed into the program.
 
@alkasm Oh. I see the problem. I am using window now. So I need to figure out how it work. Thank you
 
oh, for windows I think you use set and %variable%
> set FOO=123
> echo %FOO%
i dont have a windows box to confirm right now, tho. but you can google "variable expansion cmd" or similar.
 
I install windows Subsystem for Linux and export echo syntax work now. Thank you.
 
Greetings my lords
 
7:29 AM
cbg, idk about any lords, but I'm American so
 
I love to talk like medieval age style
 
user13727121
7:57 AM
What's the differences of using += operator and .extend()? I read that the only difference is that .extend() is a function call and can be used in function chain call (no idea what is that). For example, list_1 = [1, 2, 3], and I want to add 4, 5, 6, the result is the same when I use either the += operator or .extend() function.
 
+= only works if the right-hand-side operand is also a list, extend works with any iterable
 
user13727121
8:23 AM
@Aran-Fey I just tested it, I'm still not seeing any difference. The += operator works the same as .extend() function. The only difference I was able to notice is that if I only provide one value using += operator, I'd get a TypeError unless I enclose it with the square brackets []. And the .extend() function requires an iterable, else it'd return a TypeError as well.
 
oh, my bad, I was thinking of +
 
I suppose the underlying assumption is that we are talking about += specifically for lists yeah?
+= behaves differently for different data types
 
Pretty sure lists are the only data type that supports both += and extend, so...
 
@AnttiHaapala thanks for the share, that was interesting to know that value stays even when we de-reference it
 
8:41 AM
on the += vs extend front: a subtle difference is that += makes the name function-local.
 
I didn't understand this image though.
https://nedbatchelder.com/text/names1/names1.html#10

When we did x = x+ "there"
why it didn't append "There" to the reference of "Hello" which was already reffered
 
because x refers to a string, which is immutable.
 
and because the + operator always creates a copy
 
it is also important to note that operators are implement by types. So + can mean whatever the type operated on says it does.
 
@Aran-Fey well, shoot, touche. Time for coffee
 
9:18 AM
Cbg All.
@inspectorG4dget, I hope you get well soon. 👍
 
@Aran-Fey what happens to the immutable string when we de-refrence it ?
mean there would be any garbage collector who later deletes that?
 
That's... let's just say that yes, the memory is freed if it's no longer needed
 
9:35 AM
alright
 
If there is a PR in an open source project which was there since 6months and I asked what is the status because the last 2 months there was no activity and the PR is currently unusable, then the person responded, they have a fix and are testing it right now. How long is it appropriate to wait until asking again? I need the feature, but for an outsider I think it would be a few months to get into the code and finish it, that's why I would rather wait for the person to finish it, especially after
they said they have a fix. But if they tell me it's gonna be another 2months, I'd rather get into it myself
1 week passed since his message and I think of asking for an update again, is that ok or considered rude?
 
IMO you could have asked the estimated time at the same time when you asked for it?
 
Good point. So would you ask again with a question for the estimated time?
 
@Hakaishin volunteer to assume maintainership. In two years you know how it feels on the other side :P
 
9:52 AM
Hi all! I have a question, if you don't mind
 
sopython.com/chatroom suggests you just ask.
 
@Hakaishin I think it boils down to the fact that that's someone's unpaid work in their free time. They could take an year and it would still be unfair to "expect" them to finish it just because you need it.
 
Right -- Basically, there's a pitcher throwing out balls
 
If anyone (thinks they) can help they wll answer.
 
@holdenweb Thanks; I've got to model the problem with some code
 
9:54 AM
So if youre genuinely willing to work on this feature, perhaps start the conversation from that angle, offering your help if they need it. That might be a better way to tackle it. If they say no, they are almost done, then great you have your answer. If they say yes, i could use the help, well then you were going to work on it anyways if they couldn't finish it quickly, so it's the same as status quo in that case either ways, yeah?
 
If the pitcher throws a fastball, P(fastball->fastball) = 5/12, P(fastball -> changeup) = 3/12, P(fastball -> drop curve) = 4/12
Notice the probabilities add to 1
Now here's the thing -- how do I create a transition matrix for this thing?
There's only three states, it seems
 
@ParitoshSingh ofc I get that and I don't expect them to finish it, but I kinda expect them to give a rough timeline, because If I know it will take give or take x and I can wait so long + some safety margin, I'm gonna do other things. If I can't wait x I will try to do it myself.
 
Timelines might not hold up to the test of..time (i couldn't resist!) simply because unpaid work doesn't put food on the table
 
@ParitoshSingh Good idea, I will ask what's the status and if I can help and if yes if they could brief me a bit.
 
Yeah, i think that would be the cleanest way to get a sense of the progress and also to get your ultimate goal resolved
 
9:57 AM
I'm not sure if this is correct, but here's the transition matrix I got:
I'm just suspicious because of those double rows of 0s!
 
Dont have those rows. you dont know the probabilitiy of F given D
Unless..is it stated that they're 0?
 
If it helps, the original problem is this:
I've been working on Part a for a long time, but to no avail
So does that mean my transition matrix T is just 1x3?
 
in my "common sense" opinion, yes
 
That's strange, because all the Ts I've seen in example problems were square
 
saying it's 0 for the other states is incorrect. Their correct state is "not available"
So, if you were to make this into a 3x3 matrix, my common sense approach would say "NA" for the other rows, not 0
 
10:02 AM
@ParitoshSingh I agree with you too, but I'm just afraid it's not right
Hm, perhaps
The problem doesn't give enough information, right?
 
Aye, it only talks about transitions from Fastball.
 
So a rectangular T is apparently not possible, according to math.stackexchange.com/questions/1262163/…
Right
Now the problem is ... how am I supposed to find the steady state if I don't even have the full T?
Strange!
 
man ros has such stupid default values. If anybody ever makes something which has rgba values, they should chose a default of 0,0,0,1! not 0,0,0,0. So annoying
 
10:21 AM
Yup, still no progress
 
Anyone sees any changes in their company with the survey hr does? I never found these kinds of things sincere.
 
10:36 AM
OK, so I'm trying to understand the book's solution, but it makes no sense
Was that transition matrix just randomly chosen?
@ParitoshSingh Any ideas?
 
here is a possible 3-by-3 transition matrix
Answers like these should be burnt to the ground. Anyways. It looks like a Transpose of the style of writing the matrix that you showed me
the columns in this matrix are adding up to 1, instead of rows
 
The thing is the decimals in that answer seem to have no correlation whatsoever to the probabilities in the problem?!
@ParitoshSingh Right, I noticed that too
 
I mean, the person in this answer is Jennie, and the question asks about Gerrit Cole. are you sure youre looking at the right answer? If so, you can safely conclude this is entirely bogus
 
The names may be different, but the book states the exact same probabilities in the answer
That's why I'm so confused -- #1) It seems like the problem doesn't have enough information and #2) The solution picks out random numbers from thin air!
 
So at this point, i can only state what i've stated above, just common sense approach to how youd solve it. And i cannot guess the intention behind an incomplete question, or a strangely worded answer, because i didn't write these (phew)
 
10:43 AM
@ParitoshSingh Well, thanks so much for taking the time to try to help
I'll just go with the "possible" solution
 
Aye, but i'd also suggest a frame challenge with your teacher (assuming this is related to some homework) and see what they think, even if you have this discussion post assignment
 
"psuedo code" :|
 
11:01 AM
@Mikhail it can only be refcounted if you think about it
assuming I even understand your question correctly
 
is "custom objects" numpy speak for "regular Python objects"?
in that case, the object stores its own refcount.
 
11:23 AM
@MisterMiyagi yes, but numpy adds one, it has to
 
11:35 AM
it does? thought it just calls incref on storing it, and decref on releasing it.
 
@MisterMiyagi that's what I said
 
ah, misread your message. go on spreading knowledge, please.
 
@MisterMiyagi no.
 
12:24 PM
@MisterMiyagi "Custom objects" may actually be a reference to structured types, as discussed on numpy.org/doc/stable/reference/generated/numpy.dtype.html. I suspect we need clarification as to the meaning of that term.
 
@holdenweb I'm certain they meant object-dtype arrays
 
Fair enough.
 
12:55 PM
Has anybody switched to using their left hand, because of strain in the right hand and is it normal that my left hand hurts already? I think it's because I have no muscles built up in my left hand. Was wondering if somebody else did that switch and also I'm surprised nobody in my office has this problem, then again at home they don't continue to be on their pc.
I started using my left hand 2 weeks ago
Also I start to sympathize with vim fanatics because of hand issues
 
Maybe research Repetitive Strain Injury?
It's not unusual for muscles to ache when given unaccustomed exercise, but make sure it's muscles aching and not tendons!
I'm old enough to have started with arthritis in my hands, so I'm careful nowadays.
 
@Hakaishin hands/fingers don't have muscles as far as I know, only tendonds
hmm, hands do; fingers don't
I can totally human today
 
@AndrasDeak Feels about right :D
@holdenweb How would I differentiate these two?
 
@Hakaishin talk to a doctor
the strain in your right alone suggests that's what you should do
tendinitis, carpal tunnel syndrome and the like all need treatment
and start using ergonomic peripherals
 
1:28 PM
this is not a good sign btw, if such a strain develops it does not fix itself even if the hand starts feeling fine one day. you must give it rest for a while even when you think the pain has gone, for it to fully recover.
Essentially, err on the side of caution and dont overstrain even when you think it "feels fine"
I'd echo AD's thoughts with some urgency, talk to a doctor
 
Hello, i want to create a text file in the directory with the main.py project. How can i do that (python)?
is there someone who nows?
 
hm. are you familiar with how to make a text file?
 
@Hakaishin Not sure if that helps you, but in the past I have sometimes experienced pain (in both hands) when I was typing. I fixed that by learning Colemak, hasn't happened a single time since
 
yea i have this: import os.path

save_path = ''

name_of_file = input("What is the name of the file: ")

completeName = os.path.join(save_path, name_of_file+".txt")

file1 = open(completeName, "w")


file1.write('21')

file1.close()
can i do something that the save_path == the location of the folder of main.py
 
Have you tried googling something like "find location of python script"?
 
1:40 PM
yeah thats a good idea! tx!
I hadn't figured that out yet haha
 
Hmm interesting, I havent heard of colemak. I think it's more the mouse which is giving me trouble than the keyboard. Also I HATE doctors with a vigor. They have been utterly useless in my whole life(besides antibiotics, praise antibiotics). Otherwise they have been a pure moneysink with no result. I even tried to go to the doctors for wrist pain, they gave me a cast thingy which didn't work at all. So I'd rather not waste more money. Also I wish we had canadian like healthcare, then I could try
I will see if it stays for a few more weeks I guess I will have to go to the doctor again
 
@Hakaishin ergonomic mouse
 
I do sometimes feel uncomfortable using my mouse, but it's never been so bad that I had to switch to my other hand. But I definitely should buy a better one
 
@AndrasDeak Did you try one? They look so weird and well unergonomic. But I guess I should buy one, since I hope it's based on some actual research
 
@Hakaishin ah, if they look unergonomic then nevermind
 
1:44 PM
That's the annoying thing about buying a new mouse, you have to actually go to a shop and try a bunch
That's why I still use my 15-year old friend here *slaps mouse, which prompty falls apart*
 
I hope it still has a ball <3
 
my mouse gave up on me in 7 months. thats what i get for cheaping out
 
@Aran-Fey pretty much the same for me :P
 
(but i haven't given up on it yet! cue windows disconnect reconnect sound)
 
@AndrasDeak aw heck no, those have to be cleaned like twice a week
(may be slightly exaggerated)
 
1:47 PM
I just realized the thing causing the most pain is not even the movement of the mouse, but the scrolling. Any good alternatives for scrolling=?
 
I don't think I've used a mouse in a decade
 
what?
 
@Hakaishin ergonomic mouse
 
how?
 
@Hakaishin laptop trackpad
 
1:47 PM
wow... that sounds too crazy
 
@ParitoshSingh Mine only cost like 5-10 euros if I remember right. Every few weeks I'm surprised that it still works
@Hakaishin PageUp/PageDown? In some programs (mostly browsers) you can also middle click, then move the mouse up/down
 
Good point, I will start to use those buttons more, literally outside of consoles I never used them. Sadly I can't try out ergonomic mice due to covid and I'd rather try them first. Well I guess I will wait a month
 
 
1 hour later…
3:03 PM
Hi guys. I have a question about why setattr is not working?
There is no error, but when I use State class in other classes it returns me old values.
Am I properly setting static attributes on class State?
 
Don't you have to instantiate State()?
Are those class attributes you're trying to set?
 
Do I? I'm assessing values with State.field
look here, there are only static variables
 
@entithat Could you paste code rather than images of code, please? You can use a code paste service and link here.
 
thanks
@entithat not specific enough
 
3:07 PM
there is state.py in the root
oh, I'm probably saving State class in the wrong way
 
hmm, did anyone here worked with position of characters? I'm trying to save the position of certain characters in strings (letters) but in the smallest way possible (as in, the smallest notation/logic possible)

can't use offset/full number as it would take too much space per strings...
only thing i thought of that kind of worked was using BCD/binary numbers, and putting 1 where letters were in strings...but that use too much space in my current notation still
 
@NordineLotfi what are you trying to do? It's not really clear to me, and it sounds like an XY problem.
Some kind of compression?
 
@AndrasDeak just for a specific projects of mine. I'm not really asking for code, just for advice on the logic itself
@AndrasDeak not really
 
would take too much space... sounds very much like compression
 
@Hakaishin nah :D
I don't like my dataset to take too much space, but i still need the letters in the context of each strings...just don't care to know what those are, just their specific positions
I already have a working method but I'm curious if there better ways than what i already do is all
 
3:31 PM
Hey all!
Does anyone know how best to keep files (eg. CSV) in sync between an EC2 instance and a local machine? I'm unsure if I should be using subprocess, paramiko or boto3 in python to accomplish this. My logic is, if I run my script offline, I want to ensure that a)whenever I run my script offline, I import/sync the latest DB states from my EC2 instance, and similarly b) after I run my script offline, I'm able to export/sync my DB states back to my EC2 instance.
 
3:56 PM
@AndrasDeak, sorry for disturbing you. Why setattr does not work here? It supposes to rewrite static State class's property, but it does not work at all :(
https://github.com/zaxoavoki/pypad/blob/test/app.py#L18
 
@entithat I don't have experience with this, so what I'd do is first check on a dummy example whether it's indeed not working, and if it works in the dummy example then figure out why it "doesn't work" in your real code
 
it must work like this. However, it does not.
and I have no idea why...
 
sorry for image here xd
 
sorry for interruption.. Initially i have subdomain in public_html that host the WordPress and then now i have implement the python app inside that subdomain by removing all the WordPress files and comment out all the text in .htaccess while accessing that domain it shows 403 forbidden error.. after i add index.html file that error is gone . but now while accessing the url that is set in urls.py it say Internal Server Error.
can anybody help me which part i should look for... for this kind of situations please
 
4:16 PM
Hello, how can I use array elements as nested dictionary keys?
 
Juhu, they guy of the PR earlier today responded that he plans to spend the rest of the week on it and he didn't go into how I could help him, which sounds to me like it's close to finished :)
 
Let's say I have ["a", "b", "c"], I'd like to access map["a"]["b"]["c"]
 
@J.L.Louis there's a Q&A for that, hold on
also: that's a list, not an array
 
Yes, list, thank you :)
 
I remember an other one, but I can't find that right now
 
4:21 PM
@entithat Do you have a textual version of the code? The image isn't helpful for debugging, and the github link is 404.
 
@MisterMiyagi I have already fixed that problem, thank you
setattr was working well.
I just did not notice the changes ;D
 
"it doesn't work" strikes again
5
 
4:37 PM
what is the insertion version of dict.get() ?
instead of doing reduce(dict.get, keys, d), I want to do reduce(dict.insert, keys, d, value)
 
do you mean d[key] = value?
 
@MisterMiyagi that can be put into reduce
@J.L.Louis you can also write a function that uses a loop
 
you can try reduce(dict.__getitem__, keys[:-1], d)[keys[-1]] = value.
if that's a syntax error, then reduce(dict.__getitem__, keys[:-1], d).__setitem__(keys[-1], value)
FWIW, is this a toy problem or a real one?
 
real one, so I'm probably designing the solution wrong in the first place :/
 
I'd wager that you should try to design your problem differently to begin with :P
 
4:43 PM
so I have a bunch of settings in a file like
system::memory::cpu0::bank0 = 1
system::memory::cpu0::bank1 = 0
etc
and I'm trying to put represent that as a dict
 
If it is for handling data like that, I highly recommend to write proper functions instead of clever one-liners.
Future you will thank you for not needing to refuel their chainsaw.
 
Sounds wise, thanks!
 
I'm thinking something like
def nested_set(d, keys, value):
    if len(keys) == 1:
        d[keys[0]] = value
    else:
        nested_set(d[keys[0]], keys[1:], value)
 
Depending on your workflow, you can also consider a Mapping/dict subclass that understands such keys. Depends on whether these keys are used internally as well.
 
ofc this assumes that the data structure is already in place
 
4:48 PM
hands Kevin a recursive cookie
 
a rookie
 
>>> d = {1: {2: {}}}
>>> nested_set(d, [1,2,3], 4)
>>> d
{1: {2: {3: 4}}}
In comparison, if d is initially just {}, you'll get KeyError
Not too hard to change that behavior though
>>> def nested_set(d, keys, value):
...     if len(keys) == 1:
...         d[keys[0]] = value
...     else:
...         nested_set(d.setdefault(keys[0], {}), keys[1:], value)
...
>>> d = {}
>>> nested_set(d, [1,2,3], 4)
>>> d
{1: {2: {3: 4}}}
All that being said, 85% of the time it's easier to just have a flat dict and use tuples for keys
e.g. d[1,2,3] = 4. No recursion required
 
yeah, but each tuple is unique which makes for quite a large dict
I'm thinking of just using strings like "system::memory::cpu0::bank0" : 1
I need to compute the space complexity of that vs the nested_set method
 
It's certainly worth benchmarking yeah
 
do you actually need to access intermediaries? I.e. do you ever need system::memory to be a dict that includes both cpu0 and cpu1?
 
4:56 PM
yes, there are almost always intermediaries
 
Small strings are interned, so nested_set has the advantage there... But there may be overhead from allocating tuples
Not that tuples are particularly expensive
 
maybe JSON is the way to go
 
Can you actually change the input format?
 
I do like JSON
 
I do have a pitchfork and torches
And a pitchtorch!
 
5:07 PM
Good for angry mobs, bad for the actual intended purpose of its constituent parts
Trying to fork some hay onto my cart, and it just keeps catching fire
 
5:33 PM
You've just saved me countless hours of debugging why my carts all catch fire! stops wiggling the rear view mirror
 
@MisterMiyagi do they halt first?
 
Also inconvenient when you need to go to the outhouse in the middle of the night, and you go to light your bedside pitchtorch, and it stabs you with its sharp tines
 
@AndrasDeak My tests show that the halting problem can indeed by solved by a liberal application of brake pads.
Take that, computer science!
 
5:50 PM
@AndrasDeak <checks Python status board to see if for loops are currently down>
 
user15045124
Hi everyone
 
user15045124
I am working on self-project and would kindly request your help if possible
 
@john hello. Please don't ask for help with fresh questions on the main site as per our rules
 
user15045124
sure, but please take a look to see if my question is clear
 
9:37 PM
@J.L.Louis If strings like "system.memory.cpu0.bank0" would do, or if you wanted to modify the code to use a double-colon separator, you might want to meet hu.dotted_dict. The code's pretty gash, but it might give you a few ideas.
 
oh, nevermind, I misunderstood
 
I was replying to a comment that said he was thinking of using the strings as keys. dotted_dict has code that splits such strings down and descends a structure, of which nested dicts are a proper subset, to retrieve and set values. Seems relevant to me, but whatever.
Dunno what's got into this room lately.
 
No, sorry, I just misunderstood what you were suggesting and I thought you misunderstood the requirements.
I'll just refrain from acting on such assumptions going forward
 
Is there some way to find which class a member came from?
So for functions, sometimes __qualname__ holds this info, but I can't seem to get it to work for data members
 
@Mikhail you mean like obj.val = 3; y = obj.val and you want to recover obj from y?
 
9:50 PM
Hoping to know the class, not the instance...
 
OK, so type(obj)?
 
Yeah but I want to see the baseclass...
 
OK, doesn't matter. 3 is 3.
 
I mean, I want to find the class that originated the .val field
 
Yeah, so y == 3. That has no way of knowing where it came from, if anywhere.
 
9:52 PM
I mean its easy for functions, you just look up the __qualname__ attribute
so in your example, I want to identify the slot or dictionary from where the .y member comes from
 
 
2 hours later…
11:47 PM
Cabage
How can I vectorize this code?
outputMat = [row[:] for row in self.mat]
rows = len(self.mat)
cols = len(self.mat[0])
for i in range(rows):
    for j in range(cols):
        outputMat[i][j] = (1.0-coupling) * function(self.mat[i][j],parameters, np.shape(self.mat),nit,snapshot)
        for n in neighborhood:
            outputMat[i][j] += (coupling/float(len(neighborhood))) * function(self.mat[(i+n[1]+rows) % rows][(j+n[0]+cols) % cols],parameters, np.shape(self.mat),nit,snapshot)
 
@Marco based on that information you can't
 
@AndrasDeak hmm...more information needed?
 
Yes, an MCVE.
 
Ok, thanks.
I will try to do it.
Taking the opportunity, imagine any other faster way to speed up the processing of this code, without vectoring it?
 
No.
You have double loops over numpy array indices. They have to go.
Assuming these are numpy arrays. We'll see.
 

« first day (3749 days earlier)      last day (1182 days later) »