« first day (2414 days earlier)      last day (2549 days later) » 
05:00 - 21:0021:00 - 00:00

5:59 AM
hi
 
6:52 AM
cabbage
 
7:45 AM
cbg
and then the boss said you have done enough python scripts now its time for you to switch on Angular
a sad sad day for me:(
 
 
2 hours later…
9:37 AM
cabbagey morning
 
10:28 AM
cbg
 
 
2 hours later…
12:28 PM
I want to get a fidget spinner because I like to fidget with things but it seems like they've developed a reputation as being owned exclusively by a weird offshoot of the Bro culture that wears onesies? If I'm reading these memes properly
I'm conflicted between my two reactions of "and why should you care about the opinion of other people?" and "because if we don't, we'll get excluded from the tribe and eaten by large predators"
 
I definitely think it's "hipster" now to buy one.
 
 
morning everyone
 
caw caw @corvid
 
my arms hurt too much to type :(
 
12:40 PM
aww, you need to take some pain killers :(
 
Nah just got a personal trainer, and apparently it's way more difficult than I thought, hard to move upper arms now
 
meh, I'd rather sit in front of the laptop and become fat rather than working out.
 
@Kevin If you want one - get it. You could always sneak out to where the smokers hang out to fidget.
 
The Vape n' Spin club, where members hide from insensitive memers
3
 
Vape nation
 
1:17 PM
which movie should I watch today?
 
Get Carter
 
Un Chien Andalou
 
@Kevin much better: thefidgetcube.co
 
@Kevin isn't that the movie that's supposed to make no sense by design?
 
\o cbg
 
1:26 PM
morning
 
I know it as "that one movie with the gross razorblade scene"
 
Salvador Dalí all the way
 
1:57 PM
@AndrasDeak that's amazing
 
The guy in my office who whistles really loudly got a fidget cube and now I don't want one.
 
Ew
 
aww :(
 
People who whistle or hum in developer space can be incredibly annoying. Especially if they're super off-key
 
Cabbage
 
2:06 PM
if I have a list of contacts, what is a good property name for something which is more like an "aggregation" of contact messages? i.e., "saved messages", or "starred messages"
 
@corvid I whistle or hum when I'm walking to the toilet, does that count?
 
@DSM it would help if I paid attention to the timestamp, instead of conflating, "new to python" with "just asked a question"
 
@MooingRawr is it at least on key?
 
I missed "walking to"
@Kevin they gave them out at pycon. I wouldn't have got one otherwise.
 
I finally got around to writing a simple orbit sim in Python using Tkinter. It demonstrates that the period of an orbit is determined by its total energy. So all orbits that pass through a given point with a given speed will all have the same period, it doesn't matter what direction they're heading in, unless of course they crash into the primary. :) gist.github.com/PM2Ring/d7878c904df8da838f76dc4a15c6c746
 
2:09 PM
Cool - I remember working on my own orbit sim a couple of years ago - You helped me out several times!
 
Not using runge-kutta then?
 
If you push the time step delta_time up to 12 you'll see the more eccentric orbits start to precess, but the orbit period won't drift because Leapfrog conserves energy.
 
@PM2Ring that's pretty beautiful
 
@IntrepidBrit No way! Not for a conservative field. RK doesn't conserve energy.
@WayneWerner Thanks!
 
I'm dusting off cobwebs here - I thought RK gave more accurate results over leapfrog?
 
2:14 PM
recbg
 
@IntrepidBrit Here's the Wikipedia article on Leapfrog. The last couple of paragraphs explain its superiority over RK4 for gravity work.
 
Much obliged sir tips hat
Ah yes, that would make sense since RK uses adaptive time steps
 
Note that my code is very basic: the "planets" don't interact with each other, so it's just a bunch of overlapping 2-body problems. OTOH, Leapfrog can certainly be used on N-body problems.
 
I'm having some trouble downloading pdfs with python. The files are on a site that I need to login to in order to access. I am doing this using requests.session() to remember my login details.

Is it possible to download a pdf using only the requests module? Or is there another way I can get it to 'remember' that I am logged in?
 
I can't tell if How to save multiple files with incrementing names using pywinauto is saying "I know that you're supposed to do file I/O with open and write but I have a valid reason for using pywinauto and Notepad instead, strange as it may seem", or if he's saying "I didn't read any of those tutorials you linked, because I already know how to do file I/O, which of course requires pywinauto and Notepad"
@Jacobadtr I'm pretty sure requests can download pdfs, yes. It should be able to fetch files regardless of their file extension.
 
2:24 PM
@IntrepidBrit Adaptive time steps can be a little annoying when you want smooth-ish motion in a sim (although to make my program smooth I'd need to dynamically adjust the delay arg to the Tkinter's .after method). But the main problem with non-symplectic integrators is that accumulated errors generally modify the total energy of the system, so eg planets gradually fall into the sun or escape from the solar system.
 
DSM
Have I mentioned I used to write symplectic integrators professionally? Probably I have. ;-)
Friday morning cabbage for all.
 
@Jacobadtr I've successfully downloaded hundreds of PDF files using the requests module, but not from a site that requires logging in. The file type is irrelevant, but you do need to login correctly!
 
Thanks - I have actually now sorted my issue
I can use session.get() on any file as you suggest
I was using urlopen which was 'unaware' that I was logging in
 
@DSM I don't know if you've mentioned it, but it wouldn't surprise me. :) I know synchronised Leapfrog isn't very sophisticated, but I'm rather fond of it - I kinda discovered it myself back in the days of the Amiga, butI didn't know it had a proper name until I encountered it on Wikipedia.
 
DSM
@PM2Ring: ah, the two of us have spoken about it before! Thought so.
 
2:31 PM
@PM2Ring it reminds me of this game that I cannot find to save the life of me, but it's a linux game, and you shoot missiles at each other, a bit like Scorched Earth, in space.
 
@DSM Ah! Now I remember. :)
 
cbg guys
 
@PM2Ring Gotcha - so RK would be used in a simulation to do a specific task, like a single slingshot calculation. But not for a long running simulation
 
This was my attempt at a sim

https://paste.ofcode.org/xEjeXt7HK9L9RDG6aadQ7T
Using pygame to visualise things
never did work very well
Figuring out why I did some of those conversion factors wouldn't be fun
 
i had a question. i have a dictionary, with 50,000 keys and each key having 10 entries, which are the 10 synonyms of that key. What I want to do is to find those elements in the ENTIRE synonym pool (i.e. the set of all synonyms of all keys) which have duplicate(s) either among the keys or among the entire synonym pool, and then delete them, along with it's duplicates in the synonym pool. Considering the size of the dictionary, what would be the best way to do it?
example
`abc:{this, that, there, those}
xyz:{him, his, her, that}
those:{go, get, guide}`

becomes
`abc:{this, there}
xyz:{him, his, her}
those:{go, get, guide}`
 
2:48 PM
you can create reverse dictionary, then iterate over all items and remove those having more that one key
 
DSM
You could build the inverse map (from synonyms to key locations), and then loop over all the pairs. If a word is found in more than one place.. aargh, Kevin'd by marxin!
 
@IntrepidBrit RK4 (and indeed the whole RK family) is a great general purpose integrator, and it's well-known and available in a bunch of libraries, so it gets used a lot, even when there are better choices for certain tasks.
If you're simulating rockets that are burning fuel, you're effectively adding new energy into the system on top of the kinetic energy + gravitational potential energy, so the need to conserve energy is less critical. You can just treat any energy discrepancy as an error in the amount of fuel you need to burn (and when to burn it).
 
@marxin @DSM, i also need to remove the synonyms which have duplicates among the keys
 
DSM
@user1993: so include those too. That's not a fundamentally different problem.
 
@DSM I learned a nice thing from OEIS today, in connection with a nested radical expression involving Fermat numbers. See Interesting question regarding Fermat nested radicals for details. I love it when a simple transformation makes a huge difference to the time required to perform a calculation. But it is a bit annoying when the transformation is really obvious like that and you didn't think of it yourself. :)
 
2:52 PM
@user1993 how is it possible to have duplicates in keys?
 
I'm lost. Dictionaries can't have duplicate keys by design.
 
i mean i need to remove 'those' in my example above, too
 
DSM
k1993 doesn't meant duplicates in keys, but cross key/value matches, {key1: [s0, s1], key2: [s2, key1]}.
 
I see
 
ok
 
wim
2:56 PM
"Documentation? No, just read the code... it's all pretty straightforward." https://t.co/eXyB0hIYbh
 
@Kevin I wish someone had told the JSON people that... chat.stackoverflow.com/transcript/6?m=29338502#29338502
 
i was thinking of running a for loop for all elements of all keys, check if it matches any of the keys or any of the elements in the synonym pool. if yes, then delete it. but i think this would be TOOO slow
 
Have you timed it?
 
no, but this is the task, and considering i have 50,000 keys each having ~10 entries, i assumed it would be too inefficient
 
DSM
Think in terms of the algorithmic complexity of your operation. marxin suggested an approach which should give you O(N).
 
3:01 PM
yes, but it missed the part that i also need to remove cases of cross key/value matches
 
DSM
Which is a trivial modification of the approach, and I'm confident you'll see that if you spend a few minutes thinking about how you could do it. :-)
 
ok. so for that, what i thought was to check, in the reverse dictionary, if the entry of ANY key matches the current key, and do this for all keys. how about that?
 
Sounds like you want to be using a database to me
 
DSM
That sounds like a lot of looping. Think instead about how you can store information in O(N) which would make it easy to answer the question "where is this word located", and re-read what marxin's already proposed.
@IntrepidBrit: I got the impression these questions are coming from some online puzzle site, they have that flavour to them.
 
@DSM , no its from my Master's thesis work :)
 
DSM
3:06 PM
Then you should work through one of the online puzzle sites, they're good at forcing you to learn beginning algorithms. ;-)
 
Hello, everyone! I've just finished learning lists, dictionaries, conditionals, while/for loops.
Before getting to OOP I want to feel confident with this stuff. I'd be thankful if someone could give me a task. I'll get back with the solution on Monday
 
:p
 
Orbital mechanics simulator. Hard mode: ensure conservation of energy across time.
 
DSM
@PM2Ring: the coincidence is a little surprising. ;-)
 
3:11 PM
Apparently you need to know about Hamilton to prevent gradual energy loss. I don't usually learn physics via Broadway musical, but I'll buy a ticket if that's what's necessary
 
dumb question, anyone know how to get those enclosed-in-block alphanumerics? I can find the ones in circles, but not in squares
🅱 <= like that one, but for other letters... 🆁🅴🅰🅻🅸🆉🅰🆃🅸🅾🅽 works too
 
@PM2Ring Wow. I thinks that's going to be too complicated:D
 
@corvid I found a list of 'em at unicode.org/charts/beta/nameslist/n_1F100.html
ctrl-f for "White on black squared Latin letters"
Although in my browser some of them render as white on red, curiously
 
@DSM i think i got it. I iterate over the entire reverse dictionary, store the frequency of each key. In the process, also check if any of the previous keys match the entry of this key.
noooo! but that won't work because i will only check the previous keys, i can't check the future keys with the entry of this key. sigh!
 
3:17 PM
Why don't you have multiple keys that refer to the same bit of data in memory?
 
ok, assuming i figure how to do that, how would that help?
 
that's strange, A in that block is parsed as the red A emoji in slack, but the rest render normally
 
DSM
@user1993: you're overthinking this. Imagine you didn't have an original dictionary, you just had a list of lists, [['a','b','c'], ['d','e','a'], ['f','g','h']]. Find and remove duplicates in O(N).
 
@corvid Or, are you asking "how do I programmatically convert regular letters to block letters?"? You could do it with some quick chr arithmetic: repl.it/ITX2
This is how those characters render on my machine. Red A,B,O; gray P.
 
I was more wondering about your initial set-up.
 
3:23 PM
@Kevin Yeah, but the B and the A are in the emoji menu for sure
 
The page I linked to implies that the color is due to their use in indicating blood type.
 
DSM
O.o Really?
 
Kind of weird that they would assign that much intentionality to such a general purpose character.
 
I often communicate my blood type with unicode
 
Reminds me of how there are only like 23 small caps characters for some reason.
> As of Unicode 5.1, the only characters missing from the ISO basic Latin alphabet are small-capital versions of Q and X.
 
DSM
3:25 PM
I've just realized I don't know anything about blood types in birds.
 
I can understand excluding small capital X because it would look identical to lowercase x, but a tiny Q would not look like q
 
@RuslanDoronichev Perhaps, but maybe the answer isn't as complicated as the question. ;)
 
@DSM let me think about this, and it's similarity with my question, and i'll get back
 
@RuslanDoronichev In the mean time, you may enjoy looking at this code I wrote a few months ago. It's a bit intense at first glance, but if you're familiar with lists, dictionaries, and generators you should be able to understand how it works.
 
wim
3:55 PM
@davidism ^ from Mozilla CTO (!)
 
4:14 PM
It bothers me that str(globals().update({"str": type("Blah", (object,), {"__init__": lambda self, x: None})})) doesn't evaluate to a Blah instance.
It closes off the avenue I was going to use for stackoverflow.com/a/44205566/953482 for the constraint of "suppose you can't just search the source for the plaintext password"
Overriding str to return an object which compares equal to everything was the easiest way of getting that conditional to pass.
Hmm, can you monkeypatch the methods of builtin types? Let's see...
Bah. TypeError: can't set attributes of built-in/extension type 'str'
Ooh, __str__ is allowed to return subclasses of str, isn't it... >:-)
I'm in B-)
 
4:33 PM
@wim it's crazy. I really like the experimental stuff FireFox does with Rust and Servo, hopefully they keep going with that at least.
 
4:46 PM
I find the chart in that article a little misleading. It makes it look like chrome has ~90% market share because it's 90% of the way to the top of the graph. But the graph actually tops out at 60%.
Having slightly below 60% of market share is already impressive, no need to puff up that accomplishment with light deception
Also I don't think you should be using an exponential fit to model anything that has a finite maximum ceiling
"At this rate, we'll have ten million percent market share by 2025"
 
hundreds of babies
 
I want to say "that's only a problem if you insist on measuring personhood using just whole numbers" but I'm pretty sure that's a conversational minefield
 
and I see you pulled the pin and threw it anyway
 
Like putting an unexploded claymore mine in your curio cabinet because you like the way it reflects the sunlight
Oh, that joke doesn't work because claymores are remote-operated, not pressure-sensitive.
My bad.
 
5:03 PM
Am I being overly fussy in not liking this construction: open('search.txt').read() ? Eg, stackoverflow.com/a/44206116/4014959 I guess I've used it in the REPL, and "disposable" scripts, but I'd never use it in proper code. OTOH, I don't have a good reason why it's bad, apart from "you should use a with block to open files and ensure they get closed properly".
 
I also avoid that pattern in proper code.
I want to say "I don't want to leave it up to the garbage collector to decide when my file handle should be freed" but I'm happy to let the GC free pretty much everything else, so that can't be my true objection
It's not like I do del x in the middle of a scope because I'm done using x.
 
wim
@PM2Ring it's a code smell
pathlib.Path('search.txt').read_text() is an acceptable alternative
 
@wim My instinct agrees, but I'd like a tangible reason. ;)
 
DSM
@wim: aaargh, Kevin'd -- I was just looking through the transcripts for what that was, I think vaultah showed me that years ago.
Time for lunch:
In [305]: %timeit results = fast_compute(**data)
1 loop, best of 3: 4.86 s per loop
^ that usually takes about six minutes. Not bad for a morning's work.
 
wim
well, there is no tangible reason that i'm aware of. It's quite fine to let the gc clean up and close the handle. the only caveat being that you don't know when that will occur
 
5:10 PM
@wim Why is that better (I haven't read much about pathlib) ?
 
wim
@PM2Ring because pathlib enters and exits the context
so that you know after that line of python is executed, the resource is freed
 
@wim Rightio.
@wim Good point. If it's in global code it could hang around until the script exits. And I suppose that could cause problems if you try to reopen the file. That shouldn't be an issue for a file opened in a read mode, but it's bound to get messy if it were opened in a write mode.
 
wim
@PM2Ring no, it will likely get cleaned up immediately in almost all circumstances
because open('search.txt').read() does not leave any reference on the open file handle
in CPython at least __del__ should be called immediately
 
That's not how marriage works. You actually have N^-i husbands at each step in a cycle:
· 1 imagined husband
· 1 real husband
· -1 imagined husbands
· -1 real husbands
… and so on.
 
@wim I thought CPython doesn't guarantee that unreferenced objects get cleaned up immediately, unless they go out of scope. But it's getting late & I may be confused. ;)
@ZeroPiraeus Cyclotomic spouse theory.
And that'd be i^n
 
5:18 PM
Ah yes, you're right.
 
Powers of i are weird. I remember being a little surprised when I first realised that there's a real value of i**i.
 
wim
Unless Martijn corrects me, the GC is not involved here. The object is destroyed as soon as the reference count drops to 0 (which it does here, as soon as .read() is completed).
 
@wim Ok.
 
wim
GC is for breaking up cyclic references etc
you can prove this to yourself as follows
>>> class Foo(object):
...     def __del__(self):
...         print('deleting the thing:', self)
...
>>> import gc
>>> gc.disable()
>>> a = b = Foo()
>>> del a
>>> del b
deleting the thing: <__main__.Foo object at 0x7fffe8f7fe10>
del b decreased the reference count to 0, and gc (which was disabled) has no part in this.
compare and contrast:
>>> a = Foo()
>>> b = Foo()
>>> a.b = b
>>> b.a = a
>>> del a
>>> del b
>>> gc.enable()
deleting the thing: <__main__.Foo object at 0x7fffe8f7fe10>
deleting the thing: <__main__.Foo object at 0x7fffe80e9828>
 
5:33 PM
@wim Thanks.
 
wim
so, yeah, there's not any good technical reason to hate on open(...).read(). It's even used a few times in the standard libraries, and is pretty common in setup.py files (which should ideally work even on Python versions lacking the with statement)
but, it's a code smell due to Zen of Python #2. and when you look in git blame, people that use the shortcut usually have written genuinely bad code somewhere nearby ... :)
 
I agree that it's definitely a symptom of hacky code. And I don't mean hacky in the good sense. :)
 
DSM
5:55 PM
This is exactly the kind of microperformance question which fills some people with excitement and bores me to tears. O(N^2)->O(N) is interesting; a few percent in an O(1) op is not.
 
wim
@DSM downvoted
I usually prefer plain old if statements to the "ternary" conditional statements. The if: .. else: ... is much clearer on a coverage report. To see whether the ternary conditional is properly covered, you have to explicitly enable branch coverage in the settings.
 
6:19 PM
@DSM If one is definitely faster than the other that's nice to know. OTOH, mangling your code to use a ternary when a traditional if...else is more readable is silly, similar to trying to force code into a comprehension when a traditional for loop is more readable and not significantly slower. And we've all seen code where the comprehension version is actually less efficient but the OP has used it in a misguided desire to be more Pythonic.
@wim I don't mind ternaries, but your objection makes sense.
Here's one I wrote this afternoon.
# Columns are separated by a space,
# rows are separated by a single newline,
# blocks are separated by two newlines.
sep = (' ' if j % rowsize
    else '\n' if j % blocksize else '\n\n')
 
I think I'd probably write that as whatever the non-ternary statement is :P
I typically only use ternary statements where I need not-specifically-coalescing but something else is more.
Like maybe I'll have something like favourite_color = 'blue' if name == 'gallahad' else 'yellow'
but even in that case I might just write it as
if name == 'gallahad':
    favourite_color = 'blue'
else:
    favorite_color = 'yellow'
 
How does you calcualte what "1111" (base=2) is in base 10?
(1* 1^3) + (1* 1^2) + (1* 1^3) - what I got, isn't right
It should result in 15
 
wim
2**0 + 2**1 + 2**2 + 2**3
1 + 2 + 4 + 8
 
From where exactly did you get the numbers from
I get why you have the base of the exponential to be 2
since the base is equal to 2
 
wim
6:35 PM
well it's the same way that 1248 in decimal is 1*10**3 + 2*10**2 + 4*10**1 + 8*10**0
 
but why is it lifted in 0 through 3
 
wim
that's literally what base 2 means
 
ahh, so there is an "invisible" 1 in front of each of those exponents
 
wim
yes
 
There is just no need to type it.
thanks that helped.
 
6:41 PM
in other words, "base" just means the amount of glyphs that you have to represent your digits
In base 2 you have 2 digits. 0, and 1
in base 36 you have 0123456789abcdefghijklmnopqrstuvwxyz
 
wim
I like base 1, it's just counting:

0 =
1 = x
2 = xx
3 = xxx
...
 
Sadly, Python doesn't support some more interesting bases
@wim I'm not entirely sure how you'd like... deal with that arithmetically.
Would you have to do 1+ + 11 or something, for 1 + 0 + 2<sub>10</sub>
 
cabbage, @Code-Apprentice
@wim You need one of these for next Pycon partywigs.com/acatalog/badger.jpg
 
How are all you pythonistas today?
 
6:50 PM
Pretty excellent
 
Is there a module in python that supports sigma formula? Like:
sigmaFormula(i=0, N=5, 'd_i x K_i')
Sorry for the bad quality
 
Also, interesting point of fact: 80° starts to get uncomfortably warm, but is still cool enough that a 9" high-velocity fan will still cool you off
 
@SebastianNielsen try sum().
 
@SebastianNielsen sigma literally means sum
 
and use a list or generator comprehension
 
6:53 PM
Yeah but it's the sum of all the d's multiplied with k's....
Well, now that I think about it, a lambda functions should do the job.
Nvm
 
sum(d[i]*K**i for i in range(N))
 
@SebastianNielsen That's easy enough to do using the sum function. But sophisticated mathematics packages like mpmath have fancier versions - some can even handle infinite sums, if they converge.
 
Yeah exactly Wayne
 
I feel like my math skill is really low, but what is the D(i) supposed to actually denote?
 
I'm pretty sure that's a transliteration of the sum. Might be d(i)
 
6:54 PM
@SebastianNielsen Wayne's code is better than using a lambda.
 
@corvid it is just a variable
@corvid Probably the ith element of a vector
 
How so Pm 2ring?
 
@corvid typically the 'ith' item in a series or whatever
 
Okay I thought so, but wasn't sure
 
@SebastianNielsen Because it uses a simple expression to do the arithmetic, so it's faster than calling a Python function for each i
 
6:56 PM
it could mean something else, I think, but typically that's what it means.
Two slow things in Python: calling functions, and comparisons
 
Alright
 
depending on # of iterations you can actually spend a significant amount of time doing those two things
if you can skip them and do maths instead you're a lot happier, speed-wise
 
@WayneWerner even just < or > comparison on a numeric type?
 
C function calls are pretty fast, but Python function calls are just about the slowest thing in the language due to the additional overheads involved.
 
@Code-Apprentice pretty sure. I forget exactly what the relative cost is, but it's not insignificant
 
6:58 PM
TIL
 
of course it's extra slow if you've got to do this in that, where that is list/tuple
 
yes, a linear search is slow in any language
 
@Code-Apprentice The < and > and other comparison operators get translated into method calls on the object, eg thing < other => thing.__lt__(other)
 
oh yeah, that's why comparisons are slow. I knew I had learned a reason, I just couldn't remember what it was.
comparsions == function calls in Python
or would that be comparisons is function calls in Python? :D
 
are allocating functions expensive at all?
 
7:05 PM
Of course, that doesn't mean we should totally avoid using Python functions / methods and write a big pile of spaghetti code! :) But if you have a choice between using a simple expression vs wrapping that expression in a function and calling the function, then you should probably just write the expression, unless you need to use the same expression in multiple places.
 
wim
@WayneWerner it's just similar to string addition. so 1 + 0 + 2 would be like 'x' + '' + 'xx' == 'xxx'
 
oh that makes sense.
A million takes up a lot more space, though ;)
 
So (3*u + 1 for u in thing) is more efficient than map(lambda u:3*u + 1, thing)
 
by at least one function call per thing :)
 
wim
you can actually use a base-1 trick to find prime numbers using regex
def is_prime(n):
    return re.match(r'^1?$|^(11+?)\1+$', n*'1') is None
it works, try it!
 
7:11 PM
@wim that's wild
 
@AlexMathew Please don't link your fresh SO questions here. See the room rules for details. sopython.com/chatroom
 
I have a bad feeling about this
;)
 
oh haha, he's a regular in the Knives room
 
@wim oh the efficiency
 
7:13 PM
I love the result of my comment
 
@vaultah Rightio.
I thought the name looked familiar.
 
aw, self-delete. Well, 10k only :)
> You've literally done nothing to solve your problem beyond posting a couple of sentences. You didn't even bother capitalizing I. If you don't care, why should anyone else?
< 10k version ;)
I was going to say that with 600 rep the OP should know better, but apparently 7 years ago people were a lot more forgiving of garbage posts
30
Q: Parallel programming in Java

Alex MathewHow can we do Parallel Programming in Java? Is there any special framework for that? How can we make the stuff work? I will tell you guys what I need, think that I am developed a web crawler, its crawl lot of website from the internet, one system crawling will not make things to work proper, so ...

 
7:33 PM
speaking of my inability to into math, I never thought CSS would get this math-intensive
 
Haha math is fun
 
@corvid yup! Math actually has lots of uses. Especially when doing graphics.
@SebastianNielsen what is this from?
 
The link corvid just sent
If you scroll a little down on the page.
 
recbg
@SebastianNielsen I do
 
Sorry but, you do what?
 
7:44 PM
@AndrasDeak I would be surprised if you didn't. :)
 
I know where those objects came from in the formula :P
@PM2Ring the fact that I teach this every other semester helps a bit ;)
 
although linear differential equations are never supposed to kick my butt
 
been a while since I did any diffeq
but I definitely could solve that particular problem by hand after dusting off a few cobwebs
 
characteristic equations ftw
 
7:49 PM
I used to tutor students one-on-one in all levels of maths.
 
the weirdest thing is how easy complex numbers make a lot of different, real-life problems
 
It's basically just a springy animation, looks really nice
 
for an appropriate value of "real-life problems", considering that "trigonometric addition formulae" are top on my list of such real-life problems
 
@AndrasDeak I was just thinking that. :) If you don't know about complex numbers the mixture of trig & exponential functions must seem a bit bizarre.
 
that's some crazy stuff
 
7:53 PM
[1, 2, 2, 1, 2]
print(s[2:0:-1]) #output: [2,2] # as expected
print(s[2:-1:-1]) #output: [] # Shouldn't this output: [2,2,1] ???
(start at index 2 -- stop at index 0 -- 1 index down each time )
 
@AndrasDeak It took me a while to learn the trig sum & difference formulae properly without messing the signs up. And then a couple of years later I understood them in terms of complex numbers, and I thought "Why couldn't you tell us this stuff before?!"
 
yup:)
@SebastianNielsen I suggest that you use more meaningful elements for your test data
[1,3,5,7,9] makes it easier to see what's going on
 
It's not test data
 
irrelevant
 
uh alright.
I misunderstood
 
7:54 PM
OK
 
@SebastianNielsen How about
s = [1, 2, 2, 1, 2]
print(s[2::-1])
#output
[2, 2, 1]
 
@SebastianNielsen [2:-1:-1] stops at len(s) - 1, not 0
That's how negative indexes work
 
the problem being "index -1" implicitly referring to "index len(s)-1"
 
that makes sense..
thanks
 
Also see print(s[-1::-2]) ;)
 
7:58 PM
I don't believe that does what I want.
starts at the last index in the list, and jumps two steps down.
 
@SebastianNielsen But it gives the same output when s==[1, 2, 2, 1, 2], which is why that's not great test data: you might accidentally write a slice that appears to do what you want for that particular s, but will select the wrong items with another s.
Weird. I just warned this guy about deleting questions and he just did it again. stackoverflow.com/questions/44208218/… And it's not as if he's a low-rep newbie.
 
^ Low rep newbie like me can't see deleted questions :D
 
Arhg, this is really bugging me; here is what I am trying to achieve:
I got this list (with nice test data): [1,2,3,4,5,6,7]

And I basically want to print all substrings of length 3 in reverse order like following:
[3,2,1]
[4,3,2]
[5,4,3]   and so on...

s = [1,2,3,4,5,6,7]

for i in range(len(s) - k + 1):
    print(s[k-1+i:i:-1])
k is the length of the substring, in this case 3
I can see what the issue is, that it stops right before the 0 - therefor not including the last number.
 
@PM2Ring (actually, deletion is only a problem if an answer has been added, especially recently)
@SebastianNielsen you might have to use something like (i if i>=0 else None) as an end index. There should be a better way but I don't know what it is
the other option is indexing length-3 direct substrings and reversing afterwards
 
8:14 PM
I could simplify the question, if we got the same list.

how can I in the most efficient way save a reverse list of the first 3 items.
 
that might be simpler but I no longer understand what you want :P
I'll take that as a hint from the universe
 
I just don't like the use of the if statement, since that could bring some some overhead.
 
If the number of elements was fixed, I might do [s[2], s[1], s[0]]
 
[1,2,3,4,5]

print the first 3 items in the list #[1,2,3]
BUT in reverse order.
as a list.
 
that is so not C in MCVE
 
8:16 PM
that might actually be a good idea vaultah
 
anyway, good luck
 
    s = [1,2,3,4,5,6,7]

    for i in range(len(s) - 4):
        substring = [s[2+i], s[1+i], s[0+i]]
        print(substring)

output:
[3, 2, 1]
[4, 3, 2]
[5, 4, 3]
[6, 5, 4]
[7, 6, 5]
This is what I was looking for :P
 
I'd probably do [s[i:i+3][::-1] for i in range(len(s)-2)]
I mean that's every length-3 there
 
If I were to just fix your code:
for i in range(len(s)-2):
    substring = [s[2+i], s[1+i], s[0+i]]
    print(substring)
 
nvm, that actually seems like a better approach
does 's[i:i+3][::-1]' copy the list two times?
First it copies [1,2,3]
Then it makes a new copy again from the previous: [3,2,1]

Or is it only one copy?
 
8:28 PM
I'm not saying it's necessarily good, but that's what I'd do. I'm not a particularly good coder so you can choose whatever solution you want :P
and you should stop microoptimizing the creation of 3-element lists
 
I am simple thinking big.
 
write full code and profile that if you're worried
 
What if the list is 10000
and the substrings 100
 
then you can profile it
 
@SebastianNielsen that makes two copies
 
8:29 PM
thanks
Then I suppose the other approach actually was better.
 
Any plans this weekend?
 
This is why I was worried
The list can become very big, making the extra copy of the substring very time consuming.
 
@MooingRawr a lot of driving
 
Where you going Wayne ?
 
@MooingRawr Coding because coding is life :)
 
05:00 - 21:0021:00 - 00:00

« first day (2414 days earlier)      last day (2549 days later) »