« first day (2499 days earlier)      last day (2453 days later) » 
00:00 - 19:0019:00 - 00:00

12:01 AM
@Rawing no
at least I've never heard of one
there are restrictions for code-vs-text ratio and inlining images is forbidden with very low rep
 
No limitations, only racing conditions :D
 
user8451312
rawing, where should i put code that u provided? I don't quite get what it does.
 
Use that instead of d[key.replace("\n","")] = val.replace("\n","")
Regex patterns have to be compiled before they can be used - the old code compiled each regex in every iteration of the loop (re.search automatically compiles the regex if you give it a string). This way you compile them all only once
 
user8451312
That was very useful. Thank you :)
Code is still running...I think i will have to find whole other way to stem words.
 
user8451312
12:21 AM
hey, i've got the results! This at least finished after some time
 
I didn't expect that optimization to have a significant effect to be honest.
 
user8451312
That's great, Rawing! With other codes i tried it would finish never.
 
So is your original issue also fixed with this? You were getting an error earlier, right?
Actually, I'm going to have to excuse myself. It's bedtime for little boys. rbrb all
 
rbrb @Rawing
 
user8451312
It is, still runs slow, but faster then earlier, and i got the results. Good night. :)
 
12:45 AM
So I timed three random sphere surface point sampling methods: one that normalizes three normals; one that uses an arccos-weighted distribution for the polar angle; and one with the cylindrical coordinates. Unless I wrote one of these to be too inefficient, the first one seems the fastest by far. cc @PM2Ring @wim
In [459]: %timeit newdir_normal()
The slowest run took 14.23 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 8.96 µs per loop

In [460]: %timeit newdir_uniform()
10000 loops, best of 3: 56.1 µs per loop

In [461]: %timeit newdir_cylinder()
10000 loops, best of 3: 46.9 µs per loop
hmm, I can make the uniform one faster by storing sin(theta)
marginal difference, 56->52 mus
oh I left in the normalization for the other two methods...
lemme start over
 
wim
I don't understand why you are looping while true
 
because there's a teeny-tiny chance in the normal case that we hit (0,0,0) or something close
if that ever happens I'll be pretty angry at myself for not handling this case
 
wim
it doesn't make sense to time it for generating one point
generate an array of several thousand points
 
I will be generating it for one point at a time
 
wim
why
just generate an array of them and iterate it
 
1:00 AM
In [482]: %timeit newdir_normal()
The slowest run took 6.08 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 8.87 µs per loop

In [483]: %timeit newdir_uniform()
10000 loops, best of 3: 48.4 µs per loop

In [484]: %timeit newdir_cylinder()
The slowest run took 4.36 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 17.8 µs per loop
@wim because I haven't really thought about that
I'll have to think about the memory implications, but you're right, I could at least generate in batches
 
wim
generating with scalars like this is ridiculous
 
considering how these vectors correspond to sequential time steps, my usual reflex of vectorizing simply didn't kick in
thanks for the tip
 
wim
👍
 
but then I'll have to work a bit more on my timings too, and for that it's too late
so good night
 
 
5 hours later…
6:17 AM
recbg
 
hello
 
Good morning cbg
 
6:51 AM
Morning cbg as well
 
7:19 AM
@AndrasDeak I think your newdir_normal is wrong. Imagine you chose a random triple with U(-1, 1). I know that this would be uniformly distributed in the 2 unit cube space but not uniformly distributed in direction. Then you're projecting that vector onto the sphere. But since the vectors' end points are uniform in space, the likelihood of a point on the surface of the sphere is proportional to the volume in the cube carved out by the localized cone.
Forgive my terminology. This translates to higher likelihoods in the corners of the cube. I haven't wrapped my head around what picking the triple from N(0, 1) does to the problem, but my gut tells me that the density of the distribution fades in a cubical fashion leading to the same problem.
 
7:36 AM
Ahh, if I'm right, then you can throw away any triple that falls outside a certain radius, say .5, then project onto the surface only those triples that are within the radius. You get rid of the corner problem that way. I think this will ~double your time.
 
recbg
 
cbg
@AndrasDeak by the time you read this, I'll be asleep, hope that helps.
And I thought doubling because I'm assuming you choose your triple with np.random.rand(3) * 2 - 1 and throw away if its norm is greater than 1. You throw away a bit less than half of all selected triples. You add a comparison operation, a multiplication and a subtraction. But you swap U(0, 1) for N(0, 1) which is a tad quicker. Ok seriously, bed time.
rbrb everyone else
 
 
1 hour later…
8:45 AM
1
A: Should I mod flag users who repeatedly answer a question and then vote to close it?

Antti HaapalaI would not penalise those who actually use the hammer, redirecting to a question with better in-depth answers - whether they initially posted an answer or not. Instead I would very much want to flag all those with scores in thousands or tens of thousands in the relevant tag, who never use the ha...

 
9:41 AM
Can someone explain why the new c does not contain [[3],[1]]
a = [1]
b = [2]
c = [b,a]
b = [3]
print(c)
 
@HajderRabiee sec, let me find :D
 
You have to understand the difference between variables and values. b is just a name for a value. b = [3] means "The name b now refers to the value [3]". It doesn't matter what b was referring to before that.
 
@Ant
@AnttiHaapala alright thanks I'll check it out and get back if I have any more questions
 
@Hajder because in c = [b, a] - c contains a reference to b which is [2]. Afterwards when you rebind b = [3] you've created a rebound b that refers to the value [3] but the old value of [2] still exists (but with no direct name - unless you count c[0]) referenced by c... if you did b[:] = [3] - then it'll replace the underlying data that all references use...
 
10:26 AM
> I'm going to give it a catchy name: the Mutable Presto-Chango
Made me laugh.
 
@Rawing Amazing how that spell never made it into Harry Potter!
 
Rowling likes her latin spells too much :/
 
@piRSquared thanks, but it doesn't. Choosing normals removes any cubic bias from the system. The cube from the uniform case comes from the support of the uniform probabilities.
the probability density of the product of three normals is ~exp(-(x^2+y^2+z^2)) which is just ~exp(-r^2) with the proper Euclidean distance of the point from the origin. In other words, the distribution is spherically symmetric, so projecting the points to a sphere gives you uniform distribution on the sphere.
 
10:47 AM
You can check the very first result from googling "python combinations". That should help. — Ashish Nitin Patil 44 secs ago
Don't really like writing such comments, but couldn't help it.
 
Why can't the ast module dump the syntax tree as code -.-'
 
what does ast.dump(node,annotate_fields=False) do?
 
Turns tan(65) into Module([Expr(Call(Name('tan', Load()), [Num(65)], []))]) :/
 
I see..
and what else should it dump?
 
Well, valid python code.
 
10:58 AM
your input is valid python code :P
how do you organize valid python code in a tree?
 
Can the following be valid syntax?
@client.command(pass_context=True)
async def yt(ctx):
url = 'https://www.youtube.com/watch?v=rPOUewuNKFE'
 
Yeah, but I wanted to use ast to modify that valid python code :p
 
@AshishNitinPatil IndentationError
 
yeah, that's what I though, just checking :(
 
@Rawing you probably can
 
10:59 AM
there is nothing wrong with the code, i just don't know how to make it play the link someone puts after !yt, i put my code just so people could see what I have. — OhFlummery 1 min ago
 
@AshishNitinPatil I mean, how could it not have IndentationError?
 
I am not sure what happened... to me...
Mixed feeling between furious and courteousness I think
My brain malfunctioned
I believe I should avoid new questions for the day. Stupid overdose.
 
meh, don't be too hard on yourself
 
@PM2Ring if it ducks like a quark ...
 
Let's hear some opinions: Programming languages should support units, for example time.sleep(1 hour). Yay or nay?
 
11:07 AM
yeah, I really need some break. 6-day work weeks are bad.
@Rawing yay for standard units.
 
@Rawing Only if you can find an unambiguous way to include the literal units in the language's syntax ..
Otherwise strings are the way to go
 
@AshishNitinPatil What?! No support for time.sleep(2 fortnights)?!
 
e.g., time.sleep('1 hour')
 
people who both answer posts and then hammer them as duplicates discussed on meta, guess who's number 4 :D
 
@Rawing nope. I can already see people eyeing for 1 bluemoon
 
11:11 AM
@holdenweb Is there something wrong with the standard [number] [unit]syntax?
I really don't think representing things as strings that have to be parsed is the way to go...
 
I think he was referring to the fact that hour / unit would have to be in the list of keywords...
 
Would it?
 
and how about furlong / hogshead?!
 
@Rawing Everything's an object in python, so if the 1 in 1 hour is not tied to the hour, then hour would have to be a built-in object in itself?
 
Yeah, that's how it'd do it - units should be objects, because then it's easy to do math with them: car.accelerate(10 m/s**2)
 
11:18 AM
ahem so someone disagrees with my position
so it is better to actually answer questions than to use the hammer.
@MartijnPieters you're the number 4 troublemaker, answering questions that you're then hammering...
 
Not necessarily IMO. Unless the question requires a subtle extra than the dupe with which it was hammered.
Or perhaps the dupe finding effort was done after the answering.
@AnttiHaapala The ranking is based on absolute numbers. We need ratio to actually compare who is worse :-p
 
@AshishNitinPatil the "perhaps the dupe finding effort was done after the answering" is being discussed on meta
the "consensus" there is now: "if you answer, you must not find a duplicate."
 
meta link?
 
23
Q: Should I mod flag users who repeatedly answer a question and then vote to close it?

JALI will periodically see high-rep power users on certain tags answer an off-topic question, and then vote to close it. The community (and mod/CW) consensus is that we shouldn't answer off topic questions. I generally add a comment on these answers that the question should be closed, or to not an...

notably, people without any hammers are driving the discussion here.
1 message moved to Trash can
 
11:40 AM
@Rawing FYI there's an astropy.units
@AnttiHaapala wonder why rene added a column of all 1s :P
 
I could know how to answer the question but I do not know where to start - because there are so many errors in your code, and the with is the first one that causes the crash :( — Antti Haapala 6 secs ago
@AndrasDeak I wonder why the avg of integers is an integer.
 
ask the flower
if it really is an average, it probably averages ones
 
Cabbage
 
cbg
 
11:51 AM
Martijn Pieters 106 1.471698113207547
 
Out of all his answers?
 
so, if that's abuse, then clearly MP is the greatest abuser in the history of SO :D
 
I'm sure it's coupled to behaviour too
 
modflag MP!
 
JAL surely has a few specific buttholes in mind
 
11:53 AM
I'd rather D. "answer-all-dupes" R.
 
Btw, was the query mentioned on the meta question?
If not, should be linked.
 
@AshishNitinPatil no, in the another one
@PM2Ring @AshishNitinPatil surprisingly I didn't find myself in the sede results...
 
@AnttiHaapala That one is now ripe for del-votes from 20k+ people:
 
@PM2Ring ah I was there, 4+4
that's not too bad, 4 times hammered, with 4 answers avg
 
@Rawing That's easy to do in PostScript. ;)
 
12:07 PM
Are there any badges for close voting?
I feel like I deserve some.
 
@AshishNitinPatil no, because we optimize for sand
@AshishNitinPatil write to meta
 
@AnttiHaapala Yes, Martijn does often answer dupes that he then hammers, but whenever I've sen him do it, it's like I said on Meta: "it can be quite appropriate to write a short answer that summarises the key info at the dupe target, or helps a new coder to understand how to apply that info"
And of course it may be necessary to mention how to apply a Python 2 answer to Python 3, although I guess that sort of thing really belongs as an answer on the dupe target, or possibly a footnote to an existing answer
 
@AshishNitinPatil optimize for sand not pearls
 
12:08 PM
Jeff Atwood on June 13, 2011

In March 2010, we rebalanced our reputation system to favor answers.

While we value good questions (and asking a great question is absolutely an art), we want to explicitly encourage people to provide the best possible answers. Without people interested in providing good answers, the questions are moot. We know that answers have more intrinsic value than questions, and the reputation balance should reflect that.

The question asker already enjoys a substantial benefit beyond reputation gain from upvotes on their question — namely, they get great answers to their question! Thus, the asker shouldn’t need as much reputation gain. …

@AshishNitinPatil ever heard of cognitive dissonance? :D
 
"To put it another way, when I go to a Stack Exchange home page, I see a list of questions. If most of those are terrible questions with little to no indication that I’d be wasting my time by reading them, the value proposition of visiting and participating is diminished: I have better things to do."
this is how Jeff Atwood wrote in 2010
 
Still, if someone writes a full, stand-alone answer and then dupe-hammers it, I'd feel more comfortable if they make their answer community wiki.
 
@AnttiHaapala before the Summer of Love
 
... now... the thing is we must be nice to the n00bs asking the 12312341324123123123th duplicate that will be found by a 10 second google query
 
12:11 PM
Why do so many people feel they have the aptitude to become coders when they don't even know how to Google simple stuff?
 
Sure, sometimes you don't know what to Google unless you already know the stuff, and then you don't need to Google. But Googling things like error messages ought to be obvious to anyone with half a functioning braincell...
 
@PM2Ring why do many people feel the have the aptitude to become coders when they don't have the skill of composing an algorithm for the simplest of problems?
it's probably society's fault
"Coding is cool so I'll be a coder." "I want to earn a lot of money but blood makes me woozy"
"IT is in"/"startups are in"/"I do everything on the computer" -> "I should be a coder"
 
That too. I saw one Q last night, asking how to write code using a while loop that finds the largest (integer) square less than a given number. :facepalm: That's like one or two programs after printing "hello, world".
 
@AnttiHaapala done
0
Q: Close-vote badges

Ashish Nitin PatilAre there any existing badges for voting to close questions? If not, why not? We already have review-queue badges, but some of us don't do the review queues and instead rely on the chatroom or the new questions feed and take actions directly. I feel we deserve some badges in this regard. Or at ...

Asking that question made me "active" and I received a yearling silver. hehe
 
12:23 PM
@wim in the unlikely case that you're interested, the cylindrical version which you also used in your answer is the fastest point generator with a batch of roughly 1e6 points
In [565]: %timeit newdir_normal()
1 loop, best of 3: 212 ms per loop

In [566]: %timeit newdir_uniform()
1 loop, best of 3: 208 ms per loop

In [567]: %timeit newdir_cylinder()
10 loops, best of 3: 128 ms per loop

In [568]: %timeit newdir_cube()
1 loop, best of 3: 205 ms per loop
the "cube" version is the "generate uniform cube, reject outside a sphere, finally project"
 
@AnttiHaapala Yay, I'm achieving something!
 
@AshishNitinPatil Badges for general close-voting would be nice. But I think it's more important to reward people who put the effort into finding good dupes, and not just with badges: that sort of thing needs to get a rep reward, otherwise people will simply continue to farm rep by answering dupes.
 
What happens is that someone found a duplicate and I go "oh yea, that's indeed a dupe".
usually.
 
@MartijnPieters with 4 answers by yourself? ;) :P
 
^ inception
 
12:26 PM
(along the dupe chain)
 
Answering a dupe then hammering it to a self-answered question.
I think Martijn is ageing so much that his older self is a different person altogether :-p
@PM2Ring Yeah, will add some of that to the question.
 
Thanks
 
@AndrasDeak hey, I'm an ADHD adult. I can barely remember where I left my keys, let alone what answers I've written in the past.
 
I figured :P
 
12:33 PM
@AshishNitinPatil upvoted
@MartijnPieters "you're abusing the system" :D
 
Apparently I can't see upvotes vs downvotes on my own question. Argh meta privileges are separate...
 
@AnttiHaapala according to this query (which you shared), I'm #5.
It doesn't help that I have 25 dupe hamers..
 
@MartijnPieters yes, but sorted by number of avg. answers per q first.
 
@AnttiHaapala I'm not sure what the significance of the average answer count is here. Is it better that BalusC has waited for there to be a second answer before he hammers the post?
Is the total number of answers written a metric that matters too? What are the timings, how long between posting and hammering? Where there other dupe votes or flags prior to the application of the hammer?
 
12:49 PM
I see the "enumerate is dangerous" guy still hasn't responded. Is it appropriate to flag those comments as giving technically incorrect information?
 
@PM2Ring not really, no.
But I'll take a look.
 
Thanks, Martijn.
 
@MartijnPieters I didn't make that query :d
you should go argue on meta
28
Q: Should I mod flag users who repeatedly answer a question and then vote to close it?

JALI will periodically see high-rep power users on certain tags answer an off-topic question, and then vote to close it. The community (and mod/CW) consensus is that we shouldn't answer off topic questions. I generally add a comment on these answers that the question should be closed, or to not an...

and
-14
Q: Disable hammering via voting to close if you have answered the question

Jarrod RobersonI think you should not be allowed to vote to close a question you have answered. Even if the answer is deleted, you still should not be able to vote to close, because you can just undelete the answer and get rep from it after the question is closed. There is a loophole in the system that is bei...

 
@AnttiHaapala I've seen the posts. I voted on Jarrod,'s commented on the other.
And I know it's rene's query.
 
I'm not sure if this is a real problem but if it needs numbers on how often this happens and by whom this query might help. It shows the users that have both answered and dupe hammered a question. I guess the ones with an answercount of 1 are the ones you're question is about as that would indicate gaming? — rene 3 hours ago
 
12:56 PM
Until Jarrod puts up actual evidence of abuse, and JAL actually flags someone, I don't see much point in discussing the practice all that much.
 
Today I did answer a question that I later hammered
but... my answer fit the duplicate target perfectly so I moved it there.
sometimes this happens too
 
Wonders will never cease: this OP removed his code images & replaced them with real text, after being prompted by a couple of comments. stackoverflow.com/questions/45763675/…
 
we need the robo review
 
@PM2Ring In this case, is it okay to upvote just for the effort (the question now looks decent fit I guess)?
 
@rene: I note that I'm high up there, as are T.J. Crowder and BalusC (but with different average counts). All three of us have also written a huge number of answers, and have a large number of gold tag badges; we have a larger number of dupe hammers than most (15, 25 and 30). I'm not sure if that's available, but how many of these duped posts have other close (dupe or otherwise) flags or votes on them, cast before the dupe hammer was applied? What are the overall dupehammer stats for these users? — Martijn Pieters ♦ 2 mins ago
@AnttiHaapala: like you, I'm also more concerned about users with hammers that don't use them, just repeatedly answer the same question over and over and over again (cough Gordon Linoff cough).
 
1:11 PM
@AshishNitinPatil I think it's ok because the OP improved his question but by then it was too late for the downvoters to notice, so they're unlikely to reverse their downvotes. FWIW, I posted a comment linking to meta.stackoverflow.com/questions/285551/… but I removed it after he fixed the question.
 
hmm, thanks
 
@MartijnPieters and Daniel Roseman
 
> Also, since such users usually cater only to their respective topic questions, the review / close-votes will likely be better in quality (?) than the regular review queue efforts (no way to filter queues by topic / tag).
Updated my demand (/discussion) for close-vote effort badges
15
Q: Please reduce or eliminate the reputation required to see the upvote/downvote vote split

KyleStack Overflow is the only site I have enough reputation to be allowed to see the upvote/downvote split. I wish I could do this on all Stack Exchange sites. Could you please reduce or eliminate the amount of reputation required for this privilege?

 
re.findall(r"^([hH][iI]\b)(?!d)", "hi d")
Out[40]: ['hi']
re.findall(r"^([hH][iI]\s)(?!d)", "hi d")
Out[41]: []

Is this weird to anyone but me?
 
@AshishNitinPatil I am happily using the userscript. Works fine.
 
1:22 PM
@ByteCommander Exactly! Why put a restriction when it can be easily circumvented?
 
/shrug
 
@AshishNitinPatil nice, tried your top-user query on Finland, I am Patrick McGoohan.
 
It's not exactly mine I think. Don't remember the exact source. I did tweak it a bit.
 
@GitGud Nope. In the first regex the (?!d) matches the space following the empty string at the end of "hi", and because it's a look-ahead it doesn't consume that space
 
@PM2Ring Then I misunderstand what a word boundary is. Can you give me one example a word bondary character?
 
1:27 PM
a word boundary is a zero-width imaginary token
it doesn't match an actual character
 
there is a word boundary between hi and ` `
 
@AndrasDeak Ah!
 
Need 1 silver badge to make it to powers of 2... 4,888 ●4●27●48 (rep-gold-silver-bronze)
 
A \b word boundary is the empty string at the end of a valid word. " A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character."
 
so perhaps just \s+
 
1:28 PM
@PM2Ring I didn't read it attentively enough, thanks.
 
me too thanks
 
@GitGud I've been using various flavours of regex for years. But whenever I do regex stuff the first thing I do is to open the relevant docs. It's just too easy to neglect some minor detail.
 
@PM2Ring I did read it when I found this allegedly odd behavior, but not with enough attention.
 
@PM2Ring or beginning
@GitGud so, word boundary can be defined also in terms of lookbehind and lookahead as:
(?<=\w)(?!\w)|(?<!\w)(?=\w)
(again, zero width)
 
Got it.
 
1:33 PM
though it is much easier to write \b:D
 
@AnttiHaapala Indeed!
 
so, the simplest word tokenizer in Python is...
re.split('\b')
but does it work any more? :d
 
[print(x) for x in range(3)]
0
1
2

Can anyone tell me where in the documentation can one see that the above instruction works as it does?
https://docs.python.org/3/library/functions.html
 
Since I am demanding badges, I might as well demand badge progress / chat stats meta.stackexchange.com/questions/145468/…
 
it doesn't work any more
ah it never worked :d
(of course with r'\b')
 
1:39 PM
@GitGud For which part of it are you exactly looking for documentation? The list comprehension? The range generator? The print function?
 
@ByteCommander printing as it does. I was expecting it to output something like [None None None] or something unintelligible.
Was I clear?
 
It returns [None, None, None], because print(x) always returns None. It does not prevent the print(x) call from having any side-effects like console output though.
 
Actually it does print [None None None], I just noticed it.
[print(x) for x in range(3)]
0
1
2
Out[43]: [None, None, None]

But I still don't understand why it's actually printing the numbers.
 
> As for the chatroom, imo that's a terrible approach. Other people sharing links and telling you to "go get em" is rarely right. I completely disagree that a close vote from a C++ expert on a C++ question is higher quality than a close vote from a Perl expert on that same question.
 
The numbers are the console output, the None-list is the return value (which gets printed here only because you're in an interactive shell)
 
@GitGud what you're seeing is a list comprehension with side-effects (the side-effect being the printing)
ideally listcomps and generator expressions don't have side effects, because that can get confusing
>>> a = []
>>> b = [a.append(k) for k in range(10,15)]
>>> a
[10, 11, 12, 13, 14]
>>> b
[None, None, None, None, None]
the expression in the listcomp is evaluated as expected, and the (return) value is put into the final list
print happens to return None but it still does something
 
Good example.
 
OK. But I'm not actually typing in the instruction print(whatever) in a blank line and hitting enter.
That's what I find weird.
 
Well, not good as in "you should use that in production code", but it demonstrates the ability well.
 
you need to understand that print is just a function and "typing it on a blank line and hitting enter" just calls that function
contrast this to python 2's print which is a statement
 
1:50 PM
The list comprehension is a different syntax for a for-loop. You could also write it like this to have the same effect:
for x in range(3):
    print(x)
 
well
 
Or with the return value it's actually more like:
 
focus on that ^ v because that's what corresponds to the list comp
 
r = []
for x in range(3):
    r.append(print(x))
 
telling Git Gud that your first for loop is the same thing won't indicate that it's bad form to use a list comp to call functions with side-effects
 
1:52 PM
Yes, right.
 
For some reason this answer kinda stings hard. I put up an open question (IMO) and get a highly opinionated (in the opposite sense) answer. Of course some points are good, but how can one make such strong judgements without even mentioning edge cases.
Is it just me or someone else feel the same?
 
The proper way to write something that prints 3 numbers (instead of [print(x) for x in range(3)]) would be:
for x in range(3):
    print(x)
Or if you want it shorter, on one line and without the explicit for loop you can also do:
 print(*range(3), sep="\n")
 
Would you guys find it odd if
r = []
for x in range(3):
r.append(print(x))

didn't print anything?
 
The * unpacks the iterable returned by the range function and the print function's sep="\n" keyword argument tells it to separate the values with a linebreak instead of a space.
@GitGud This also prints the lines 0 1 2, if you fix the indentation.
>>> r=[]
>>> for x in range(3):
...   r.append(print(x))
...
0
1
2
>>> r
[None, None, None]
 
@GitGud you'll have to start to get your act together because you acting surprised at basic language features after spending this much time here is a bit cumbersome
you've been working with regex challenges for a long while; you should switch to a generic tutorial instead
 
1:58 PM
That wasn't very nice.
 
Even I don't understand the print not printing part. Can anyone elaborate?
 
@AshishNitinPatil it's printing.
 
Ah, my bad, should have checked.
And I even missed the stuff pointed out by Bute Commander... I really need the break
rbrb, need to unplug internet for some time
 
hey... don't unplug the internet - I'm using it at the moment! :p
 
@AshishNitinPatil I've replied to that.
 
2:09 PM
@PM2Ring sounds like I'm missing out on drama somewhere :(
 
Ahhh. Thanks.
 
2:26 PM
@JonClements somebody killed the main switch in my place :-p Hope it doesn't affect you :)
 
2:39 PM
@JonClements thanks @JonClements. More info about the : operator apart from official Python docs?
 
What further information are you after? It's just a slice
 
well I don't follow why that b[:] would update c. So it's a rebind of the value b + update of the references?
Or...actually I think I do now :)
 
>>> a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a[2:4] = [10, 20]
Similar to that ^^^ but replaces the entire slice (eg, the entire underlying list)
 
@HajderRabiee When you have b[:] on the left side of an assignment, eg b[:] = c, it means "copy the stuff from the iterable named c to the existing list object named b". So there's no rebinding going on.
 
@PM2Ring ok thanks.
 
2:49 PM
You may find this article helpful: Facts and myths about Python names and values, which was written by SO veteran Ned Batchelder.
 
@PM2Ring So it's like for i in range(len(c)): b[i] = c[i], right?
 
@ByteCommander that's a fairly good way of thinking of it :)
 
@ByteCommander Yep. Except it also truncates b if necessary.
 
What if a,b referred to two custom types (class A...). Would it be possible to rebind b and then cause a change in c?

Given class A with name parameter in constructor
a = A('hello')
b = A('there')
c = [a,b]
b = A('world')

Wolud c contain the 'world' instance?
 
2:52 PM
Alright so a rebind for the name b is what happens only.
 
@HajderRabiee That stuff is covered in the link I just gave you. Here's a condensed summary, with cute diagrams. python.net/~goodger/projects/pycon/2007/idiomatic/…
 
"cute".
Now I expected fluffy bunnies and the like, but only got some cardboard boxes. I'm disappointed.
 
Ye me too, thanks!
 
always these clickbaits :P
 
this chat is awesome, probably wouldn't have gotten those two links by searching the forums an entire day :)
 
2:56 PM
It can take a while to get used to Python's data model if you're coming from other languages that have a more traditional data model, eg languages in the C family, since there's a tendency to translate the Python stuff into the model you're already familiar with. But IME, that's rarely a good idea. ;)
 
@ByteCommander don't mention bunnies - you'll summon poke! :p
 
Anyone know about sockets? l = sc.recv(1024) when sc is sc, address = s.accept() and s is s = socket.socket(). What could mean while (l):, I don't understand the (I).
 
@PM2Ring Comparing to C, couldn't we say that all Python names are basically like C pointers?
Or am I confusing something here...
 
@ByteCommander they'd be closer to C++'s references...
 
I've done C,C++,Java previously so my head is confused atm.
 
3:01 PM
I'm not really familiar with C++...
 
but it's getting there, I've managed to write a lot of Python without understanding the underlying model but now it's becoming necessary :)
 
I must admit that when I first started on Python I did try to understand Python in terms of pointers, references, etc, (I learned IBM 360 mainframe assembler in the mid 70s, and C in 1980) but I eventually realised that it wasn't really helping. So now I just think of Python objects living in a magic memory space that I (mostly) don't need to know the details of, and life became a lot simpler.
@ByteCommander Python names are like keys in dictionaries, and the objects are the associated values.
 
Yeah... I think once you read and re-read Ned's article a few times and it sinks in... it does save a lot of headaches
cos I came to it from a C++ based background, so was "thinking the wrong way" originally
 
I think I kind of understand how it works but without the ability to describe it properly...
"Magic"
 
@Byte make sure to do the hand wavey thing when saying Magic :p
 
3:15 PM
I should've mentioned earlier that slice assignment can also extend the destination list, if necessary:
b = list(range(5))
c = list(range(10))
b[:] = c
print(b)
#output
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
If you tried to do that with for i in range(len(c)): b[i] = c[i] you'd get an IndexError exception once you got past the end of the original list.
 
@PM2Ring You did :)
 
No, I only mentioned that it could truncate b if necessary.
 
Oh... good point... PM 1 - 0 Puppy :p
 
Even better than normal slice assignment is extended slice assignment, where you supply a step value too. There are some nice Python 2 examples here that use extended slice assignment to do the Eratosthenes sieve algorithm. You can see a Python 3 version here.
 
I stumbled back upon sqlite's with clause again the other day... I'd forgotten how much in awe (not quite sure why - maybe it's the fact a tiny embedded database library can do so much more than simple store and select) I'm in of the sudoku solver example...
 
3:38 PM
I'm a little surprised that chepner answered this obvious dupe: stackoverflow.com/questions/45773206/… At least Danil Speransky has the excuse that he's more into Ruby & JS, so may not realise how common this question is.
FWIW, there's a nice Python Sudoku solver here. I stumbled upon it a few years ago, when I was looking for Python code for Knuth's Algorithm X. That code can be condensed even further by using yield from.
 
I wrote a solver once too.
The conclusion after it was finished was that it's much faster to simply try and fill in numbers until you get to a conflict and then roll back instead of trying to implement real strategies...
 
@ByteCommander it's also fairly interesting building puzzles that are solvable...
 
 
2 hours later…
5:20 PM
@AshwiniChaudhary In reference to stackoverflow.com/questions/45773990/… As the old saying goes, there's no point closing the gate after the horse is bolted, so in situations like this it can be fun to turn it into a game of code golf. ;)
 
5:39 PM
@PM2Ring We need better gates and guards I guess. :-P
 
Maybe Martijn decided he might as well post a quality answer, after seeing the 2 low quality ones that had already been posted.
FWIW, I had a quick search for a dupe, and couldn't find one for this exact case of finding the unique chars from a list of strings, preferably retaining the original order. OTOH, I wouldn't be surprised if one exists.
 
@poke Done
 
thanks
 
5:56 PM
This doesn't look like a "variable variables" question to me. I think the OP just wants to know how to make a numeric series of strings for his email subject lines, rather than hard-coding those strings as literals. But I could be totally wrong. stackoverflow.com/questions/45774618/… 10k+ only
 
6:07 PM
@PM2Ring sounds more like a spam generator
 
Could be, or it could be a harmless simulator project, like the OP claims.
 
yup
Does anybody know of a way to construct a tuple from a different iterable without using tuple()? Numba is playing games with me
>>> from numba import jit
>>> @jit(nopython=True)
... def foo():
...     a = (1,2,3)
...     return a
...
>>> @jit(nopython=True)
... def bar():
...     a = (1,2,3)
...     return tuple(a)
...
>>> foo()
(1, 2, 3)
>>> bar()
Traceback (most recent call last):
  [...]
  File "/usr/local/lib/python3.5/dist-packages/numba/typeinfer.py", line 969, in resolve_value_type
    raise TypingError(msg, loc=inst.loc)
numba.errors.TypingError: Failed at nopython (nopython frontend)
Untyped global name 'tuple': cannot determine Numba type of <class 'type'>
Hmm, nevermind, I can do that manually for my use case. But it's still somewhat annoying considering that numba claims that it supports "tuple construction"
 
Does this work?
a = (1,2,3)
t = ()
for u in a:
    t += (u,)
print(t)
Sorry. Stupid clipboard error
 
nope...
> cannot unify () and (int64 x 1) for 't', defined at <stdin> (4)
anyway, I can just generate 3 random integers manually like a peasant...
 
How about builtins.tuple([1,2,3])
 
6:19 PM
otherwise I could also try to manually do tuple = jit(tuple)...
@PM2Ring nope
and I'm moving on, thanks for trying :)
this is great, a numpy example doesn't work
 
def tuple2(*args):
    tpl = type(())
    return tpl(*args)
 
6:50 PM
So, just return args?
 
hmm, the newest version on pypi is 0.34 but the docs are 0.35
oh, no, that's the current dev version
numpy.random should be supported since 0.26 yet I can't get it to work...guess I should try harder
 
00:00 - 19:0019:00 - 00:00

« first day (2499 days earlier)      last day (2453 days later) »