« first day (1581 days earlier)      last day (3592 days later) » 

00:33
If you import a Python file and call its init, it HAS to complete doing so before your code continues right?
So if I have:
import static_data
data = static_data ()
main ()
The code in main() will always have whatever was done in static_data (), correct?
What is the purpose of combiner in this program?
def accumulate(combiner, start, n, term):
    """Return the result of combining the first n terms in a sequence."""
    "*** YOUR CODE HERE ***"


def summation_using_accumulate(n, term):
    """An implementation of summation using accumulate.

    >>> summation_using_accumulate(4, square)
    30
    """
    "*** YOUR CODE HERE ***"

def product_using_accumulate(n, term):
    """An implementation of product using accumulate.

    >>> product_using_accumulate(4, square)
    576
    """
    "*** YOUR CODE HERE ***"
Because square will be passed as term
how to combine the terms ie math.pow
probably more likely operator.add
oh i think it is add
yes
but it can be any function that takes 2 items and returns 1
I assume ... really it can be whatever you want since you have to write the code
lambda x,y:x*y-y
Can a pure function return more than 1 object?
like objects of type list and int
01:16
what? sort of .... def f(): return 1,2; a,b = f(); a_list = f();
buh, interviews are hard
did you pass @corvid?
or you blow it?
:P
passed, got an offer. Kinda surprising
good offer?
you gonna take it?
this was that 3rd interview?
oor this was the other place?
this was the place I did the project for, offer was okay but since I have a few probably gonna choose a different one
01:19
right on , well gratz anyway
did they make you code in this interview?
nah, but they said they liked the project I did (and thanks to python room for helping with random inane problems)
so this was basically ... lets make sure your not a psychopath interview?
yeah, that's why I'm surprised I passed!
uh, I mean
lol
ok well im out see you guys later
user559633
take care
05:34
cbg
s_m
s_m
06:02
is there any one. i need a little help from this chat room.
user739721
07:01
hi guys
user739721
quick question
user739721
what happens when a git branch is closed
user739721
is it deleted?
closed??
user739721
yes
07:04
yes??
user739721
You create a PR
you are talking about github not git
user739721
on bitbucket or github and there's a check box 'close branch' when PR is merged
user739721
what does it mean
I guess this comes from the hg --close-branch option
in git a branch is "deleted", but bitbucket being Hg initially can call it anything and github following the suit :D
user739721
07:13
:D yeah
user739721
thanks Antti! much help :)
user739721
btw nice profile :)
user739721
keep up ;)
thanks
np
user739721
so long
cbg
Who is this Margin Peters? I imagine a shadowy figure on the edges..
Ah, I see @davidism has been asking that exact same question.. :-P
07:52
The adopted Indian stepbrother of Tim Peters I guess?
08:25
morning
Hey up
Cibbege
08:59
cbg
why do ppl insist doing NLP on python 2.7
"I started a new project, I am using Python 2.7, I do not know Python, I do not know anything, I get Unicode errors, how do I fix them"
"but LPTHW told me to use python 2!!!!"
maybe so,
I mean, you go into a shell, and you have an unicode string, you cannot print it because of unicode errors, you cannot save it to file, then you do repr and get something useless etc... and you say "I am doing natural language processing"
there is nothing natural-languaey in 8-bit bytestrings
NLTK works in python 3 nicely as I use it at least every week
just tried to solve 1 user's unicode problem, 100 rep user throwing 50 rep in bounty and ignoring everyone telling that "upgrade to Python 3 and you don't even need to solve this"
re-cbg
hmm
just noticed that bare python is still lacking c.f. zope interfaces
@MartijnPieters can one do some tricks with bare python to do isinstance checks,
would want to do isinstance('^.*$', RegexString)
;)
ABCMeta subclasshook only can deal with classes
but not values
09:34
hi
setup.py and setup.sh can be used as alternative to each other?
Never heard of setup.sh.
@AnttiHaapala ABCs have a isinstance hook too.
The subclass hook has to only deal with classes, that's kinda the point.
@user123 No.
@Ffisegydd name "setup" is not fixed for .sh here, but in general we see many shell scripts in various packages
@user123 I'll rephrase that: I've rarely seen shell scripts used for setting stuff up, whatever they're called.
setup.py is the norm.
@user123 Automated tools like pip look for the name setup.py, as it is a Python script.
09:44
May be I am not sure in which situation I should use setup.py and shell script
shell script I understand, when one want to execute couple of sequential command it helps
not exactly when and how setup..py
If you're talking about installing a Python package, then use setup.py.
setup.py is only for installing python packages?
setup.py is used for installing Python packages. As Martijn said, it's what pip will look for automatically.
suppose i have couple of modules, each has execution in different way using python command.
to get entire flow working, I want to combine all this modules to be executed in paraller/sequential and reach final result. So finally there should be single command or files executio, which should execute entire bundle.
Is my requirement clear?
Correction: yes it's clear. You could use either a Python script or a shell script.
But you wouldn't call your Python script setup.py.
As it's not doing any setting up, it's just running some code.
09:49
@Ffisegydd I am sorry, but little confused what to be done in my case
Use whatever you want, just don't call it setup unless it's actually installing something.
@Ffisegydd okay, so simple shellscript will do what I want?
I don't know what you want to do in detail, so I don't know.
Try it and see.
10:09
stackoverflow.com/questions/28493114/… TMI on python double repr already :D
I have a memory loss
I could remember only 49 first digits of PI correctly, forgot that 50th was 0, now that could have been a crucial error
10:30
why do ppl edit questions so that they remove whatever is interesting from the question so that what remains is a duplicate.
@AnttiHaapala :) There's an xkcd thread for people like you (and me) How many digits of Pi do you know?
I fixed up my factorial timing program. And I added an answer to the OP's actual question, to make PureFerret happy. :) stackoverflow.com/a/28477818/4014959
I did learn the 40 first in highschool 15 yrs ago, in and then up to 250 just to annoy 1 girl who remembered 200. Good that I forgot the last, not first, 200 :d
"But I suppose 50 isn't bad, since if I had to use it to compute the circumference of a circle as big as the galaxy, an exact knowledge of the radius would give me a figure off by only about 10^-29 meters." this.
I have memorized the reading of the digits in Finnish with rhythm
I guess would be really hard to try to speak them out in English :d
10:39
One of my high school math teachers knew pi to 40 places, so I had to learn 50. :) FWIW, that guy introduced me to programming: he gave us one lesson in BASIC each week, although at that stage we had no access to hardware to run our code on. A few years later I changed schools, and my new classmates challenged me to learn 100 places. I still remember them all, 40-odd years later.
Nice. And the code's quite clean, too, which just goes to show that JavaScript can be elegant in the right hands. But that reminds me, I need to play around some more with SVG before I forget what I learned last year. :)
d3js.org has many pretty examples.
@AnttiHaapala Rhythm definitely helps; some people memorize digits of pi (and other such "useless" strings of digits) using not just a rhythm but a tune as well. That's quite an old learning method: my grandma was taught to memorize all sorts of things including the multiplication table and the major rivers of Australia by singing them.
oh the joy the rivers :D
10:48
what's "cbg"?
cbg is short for cabbage
the universal greeting
uh, okay
why is salad language a thing
oh wow.
literally peas.
11:09
Don't worry about it too much, Mark. Most of the contents of that list are rarely used, apart from cabbage / cbg, rhubarb, rbrb, and yam. :)
gotcha
Salad language is pretty basic compared to Winchester Notions
Do python gearman workers executable from shellscript?
@user123 sorry, it's not clear at all what you're asking.
@Ffisegydd Usually I start two different gearman worker in different terminals using python command, once those gearman workers get ready, I execute client file which send request to both listening workers. I was trying to put all three command in shellscript and execute them in one go, but could not
11:16
@user123 ask a question on the main site with the full details of your problem. It'll be easier than asking in chat.
okay np
11:44
I wish there was a "too localized"
LinkedIn is restricting access to most of its application programming interfaces (APIs) to companies that have struck up partnerships with the social networking company.
omfg. developer.linkedin.com/support "We active collaborate on the #linkedin tag on Stack Overflow". No you fu**ing don't. I've seen maybe 3 people who work for LI, and they barely ever answer.
11:59
@Ffisegydd even better :D idiots linked to the featured tab which has 0 questions
ah sorry no, it just remembers my tab :D
Troll account, account already flagged.
@MartijnPieters Justin Kominar is the linkedin api support engineer :D
@AnttiHaapala ah, right. Glad to see them taking a lead in closing posts then.
"closing posts" at 274 rep? :d
doesn't even know how to flag
Nope, so I am still using the wiki messages @Ffisegydd came up with.
if it is about api migration you can link to that specific page
maybe put it in the wiki
12:36
What a trainwreck of a Meta post: meta.stackoverflow.com/questions/285989/…
@AnttiHaapala Frankly, I don't have much sympathy for LinkedIn and their handling of Stack Overflow.
Dunno if luck, got an upvote at 11:55pm UTC yesterday... Makin my daily rep 200 ...
@MartijnPieters me neither
but that Justin probably is not at fault though
@BhargavRao grrr
1 day nearer to legendary !!!
Oops ... 140 days far away
damnit
@BhargavRao how can you get 200 :(
Magic ....
12:46
@AnttiHaapala No, I'd hate to be a LinkedIn support engineer right now.
I have gotten 150-180 now 4 days
@BhargavRao maybe someone should post the Tank you there
Thanks to users who tank you
I had a user who tanked me yesterday, then I got 2 upvotes from others
And I don't write long answers ... Short and sweet
@BhargavRao there is no short and sweet answer to that
I documented whatever I found for others to verify :d
Questions that can't be answered in twenty seconds won't get lots of upvotes anyway.
3
it alll depends on compiletime options
12:53
Yeah. The other answer was --- Short sweet and completely wrong
I was just thinking that tonight I will add tl;dr
re-cbg
because well...
The best answer is one where a one week old newbie can read it and say, "yep, this is correct" without even opening his REPL
12:55
I also want to find a case of the number being rounded incorrectly
Neither Martijn nor I can replicate the error
Oh, this is a first. Some good guy corrected my answer and upvoted it
@BhargavRao What typo?
How do you know that the guy who corrected your answer is the same guy that upvoted it?
All within 3secs
12:57
closed..
wheee, rollback after rollback on meta.stackoverflow.com/posts/285989/revisions now. Moderator lock in 3.. 2..
Also, how do you know that your question from here got two upvotes from users that weren't the OP? Maybe one was from the OP and one was from someone else.
@AvinashRaj You wrote update as UPdate, updtae and so on ...
@Kevin Nope.. Upvote 2hrs after accept
rushing to answer all the questions which has the regex tag.
People can accept answers and upvote them much later. Source: I did it myself once
12:59
But why?
@AvinashRaj Great. Get the Py gold too, you can hammer dupes
Because I forgot, and noticed the discrepancy upon further reading.
You don't tank people?
@BhargavRao but it would take min 3 months....
Well, these days I don't ask questions at all, so...
@AvinashRaj Don't waste time on sleep, food, family. Focus on Py gold
@Kevin So no tanking, No thanking?
13:02
Did anyone have the link with the people who made the regex module?
i don't know why they failed to implement \K ...
Misspelled __init__.
BRAVO! you're the man! — Sandeep Bhat 18 secs ago
Destroy him for calling ninja as a man
:)
me also..
but i love matrjin's ninja..
it's so cute and little.
i'm waiting for the day where all people in the world would receive the equal bandwidth
13:10
Not a chance, as long as capitalism exists.
Well that was bad on my part
More money -> bigger pipe, and so shall it ever be
i bet that i'm the one who receives lower bandwidth as compared to others in this room.
13:14
Reliance 2g GSM ...
connected via mobile.
lol :-)
Lol ... Mine's BSNL 2g Even worse
I have a piece of wet string that I've tied to a phone line. I attach and detach a battery to it to provide electronic pulses.
@AnttiHaapala If you could stop writing blog posts (Reminds me of that meme)
@BhargavRao why ? you're in Banglore. There are so many possibilities to get max bandwidth..
13:16
@AnttiHaapala Small Idea, Edit the question (If you know why)
@AvinashRaj Not at home. So.
@BhargavRao why? :D
bc it says print()?
Illuminator
noobs don't know how to ask :(
I wanted to understand how this works, it wasn't a simple piece of work
You'll be nearer to Illuminator badge
@AnttiHaapala in that the it seems should be in that it seems
13:22
edited
in that the this that it thus so that seems
13:44
@AnttiHaapala Thanks for putting in all that work to create such a thorough answer!
Peculiar. I'm source diving to see how string formatting works, and from this section, it seems like "%d"%("1") ought to work, but on my machine it gives a number is required, not str.
Is PyNumber_Int(v); not equivalent to int(v)?
And if it isn't equivalent, why are the docs a big fat liar?
Ah! I see. str types fail the initial PyNumber_Check check.
@Kevin it is not
the docs say it wrong
it should state that "iff isinstance(o, Number) this is equivalent to int(o)"
Kevin, consider: it makes sense for int to have a .__str__() method, but it doesn't really makes sense for str to have an .__int__() method.
motivation to start game development for today; try watching let's play of bad games
Because all ints can be converted to string, but not all strings can be converted to ints?
@corvid Tell us more about your project.
13:54
it's called "I have no idea what I am doing", the adventures of a terrible programmer
4
@Kevin Pretty much
Hmm, I'm imagining an early 90's platformer where you collect floppy disks and zap bugs
The first chapter is free, with the remaining 66% of the game available by mail order from Corvid Software Inc
when you get to a really high level, your damage gets high enough to overflow 32 bit signed int, so now your damage makes no sense
Requires 16 MB RAM and a Sound Blaster 2.0 audio card.
14:00
"If your PC is too good to play the game, we can accommodate you with special emulation software for only the CHEAP price of $20! (Per game, per month)"
buy the game, then buy our first DLC, called "all the game's content"
@corvid Reminds me of Bleach, where one character was once the most badass swordsperson, to the point where her ultimate attack could bring the dying back to life. I guess she overflowed the damage into the negatives.
"Best" is opinion based
@Kevin not to mention probably a dupe.
OP clarified that it means "best performance", so stop trying to close as opinion based I guess.
get must be better.
14:14
Hmm, but even that may be broad, because there are many use cases for dicts, and the most efficient method may be different for each one.
@Kevin just noticed I answered it but you already did that answer in a comment
As Martijn says, a use case with frequent misses is quite different from a use case with frequent hits.
My instinct is that get would be preferable in the former, and try-except in the latter.
Since you would prefer not to make a function call if you don't have to
I guess setting up the exception frame costs as much as method lookup
@corvid: your answer is really rather useless right now. In spite of the upvotes.
You don't specify why it is better.
The whole question is opinion based, and your answer illustrates why the question should be closed, not answered.
... Unless get and [] have roughly the same function calling overhead
@MartijnPieters I guess he said performance, but I did it for readability, so it's probably not relevant... either way, seems like a micro-performance thing at that point
It matters how often a key is going to be missing, for example.
@corvid Then be explicit about why you say what you are saying.
if the point is "I want to get the value of this key, or constant value" there is a method for that already
Now I think it's even more broad because the runtime for get may vary between implementations of the language
Because I can now post an opposing view, with just as little motivation, and be equally right.
14:17
one can argue that if there is 1 method that does the same as 4 lines of code, it is the most pythonic and most pythonic is best ;)
it is primarily opinion based but it is guido's opinion
Greetings
I always thought python would prioritize readability over performance in the most general cases :\
That's the general philosophy, yeah.
I was thinking of making a "don't even bother thinking about such mirco-optimizations until it matters" comment, but at this point it would be well drowned out
holy shit, on python 3, the get method call is 2.3 times slower ;)
for existing keys
14:21
I have a few classes in a file for each in my Project and some of these are used in other classes, which method should I follow while using these classes? Creating instance of each class in their file, or writing all classes in one file?
@AnttiHaapala compared to what?
the try-foo['bar']-except KeyError
thus the method lookup is abysmal
@KeremZaman I prefer instantiating all classes in one file. Generally, I like it when the files I import have no "main" code, just classes and functions.
I am not sure at all that the method lookup is correct
Although it's fine if one module instantiates a class from another module, as long as it's doing it inside a function/method
14:22
there has to be a way to optimize it
Ex. This is OK
#a.py
class Fred:
    #...

#b.py
import a
class Barney:
    def troz(self):
        self.x = a.Fred()

#main.py
import b
y = b.Barney()
No need to create a Fred instance in main and pass it as a parameter to Barney.troz or anything.
huh... apparently 3D models can be exported as JSON now. Is it a dumb idea to save this data in a database?
What could possibly go wrong?
too much data and too many requests I suppose would be my concern
@Kevin you are right it makes more complicated and long in unnecessary way.so one file, best solution thanks
14:26
I think I may have misunderstood the question.
I like having separate files for each class.
I usually don't have a separate file for each class, but will have separate files for each group of classes.
I thought by "Creating instance of each class in their file", you meant "creating a class in a file, and then doing x = MyClass() in that same file, and then other modules refer to x."
oh, sorry @Kevin I really misunderstood what you've said :)
yes I meant what you thought
Ok, starting over: Sometimes I put each class in their own file, sometimes I have one big file. One big file is OK for smallish projects, but eventually it becomes nice to split them up.
ok, I understood thank you
14:35
does exec like php command is there in python to execute any python command inside python script?
Yeah, it's called exec
(obligatory disclaimer: using exec is a bad idea, and generally indicates there is something wrong with your program design)
yes, was about to write it.
99 % of times it is still bad idea...
but it is still used even in the standard library
1 % of times it is something really ingenious...
There's also eval, which is just for expressions and not statements.
if i want to execute some installation command like "sudo easy_install pip", is it advisable?
eval is worse than exec in that it is almost always an error
14:39
exec runs Python code, not shell commands.
You want subprocess probably.
and sudo easy_install pip is a bad idea :D
What Kevin & Antti said. If you think you need to use exec or eval(), you're probably wrong. And if you're new to Python, and think you need to use them, you're almost certainly wrong. :)
Question: when is it preferable to use os.system over subprocess.call?
for some reason, making modular applications seems so hard to manage in languages other than python
14:41
@Kevin Never? :) More seriously, if you don't need to have any control over the commands stdin, stdout, or stderr streams, then os.system() may be adequate.
nope, it is never. os.system always uses shell, it is very bad idea
Follow up question: why does the standard library have a function you should never use?
because of backward compatibility
and because it is a c wrapper
@Ffisegydd so subprocess.call() having any issue if I want to execute python command
NAME
       system - execute a shell command

SYNOPSIS
       #include <stdlib.h>

       int system(const char *command);
14:43
@PM2Ring can you please give you valuable suggestion for this
@user123 rather than being vague and wishy washy, please just state explcitly what you want.
@user123 you have a probable XY problem
sudo easy_install pip isn't a Python command, though.
@Ffisegydd I want to check in python script whether particular python package is installed or not, if not then I want to isntall it inside python file. That is why I wanted to know
Now you say, "oh, sorry for being unclear. Will call have any issues if I want to execute a shell command?" and then we say, "no, that should be fine, but remember to pass a list of strings to the first argument and not just a string, that's a pretty common mistake"
14:46
@AnttiHaapala yes, : D, i was in xy problem
@user123 Okay so you want to run a shell command from Python? Use subprocess then.
@Ffisegydd thanks for making it clear
@user123 Make sure to take into account any security issues etc. For instance if you were accepting strings from a user then you may not want to run them using subprocess as the user could enter malicious code. If you're hard coding the strings yourself in the program though, it should be fine.
Is there a list of the valid encodings you can pass as the second argument to bytes? I can't find it in the docs
nvm, found it
@user123 Hmmm. I don't know if that's a wise idea. I recommend the script printing a helpful error message if a package it needs can't be found and then quitting. Otherwise, things could get very messy.
14:49
I'd personally use pip install -r requirements.txt for this.
@Kevin encodings.aliases.aliases,
cbg @davidism
I was about to do something, but I've forgotten what it was, and it's angering me.
I need to do the needful but I cannot remember what the needful was ;_;
I'm going to play with my Kendama instead D:
You were about to put out the grease fire in your kitchen.
14:57
Does anyone happen to know if this algorithm: pastebin.com/nR6XF30r has a name?
Vivek Sable's updated his closed fastest way to test if a key's not in a dict question with some timing tests, but the tests are very unrealistic.
It smoothes the values of a normal randomizer to prevent long win/loss streaks, by introducing a counter - I think the code explains it pretty well...
I voted to reopen his question, since he was nice enough to fulfill my timeit suggestion :-)
OPs that engage with commenters are the kind of users we need more of!

« first day (1581 days earlier)      last day (3592 days later) »