« first day (2714 days earlier)      last day (2239 days later) » 

12:02 AM
String questions like that always make me imagine people having the same problem with physical objects.
 
I saw my friend John yesterday and called out "John"! Now how do I get the quotes off him so I can use him?
 
"I bought this picture of a house for 200 grand. How do I get rid of this weird border thing so I can live in it?"
"Dude, that's not how pictures wor-"
"IF YOU DON'T HAVE SCISSOR RECOMMENDATIONS YOU'RE NOT HELPING WHY IS STACK OVERFLOW TERRIBLE"
7
 
rbrb
 
wim
OK the scissors thing worked but now I have this new problem ...
 
wim, that's because Python can't do 3D, you need to use C++. Everybody knows that.
 
12:54 AM
Is there a good answer that explains that global has to go inside the function, not at the top level, and why, while not encouraging people to use globals?
 
 
1 hour later…
1:55 AM
@abarnert That would be wishful thinking
 
 
2 hours later…
4:05 AM
@abarnert Case in point: stackoverflow.com/q/49419955/4909087 The error is deceptive, and np.any/np.all is not the answer here :D
 
4:26 AM
I tried to write the entry on the canon page to explain when it is and isn't a dup without going into too much detail. Do you think it needs more info?
 
Link please?
 
This is a different case than either "use any" and "get rid of the condition, keep the mask array around". I don't think the canon page could actually explain this case to someone who doesn't know numpy well, but at least it can hopefully make them realize they don't know whether it's a dup or not and leave it for someone who dos.
 
hi everybody
 
The question that actually sent me searching for all the dups didn't fit any common scenario—what the user wanted was to loop over all the values >0 so he could set every value back to 0, which… yeah, there's an easier way to set every value to 0.
Hi
 
Hi all, I have a question on Python 3 here : stackoverflow.com/questions/49399471/…
Post it yesterday, didn't get too much attention, thought you guys would like to take a look
 
4:37 AM
@YukaLangbuana I'm still not clear on the question. What happens if Matt matches John in one property, but Luke in another (and Luke and John don't match each other at all)? Does Matt appear in two groups? Or do you merge the two groups? Or arbitrarily pick on of the two to group Matt with?
Also, if Matt and John match in both position and school, is it OK to have two Matt&John groups, or do they have to be collapsed into one?
 
5:03 AM
Hi All, I read this as a lambda function example:

*Sorting by an alternate key

>>> sorted([1, 2, 3, 4, 5, 6, 7, 8, 9], key=lambda x: abs(5-x))
[5, 4, 6, 3, 7, 2, 8, 1, 9]

But not able to make out that how abs(5-x) applied on sorted and got the given output. Could someone plz explain?
 
Have you read the docs on key functions?
 
yes, i read
 
In [2]: [keyfunc(i) for i in range(10)]
Out[2]: [5, 4, 3, 2, 1, 0, 1, 2, 3, 4]
That may help you reason about it.
 
What do you not get from the HOWTO?
 
key is used to extract a comparison key from each list element
in this particular example, how abs(5-x) applied in sorting.
 
5:07 AM
If you read the part about the old-school decorate-sort-undecorate method, using a key is like that, just more efficient. So think it through that way. First it does this:
[(key(x), x) for x in lst] gives you [(5-1, 1), (5-2, 2), (5-3, 3), etc.]
Then you can sort that, and then take the keys back out.
When sorting it, because (5-5, 5) is (0, 5), that comes before (4, 1) and (3, 2) and (4, 9) and so on, so it ends up first on the list.
 
If i have two files APP and MODEL.

in APP have a variable named class_type = "faster"

in MODEL have a class like this class Animal(class_type)

How can i import class_type of APP in MODEL?
 
Oh yes, thank you for the awesome explanation. This we called as sorting on alternate keys?
 
@CodeQuestor away of the computer the camel seen like have a penguin instead of the 2 leg
 
from app import class_type ? @VictorA.
 
@VictorA. In deserts, it will be camel only :-)
 
5:16 AM
@CodeQuestor magical sand penguin? jajaja i have more than 4 hour coding Flask jajaja if hurt learn from zero, my mind start talk non-sense
 
@abarnert I just edited the "matching value" result to clarify the confussion
 
@sytech the example is from Flask, im importing models, but if i import specified class, i get error, but if i import => import models, work, why?
cannot import name User
 
It's a circular dependency. This document explains the problem and solution pretty well.
 
@sytech i found the same jejeje
7
Q: "ImportError: cannot import name mail" in Flask

XarI have built is a simple web app with Flask and Python, which I intend to upload to Heroku. When starting my app locally, with the following script: #!venv/bin/python from app import app app.run(debug = True) I get this error message: Traceback (most recent call last): File "./run.py", line ...

 
@CodeQuestor I don't think I've seen it called "alternate keys", but that's a good name for it.
 
5:22 AM
thanks, i used

import models
@sytech do i need create the init file? with flask creation or in same files works
 
6:04 AM
@VictorA. This camel look like penguin is taken from Perl O Reilly's Book :-)
 
6:38 AM
Morning cbg
And evening to @piRSquared.
 
6:59 AM
cbg
Is it just me or the number of cv-pls requests has gone down (here)?
 
7:20 AM
Usually I send them to room 41570 (SO Close Vote Reviewers) these days.
 
8:08 AM
cbg
 
8:21 AM
cbg o/
 
@AshishNitinPatil I have not noticed many here either.
 
@AshishNitinPatil Here's one: No MCVE stackoverflow.com/questions/49412460/…
They're almost there, but for some reason refuse to provide the problematic table definitions.
 
9:02 AM
could be sensitive info?
 
> Sorry to disagree, you'll have to find a better duplicate. os.listdir returns the file names, os.walk returns a triplet root+list of files+list of dirs for each dir. Not as easy to grasp.
ಠ_ಠ
On a question that's about "I tried to open the file using just the file name, without turning it into a complete path first"
 
9:18 AM
@davidism: nice going on the Flask tag!
 
9:30 AM
@Pizzalord Which is why a MCVE does not have to be the actual problematic code, but a code that reproduces the error.
Usually the actual code is far from minimal anyway.
 
9:49 AM
import json
script = soup.find('script', { 'id': 'is_script' })
rawData = script.text.partition('window.__INITIAL_STATE__ =')[2].strip().rstrip(';')
data = json.loads(rawData)
for k, v in data['productSummary'].items():
if k != 'asyncStatus':
var = v['value']['media']['images']
for i in var:
print(i.get('url'))

Melon for a spark.
 
jjj
10:10 AM
@Aran-Fey LOL (cool eyes btw)
 
I mean, I can kind of see where he's coming from, but still... if the OP really needs step-by-step instructions a la "now take these two variables and put them together to get your file path" they're doomed anyway
 
jjj
10:49 AM
Yeah, I agree. It's just a bit funny to what length you can go in proving that something is not a duplicate.
 
People just really dislike having their precious issues called 'dupes'
 
Hmmm. Is it true that the worst-case complexity of [my_list.index(x) for x in my_list] is (len(my_list)+1)/2, i.e. linear?
Since index will always find the first occurence, the worst case is a list with no duplicate elements like [1, 2, 3, 4, ...]. So my_list.index(1) takes 1 step to complete, my_list.index(2) takes 2 steps, etc. So that's 1+2+3+4+...+n = (n+1)/2, right?
 
can you assert that index traverses from back to front instead of hopping around randomly, making its worst case n^2?
actual opinion: yes.
 
1+2+3+4+...+n = (n+1)(n) / 2, so quadratic...
 
@GillesCastel I knew there had to be a stupid mistakes somewhere, thanks
 
11:15 AM
Cabbage
 
cbg o/
 
Accept on a dupe I answered 2.5 years ago... probably a new record
 
that someone takes the time to go back to an 2.5 year old question to accept an answer :O
 
@abarnert I'd expect numpy canon posts to only be used by numpy users
@Pizzalord they also edited explaining that having used python for a while now they understand... :)
 
jjj
11:34 AM
That's really nice actually
 
thats quite nice from that user then
 
Well a fluff edit to a question closed 2+ years ago is somewhat pointless, but they ceetainly meant well
Oh, and OP had 1 rep before the accept (wonder if they came back to ask anew)
 
probably did and then understood your answer
 
 
1 hour later…
Hi everybody
 
Cbg
 
user9107868
Cbg.
 
cbg o/
 
user9107868
I'm as suprised as you to be here.
 
1:02 PM
but but...
I want you guys to do my homework, just joking i would cv if i coud
 
I need someone to come sit at my desk this morning and do my work for me too ;)
 
if they could give me a backrub while they're at it, that would be nice
 
I could also do with someone to learn for me...
 
Both of these sound delightful now that you mention it!
 
I don't understand why I cannot send an email. I am using the code from the docs https://docs.python.org/3.4/library/email-examples.html#email-examples but I get a `File "C:\Users\Simon\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it` error.
 
1:15 PM
\o cbg
 
I have tried disabling firewall but I still get an error. I wrote the text file using: file = open('test.txt', 'w', encoding="ascii"), file.write('hello'), file.close()
 
What's unclear about the error? The mail server you're trying to connect to refused the connection.
 
What are the possible reasons? I tried "localhost" part to "127.0.0.8" but alas :(
 
Are you running a mail server on localhost?
 
Yes I am. Could this be the problem?
 
1:19 PM
Why would the problem connecting to a mail server be "I'm running a mail server"?
 
I am not sure I understand what you are saying. Are you saying I am trying to connect to myself?
 
I'm reading this conversation as,
D: Are you running a mail server on localhost?
S: Yes, I am. Could it be a problem that I'm running it on localhost, as opposed to something else?
D: No, there shouldn't be anything special about connecting through localhost compared to any other way. So if the mail server has a problem, it's not specifically a localhost problem.
By this interpretation, trying to connect to yourself is not an issue and you should focus your efforts on some other lead
 
Oh right. I understand now,
 
cabbage
 
1:34 PM
But If I change smtplib.SMTP('localhost') to smtplib.SMTP('smtp.gmail.com') I get a different error. But I am no longer on localhost
 
i solved the problem of that day when you help me :)

How can i set Integer(size)? that give me error
 
You can set integers the same way you set any other value: with assignment ex. foo = 23.
 
@Simon I don't get what's confusing here. The server is refusing the connection. So either the server is misconfigured, or it requires more than just the server name to connect to it, such as authentication. That doesn't sound like a Python issue, that sounds like a "figure out how to correctly configure a mail server" issue.
 
Sorry not specified, in Flask-SQLAlchemy, how can i set a Number = db.Column(db.Integer(SIZE), nullable=False)
 
@VictorA. stop typing on multiple lines
Integers just are, they don't have sizes.
 
1:37 PM
and for store a phone number do i need save in string?, are then (integers) only for pk, fk and money-sums
 
What do you think?
 
+36-20-...
 
Storing phone numbers as numbers would end badly...
 
cbg everyone
 
@VictorA. stop pinging me with every message, I'm actively reading chat.
 
1:39 PM
Can't store 1-800-CALL-KEV in an int. Unless it's a base 128 int.
 
i think strings jejeje, because in college we save number like integer somethimes, but a professor says "if you dont gonna calculate with him put varchar"
 
if your database is generic enough, any kind of assumptions regarding the phone number will lead to disaster sooner or later
 
@davidism Ok. So if I search how to properly authenticate/whatever is causing the problem then the python part of it should work. Thanks for the guidance.
 
This room was placed in timeout for 10 seconds; garlic
 
heh, the animation killed my tab
 
1:40 PM
@VictorA. please review our room rules before continuing: sopython.com/chatroom
You're asking ridiculously basic questions. Try things for yourself and come to us if you have a specific Python issue.
 
inner functions make my head hurt.
is there a clever way to avoid late binding closures?
 
How bout default arguments in the inner func:
def f():
    x = 23
    def g(y=x):
        print(y)
    x = 42
    return g

f()()
 
@Kevin Brilliant, thank you. <3
 
but I don't want to make changes in class
 
Idiomatically one might do def g(x=x): so you don't have to come up with a new variable name, but I picked y here so as not to confuse the issue with multiple identical names in different scopes
 
1:48 PM
@arshpreet Pass the variables as arguments?
 
@arshpreet Just like in any other method belonging to a class, you can make its variables accessible to other contexts by 1) returning them; or 2) assigning them as attributes to self
 
@Kevin but I don't want to make changes in class
 
If you are unable to change the function definition, then you're out of luck, because right now those variables get garbage collected at the end of the function. They're not just inaccessible, they're nonexistent.
 
@arshpreet It's hard to tell what exactly your problem is. Please give us a mcve to work with: Some code, the output produced by the code, and the output you want to get instead.
 
Unless by "changes in class" you mean "specifically changing either the return signature of the function, or its argument list, or changing what attributes belong to the instance" in which case I guess you can use globals, but that's not a maintainable solution in the long run
 
1:52 PM
I like the strategy of "start as if they've already responded to my question, wait, then ask the question".
@arshpreet welcome, please read our room rules: sopython.com/chatroom. In particular, come up with a full problem statment and minimal example before asking for help.
 
@davidism apology for that, I am taking care of it right now
can anyone tell me how to format code in chat?
 
Try reading the room rules that I just told you to read.
 
cool
 
3 messages moved to Sandbox
 
Here , If I have to use base_url after calling the class, how I can use it? dpaste.com/2TQD3DK
 
2:00 PM
return it
 
that is the thing, can't return it
 
Then you can't use it.
 
any option without updating the class?
I guess not?
 
Can you change what a piece of code does without changing that piece of code? Not really, no.
 
agreed to that.
BTW why we really use call method then?
 
2:03 PM
Because it's perfectly useful if you have the ability to actually define how it works
 
yes but any real world use case like here I can avoid __init__()?
 
"I can't modify this code. Why do we even use code?"
 
Or are you asking "why does this specific class have a call method if it doesn't seem to do anything permanent?". Good question.
 
It still does a thing, it just doesn't return anything.
In most languages you can call things for their side effects.
 
@davidism yes that is interesting , it happens sometimes i guess, you can play with it but not allowed to edit
 
2:05 PM
I really don't see how. This is getting sort of frustrating. Perhaps it would be better for you to try to read up on this on your own for a while.
 
It seems like your problem revolves around a poorly-implemented piece of code that you can't change. The next step is pretty clear to me: go to your professor or boss or project manager or whatever and say "hey, this code you gave me has a problem. Can you change it?"
 
user9107868
@davidism garlic?
 
inb4 davidism decides that weeding is the most entertaining thing he can do :)
 
@Kevin yes, it's real world problem now :)
 
I'm almost finished rewriting the Flask tutorial. Just need to do packaging and testing pages.
Going to need some beta readers soon.
After procrastinating for months, I've basically done the whole thing in a week.
 
user9107868
2:09 PM
Guinea pigs? You need someone to read it?
 
I know how to read! And would like to learn Flask actually!
 
I am available for identifying typos and making mountains out of molehills re: word choices
 
user9107868
And I'm available 'cus I have nothing better to do. I specialize in spelling and grammar.
 
I likely wouldnt be able to give much technical feedback. But could give you a set of beginner eyes.
 
Davidism probably wants a unicorn to emerge from the forest and say "I know all about Flask and have the time and inclination to give deep technical reviews"
but alas I am only a donkey with a paper towel tube taped to my forehead
3
 
2:12 PM
 
This is kind of like going to a code jam and ending up with you plus four "idea guys"
@AndrasDeak Precisely what I was thinking of. I see you are a man of culture, as well.
 
You all have me rolling this morning. Too funny.
 
There might also be a Far Side comic with that same premise, now that I think of it
 
I only know a handful of Far Side strips via The Internet, but I know every single pbf
of course the volume is probably somewhat different
 
user9107868
@Kevin I'm a cat with a toilet paper roll on my head.
 
2:16 PM
I have three volumes of "the far side gallery" on my shelf right here. Let's see... 200 pages, with an average of three comics per page... So just these three books constitute 1800 gags.
PBF's archive fits in roughly a 14*9 grid, so that's ~126 gags. So yeah the volume differs by an order of magnitude or two
 
user9107868
NasBEN you may want to reconsider how you are going to go about asking that question.
 
I HATE PIP
 
@AnttiHaapala awww, but pip loves you.
 
user9107868
sudo pip remove *
 
user9107868
It fails. Because "Desktop" is not installed.
 
2:19 PM
I, too, felt that the protagonist of Great Expectations was a bit of a twerp
 
so the problem of course is that pip doesn't do any dependency analysis
so I need to write a requirements.txt, by hand, every single *king time?!
 
Which is exactly why Miss Havisham refused to fund his education. nods
 
user9107868
@AnttiHaapala how many packages are you making?
 
this program has 100+
 
user9107868
Holy tomato.
 
2:21 PM
and we need to upgrade them
I mean not all of them are ours
only 20
 
user9107868
Make a universal requirerments file.
 
can't you just use pip freeze?
 
so pip is like this: if a requires b >= 0.2 < 0.4 and c requires b <= 0.3
so if you install a first, then c it works, if you install c first then a then c is not going to work
if you upgrade c then a isn't going to work
 
user9107868
Use pip altinstall
 
it isn't dark magic - since pip does know that both a and c are installed
 
2:23 PM
@TheOneWhoMade you're really not helping, and it's not feeling very clever either
 
it should always do full dependency analysis
 
user9107868
@davidism ok.
 
the worst thing is that if I have d that depends on both a and c, then it might, or might not, work depending on whether a or c is listed first. :D
 
I'm not sure how to deal with issues like that (since I've never had to deal with it), but pip freeze > requirements.txt has always been satisfactory for generating my requirements.....
 
I suppose they're interrelated enough in use that you can't just have a, b, c using different versions of the same package? Not that I know how you'd do that.
 
2:25 PM
they're run in the same process, that's why.
python doesn't let one do that, this isn't javascript :(
 
but you have to do it from a clean venv, otherwise it will pull reqs you don't actually use.
 
sub dependency versions are really annoying, I thought pip was doing something to address that
 
@JGrindal the thing is everything has got setup.py and they've got perfect solution on what will work with them
but pip doesn't care
so every time i'd hand install a library I need to tweak all versions again
 
@AnttiHaapala Gotcha. I haven't dealt with a requirements list as long or complicated as you're dealing with. I'm not quite sure how to go about that.......
 
2:28 PM
I was looking at that too. I'm not clear what the invitation was for in the first place. Is he offering to clean up the English mistakes? You don't need a chat session for that, just edit them out
 
@AndrasDeak I thought I'd upvote her for her to get enough rep, then I read the question. Oh well.
 
user9107868
@Kevin I edited the question. I just want new users to know that we are approachable, and they don't need to not ask because they are afraid.
 
who's "we"?
 
Stop inviting people to the room on our behalf.
 
And if that is the intention, there's an ambiguity here and I think the OP is interpreting "Most of us will help" not as "most of us will give you grammar tips" but "most of us will give you the answer to your question, but only in chat"
 
user9107868
2:29 PM
@Kevin Then I should clear that up.
 
user9107868
@davidism I didn't specifically invite them to this room.
 
user9107868
@AndrasDeak the SO community, in general.
 
Ah, OK.
 
But as you say, none of this is directly related to this room, so I have no horse in this race
This is just my molehill-mountain automatic reflex
 
user9107868
@Kevin that reflex would be nice if you went through the review ques...
 
2:32 PM
FWIW the user ended up here and TheOneWhoMade posted a message out of the blue aimed at them, which made me look at that question in the first place
 
user9107868
Would you like me to redirect the user?
 
I can only identify problems, not solve them :-P
 
user9107868
Kevin then you would have to do the "triage" que.
 
user9107868
filler
 
user9107868
 
2:36 PM
PyPI dependency graphing... kgullikson88.github.io/blog/pypi-analysis.html interesting
 
Hey quick thoughts on this answer. That should be downvoted for sure right? Really seems like a comment to me.
 
@AnttiHaapala wonder about those two huge clusters, if one of them is the scipy stack
 
user9107868
ZackTarr It kindof looks like an answer, so I am leaving that up to you.
 
@ZackTarr not a comment at all
besides, comments should be flagged, not downvoted
 
That looks like an answer.
 
2:37 PM
downvotes are for low-quality or wrong answers
 
@AndrasDeak there's adjacency matrix down there
 
@AndrasDeak Noted on that.
 
I closed the question
it lacked MCVE and a specific problem and whatnot
 
Wasnt sure. It seems to be more of a statement rather than an answer.
 
@AnttiHaapala ah, didn't see the corresponding legend, thanks
 
2:38 PM
Oh well then it doesnt matter now. Thanks!
 
neat
 
It looks like an incorrect answer, since it's not printing each character in the list element one-at-a-time like the OP wants(?), but it still looks like an answer
 
user9107868
Kevin then I should remove my upvote...
 
Only if you agree with my interpretation of what OP means by "prints every word from specific word"
 
user9107868
I agree with that.
 
2:42 PM
Remember this chat room isn't a cult, so think for yourself.
6
 
It looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck. Is what Im getting from this now haha.
 
I also thought it might mean "print every word in the list, starting with the specific word, and continuing to the end of the list" in which case every answer is wrong. I'm beginning to think that there was a reason this post was closed ;-)
 
user9107868
umm... geese aren't ducks
 
user9107868
@vaultah has a decent chance of making it into the election. Best wishes!
 
user6276743
2:55 PM
Quick question: I have created a person object, which has a random location assigned to it upon initialization. There is a global variable which keeps track of the number of ppl in each room that has to be incremented.

Is it better practice to increment the global variable from inside the class init, or after intializing?
 
@TheOneWhoMade thanks
 
@WeavingBird1917 if your "room" is a class why not have a class variable there rather than a global variable
 
user6276743
@MooingRawr I just have an array which keeps count of the total number of ppl in each room. Only the ppl are classes.
 
If the Person instances are stored in a collection such as a list, then you don't really need a variable to track the number of people in the room, you can just do len(people_in_room) on demand
 
@WeavingBird1917 are you sure it's an array?
 
user6276743
2:59 PM
Yes, they are kept in a list, but the number of room is dynamics, so all the people are in one list.
 

« first day (2714 days earlier)      last day (2239 days later) »