« first day (2469 days earlier)      last day (2705 days later) » 
00:00 - 17:0017:00 - 00:00

00:46
hey!
`ipdb> plt.plot(num_iters,var1,"Layer1")
*** ValueError: Unrecognized character L in format string`?
 
2 hours later…
02:30
late night cbg
03:30
cbg
It's good to see a decent question every once in a while. Definitely a very noob question, but worded clearly to understand what they are trying to do.
04:00
Hi guys
hello
04:40
cbg
05:13
is there a reason import work in shell but in ipython notebook?
 
1 hour later…
06:31
@davidism You'd get a new app and request context if you use another Flask app as a 'nested' WSGI container. It's an esoteric use-case but it is technically supported.
@davidism: if you used the current app to run another request (either via test_request or by using app as a nested WSGI object), you'd get a new request context nested.
again, esoteric but technically possible and supported.
@SunQingyao: as for multiple app contexts being on the stack, if there is another app context active, some other code is responsible for that.
Don't worry about it being there.
If a different app context was already active, then it is there for a reason, some code pushed it onto the stack, and it is then responsible for popping it off again. It is of no concern to the new app and request context being pushed and later popped.
You are overthinking all of this, by the way.
Just start building your app. Put stuff in the request if it only makes sense in that single request. Put everything else on the g app context. Especially if it might be needed in a command-line script.
And unless you are a core Flask developer or are doing something really weird like using another Flask app as a nested WSGI app, you don't need to worry about how the app contexts are managed.
@MartijnPieters Thanks for your explanation and advice. And yes I'm feeling quite exhausted after diving too deep into the implementation of Flask. I'm going to do something interesting and craft my own Flask app :)
@MartijnPieters chat.stackoverflow.com/transcript/message/38225135#38225135 I suppose database connections only make sense in a single request, but should be stored into g, rather than request?
 
2 hours later…
Cro
Cro
10:00
cbg
how does python save raw binary data into a file?
you mean "how do I save binary data into a file with python"?
or are you literally asking how python does it
Cro
Cro
the first one
because that i couldn't modify tensorflow cifar tutorial input to my own data (abbott)
10:25
Cabbage
@Antti Whatever OP was doing, apparently they solved it now
thanks buddy it worked perfectly. — aditya aundhekar 16 mins ago
10:49
cbj all
has anyone used mongoengine
facing this issue
Why is Python suddenly saying that END is not defined?
any thoughts?
NameError: name 'END' is not defined
@SohaibAsif No sorry
@Jake based only on the information you provided, the answer is "because you haven't defined it".
Jun 23 at 12:36, by Andras Deak
@Jake "it comes up with an error message" is never sufficient, see also what an MCVE is and How to Ask. Most python errors are quite informative (don't know whether for tkinter as well)
Yeah but it worked yesterday
10:59
Again, that doesn't help us who can answer your question because the required information is insufficient.
Okay, then the answer is "something changed"
@Jake Because you forgot to add from tkinter import * to your code I guess
No I have got import tkinter as tk
That's not from tkinter import *.
If you import it like that you're gonna have to use tk.END.
Oh ok
11:06
@vaultah You’re so dark.
@Cro if you have binary data to write to the file, then it's easy: with open('/path/to/file', 'wb') as binary_file: binary_file.write(binary_data) But that's something a 2 minute google search would've solved, so I'm not sure what your question really is.
I googled exactly that, and got this as the first result - https://stackoverflow.com/a/23199902/2689986
You may have difficulty digesting the answer, but you should start by finding / trying to find it first, by yourself.
@SohaibAsif no clue how was it working before but that seems to be working fine? why would you expect derived to return base object?
because the purpose is to inherit base class and do stuff on inherited class objects
also as in mongo the data saving source is single collection i,e; Base
I think we may have different understanding of oop
but nvm
11:45
cbg
Good time of day to everyone :)
hello
ugh....
cbg and salutations
and then a freakin' pandas answer
I give up
12:05
Wasn't there something in the stdlib that could print data in a table format?
cbg all
hmm, maybe I was thinking of tabulate but that's a pypi module
12:19
@Ffisegydd Nice. I'd love to do more stuff with trees, but I've never been able to come up with a good rendering algorithm that allocates a reasonable amount of screen space to branches on the same level.
Consider a tree with this structure:

    A
   / \
  B   C
 / \   \
D   E   F

How would you write a rendering algorithm that decides that the C-F edge should be slanted right? It won't happen if you go with the easiest approach, which recursively builds branches and connects them with whatever space is necessary:

branch 1
  B
 / \
D   E

branch 2

C
|
F

Naive combination of branch 1 and 2

     A
    / \
   /   \
  B     C
 / \    |
D   E   F
The naive representation here requires edges A-B and A-C to have a length of two apiece, which is suboptimal.
@Kevin start from bottom?
leaf nodes
Are you suggesting something like:
Stage 1

D   E   F

Stage 2

  B   C
 / \   \
D   E   F

Stage 3

    A
   / \
  B   C
 / \   \
D   E   F
Using the strategy of "starting with the lowest depth, pack nodes as tightly as possible, then move upwards and add parents, packing them as tightly as possible, until reaching the root node"? But consider the tree:
      G
     / \
    /   \
   /     \
  H       I
 / \     / \
J   K   L   M
|           |
N           O

Stage 1

N   O

Stage 2

JKL M
|   |
N   O
Oops, J and K and L are touching... We don't want that.
12:36
of course you cannot just print without going through the entire tree.
We could move O farther to the right once we notice we don't have enough room for K and L, but the algorithm no longer adheres to the constraint of "once you have decided the position of a node, it's permanent" which was an attractive property on its face
well, you just can't.
To be clear, I'm not claiming that these are insurmountable problems. I only want to demonstrate that a good rendering algorithm isn't completely trivial.
13:10
New topic: today I want to write a script which uses subprocess to execute some powershell-specific commands. I assume this will be completely easy and intuitive.
Cabbage
well I went on a comment rant here because my awful mood continues
Drawing trees / connected graphs nicely is hard, which is why I normally just let Graphviz do it for me. ;) OTOH, GraphViz does make odd choices sometimes, but you can get it to output the graph in DOT format so you can edit it by hand before rendering it to a bitmap or vector graphic format.
@idjaw Gone
13:18
good. Thanks PM
@Kevin I think I looked into this before and IIRC, it will not be fun.
cbg \o
I don't need a full-blown session, I just need to execute a single command, so I think I may be able do avoid using Popen.communicate or whatever.
I see powershell.exe has a -Command parameter which ostensibly lets you pass a command in through as a string, and then immediately exit. This is exactly what I want. It has rejected my first four attempts at escaping all the necessary quotes and parens and such, however.
Ah, seventh time's a charm. powershell -Command "& {[reflection.assemblyname]::GetAssemblyName(Widget.Viewer.dll') | fl}" does the needful when I execute it from the command line. Let's see if it works in a subprocess call...
how to connect godaddy database connection for python flask website
That's extremely vague and not really related to Python in any way
you happen to be using Python, but that work is admin-level stuff
13:31
import subprocess

def get_dll_info(filename):
    cmd = "powershell -Command \"& {{[reflection.assemblyname]::GetAssemblyName('{}') | fl}}\"".format(filename)
    output = subprocess.check_output(cmd)
    d = {}
    for line in output.split("\n"):
        if ":" not in line: continue
        key, _, value = line.partition(":")
        d[key.strip()] = value.strip()
    return d

info = get_dll_info("Widget.Viewer.dll")
print(info["ProcessorArchitecture"])
Success! Too bad it takes ten seconds to run.
Rather puts a crimp in my plan to run this on the dozens of dlls in my project directory
I feel a bit weird using my own answer for this, but does anyone agree? here
?
it's almost borderline opinion because there are several implementations for this, and there does not seem to be any idiomatic way to do this. So, technically my answer isn't the one.....I'm at a bit of a loss whether I should keep this as a dupe.
@idjaw I'm definitely not an expert on that topic, but it looks ok to me. But maybe we can wait for some feedback from the OP before we hammer the new question.
@PM2Ring Oh, yes, absolutely. I should have clarified that. I was looking more for confirmation whether my direction was OK for now.
thanks!
@feedMe It does not matter if it is homework! This type of rejection of homework needs to stop. The qualification of an answerable question is whether it meets the requirements of an "answerable" question on StackOverflow. Not whether it is or is not a homework question. That is absolutely ridiculous. — idjaw 8 secs ago
I'm kinda almost losing it soon and might start venturing in to flag-worthy comments soon....
I really need meditation, or a punching bag.
Coincidentally, I just wrote some code that waits for input with a timeout, mostly because I need the practice doing stuff with threads. :) stackoverflow.com/a/45216560/4014959 If anyone has any constructive criticism, please let me know.
Here's a slightly fancier version. gist.github.com/PM2Ring/215147b4de22e158a7b1d78f40300031 I'm not totally happy using a function attribute to hold the countdown timer, but hey, it works. :)
13:49
it looks fine to me. The usage of a thread and a timer is legit.
This poor poor individual -> stackoverflow.com/questions/45216717/…
SOAP and WSDL.....good lord, what archaic system are they diving in to.
nothing but pain there
I...I had to make a comment...
I'm expecting it to get removed :P
Question: does anyone know why building Python might produce this error? /opt/python3/bin/python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
Permissions problem, perhaps?
That's the most common cause of missing file errors, in my own experience
process A tries to create file foo.jpg, but fails because the directory is write protected. Thanks to short-sighted design, it silently returns instead of crashing. Then process B tries to access file foo.jpg, and crashes with No such file or directory
Running everything with administrator permissions is the "thumping the side of your television when the screen gets fuzzy" of the '10s
@WayneWerner Interesting. I don't have one of them. I have a libpython2.5.so.1.0 and libpython2.6.so.1.0 and libpython3.1.so.1.0 but the closest match for 3.6 is libpython3.6m.a
14:05
46 rep more :D
@davidism why the yam do people never edit the question....why......sigh.
Well, I ran strace on it...
it was looking for the file a bunch of places it didn't exist
I can add LD_LIBRARY_PATH=/opt/python3/lib and it'll find it
but that seems... incorrect?
@idjaw which question?
@davidism The Flask 405 question
lol...foot in mouth
they just did LOL
14:14
@idjaw and I still can't reproduce it
@idjaw Redis question guy, Mike D has been active on SO in the last few minutes, but he still hasn't given any feedback.
@PM2Ring how can you tell they are active.
@davidism same
@AnttiHaapala op makes his question undeletable by upvoting the answer about their typo
@idjaw Go to their profile page. It's not totally accurate though, and it ignores chat.
@davidism Well that's easily fixed...
Who would win in a fight: DenverCoder9, who last posted "nevermind, I figured it out" nine years ago on a problem identical to one you're trying to solve now; or ~-SSJGoku666-~, who was last active nine seconds ago but still hasn't answered your repeated requests for clarification in his question?
14:19
lol
Perhaps the question is not "who would win in a fight" but rather "who makes you most wish that it was possible to slap someone through tcp/ip"
There's now an answer by a 1 rep user, but I have no idea how good it is. He seems to know what he's talking about, though.
cbg-noon
just a quick hi
@davidism The OP just edited it again, but it still doesn't look very minimal.
14:31
Yeah, they're not actually reading the link, they're just throwing more things in.
Is OP like trying to put out a fire by throwing random things into the fire in hopes of smothering the flames, but in reality it's just making things worst?
DSM
DSM
Thursday morning cabbage for all.
14:50
\o cbg DSM, in before the storm :D
huh today is thursday. sometimes it's nice to realize the week is closer to the end than you thought...
15:06
So I've been messing with a "simple" problem and can't find a solution:
An exercise asks me to remove duplicates from a list. I'd like to preserve order, because presumably that's useful (so simply set-ting it is out). I'm trying to find a solution that modifies the list in-place, but I can't figure out how to do it.
I either hit list-error, or don't remove *all* duplicates.

`for i in n:
for j in range(len(n)-1):
if i == n[j] and j != n.index(i):
del n[j]
breakprint(n)`
does it have to be in place?
DSM
DSM
n[:] = OrderedDict.fromkeys(n) # (don't even need list, come to think of it!)
for i in n:
for j in range(len(n)-1):
if i == n[j] and j != n.index(i):
del n[j]
break
print(n)
sorry was trying to edit..
I was trying to figure out a way to do that. You *could* just create a new list and output the new list, but I'm trying to learn as much as I can, and it seems to me there should be a relatively concise way of doing so.
@DSM - make that a comment, else he will think it is a function call
@PaulMcG thanks, but I'm not that fresh lol
15:12
If only there were a 24-star post describing how to format posts with code in them...
DSM
DSM
But if we're not trying to be maximally concise, just keep a set to store the already-seen values. Don't try to delete from a list you're iterating over.
@PaulMcG lol
Yes yes, and I tried to follow it, manually indenting...
@toonarmycaptain they have to be stand-alone. They can't be combined with a message
Very generally, the tricky part about mutating a list while iterating over it is: when you remove an element from a list, all the elements to the right of that list shift one element to the left. So now there is an unexamined element at the index you were just looking at. But the iteration continues to the next index, and that unexamined element remains unexamined forever
As an example, see: ideone.com/0rBsie. Notice that "42" never gets examined by the algorithm.
It goes from 23 to 99 to 23.
This happens even if you iterate directly over the list with for item in seq: rather than its indices with for i in range(len(seq))
15:15
you can almost always iterate backwards though right?
this is pretty complete: stackoverflow.com/questions/480214/…
and I'm going to not care about "in place"
@enderland yeah, although it may not always be practical to do so.
For example, trying to discard all duplicate items except the leftmost ones. It's hard to turn [23, 42, 99, 23] into [23, 42, 99] while iterating right to left.
Iterating backwards is the most-often recommended approach if you have to do in-place. You can also manage the index counter yourself, either incrementing or deleting in each loop, but not both. But the best way to do this is as shown in @DSM's post - create a new list and then assign it back in-place to n[:].
"either incrementing or deleting in each loop, but not both". Agreed, this is the typical solution to the "unexamined element" problem inherent to automatically incrementing approaches.
seq = [23, 42, 99, 23]
i = 0
while i < len(seq):
    if i != seq.index(seq[i]):
        del seq[i]
    else:
        i += 1
print(seq)
DSM
DSM
But all this deletion stuff can be really slow.
15:23
But I hate calling len(seq) every time - my druther would be to loop forever and break out on IndexError
Performancewise, len on lists is O(1), but your preference is still understandable on the basis of aesthetics.
Hey all, I understand I could just iterate over and add to newlist items not already in newlist. I was just wondering if there was a simple way to do it in place, preserving order.
The code I posted above does it in place.
Oh cheers sorry just came back and hit return on unsent.

n[:] = OrderedDict.fromkeys(n) did it too.
*goes to look up seq *
It's short for "sequence". The name doesn't have a special meaning, really
15:26
@toonarmycaptain - I think part of the point being made is "in-place" is often considered for the purposes of saving space or memory or something, but in practice (in Python at least), it is a flawed optimization.
Even the lovely one-liner posted by DSM builds a temporary data structure, and then iterates over it to replace the contents of n by assigning to n[:]
My philosophy is: If your design has tight space/memory constraints, why are you using a high level language in the first place?
^^
@Kevin smh, didn't read your listname and assumed it was something I hadn't used before.
@PaulMcG fair enough, and I do get that. I'm just learning, trying to be thorough, and didn't understand how to do it "in-place".
DSM
DSM
That said, it's usually a better idea to do seq.append(x) than seq[:] = seq + [x], but I agree that lots of people try to optimize code in Python in ways which don't really apply.
Hmm, what's the time complexity of the OrderedDict approach? I assume it's at least as good as the O(N^2) manual deletion approaches, but is it better?
My favorite resource for built-in type time complexities, wiki.python.org/moin/TimeComplexity, regrettably has nothing to say about ordereddicts
DSM
DSM
15:32
Since they could implement it in O(N), I'm assuming they did.
Is there another way to handle paths with spaces aside from adding ""? Shutil.copytree and copy2 work sometimes and sometimes dont.
Python doesn't care if your path has a space.
And by "handle" you mean...?
Use pathlib.Path (now changing that to my profile status...)
15:34
If I have copytree copying files it'll work fine for 50 files and then fail on one because it doesn't see the entire string for the path. It cuts it down at a space
How do you know it's failing because it "doesn't see"? Again, Python doesn't care about spaces in paths.
if not os.path.exists(dst):
            os.makedirs(dst)
        for item in os.listdir(src):
            s = os.path.join(src, item)
            d = os.path.join(dst, item)
            print(d)
            if os.path.isdir(s):
                copytree(s, d, symlinks, ignore)
            else:
                if not os.path.exists(d) or os.stat(s).st_mtime - os.stat(d).st_mtime > 1:
                    #print('copying %s' %s)
                    shutil.copy2(s, d)
                else:
                    #print('file %s already up to date' %s)
Curious, copytree works OK on spacey directory names on my machine:
C:\Users\Kevin\Desktop>mkdir "folder with a space in it"

C:\Users\Kevin\Desktop>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copytree("folder with a space in it", "copy of a folder with a space in it")
'copy of a folder with a space in it'
>>> import os
>>> "copy of a folder with a space in it" in os.listdir()
True
>>>
You can gain insight into what copytree is doing by decorating copy2 with some logging statements, and pass that to copytree's copy_function argument
DSM
DSM
@Kevin: works for me as well. Whatever the problem is, I doubt it's space-related.
when run it shows every file thatis being copied. It'll show D:\tools\path to file\filename and then one will fail because D:\tools\path is not a file
I have no yamming clue what is being asked here: stackoverflow.com/questions/45219235/…
what is the key, what is the value. What is being checked, actually?
ugh...I don't think SO is for me today
Not in the right mood to deal with this
@PaulMcG can you elaborate on decorating copy2 with logging?
15:40
@idjaw I think you need more dogs in boots today.
Probably something like:
def logged_copy2(*args, **kargs):
    print("calling copy2 with arguments:", args, kargs)
    return copy2(*args, **kargs)
@Programmer you're right....Pugs and Boston Terriers in shoes
here I go
then you pass logged_copy2 as the copy_function parameter to the copytree function
directory-manipulating programs of this kind are a bit of a pain because creating a true MCVE for them almost always takes more work than just "paste all my code into pastebin". The people you're sharing the code with probably don't have the same directory setup as on your local machine, so ideally you would also include code that automatically creates and destroys a sample directory that has the same properties as the troublesome directory you actually have.
In other words, the very first thing the MCVE would do is create a directory <current working directory>\tools\path to file\filename if it doesn't already exist
LOL, this poor OP's just tried to accept all of the answers. :) stackoverflow.com/questions/45217726/…
15:52
makes sense. i'll play with it some more and come back with a better example if I get nowhere
Like Highlander, there can be only one :) — Wayne Werner 12 secs ago
o/
I come in peace, seeking guidance
good place for it, maybe
I have a python script fetching price data (think stocks). Right now, it's just an endless log in my terminal. I want the last line to be constantly updated with the current price, colored based on up/down (updating the line instead of printing a new one). This bit isn't the issue. However, when the value changes, I want to print the old value in the constant log above it in addition to overwriting the bottom-most line with the new colors and values
at least if your guidance is Python related
If you're on linux, you can use terminal escape sequences
16:06
As you're already a RO of another high traffic room, I'd not bother pointing you to the rules. ;)
or, curses
Welcome to Room 6
or as we say here, Cabbage
Sure, the actual coloring and updating the same line is fine. I'm not entirely sure how to have regular terminal output above it though
I feel like it should be really easy and I'm missing something
Thank you, Bhargav!
For what it's worth, I have read and understood the rules :D
@RaghavSood In a terminal, actually not really! But kind of :)
is it cryptocurrency price data?
16:08
Is this just for a linux-y system?
@RaghavSood Hah. I understood that. ;)
Rats, I've been found out runs away from LangeHaare
@RaghavSood :-)
It's a personal use script, only needs to work on the OS X terminal
excellent
then the easiest thing is terminal escape sequences!
16:08
@RaghavSood It's fairly easy if you're using a terminal that supports ANSI/VT100 terminal control escape sequences, which is the case for virtually any unix / linux terminal.
You on linux? If yes curses. If no curses. — Bhargav Rao ♦ Jan 9 '15 at 16:34
@RaghavSood Give me a sec & I'll find an old answer of mine that almost does what you want.
Yeah, I can get it to color and update the line with those, already have that in place. Compare the value to the last one, set a color, print. Easy enough. I'm having issues with printing to the regular log above it in addition to updating the last line
You can use curses if you want, or basically you decide how many lines you want to print out in the previous log.... oh actually
16:10
@RaghavSood You just need to set a scrolling region. See here for an example.
So you want something like...
I essentially want something like this:
ad infinitum
Price Curr - 5
Price Curr - 4
Price Curr - 3
Price Curr - 2
Price Curr - 1 <--- this and above is just regular terminal output
Current price <--- only this line is colored red/green depending on history
enervated cbg
I have the coloring and current price updating just fine. Just having issues with combining that with a regular, run of the mill, scrollable, plain old terminal output above it that's also constantly updating
could you do a hacky version with pypi.python.org/pypi/termcolor ?
ahh I see so when you scroll you want to keep the current price at the bottom?
16:13
Well, hadn't actually though about that. Don't really care if it's stickied at the bottom while I scroll, provided it is still at the bottom when I scroll back down
@RaghavSood does this do what you want?
import time

try:
    x = 0
    while True:
        x += 1
        print(x, '      ')
        print('xxxx', end='\r')
        time.sleep(0.1)
except KeyboardInterrupt:
    print('^C caught, goodbye')
    pass
curses has an abstraction that simulates multiple windows, right? Maybe you could have one window for the scrolling content, and one window for the single line of non-scrolling content.
Huh, my python3 appears to be dead
Peronally I'd just say to Hell with it and make a GUI with two independent text boxes.
But where's the fun in that
16:16
@RaghavSood so really what you want to do is when you get a new price, overwrite the bottom line (previous current price) with an uncoloured "past price" version, and then write below that a colourful copy of the new price?
If ^^ doesn't do it, then you'll want curses. You can use urwid or something on top of curses for making it easier
Certainly I understand the desire to have the sweet hacker aesthetic that comes from a console-only application, but you've got to decide for yourself whether that's worth the extra order of magnitude of development time required
@LangeHaare Yup
It's a personal project, never going to be used in prod, and I kinda want to figure it out now, and I'm learning through it, so good enough for me investment-wise
We have far more simple and stable systems for the actual use cases of our price data
This is just for fun
Also, our actual use cases don't involve spitting the prices into a terminal, so there's that
what kind of job are you working at?
(I mean assuming you use this data at work)
I work at coinhako.com, it's our own data :P
Well, I'm working here for now
Heading back to college once the summer is over
16:19
awesome
look at this
from time import sleep
x_old  = 0
for x in [1,2,3,4,2,1]:
  print '\r old {}'.format(x_old)
  x_old=x
  print 'NEW {}'.format(x),
  sleep(1)
My main issue right now is that I actually need to read the last line in my console. This takes time and effort. I'd much rather just glance at a color, and have the history handy if I need to see a trend
So I'm willing to spend a few hours saving myself fractions of a second
DSM
DSM
...
I'm more partial to the other one :D
that should have the behaviour of having the different latest price at the bottom and streaming old stuff above it, just adapt with the colouring you already have and your data stream
16:23
@RaghavSood Oh, ok. That's not so easy. The VT100 scroll region doesn't play nicely with the terminal's scroll bar or the mouse wheel. I don't know much about curses, so maybe you can do it with curses, but it wouldn't surprise me if you can't (without doing crazy stuff like rebuilding the whole display every time you scroll up or down a line).
@LangeHaare When I run it it prints out all of the old values, then the new one
Doesn't have a constant "NEW" line at the bottom
@RaghavSood hmm works for me Shrug
I think the best solution might just be what LangeHaare mentioned. Overwrite the last line with normal formatted stuff, then just print a new line with colors
yeah the key bits to do that in what I posted are \r goes back to the start of the current line (to overwrite), and printing the new one with , at the end stops it from adding a newline (so that when you go back to the start, it's the start of the correct line)
Yeah, let me see if I can get it to work on my end
Appreciate the help and advice from all of you!
16:28
I found whats giving me the path error but I dont understand why.
If the only difference between the normal terminal output and the sticky bottom line is that the sticky bottom line is colored and the normal terminal output isn't, the lazy solution is to quietly change your program requirements so that the normal terminal output is also colored. Then you don't have to overwrite anything at all. Simply printing ordinary colored terminal output will work fine.
    try:
        if not os.path.exists(dst):
            os.makedirs(dst)
        for item in os.listdir(src):
            s = os.path.join(src, item)
            d = os.path.join(dst, item)
            if os.path.isdir(s):
                copytree(s, d, symlinks, ignore)
            else:
                if not os.path.exists(d) or os.stat(s).st_mtime - os.stat(d).st_mtime > 1:
                    print('copying %s' %s)
                    shutil.copy2(s, d)
                else:
                    print('file %s already up to date' %s)
Every time the copytree finishes a directory it tries to run the os.system(blah) and then sleep for 10
why wouldn't it finish copying everything and THEN run the application and sleep
@RaghavSood you should make sparklines :)
Mixed indentation that makes it look like os.system is outside the loop, but actually it's inside the loop?
let me guess, this code is inside a function named copytree
16:31
because everything wasn't done copying the updatedprogram.exe doesn't exist in the new path yet so it was giving the "does not exist error" which was missleading
@WayneWerner Yeah but then I'd also have to get comfortable with reading them fast enough to react to the price changes as fast as I can with text right now
Maybe next time
In any case, an MCVE would continue to be good
I tried putting the os.system outside the try and I get the same thing so I dont think its an indentation issue.
@rawing yes I took this from an SO post.
hmm, why would every call to the copytree function sleep for 10 seconds... :/
:(
this is not a mistake I should have made. lol
16:36
cbg
@RaghavSood Did you take a wrong turn at Albuquerque?
@kevin I was figuring it was something simple that would jump out and someone in the room before I spent the time building a full example.
and it was.
No one in Android was helping me with python for some reason, figured I'd stop by the motherland
thanks everyone
@RaghavSood haha, imagine that.
DSM
DSM
@sidnical: FYI the "I was trying to save my time at the cost of other people's" line isn't always received well. Just make an MCVE and then everyone's happy. :-)
16:41
@Kevin can you help me with that code you gave me earlier? I've been trying to figure out what it's doing. What I think it's doing is `seq.index(seq[i])` is giving you the smallest index for/the index for the first time a value at seq[i] appears in the sequence. So if it appears more than once, the second time it appears, `i` will be the second appearance's index, while `seq.index(seq[i])`will be the index for the first appearance, triggering the if/delete code.
Am I correct?
@DSM understood
@toonarmycaptain That's right. Note that .index has to scan the list until it finds a match, so it's not very efficient.
@toonarmycaptain So Kevin's algorithm is ok for de-duping small lists, but it's rather slow on big lists. If n is the length of the list, the runtime of Kevin's algorithm is proportional to n², but DSM's is (probably) proportional to n.
Thanks @PM2Ring
I'm just learning the mechanics of how things work, not too bothered with every piece of code I play with being efficient/quick right now.
16:49
@toonarmycaptain Fair enough, although learning when algorithms are O(n²) rather than O(n) is pretty useful information.
I agree with everything PM just said.
@PM2Ring I actually just crashed Spyder, proving your point ;)
Sorry, I was out to lunch for a bit there
Have you skipped 0 on purpose? Because it makes your numbers very non-uniform. — Błotosmętek 23 mins ago
@Błotosmętek It was on purpose. I don't like the idea of things starting with 0, my personal preference. — Russell 16 mins ago
OPs sure are interesting, sometimes.
The .index method is handy, and it's certainly faster than manually scanning a list with a Python for loop, but it's generally a good idea to avoid using it inside a loop. If you find yourself doing that, it's worth spending some time thinking about alternative approaches.
Hopefully he's just generating dummy data and even distribution isn't actually important
16:57
Fair enough, I was just doing a list exercise "7. Write a Python program to remove duplicates from a list." - only found solutions with imported modules, generating new lists etc, and was thinking "It doesn't ask for a new list, how do I do it in-place?"
...4 hours down the rabbit hole, and living out the xkcd comics shared in here earlier, lol, here we are. :)
Nothing wrong with writing an impractical algorithm for the sake of academic curiosity.
3
That describes like 80% of the code I write
What, impractical?
@Kevin Hopefully. But it makes the problem harder than just doing something like f'\\x{random.randrange(256):02x}'
00:00 - 17:0017:00 - 00:00

« first day (2469 days earlier)      last day (2705 days later) »