« first day (1601 days earlier)      last day (3341 days later) » 

DSM
3:02 PM
Morning cabbage for all.
 
Mornin'
 
Rbrb
 
DSM
This question incorporates a whole host of confusions.
 
I knew the answer to a question, but the OP had "also, how do I do [completely unrelated thing that Kevin has no clue about]?" on the end of the post, so I spent twenty minutes deciding whether to answer at all.
 
3:11 PM
Duplicate, but I don't have a hammer in the original tags.
 
OPs, please please please ask separate questions for your separate questions.
 
open or open not, there is no read - Yoda
 
DSM
Reading the previous questions, they don't seem great, but the ones I looked at don't seem actively trollish. Wonder how the OP convinced himself of that one.
 
maybe he tried "myfile.txt".read()
confusion between file names and file objects seems to be a very common problem among new programmers
They can usually puzzle out the issue on their own, but their code is forever riddled with poorly chosen variable names. file = "myfile.txt"; f = open(file)
 
DSM
3:17 PM
Bets on whether someone tries to be clever and posts a globals() hack?
 
who needs globals() when you can just eval() :D
 
eval('globals()')?
 
I kind of see where alternate Kevin is coming from on that "no read method" question.
 
ast.literal_eval('eval("globals()")')
 
DSM
I knew it. You Kevins all stick together.
 
3:20 PM
KevinScript.execute(create_call_node(make_external_function(lambda: eval("globals()"))))
 
cabbage
 
DSM
Top o' the morning to you.
 
@DSM Yes, Kevins do tend to form together into a gelatinous mass. It's a good defense against predators.
 
3:39 PM
hmm... my library keeps saying my query string is invalid but python seems to parse it fine.
>>> pp(p.parse_qs(p.urlsplit(url).query))
{'client_id': ['rs39bq4r7wd5668nwgbewwbe4fvyjzju'],
 'redirect_uri': ['http://localhost:3000/_oauth/battlenet?close'],
 'response_type': ['code'],
 'state': ['f1TBvGPlM7w5qq2UdkARfyqMgzkBjPjcVHlxUVAloyR']}
 
what's the original string?
 
https://us.battle.net/oauth/authorize?client_id=rs39bq4r7wd5668nwgbewwbe4fvyjzj‌​u&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F_oauth%2Fbattle‌​net%3Fclose&state=f1TBvGPlM7w5qq2UdkARfyqMgzkBjPjcVHlxUVAloyR
 
also, what library and error?
 
meteor's oauth server. (oauth_server.js:78) Unable to parse state from OAuth query:.
 
Is that state value something you generated, or something you were given?
 
3:42 PM
I generated it just by making a random identifier, the docs seem to say that's how the state should work
 
maybe try a smaller string, or an integer instead
 
tried all of that :\ the debugging tools aren't the best here either
 
When you tried a smaller string, what was the result? If it worked, try a string larger than that one but still smaller than your original one. If it gave an error, try an even smaller string.
 
DSM
@davidism: sometimes it's tempting to link to various PRs you've had accepted to a package, not to prove that you're necessarily right, but that someone should at least hear you out. I think I've only given in to that temptation once or twice..
 
Yeah, but what were we talking about again? :-]
 
3:56 PM
Can't a man just talk about PRs without an ulterior motive?
 
DSM
Igor's "Flask-user extension has its own way of working"-level comments..
 
Ah, stalking me, huh? <3
Can't make up my mind today. :S
 
4:17 PM
@davidism does flask have a convenient method to retrieve templates... something like:
@app.route('/page/<path:page>')
def get_page(page):
    return render_template(some_clever_function(page + '.html'))
 
you mean assuming that <path:page> doesn't map to the same path in the templates dir?
I do various interesting things with templates for the "static" pages on sopython-site: github.com/sopython/sopython-site/blob/master/sopy/pages/…
 
they'll be in the root of temlplates
so if someone goes to /page/whatever, then it renders the /templates/whatever.html template
 
you probably don't have to do anything then, just call render_template like normal
but you're basically describing what I just linked above :)
 
wow... okay... my brain isn't switched on at all today :(.... render_template(page + .html') is fine...
 
I do some checks to make sure the template actually exists so that I can redirect to the index rather than raise a 500
 
4:21 PM
okay... so I can just try/except it, and on an exception raise 404 instead though?
 
Yeah, that would work too.
I wanted to be able to list what templates were available, so that's where the extra stuff comes in.
 
Makes sense... but in this scenario I only care if exists/not... don't need to know anything else
Using Flask is so much more pleasurable than using Django
 
Finally figured out what that user was asking about Flask-User. It's surprising how many answers boil down to, "you wanted to know how it worked, so I looked at the source and here's how it works". :-/ stackoverflow.com/a/28882657/400617
 
I like questions that require source diving, because most fast gunners don't want to bother
Which means I have lots of time to answer, unless Martijn beats me because he just happens to know off the top his head what file to look in. Which only happens like 20% of the time.
 
4:38 PM
@Kevin Martijn look at source code? Bah... I bet he's memorised it :)
Could probably throw something like - what is line 7 of PyTuple_New and get a response :p
 
:-)
 
Yeah alright
 
Hi All
 
cbg
 
4:49 PM
I am trying to count occurrences of two keys together in a dictionary.
test = [{'Category': 'a', 'Num': '1', 'Day': 'Tuesday', 'Date': '2013'}, {'Category': 'b', 'Num': '1', 'Day': 'Tuesday', 'Date': '2013'}]


from collections import Counter
counter = Counter(item["Date"] and item["Day"] for item in test)
print counter
 
Can os.walk ever return an empty iterable?
 
It is counting correctly but, i loose the key when printed
Counter({'Tuesday': 2})
 
@CoKoder Maybe you want a tuple? counter = Counter((item["Date"], item["Day"]) for item in test)
and doesn't combine two objects, it evaluates whether they're truthy or not and returns a bool
 
I hate it when an OP deletes a post just as you are about to post your answer
 
so item["date"] and item["day"] simply evaluates to True if both strings are non-empty
 
4:51 PM
@Kevin, thanks it worked!
 
user2555451
@Kevin - os.walk returns a generator. And yes, the generator can be empty.
 
user2555451
>>> from os import walk
>>> walk('c:/path/to/file.txt')
<generator object walk at 0x0205BF08>
>>>
>>> list(walk('c:/path/to/file.txt'))
[]
>>>
 
I think that may be this guy's problem. he creates a variable in his walk loop and returns it outside the loop. This would cause a name error if it doesn't walk anywhere.
 
user2555451
On a side note, why would os.walk allow you to give it a file name?? How do you walk a file?
 
@Kevin, another question. How to access this paired key.
Counter({('2013', 'Tuesday'): 2})
print counter['('2013', 'Tuesday')']
this does not seem to be working to print 2.
 
4:56 PM
Just counter[('2013', 'Tuesday')]
 
Surprising, I'd expect print counter['('2013', 'Tuesday')'] to give a SyntaxError.
 
or counter['2013', 'Tuesday']
 
Or when you say "this does seem to be working", do you mean "this doesn't seem to be working"?
In which case, it's not surprising.
But yeah. What 61612 said.
 
Yep, sorry my bad! and thanks for solutions.
 
@Kevin that imagestack question is aweful ...
 
4:59 PM
@JoranBeasley Yeah, I'm bailing out of it
assigning a variable inside a loop and then returning it outside the loop, is indicative of a serious misunderstanding of Python's execution model
(unless you're doing it intentionally, but that's rarely the case)
 
and hes got the global stuff ... that isnt used at all in the function except to overwrite
this person clearly should take some programming classes ... I think he needs more help than SO can provide to him
 
He seems bright enough. I have great faith that he'll work things out eventually.
 
The CSS of the user profile page has gone for a toss I guess! There is too much gap between the asked questions
 
I dont think he is
I think he needs to take some programming classes
 
Replying to my comments using complete sentences with less than a five minute turn around time automatically adds twenty IQ points to my perception of the OP ;-)
 
5:09 PM
Hmm, I have 11115 rep, should I downvote so that it's 11111?...
 
lol! I actually came across a guy in JS today. His rep was 11112!
 
I came across a guy whose name was 61612!
Finished downloading a 6Gb update for CoD AW...
 
the problem with his code exists between the chair and the keyboard
(the guy with the globals and the locals)
 
7 answers in the last day, 0 accepts (and there were no other answers). Ops need to stick around/check back sooner, the wait bothers me!
stackoverflow.com/questions/28861050/… "use search/google" is not a good comment
I don't like having active flags sit around
Hey, there's a new review queue: Help and Improvement
 
DSM
5:31 PM
I don't understand why people are so interested in understanding the implementation details of when Python reuses immutable objects and when it doesn't. What does it matter? Why is everyone so obsessed with calling id on everything? Am I just cranky?
 
No, it is an obsession I don't understand either.
The Help queue is supposed to be for the "needs improvement" questions from Triage, but they're all blatantly close-worthy questions so far. Triage is definitely not working as intended.
 
DSM
Yeah, I'm not sure what edit could salvage something like
> We have to generate more than 400 pages of pdf file using tcpdf and currently we are able to get only less than 300 pages

can anyone help on this
 
hah
@Kevin
just us / that works for all os's in python and doesnt need rawstrings or escapes but either path=r"C:\test" or path = "C:\\test" or path="C:/test" will all behave correctly, path="C:\test" will not
 
I guess it's because most of the time, if your programming language behaves in a way you don't expect, that means that your understanding is wrong and you'll inevitably write code that doesn't work as a result. So when someone discovers that id does something surprising, they want to understand what's going on, even though it doesn't actually matter in this particular situation
 
is the right answer to the OP (globals and locals)
@Kevin are you talking about my answer to the id(x) id(y) problem
 
5:37 PM
@JoranBeasley I bet that would have been a lot easier to figure out if OP had told us what he was typing for the command line arguments in the first place
@JoranBeasley Nah, just replying to DSM
 
4
A: Help Improve The Help & Improvement Queue!

davidism Remember, these are users that came to us with relatively good questions on their first or second try. Large Data Set | Can't Create Foreign Key (queue) How to fade-in text when a button is clicked on in adobe edge? (queue) How to generate Java Class from Data Base to use Hibernate 4 (queue...

> I no longer have a desire to help or improve in this queue. :(
 
woohooo I answered a question... (instead of asking one!)
not entirely sure it's the best way to do it, but it kinda makes sense
 
5:53 PM
would not using https on localhost cause problems with oauth?
 
Unless the oauth provider cares if the redirect url is https, no.
 
most of the time they dont
 
It wouldn't really matter, since someone else could see the url with the token even over https.
 
6:15 PM
Hey guys, anyone have an idea why my script breaks at #include <Python.h> when I try to run sudo pip install Scrapy ?
 
probably because you need sudo apt-get install python-dev
 
What is python-dev?
 
It's the headers needed for building c extensions against python
 
Ok
 
Some distros, such as Ubuntu, do not include them when installing a library, they separate them out
 
6:18 PM
just go with "Its black magic ... that makes things work"
@davidism I would argue most distros do that
 
Arch and Gentoo ;)
 
:P
not all distros :P
 
I always forget that I need to watch out for that when I give instructions, because everything "just works" on Arch.
 
Still doesn't work
I run sudo apt-get install python-dev, and it seems good. I then do . bin/activate within my environment directory.. then I run sudo pip install Scrapy and I get that Python.h error
 
oh you left out that part
 
6:21 PM
Sorry
 
you need to provide it to your virtual-env
maybe just runing the apt-get after bin/activate is sufficient
 
Heh, I thought of that and tried
 
@Martin don't sudo pip install
 
`python-dev is already the newest version.`
`0 upgraded, 0 newly installed, 0 to remove and 325 not upgraded.`
 
sorry i dont linux so maybe @davidism can help you :P
 
6:22 PM
Alright
So just pip install ?
 
never use sudo and mess with the system install
yes, just pip install within your active environment
 
Alright, noted.
 
godspeed and good luck ... im gonna go get some more coffee
 
Cheers
Or uh Rhubarb *
So any ideas why Python.h is no good, davidism?
 
are you using python2 or python3 in your virtualenv?
 
6:24 PM
3
 
If you're using python3, you need to install the python3 headers: sudo apt-get install python3-dev
 
lol
Alright cool
Man there's a lot of really specific stuff to know about Python if you want to work with it efficiently eh
 
do you need the state in both the redirect url and the request url?
 
@corvid try just not using the state, it's not needed for most cases
(in fact I can't think of a case off the top of my head that it is needed)
 
alas, Unable to base64 decode state from OAuth query: undefined
 
6:27 PM
@corvid hmm what api are you consuming?
Ive never heard of one that requires state
 
@JoranBeasley you mean the framework I'm using, or what I am authenticating with?
 
you are consuming some api with oauth2 right?
what api are you consuming (eg api.paypal.com)
 
6:45 PM
re-cbg
 
re:re-cbg: cbg
 
Is there an option with pip to install any dependencies that are required if they aren't therE?
 
Should do automatically.
If they are declared in the setup.py, which they should be.
 
Okay so whatever I have to install are not necessarily python packages, they're system packages ?
 
Ah. Well pip can't install them in any case.
You need to do those yourself.
 
6:53 PM
Yeah I know I'm just asking for better understanding
Ugh so Scrapy doesn't work with Python 3 :(
 
Do you really need Scrapy? Most sites nowadays either have an API that it much easier to call, or don't really want you scraping to begin with.
 
Yeah I know, but this client doesn't
I wish I could do this some other way
In my virtual-env, how can I install packages for python 2.7 ? :s
Instead of 3
 
You make a virtualenv for python2 and use that
You can't use two versions in the same env.
 
okay
 
Consider also that Scrapy is still probably overkill for what you're trying to do
 
7:04 PM
Maybe
 
What's wrong with fetching some pages with requests and using BeautifulSoup like you were before?
 
I'll try it without for now
Idk I guess I felt like I was re-inventing the wheel
off-topic question: Does anyone here use Tilda ?
 
Ah yes, the opposite of the "not invented here" syndrome. ;)
I did for a while, but I found the dropdown more annoying than useful.
I prefer to just open a terminal window and get a window.
 
I might do that soon I'm getting annoyed
Every time I pull it down I get a tilda lol
Ok for some reason I can't import BeautifulSoup ......
pip install BeautifulSoup4 works fine
import BeautifulSoup4 says it can't find it
 
DSM
import bs4
 
7:10 PM
oh
Yeah I'm dumb. In Python 3 do you need to do the encoding stuff at the top line?
 
no, unless you don't want to use utf-8, since that's the default
 
# -*- coding: utf-8 -*- ?
 
DSM
How can a user from an unlinked account post a question? Or was the account deleted in the last few minutes?
 
Nice
 
I cant believe i have 2 downvotes on my id(x) == id(y) answer
 
DSM
7:15 PM
(This one, in case anyone's wondering.)
 
I can't believe I drank that wine that quickly.
 
I can't believe it's not cabbage! (Yes I can.)
 
DSM
That said, I don't think the fact the user's account no longer seems to exist is a valid close reason. A really good, on-topic question would continue to be really good even if the user immediately rage-quit and was disassociated from it.
Never a ninja around when you need one.
 
Yeah, I didn't vtc it, seemed fine to me. The state of a user isn't a valid close reason for a question.
\o/ got a "Good Answer" for my response to the Improvement queue
 
7:20 PM
hmmm it showed up as a reason so i voted to close :P ... i guess you convinced me ... retracted... still not sure if i would call it a "good question though"
 
Is there a better way to do if category is "coffee" or "tea" or "cocoa" or "indulgent" or "espresso" ?
 
At first glance it seems better than most "how do I read these gene sequences" questions.
 
DSM
By "better" do you mean "one that works"? :-)
 
^ that
 
Yeah
lol
 
7:22 PM
if category in {'tea', 'cocoa', 'indulgent', 'espresso'}:
 
Man I tried (almost) that
For some reason I tried if category is in ...
Thanks
Will it work with [] instead of {}
 
Yes, but it won't be as fast.
 
Is there a thing like jsperf for python?
 
profile along with snakeviz
I say "not as fast" but that really doesn't matter at this point. Just write your program, worry about profiling later if you think there are actual performance issues.
 
Okay thanks
Sure but I mean it's still good to keep in mind which ways are faster
 
7:30 PM
lookup on a hashed structure (set, dict) is faster than on an indexed one (tuple, list), so if you're going to perform that check many times a set will perform better
 
DSM
Membership testing in sets and dicts is O(1). In lists and tuples it's O(N). So in all but the smallest cases (or most expensive hashes) sets are on par with lists, and in other cases they can literally be millions of times faster.
@davidism: hmmph. Kevin's not around, so it's your turn to beat me to things now?
 
I can't find the conversation, but a while ago I think @Martijn showed that initializing a set was just as fast as a tuple for a static structure at compile time, so you don't even need to worry about the hash overhead for creating the set.
 
meh, I'ma give up on this project for a bit, this is way too frustrating
 
@DSM let's just say our posts complement each other :)
 
Hello, I'm trying to understand [martineau's comment ](stackoverflow.com/questions/28884581/…) on "working with big datasets". I thought I understood tdelaney's comment, but martineau is making me think I missed something. Anyone care to enlighten me?
 
7:39 PM
Hello, anyone here?
Great, I need some help with something. I am basically getting input seperated by space lines. Like this : 3 4 56 674 -1
How can I get each int specifically?
Get the first one, then the second one, and etc
Sorta like cin in c++
 
[int(x) for x in my_string.split()]
 
DSM
@OliverW.: I think he's just saying that the overhead involved in doing os-y things can be big, and so you want to minimize things like opening and closing.
 
Not using split, I know that
Anyother ways?
 
DSM
Huh? "Not using split"?
 
no, that's the way you split a string
 
7:42 PM
The only way?
 
DSM
The right way.
 
why do you want a different way (if it even exists)?
 
Like in c++ you can do while(1){cin >> x;}
Because I am having problems with it, sorta
 
Oh, you want to read input one character at a time?
 
DSM
Wait, are you trying to read input from the user, or split input from the user into parts?
 
7:43 PM
One number at a time
 
for char in my_string: # do stuff with char
 
read input from a competitive server
 
DSM
@davidism: ah, I'll let you handle this one, rather than us trying to tag-team it. :-)
 
@DSM no, I'm about to tell him he has an XY problem
 
They just installed python support
And Im having some problems
How about assingning all int to an array?
Maybe that
 
7:44 PM
@MikhailTal you'll have to figure out how to explain what you actually want to do, as it's not clear why your trying to do what you've written so far
 
Im recieveing an unknown amount of input terminated with a - 1
 
cbg
 
So I only have a string
 
[int(x) for x in my_string.split()] will get you an array of ints from a string
that's it, that's the answer
 
Okay, ill try it that way and see how it goes
Back in a min
 
7:46 PM
@BhargavRao no, why do you think that should be closed?
 
Yeah!
I read the question now
It is pretty clear. It had come in the rev queue
 
@DSM, so why does he say I am talking about premature optimization then? Keep a reference to an opened file, create a buffer, enter the for loop, append to the buffer and every so often flush the buffer to the file. At proper ending of the loop, the file would have to be closed of course. That would put the load only on a single check inside the loop. Read/write operations would be kept low, no? I feel I'm still missing the point of his comment?
 
@OliverW. perhaps it would be better to explain what you're talking about in an answer with code, rather than trying to justify it here?
@MikhailTal since it sounds like you have a C++ background but not a lot of Python experience, consider becoming more familiar with Python before asking questions here
the official tutorial is a good place to start, or Dive Into Python (although it's a bit outdated)
 
DSM
@OliverW.: there are two separate lines of thought here. One is: "open the file once or many times?" answer: once, and it sounds like you agree. Then there's your lines about buffering for the "really big stuff", which looks like it's meant to be replying to something tdelaney said but doesn't seem to. There's really no need to implement your own buffering.
 
@davidism Im really familiar with python. Worked with tkinter and all. Thing is, due to limitations I havent used it almost at all for comeptitive programming. Since the support was installed a few days ago, I'm now a very valuable resource for my competitive team since I can do the first exercises fairly quickly
 
7:51 PM
@davidism, you're right, it sounds like I'm justifying here. The thing is that I'm not sure I understood the comment, considering big data is not my field of expertise.
 
rbrb, lunch
 
DSM
In particular, if I have a really big file (say several 10s of gigs) I'm not going to be able to assemble a list in memory and write it out. But if I can work line by line, I might as well -- there's not much cause to write a separate chunking level.
@davidism: lunchtime rhubarb!
 
@DSM, the reason there's no need to implement my own buffering is because the write method buffers automatically right (and as long as you don't force a flush..)?
 
DSM
Correct, it's already there.
 
Alright, then I got that part. Thank your for the clarification.
 
DSM
7:54 PM
And this conversation has already lasted longer than the time you'd save by trying to be clever and tweaking the buffering level on modern hardware. ;-)
 
Hi. I want to pass an object to the constructor of a class. Is it possible to return the first attribute of the object whatever its name is ?
 
@DSM by orders of magnitude i would think
no
@Kabyle no .. constructors cannot have any returns
(the return is the newly constructed class instance)
 
@JoranBeasley thank you. Suppose it is just a method: can I return the first attribute of the object I pass to it without knowing the name of this attribute ?
 
no since attributes are unordered afaik ...
 
@JoranBeasley thank you very much
 
8:06 PM
unless it is using __slots__ or something
@Kabyle stackoverflow.com/questions/4220747/… ... might help you with your problem (if you can control the object being passed in)
 
wow ! very interesting ! thank you very much again, I am going to read that right now @JoranBeasley
 
8:21 PM
Guys {} is a dictionary, right?
Is there a way to preserve its order?
 
it is, and no. you'll need to create an OrderedDict from a list of tuples if you want that
 
Okay
 
8:53 PM
@davidism: in Python 3, when using a set literal ({...}) with an in test the set literal is replaced by a frozenset() object stored with the constants.
Just like in (...) and in [...] results in a tuple object being stored like that.
>>> compile("foo in {'bar', 'baz'}", '<stdin>', 'exec').co_consts
('bar', 'baz', None, frozenset({'bar', 'baz'}))
>>> import dis
>>> dis.dis(compile("foo in {'bar', 'baz'}", '<stdin>', 'exec'))
  1           0 LOAD_NAME                0 (foo)
              3 LOAD_CONST               3 (frozenset({'bar', 'baz'}))
              6 COMPARE_OP               6 (in)
              9 POP_TOP
             10 LOAD_CONST               2 (None)
             13 RETURN_VALUE
 
Cool, thanks. :)
 
@davidism This happens in Python 3.2 and up.
But no one should really use 3.0 or 3.1 anymore.
 
It irks me that two of my answers have been downvoted. The common factor is that the same user has participated in both posts. 1 2 I think both those answers are good, and his answers are less good. Maybe I'm jumping to conclusions.
 
DSM
Don't remind me. 3.0 was bad enough I started to worry about Python's future.
 
@MartijnPieters Why would anyone still use 3.2?
 
9:04 PM
@ThiefMaster Good point.
 
PyPy targeted 3.2 until recently (although the optimizations probably aren't as relevant in that case)
 
I'd say if you are required to use an ancient version (and I'd consider 3.2 ancient) something else (e.g. your sysadmins or management ;)) is wrong.
 
Actually, it still targets 3.2, 3.3 is in development.
 
I have a copy of Python 1.6 I play around with on occasion.
 
DSM
I used to have a 1.5.2 but it eventually bitrot on me and I wasn't motivated enough to get it to compile..
 
DSM
   In file included from ./../Include/Python.h:57:0,
                 from fileobject.c:34:
/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here
 extern _IO_ssize_t getline (char **__restrict __lineptr,
                    ^
make[1]: *** [fileobject.o] Error 1
make[1]: Leaving directory `/home/dsm/Downloads/Python-1.5.2/Objects'
make: *** [Objects] Error 2
And similar. Life is too short. :-)
 
Umm... Python 3 didn't really get good until 3.3
3.0 was not that imppresive :)
 
@DSM eh... i just went and got a version that compiled without complaining
it was more of a curiosity
 
DSM
Urf, the Python docs are wrong.
> For the list and tuple types, x in y is true if and only if there exists an index i such that x == y[i] is true.
That's not right. :-/
 
how so?
 
DSM
9:25 PM
Identity is tested before equality when doing list and tuple membership testing. Consider an object not equal to itself, like nan:
>>> x = float("nan")
>>> y = [x]
>>> x in y
True
>>> any(x == y[i] for i in range(len(y)))
False
 
>>> any(x is y[i] for i in range(len(y)))
True
@DSM so you are correct
 
DSM
I think the logic is something like x in y <-> any(x is y[i] or x == y[i] for i in range(len(y)).
Vaguely remember having to write up an answer explaining this in a nan context before.
 
Woo hoo.... got python-3.x silver badge... :p
 
DSM
\o/
 
Miles off a gold though :(
 
9:36 PM
What is the point of is anyways? Like, when would you want to compare ids?
Just an efficiency thing?
 
when you want to know if two are the same
 
DSM
@Jon: I don't even have a silver.
 
6
Q: Understanding Python's "is" operator

aniskhan001 The is operator does not match the values of the variables, but the instances themselves. What does it really mean? I declared two variables named x and y assigning the same values in both variables, but it returns false when I use the is operator. I need a clarification. Here is my code...

 
I mean how do you apply that knowledge? What's the point of knowing that?
 
@DSM did you see my pandas answer... I thought it was quite cool... not sure it's the best way... you know more than me - is it any good?
 
DSM
9:38 PM
Lemme read..
 
@QuestionC For some objects there is only ever one copy.
Testing if something is the same object is faster.
So you always use is None or is not None, because None is a singleton.
@JonClements Congrats!
@JonClements There's just me and Regebro
@QuestionC: there is also debugging shared object issues.
Like testing that something that was returned from a function is still the same object.
 
DSM
@Jon: I'd have used .loc[[0,1]] instead of reindex, just out of personal preference, but looks fine to me. I can't think of anything slicker offhand, anyway.
 
Mutable objects being manipulated in different places can be hard to debug without is.
 
@DSM ahhh.... I'd have thought that'd choke...
 
DSM
@Jon: nah, you just get nan if there are no matches.
 
9:50 PM
@DSM ahh... that's cool
 
Is designing a Producer-Consumer model with threading module appropriate?
 
@DSM edited to include your suggestion... :)
@thefourtheye it's certainly better than using the zipfile module :p
 
@davidism: I must be lucky, my first help and improve post was quite reasonable.
 
Well, I just realized that the Python script which I wrote a year back was making a minimum of 1 lakh requests and it takes 9 hours to complete. It actually makes 2000 req first, processes data and from that it makes around 1 lakh reqs.
 
@davidism: I was very lucky, nothing but dross from here on out.
Gah.
 
9:57 PM
So I am thinking of setting up a Producer-Consumer model. and then I found the following in the threading docs
> If you want your application to make better use of the computational resources of multi-core machines, you are advised to use multiprocessing or concurrent.futures.ProcessPoolExecutor. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously.
 
DSM
@Martijn: yeah, after davidism's comment I tried playing too, and the first ten all looked close-worthy to me.
 
@JonClements good job helping him use csv.reader :P
 
Clearly is left justified. — Malik Brahimi 48 secs ago
@Joran does that make any sense to you?
 

« first day (1601 days earlier)      last day (3341 days later) »