« first day (2297 days earlier)      last day (2875 days later) » 
01:00 - 23:0023:00 - 00:00

01:05
hey everyone
I'm looking for a way to not print traceback messages
at all, if any knows know (pref in python3)
why not?
because I get a lot of them
it's just some errors, my code is fine
Cabbage
cbg
@BobEbert that is so messed up!
01:11
"my code is fine, it's just a bunch of errors"
the obvious solution is to fix the errors instead
thanks?
haha
16
Q: Hide traceback unless a debug flag is set

matt wilkieWhat is the idiomatic python way to hide traceback errors unless a verbose or debug flag is set? Example code: their_md5 = 'c38f03d2b7160f891fc36ec776ca4685' my_md5 = 'c64e53bbb108a1c65e31eb4d1bb8e3b7' if their_md5 != my_md5: raise ValueError('md5 sum does not match!') Existing output n...

yeah, I read that already but I still get an error :p
thanks for the help though
sys.tracebacklimit=0 doesn't suppress the error
it summs it up
really funny
comedian
01:25
Hello, I am having issues with Django models not saving. Does anyone here know what the process is for Django saving a model when .save() is applied to a newly created model?
@BobEbert So fix the errors or at least catch the exceptions.
I get that :p, thing is, even if I catch the exceptions, it's still printed out
like.. saying timeouterror or wtv.. even though I did.. except: pass
Hidden Figures is a great movie. Everyone should go see it!
01:32
sounds like a matplotlib feature
I've been interested in the American space program for as long as I can remember, but didn't know about the women who were a vital part of its success.
I don't know how things work in The West, but I searched for literally hours for a shop where I can buy 6-32 screws to mount a few HDDs, and then I ended up dismantling my old PC and scavenging the pieces:/
and only 4 of the 20 screws were actually 6-32, the rest were almost-compatible metric screws
I know nothing about screws...
the little comfort I have is that when I'll order 50 of these little bastards, they'll cost me 1337 local monetary units
started to learn a little when I was building my latest computer, but I already forgot it all.
01:37
@Code-Apprentice a few hours ago I knew nothing about screws shorter than 2 centimeters
1337? Is that a coincidence?
@Code-Apprentice yes
Your screws are the best of the best!
screw them regardless
bah...I rented Scully from Redbox last night and I still haven't made time to actually watch it ;-(
I thought this might happen. So do I keep it for another day or just return it?
01:40
yeah, the new X Files season is pretty wild
Yeah, even if everything else in an old PC is rubbish it's worth scavenging the screws and maybe the powersupply, unless it's burnt out. Oh, and the dead HD is good for magnets but you already know that. :)
it stopped being my current computer when the PSU said "bang" and all the lights went out...
There's another X Files season? I thought the one last year was just a one-shot thing...
@Code-Apprentice I meant that one:D but it's only half a season, with the rest hanging like the Sword of Damocles above the good taste of mankind
I have two computer sitting here that I'm not using. I tell myself I'm gonna pull the hard drives, murderate them, and dispose of the rest. Didn't think of scavenging the screws.
01:44
yeah, I usually just atomize the HDDs and play with the magnets
it's a minor miracle that I still have all my fingers and both my eyes
@AndrasDeak I only caught a few episodes of it. I'll have to add that to my "To Watch" list after I finish Silicon Valley Season 3, the rest of GOT, and Halt & Catch Fire.
What is your favorite method of atomizing?
don't keep your hopes up
@Code-Apprentice screwdriver
with an appropriate torx head:P
no drill? Or better yet, a jack hammer?
nope, I'm a civilized man
screw that
01:46
my goal is not causing damage; that's only a byproduct of playing:D
which reminds me, I might still have a few hdds lying around which I actually should make irreversibly and utterly useless, before throwing out
talking about drills and hard drives: youtube.com/watch?v=8yC1zwFiiyg
In Ancient Times I knew a Swiss guy that liked to take old HDs to the rifle range. He said it was very satisfying to use them as targets. :)
Windows user, eh?
No, Amiga. But HDs weren't very reliable back then.
:)
What was the capacity back then? 100 MB?
hmm, I think I can easily remember when GB wasn't trivial at all, so it must've been much less
01:56
Eventually. 20 or 40 was more common. And we backed them up to 880kB floppies.
googled floppies, so much childhood nostalgia
1.4 MB hard-case floppies were the shit!
IIRC, the biggest HD I used on my Amigas was 250MB.
I still have several boxes of them in storage.
Me too, but I expect there would be a fair bit of corruption by now.
02:02
Typical of our age:|
I haven't even tried to look at any of them
Amiga double density floppies had more capacity than DOS ones, but we never got quad density... Although I guess some people might have hacked together a quad density Amiga drive.
overclocking floppies...
Of course, I have kicked myself in the ass for years. At one point in time, I compressed all of my first C and C++ projects into a multi-disk zip file. I even wrote on the labels what they were and numbered them. Then later, I had the bright idea to write over the last disk with something else!
Oops!
02:05
As you know, the last disk contained all of the file structure information, so I never retrieved the code back ;-(
I kept telling myself I'd write a utility to extract the data. Even if it was one long ass text file, I could have broken it up from there, but never got around to that project.
Rbrb
rbrb all, off to play Go with a friend.
rbrb
I'll also drag my melancholic ass to sleep, rhubarb
02:28
@Code-Apprentice Good luck! I haven't played Go for years.
 
2 hours later…
04:39
@PM2Ring Maybe we should play some time.
 
1 hour later…
06:07
cbg
06:22
cbg
 
1 hour later…
07:37
cbg
 
2 hours later…
09:23
:D
cbg
09:36
Is there any way to call several undefined method sequentially in python class? like this:
MyClass.Method1.Method2()
10:09
"undefined methods", do you mean "arbitrary methods"?
Method1 isn't a call, if you mean MyClass.method1().method2(), then yes, it is possible, if method1 returns a value that has method method2
so; I guess the answer to your question is "no, there's no way of chaining arbitrary method calls on a same value" :D
10:22
\o cbg
What is better? Going back and forth with OP about indentation OR just quickly fix his indentation in question so that the question can be closed?
-1
Q: python. Unable to run program

iridescentI'm new to Python programming. I was trying to achieve the following output: Account c Account count = 1 Successful transaction! Balance = 10000 Successful transaction! Balance = 9000 Not enough balance This is my code class Account: accountCount = 0 def __init__(self, name, account...

If the question should be closed anyway, indentation does not matter.
10:53
Yeah, it can be closed right away. But he would still be confused. So there are 3 ways you can explain what's wrong, 1. In the comments 2. Edit and correct the indentation in the question itself 3. Post the correct indentation as an answer. Comments sometimes take too much back and forth messages.
Just leave a comment and don't respond afterwards. Then there is no back and forth.
11:33
@MYGz do not "fix" the code in questions, ever.
just point out in comment and close
one needed
Heh. "code" was important :D
there have been far too many cases of people "fixing the indentation" (and the bug) without even providing a solution.
:D Bug masking
anw, the question should tell what's the problem, not just the solution :D
heh
11:43
what you can do with code is to add the code block, or press the code button to dedent the block if you're sure you can still reproduce the original problem with that :D
Formatting keeping the bugs alive.
Can't harm no bugs. It's a safest place for bugs.
No bugs were harmed during this edit - American Humane Association.
12:14
LOL :D
12:43
I want to convert a list of characters into a string, but somehow I keep forgetting this. And somehow I don't want to write a function for it.
def listToStr(l):
    return ''.join(l)
s = ['e','x','a','m','p','l','e']

listToStr(s)
Out[35]: 'example'
perhaps ''.join(s) is shorter than listToStr(s)
Shorter, but the problem is, I usually forget the syntax for it. "listToStr" says to my brain "I've got a list, but I want to make it into a str"
It was confusing for me also, but it becomes natural after sometime. It's like you want to join the elements of iterable, but you can also specify a delimiter.
12:59
I'll try to get used to it.
I just ran into something strange with list comprehensions. Solving a problem suggested by a textbook, I came up with the following code. The specification requires that the input contain only characters A-Z.
# Usage:
incStr1('AAA')
Out[68]: 'AAB'

incStr1('XYZ')
Out[69]: 'XZA'
def incStr1(text):
    # Base case for recursion:
    if text == "": return "A"

    head = text[0:len(text)-1]
    tail = text[-1]

    # (A)
    if not all([ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for ch in text]):
        raise ValueError

    if ch == 'Z':
        ch = 'A'
        head = incStr1(head)
    else:
        ch = ord(tail)
        ch = chr(ch+1)

    return head + ch
If I remove the section marked (A), then the code fails because ch is not defined. But even with (A), why should ch be defined at all? It just happens to work.
What is your objective? Just increment the last letter, and if last letter is Z then increment last and second last?
It is supposed to a Perl-style string increment. That is, "A" becomes "B", "Z" becomes "AA", etc.
The restriction/simplification suggested was that the string contain only A-Z, hence the 'if not all' statement. But after writing that, I thought, 'I don't actually need to restrict it in this way', but after removing it, it no longer works, simply because of the surprising scope of the ch symbol.
Apparently it is answered here: http://stackoverflow.com/questions/4198906/python-list-comprehension-rebind-names-even-after-scope-of-comprehension-is-thi
Probably a valid reason to upgrade to Python 3. Oops.
In Python 3 the list comprehension does not 'leak' the iterator symbol. But in for loops, it does leak. I guess it is still a bit confusing either way. That a 'for' loop leaks seems to make a little more logical sense, however.
Here is the fixed version:
def incStr2(text):
    # Base case for recursion:
    if text == "": return "A"

    head = text[0:len(text)-1]
    tail = text[-1]
    ch = tail

    if ch == 'Z':
        ch = 'A'
        head = incStr2(head)
    elif ch == 'z':
        ch = 'a'
        head = incStr2(head)
    elif ch == '9':
        ch = '0'
        head = incStr2(head)
    else:
        ch = ord(tail)
        ch = chr(ch+1)

    return head + ch
Now it works with any string that could be incremented, like 'asdjn12938'. That is more Perl-like. Of course, Perl has some weird cases like 'abc1def'. Incrementing that results in the integer 1 for some reason.
13:25
" If i remove the section marked (A), then the code fails because ch is not defined. But even with (A), why should ch be defined at all? It just happens to work."
@MYGz It is not just the last and second last, hence the recusrion. incStr('ZZZ') should result in 'AAAA', no matter how many Z's there are.
I guess it is one of those things that I never thought about but just now accidentally ran into.
I believe it's because it just raises a value error...since it's not defined and the script runs through each letter in your list, it'll pass it if you've got a letter and then go to it later and raise an error if you have a number...at that point ch has been defined
hmm
Sorry I might be misunderstanding then xD
No. If I remove (A), then the line that follows will raise UnboundLocalError:
def incStr1(text):
    # Base case for recursion:
    if text == "": return "A"

    head = text[0:len(text)-1]
    tail = text[-1]

    # (A)
    #if not all([ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for ch in text]):
    #    raise ValueError

    if ch == 'Z': # XXX
        ch = 'A'
        head = incStr1(head)
    else:
        ch = ord(tail)
        ch = chr(ch+1)

    return head + ch
In Python 3, the line marked XXX raises UnboundLocalError regardless, because the above list comprehension does not 'leak' ch.
13:33
Correct because by defining that ch is in A-Z in (A), it acknowledges that X is in there.if you take it away, you remove what ch is defined as. That's how I see it.
You may not have "ch=str()" but you are forcing it to recognize that ch is in A-Z.
It is a valid improvement in Python 3. But it would be nice if Python had a real notion of 'warnings'. For example, it would be nice if the interpreter in Python 2 noticed this and said "Hi there dear Programmer, I noticed you're making use of a symbol that only exists because it 'leaked out' of the above list comprehension. Maybe you should not do that."
Oh, yes,precisely.I agree wholeheartedly. You could always run a check on that or create a function that checks for that. Check for it in locals at one point or explicitly define it before leaking it.
I'm out! I've got some art I need to work on this morning. Cheers and goodluck!
Well, that doesn't really work either. If you have the foreknowledge to write extra code like that in order to check for confusing situations, you probably would have just avoided the potentially confusing code in the first place. In this case, it is something that I misunderstood about, that 'ch' was confined to the list comprehension, but it is not.
14:26
re-cbg. Damn. I see I missed a discussion about Python 2's leaky list comps. Before I go back & read the details, I'll just say that I didn't mind them. Sure, I got bitten by them in my early days, since my C instincts were trained to expect a list comp to run in its own scope, not that of the surrounding code (every block in C creates a new local scope). But it was easy to work around, and was occasionally handy, so I soon got used to it.
Bear in mind that was before Python had generators (or dict or set comprehensions). It totally makes sense to me that a generator expression creates a new scope, since a gen exp is really syntactic sugar for a generator created using def. I suppose it was a sensible thing to make list comps consistent with generators, scope-wise.
However, a Python 3 list comp is slower than a Python 2 one because it's expensive to create a new Python scope compared to a C scope. Similarly, calling a Python function is slower than executing the same code in-line.
@PM2Ring But, if you depend on the scope being leaky, this will bite you if you want to move to script to a Python 3 interpreter. So for that raeson I'd prefer to avoid it. I'm not too worried about the speed aspect. My example code uses recursion for example, which for all I know is slow as hell. But until it's a speed critical computation, I will not care much about the performance.
I guess the same C instinct made me think that the symbol was in its own scope too.
Well of course I wouldn't rely on a list comp being leaky these days because I almost always write Python 3 code. And I mostly write bi-versional code unless I'm doing something that's radically different in the 2 versions, eg low-level byte work, or Unicode.
And even before it was decided to remove the leak in Python 3 I rarely wrote code that relied on the leak, because it smells like a side-effect. And if I did, I'd mention it in a comment.
That seems reasonable. I corrected mine to the following, which, surprisingly for me at first, just happens to have the same meaning whether the 'ch = tail' line is present or not.
...
        # The characters in text must be A-Z or a-z.
        if not all([ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for ch in text]):
            raise ValueError

        head = text[0:len(text)-1]
        tail = text[-1]
        ch = tail
...
FWIW, I did write some code a little while ago that needs the leakiness, but it was rather special, and not intended to be used in a sane program. :)
so in Java, in order to mock, I need to write an interface for the mocked class. This results in having interfaces on almost all classes
cbg btw
14:37
After all, with the way I'm thinking about the above, I could have written the following instead. In this case, the 'ch = tail' line is mandatory to produce the correct result:
        # The characters in text must be A-Z or a-z.
        if not all([ch in 'ZABCDEFGHIJKLMNOPQRSTUVWXY' for ch in text]):
            raise ValueError
No, actually that would still be fine. Because I guess the list iterates to text[-1] last
DSM
DSM
Brief cabbage for all.
Hi, DSM
so ch always has text[-1], which is the same as saying 'ch = tail'
DSM
DSM
if not all([ch in 'ZABCDEFGHIJKLMNOPQRSTUVWXY' for ch in text]): seems strange to me.
I like nice docs:
> Now, a word of warning. I will mock an interface in this example. That doesn't mean you should only mock interfaces. I hate useless interfaces. And you want me to be happy. Please don't create an interface just for the pleasure of mocking it. Just mock the concrete class. Thank you.
14:41
BTW, it's far more efficient to pass a gen exp to all() or any() than a list comp. all() and any() short-circuit, so they stop checking items as soon as they have a definite result, but if you pass a list comp the whole list has to be created before all() or any()can start doing their tests.
DSM
DSM
Yeah, (1) needless listcomp, (2) inlined long constant, (3) string membership test, and (4) the comment doesn't seem to match the code, unless text was uppercased in a different location.
I haven't read the earlier messages on this topic yet, I just assumed it was an example list comp to have something concrete to talk about. Sensible code would do text.isupper()
DSM
DSM
That's not quite the same, though, if there are non-ascii letters floating around (Рor Ϧ or whatnot..)
Fair point.
In that case, you'd use a set instead of a string to test that the chars were valid.
@Brandin Guido explains why .join is a str method, not a list method. Briefly, it means that you just need one join method to handle any kind of string collection or iterable. OTOH, .join needs to make 2 passes over the collection, first to get the size of the destination string & second to copy the strings (and delimiters) to the destination. So it's more efficient to pass .join a list, list comp, or tuple than a gen exp.
14:58
\o incStr1(bzaazfd)
@DSM How should I write it, then? Yeah, the comment should be A-Z.
BTW, in Py3, you can do this:
>>> *head, tail = 'abcde'; print(head, tail)
['a', 'b', 'c', 'd'] e
Does someone know problems between GUI and recording together? (In my case: Tkinter and microphone with pyaudio). I get IOError Input overflowed. I have tried to change chunk and rate and to catch the Exception. Can someone help me with this problem? For more information (e.g. the code), click here. Thank you!
@PM2Ring That seems like potentially useful syntax.
@Brandin I'd use a superset test:
valid = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
for text in ('HELLO', 'HeY', 'XYZ1'):
    print(text, valid.issuperset(text))
# output
HELLO True
HeY False
XYZ1 False
DSM
DSM
15:12
I'd use string.ascii_uppercase instead -- I still think fondly of the one time an OP forgot a letter and I got to call him out on it. ;-)
@PichiWuana Sorry, I've never used pyaudio. But you probably don't want to reduce RATE unless you want to sacrifice quality: 44100 bps is the CD standard rate.
string.ascii_uppercase seems the best. set may be good if doing multiple tests, but in my case I do it only once, so I think 'in' is clearer.
@DSM Well, i probably would too. I feel sorry for poor old string, losing most of its former functionality. ;)
@PM2Ring I just read answers that when they changed it to 48000, it fixed the problem.
@Brandin You can still do in with a set, and it will be faster than doing in on a string, even taking the time to construct the set into account. And of course, you could put the valid letters set into the script as a set literal, so it gets created at compile time.
15:17
Does someone have a clue if the solution to my problem may be to use threading?
DSM
DSM
Unfortunately I don't use either tkinter or pyaudio and so can't help..
@PM2Ring I guess you mean like this:
...
# Each character in text must be A-Z.
letters = set(string.ascii_uppercase)
if not text in letters:
    raise ValueError
...
Or even:
...
# Each character in text must be A-Z.
if not text in set(string.ascii_uppercase):
    raise ValueError
...
I'm not too interested in the speed of running. Just in the speed of human understanding when I read what it is doing.
DSM
DSM
if text is the full string, it's not going to be in the set.
Which brings me back to:
            # Each character in text must be A-Z.
            if not all([ch in string.ascii_uppercase for ch in text]):
                raise ValueError
DSM
DSM
15:26
As PM2Ring explained, you should avoid a listcomp there.
letters = set(string.ascii_uppercase)
if not all(ch in letters for ch in text):
Ok, so the alternative is this:
        # Each character in text must be A-Z.
        letters = set(string.ascii_uppercase)
        if not letters.issuperset(text):
            raise ValueError
I guess it works, but I don't like how it looks. I guess my brain is not good at set theory or something, because it makes my head hurt a little bit.
DSM
DSM
If you really want to use the all(ch in letters..) approach, you can; you've probably spent more time thinking about this than you'd ever save. :-)
Well, to me, Python programming is not about saving processor time. It is about writing things that don't make my head hurt too much when I read them later. I still don't know where the optimum is. If the 'issuperset' thing is useful in other contexts, I will try to adopt it as an idiom. But for now it reads a bit cryptically.
15:33
@MYGz Unfortunately I cannot read the message in the dialog.
I can't make it out.
DSM
DSM
I see "Please wait while the features are configured / This might take several minutes", although a lot of that is pattern forcing..
You are not suppose to read the message!
It's a joke! The progress bar doesn't care to stop at 100%!
DSM
DSM
@MYGz: I got it, FWIW. ;-)
ew windoz
Lol. windows = computer for non programmers!
DSM
DSM
15:39
Time to bail. Rhubarb for all!
s/GIRL/GRILL/
@MYGz what, you don't eat grill, you are not a cannibal are you?
haha
Hey I got a quick question, I am developing a Python CLI program that must talk to a server [ probably over HTTPS/ OR anything that makes more sense ]. What protocol should use on the CLI program. Make a TSL connection and make requests to the webserver or directly call using HTTP requests ? Any advice is much appreciated
People who didn't go to school running a Sandwich outlet, since English is not a first language, you will find these types of menu :D
15:48
@kt14 there isn't enough info to answer your questin
but most probably, HTTP will do the job
What's the upload limit?
Ok the button got activated.
@khajvah, sorry where could be more specific. If this helps: The CLI Program authenticates the user -> user can run commands on this local machine -> and the cli program makes a call to the webserver (Django App and a specific URL) then then a view function would be executed. If I wanted to make the data and connection more secure, then HTTPS would be good or else I should wrap then in TSL Socket
@Brandin I agree it's a bit cryptic. It may help to think of a.issuperset(b) and b.issubset(a) as complementary. Also see their even more cryptic operator versions. ;)
Nik
Nik
Can you tell me how to condense this code. It has a lot of repeating design elements. Doesn't seem DRY.
Well, the list comprehension syntax was cryptic at first, too, but now I suppose I am more used to it, so I am thinking in terms of it or something.
16:03
As I said the other day, it's silly wasting time on micro optimization; OTOH, it's good to use fast built-ins that are often running at C speed rather than reinventing the wheel with a Python loop.
Sorry if I'm a bit slow I'm typing on a phone.
@Brandin Yep. And the more you practice with them, the easier it will be to think in terms of list comps and gen exps.
16:32
df = pd.DataFrame(data = [[1,2,3],[1,2,3],[1,2,3]], index=['A','B','C'], columns = ['A','B','C'])
Why does print df['A':'B'] returns rows and print df['A'] returns column?
Couldn't get a clue.
17:04
18:03
Has anyone found a web framework-agnostic github webhook library? Everything wants to be either a drop-in "run these scripts" tool or a plugin for specific frameworks :/
@KevinMGranger What are you trying to do
Make a bot that goes between github and discord, ideally using asyncio
I'm sorry, I'm not following the "discord" part
Just a chat service. Has a nice API.
I basically want to bring slack-style github integration to it, so it needs to listen for webhooks from github and then send data to discord
yeah...was just thinking exactly that
neat.
I have a feeling you are leaning towards something that doesn't quite exist yet. Which could be exciting if you're in to making something awesome for this.
well, in the world of discord.
18:12
I don't know how much I'm going to generalize it, but I will definitely at least spin off the io-agnostic webhook part
hmm....I only briefly skimmed this, and don't know if it is relevant. But have you seen this?
No, but I prefer to go lower-level with this anyway. Everyone likes to throw in a bunch of features for convenience that complicate things :/
ah. you're getting in to fun territory 😀
Microframeworks aren't enough for me! I need nanoframeworks!
18:28
Hey can someone explain an answer to me quickly here? I found "the answer to my question" on SO but I just don't get it. It seems total magic to me, and because of that really more like a hack than a good solution.
stackoverflow.com/questions/34562113/… <- this question is exactly what I wish to do (apart from actually NOT wanting to give a "string-counter" a specific "name")
Is the "subclassing Counter to inject the superclass typing.mapping" the only way to go? - Since that would require me to come up with a name for it.
18:47
@Harry Using re, I changed the above to the following:
# Each character in text must be A-Z.
if not re.match('^[A-Z]*$', text):
    raise ValueError
I guess it is convenient to do validations. Sometimes it's tempting to go overboard with regular expressions, though.
19:08
@Brandin yeah i like using re module too much but yeah sometimes i just overdo it. just got my privilege to chat room. glad to meet all you guys.
19:20
Hey guys, quick question, how do you this ['1','2','3'] from '123' ?
or just [1,2,3] from '123'
string = '123'
li = list(string)
uuuh, since "123" is already a "sequence" by anything standard you could just make a list from it.
the list constructor accepts any sequence: list("123") hence works.
Ah, I figured it.
But you can also do things like: s for s in "123" to iterate over strings. Nothing magical or special about this.
20:00
Hmm if I have a complex class for which I can need a "clear multiline-print" option (but that would be many lines), should I overload __str__() or should I make a specific decorated_print() function?
20:18
recbg
@PeterVaro OMG what happened to your face
@AndrasDeak yeah well, after 5 years, it was about time for an update :)
:)
And your location's changed, right?
Now that I think about it, I even remember you mentioning it a while back...
almost 4 months ago, yeah
I'm highly observant...
20:44
How do you write "deescalate" in english?
Like that, or de-escalate or even de escalate?
definitely not separately
google onebox says hyphen
it makes sense, as "deescalate" might be ambiguous
not that ambiguity ever worried the English:D
Thought so too, but I haven't seen the hyphen actually ever being enforced by spelling rules in english. (Unlike dutch where it is clearly stated when you have to use a hyphen, and you can't use the hyphen otherwise).
yeah, my subjective impression is that English is pretty loosely defined, but honestly I've never tried to find the rules:)
my go-to grammar consultant is google
20:59
why isn't there a nice Python IDE, like intellij for Java
pycharm is made by the intellij guys, isn't it?
yeah but Java development is so convenient
right, jetbrains
autocomplete and autoimports are magic
@khajvah judging from my short encounter with android: isn't most of that convenience coming from auto-generation of boilerplate?
in python you don't have that to begin with
21:02
I think Java being strict makes it easy
@AndrasDeak just imports
you type the class name, press shift+enter and boom
The reason you need those features so much in Java is its verbosity. The ideal is not to need such features as much.
21:20
@khajvah pycharm also does that?
Pycharm uses a static typechecker to recognize what a variable is, and can hence give all possible methods - so long as it is statically determinable. (Using type hints from typinggoes a long way).
Developing good Python code is harder than good Java code.
If that is true your application might be better suited for java I think?
any large program I guess
Python is easier to mess up.
Java has evolved to handle large programs and large teams. Python has evolved for one-man teams and small programs.
that one man being the BDFL?:P
21:29
@MYGz This isn't much of an answer, but normal slicing is just a row-wise selection mechanism on DataFrames, like a boolean array. I remember in McKinney's book he said something like "This might seem inconsistent but it is very practical" or something along those lines. Obviously you've just gotta use .ix.
21:51
Wait what, I just now noticed python 3 doesn't have a compare argument in the sorted function anymore XD
@paul23 compare function?
it has key
Have to figure out how to use "key + tiebreaker second key"
I think if the key returns a tuple, it sorts gradually
Lexicographical you mean? (Which is what I want, text is sorted that way)\
21:53
>>> dat = [(1,4,2),(2,3,4),(1,3,5),(3,4,5),(2,4,1)]
>>> sorted(dat,key=lambda x:x[:2])
[(1, 3, 5), (1, 4, 2), (2, 3, 4), (2, 4, 1), (3, 4, 5)]
@paul23 I think, yeah
But indeed didn't think of that, thanks
22:17
I'm trying to do many asynchronous web requests, but the threading almost freezes when the last threads finish. How can I solve it?
@linuscl what kind of web app?
Stock scanner, should I post the code?
no, what framework, etc...
threading, urllib.request
?
I don't understand how you are asynchronously processing the requests
did you use any web framework? which one?
22:23
They never mentioned a web app.
oh sorry, right
urllib requests only
I'm trying to add a timeout function
right now
@linuscl since my psychic remote-viewing powers are a little rusty, yes, you have to post code in order to get help with code. Make sure it's an MCVE, and if it's more than 10 lines use a pastebin.
You'll also have to clearly describe your problem. What does "almost freeze" mean? How are you sure it's your code and not the requests you're making? Why do you think it's related to threading? Etc.
I'll try it
Here the code: pastebin.com/U4giGcQW
I'll try to make it more MCVE
4
Q: Urllib and concurrency - Python

RadiantHexI'm serving a python script through WSGI. The script accesses a web resource through urllib, computes the resource and then returns a value. Problem is that urllib doesn't seem to handle many concurrent requests to a precise URL. As soon as the requests go up to 30 concurrent request, the reque...

22:29
Quote: If you need more concurrency, you'll probably have to pick up some kind of asynchronous network IO tool (eg. Eventlet seems to have a suitable example on its front page), or just launch each urlopen in its own thread.
I launch every urlopen in a single thread...
I am not sure if GIL will let you download all that concurrently parallely
It looks like the some of the urlopen threads get freezed after running, all the others complete, only some stop running
maybe I have to limit it. I should try to start a few, wait, start the next...
@linuscl I still don't think this is better than just sequentially running urlopens
from performance point of view
What's your opinion?
I would use eventlet
or just download one by one
22:37
eventlet.net/doc/design_patterns.html -> It looks like urllib (implementation), so I don't have to change so much
>>> import eventlet
>>> from eventlet.green import urllib2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/eventlet/green/urllib2.py", line 16, in <module>
    ('urllib', urllib))
  File "/usr/lib/python3.6/site-packages/eventlet/patcher.py", line 93, in inject
    module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
ModuleNotFoundError: No module named 'urllib2'
first problem :(
AttributeError: module 'eventlet.green.urllib' has no attribute 'urlopen'
I don't think I'll be able to use eventlet
@linuscl try urllib.request.urlopen()
gt = eventlet.spawn(urllib.request.urlopen, 'http://eventlet.net')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'eventlet.green.urllib' has no attribute 'request'
22:53
In [1]: from eventlet.green.urllib import request

In [2]: request.urlopen("http://localhost:4567")
In my file:
File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 24] Too many open files>
@linuscl can you pastebin the new one?
you shouldn't use traditional threads
any more
01:00 - 23:0023:00 - 00:00

« first day (2297 days earlier)      last day (2875 days later) »