« first day (2867 days earlier)      last day (2306 days later) » 
00:00 - 17:0017:00 - 00:00

wim
wim
17:00
meh.. a dict with consecutive integer keys is just a list
if the "missing" fields could be sparse in the row, then I would agree and would suggest a dict writer.
otherwise, clearer:
if len(mydata) > ncols:
    raise MyTooMuchDataError('you done screwed up')
unless you're going to precheck all of mydata first before creating the file, why not just let dictwriter handle that case, catch its exception and re-raise with a custom exception if required?
(ie: what's the point of an if check if that's already going to happen anyway?)
do programmers who do not speak english have to learn the english keywords of languages?
...there are programmers who don't speak english? How do they read documentation?
wim
wim
@JonClements tbh I would not put such a check in unless it was a business requirement in the first place
csv files with ragged row lengths are OK, they load perfectly fine in spreadsheet programs such as open office
17:13
@ThePeskyWabbit yes
try and put 'em into any form of RDMS though @wim
wim
wim
I'm not saying it's a good idea
nor am I saying it's not always going to work depending on a use case... :)
we've the same point but made from different directions... all is good :)
wim
wim
I tend to program with "garbage in garbage out" assumption, if you are foolish enough to call functions in ways that are not documented as supported then you get whatever you deserve
If I'm looking at a recursive function, and I don't know how deep it will go (therefore could be concerned about running out of memory), is there an equivalent to xrange() that would let me use a recursive function? ... or should I just solve the problem through something aside from recursion?
wim
wim
17:16
because, if you try to defend against all kinds of stupid input, it can be an endless excercise
and eventually all the extra stuff for the "defensive" programming obscures the actual intended design of the code in the first place
lol thanks for the help guys nargs was definately able to solve the problem
wim
wim
@user3.1415927 I don't see what xrange has to do with recursion at all. Could you elaborate?
Sorry, incomplete explanation.
xrange() lets me use a large (memory-prohibitive) range function, right?
It's pretty hard to run out of memory while recursing in Python, since there's a built-in recursion limit already, and it almost always triggers long before you run out of space
So I was wondering if there was something (similar, that used iterators, I think), that would allow me to not shoot myself in the foot.
17:20
You could even lower the limit if you wanted. docs.python.org/3/library/sys.html#sys.setrecursionlimit
@Kevin Orly? Hm; I hadn't run into that yet.
Oh, I was using Python2.
I'll have to look into that further.
That's fine, it's in Python 2 also
I didn't want to crush the computer, since the session has other useful things I don't want to kill, I was being cautious...
@Kevin Very thanks.
@wim "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." en.wikiquote.org/wiki/Rick_Cook
TIL running queries via pandas.read_sql(my_query, sqla_engin) is a blocking thing. That means I can't run it asynchronously via async/await. Instead, I have to use asyncio.get_event_loop().run_in_executor(stuff). I think I learned that. Anyone have an example that spells this out?
17:26
SQLA is not asynchronous.
@IljaEverilä yeah. So I have to employ multiple threads
@user3.1415927 Can you show us your function? It's good to avoid recursion if an iterative version is easy to write. OTOH, some algorithms are naturally recursive, eg stuff that has to process a recursive data structure. As Kevin mentioned, Python has a recursion limit to stop rogue recursive functions from clobbering all of your RAM. You can raise that limit, if you really need to. But there may be ways to modify the recursion so that it doesn't go too deep.
man, I wish I had a say in the data I got (its all garbage, its always been garbage....except when I worked with POS systems long ago)
@piRSquared There are some extensions or some such that make it somewhat async.
But in the end if the DB-API driver is not async, there's not much to be done.
I think there's a version of Psycopg2 that works.
No, wait, it was aiopg.
17:51
@IljaEverilä this seems to work. Going to do this sort of thing with my problem now
@IljaEverilä congrats on 20k :)
also, cbg
user8682794
hi everyone! I have been using Python for awhile now for my scientific needs. However, I am increasingly getting requests from collaborators to work in Julia. Is it worth learning the latter? The former covers all my needs, so far at least.
@coldspeed Thank you :)
Are you a mathematician or a programmer?
17:57
yes
I like Julia, but I hate languages that start arrays at 1 D:
user8682794
@user3483203 i'm a scientist not a programmer. I just do not understand why i should switch to Julia. I can get the same speed gains with Numba.
Did they say why they want you to switch ?
A lot of the non-developers I work with prefer Julia. They claim the syntax is more intuitive
Just fyi, Julia works pretty well with Python, so you may not need to switch to collaborate
user8682794
18:02
@IMCoins apparently it is "the future" and they all go there. But i do not see any specific reason to switch
I've done projects where one person was using R and I was using Python without a problem before
user8682794
@JGreenwell they claim it makes it more difficult to share code
that why I said may work for you :) (really it depends on you and the project - what do you want to do?)
As far as I know, for the research I've made in the past (meaning : I have no sourcing now) : Julia will surpass Python and R in ~10 years.
But that's just predictions. Who knows.
That's a bold claim
18:05
I have never seen Julia code as an analyst or researcher so shrug
Java was suppose to make C++ obsolete when I was young
NoSQL was supposed to put SQL into obsolescence
user8682794
is Julia so much faster than Python with Numba?
Fortran is still here (for good reason), Cobol is still here (sadly)
oh wait, I thought we were talking about the silliest predictions people have made about tech popularity
user8682794
my impression is that Julia is still in very early stages
user8682794
18:07
and translating all my code to Julia is not a trivial task
user8682794
@IMCoins R is not going anywhere anytime soon. It has a very strong stats ecosystem.
If I recap, they want you to change and make a bet on the future.
user8682794
@IMCoins yeah the main argument is this plus speed and easier collaboration / code sharing
I've heard people saying (last 2 weeks, in a conversation in which I wasn't involved) : YAML is the future.
> I predict the Internet will soon go spectacularly supernova and in 1996 catastrophically collapse. - Founder of 3com
@coldspeed ^
18:11
@coldspeed @DSM that dup target gave me something add (-:
I deleted my answer because it was exactly what the dupe had
@PearlySpencer Why would it be a better instrument at code sharing, and would make collaboration easier ? I mean. If they only have arguments based on their emotions... there is no need for arguments there. Just state that you "prefer" Python and that's all.
user8682794
@IMCoins they won't have to translate the code from Python to Julia? Not sure if i am honest
user8682794
It does not make sense to me either but they seem quite annoyed that i don't want to change
There are LOTS of question to ask. Here's one for you that might help you to convince them : Will you hire developers in the future ? If yes, will it be easier to search for Julia programmers, or Python ?
18:16
Julia has a few utilities for running Python code. Actually that's kinda what me and the other guy did (I'd write some code & show results w/Python then he would do same with R cause the math was the same and Jupyter notebook allowed use to change back and forth pretty well)
user8682794
I do not mind learning new stuff but there must be a compelling reason to do so. I am at a stage in my life where I have other responsibilities too
Well, they should be the one giving the reasons. ;)
user8682794
They did, i just do not find them compelling
user8682794
so i was wondering if it is worth the learning curve to sit down and teach myself Julia
Questions I would have (beyond why is it better): 1. can we work together if I don't change over to Julia? 2. Is there a utility which makes the programming less of a thing than the math? 3. Do I care enough to keep researching with you to take myself out of Python and invest time learning Julia (to include research time lost in transition)?
Sometimes you're going to encounter someone who says "No! We do it my way or I won't work with you." and nobody can tell you if it is worth it but you
wim
wim
18:23
The most impressive browser python impl I've seen thus far: pypyjs.org
you can import os and dump out open(os.__file__).read() to convince yourself that this is literally pypy and not only js transpiling hacks
19:06
>>> x = 'asdfasdfasdfsadfasdfasdfasdfasdf'
>>> y = 'asdfasdfasdfsadfasdfasdfasdfasdf'
>>> x is y
True
>>> x = 'äöä'
>>> y = 'äöä'
>>> x is y
False
no module named ctypes
:(
So? With those strings, x is y results in False in a plain CPython REPL too.
And it doesn't make a difference if I explicitly call sys.intern('äöä').
wim
wim
19:24
why you want ctypes in pypy?
@PM2Ring TIL intern had moved to sys.intern... thought it'd just been removed :)
silly interns, always causing trouble
not a builtin I've ever used or found a need to use... but... interesting to see it just moved rather than just removed as I thought it had been
wim
wim
Makes sense to me - since it is implementation detail it should be in the implementation-specific module (sys) not a builtin
Huh, there's a whole section of them docs.python.org/2/library/…
@JonClements Yeah, I thought it had been removed too. I only learned about sys.intern a few days ago.
wim
wim
19:39
apply, coerce, buffer ... they are all kicked out in Python 3
> Python programmers, trainers, students and book writers should feel free to bypass these functions without concerns about missing something important.
yeah... I remember apply it just got thrown out with syntax stuff that was much easier
wim
wim
^ Gonna drop that line on every question asking about strings/integers and is !!
never used buffer (might have used memoryview now and then) and I think I used coerce once
but fairly sure that was in a class magic method than actually calling it directly...
19:52
and can't even remember why coerce seemed a good idea at the time
lol, my wife wants to know what we are coercing interns to do...I love technology terms :)
I've always liked the disclaimer on: redis.io/commands/slaveof
I'd comment in a meaningful way but I can't be sure what will be construed as toxic in a few year's time
This OP isn't allowed to use try...except. I assumed it was a restriction by his teacher, but no, it's a restriction from his project manager. :( stackoverflow.com/questions/51973611/… I guess this project manager is a bit old-school...
wim
wim
20:02
@JonClements wow
How old school do you have to be to avoid exception handling? When was C++ written? :D
'85
What's wrong with int return_code = somefunc(a, b, c); if return_code != 0...? :p
wim
wim
@PM2Ring hilarious
Exceptions can be pretty slow in some languages. In Python, EAFP is only faster than LBYL if the exception is rarely raised (eg <5-10% of the time). OTOH, EAFP can be safer, eg if you need to avoid race conditions.
wim
wim
if you show me how to do LBYL with a network request, I'll be impressed
20:06
or file access, safely
exceptions are powerful things when you grok they escalate up the stack until the nearest handler... (or just ultimately cause a system exit)
And of course, in some situations, like reading from a URL, EAFP is far more straight-forward than LBYL .
wim
wim
in the context of the question posted, EAFP is the only way possible.
a properly designed function should ideally be able to handle its own errors, but it needn't know the context it's called in, so it should do what it can that makes sense, but otherwise, just let it go up the stack until something that understands the broader picture can make sense of it, and then decide...
wim
wim
this is dns lookup
20:09
is that using something like twisted/asyncio ?
@wim I guess so. I can't think of how to do it with LBYL. ANd I doubt that the project manager would be happy with the posted answer, which hides the EAFP by getting threads to do it.
wim
wim
socket
you would have to wrap the entire socket library in a LBYL layer and monkeypatch it
totally ridiculous proposition
does anyone seriously use socket directly these days though?
wim
wim
@JonClements not sure if sarcasm or ..
20:11
@wim no... not sarcasm... for instance - why would one write urllib stuff when you've got requests, or use socket when you've got reactors available in twisted?
wim
wim
so urllib and requests don't count as someone using socket?
He said "socket directly"
wim
wim
oh
well, yeah
I enjoyed my time with twisted
wim
wim
I use socket.gethostname and socket.gethostbyname all the time
20:14
put together some nice stuff with it
We get lots of questions involving direct socket use. I guess it's nice to have some experience doing that. It gives you some appreciation for what's happening at the low level when you do higher level stuff.
wim
wim
it's also a good boundary to patch out in unit testing
because people don't know it exists or weird bosses forbade you from using twisted (cause its called twisted)....which has happened
wim
wim
so I would say, yes, I use socket directly in virtually every project
@user3483203 Done.
20:16
tyty :)
wim
wim
@JonClements Do you think they will accept a PR for CLIENT KILL disclaimer? :D
"It's unfortunate working with a difficult client, however..."
Swear I remember using try { ...foo... } catch (SocketException e) { ...bar... } in Java so I don't know why anyone would try to stop that (and Java exceptions could be pretty slow)
@wim "boy do we have the command for you!!!"
:P
@wim sure - but that level of operation is completely different than trying to have bi-directional communication... which I've seen people use while loops instead of .selecting on etc...
and then they get completely confused when read operations don't return something in one go because they're forgetting how the protocol works etc...
@wim if you want to try your luck - feel free :)
wim
wim
20:38
I dug up some history on this and found github.com/antirez/redis/issues/3185
the "issue" seems to have affected couchdb, drupal, and django all in May 2014
21:07
Yikes the second half of that thread is painful to read
wim
wim
21:28
yes. antirez was incredibly patient.
Is there a way to abort an already created coroutine? I don't want to create a task and immediately cancel it because that starts executing it and leads to other issues. Simply ignoring the coroutine works, but gives a RuntimeWarning.
Can I make 2 stupid questions? I am reading a tutorial about lists and it has a table with some examples of things that can be done with a description, but there are a few which doesn't has a description and I had to find myself. I've find all of them except 2, and I can't understand them. Just look at this:
L = [i][j]
What does that? The example above was "L = [i]" and I'd understood it as: "create a list having the object 'i' as its first value", but if you create a list with only a value, and know you are trying to acces to the "j" value (list[j]), its obvious that if j > 0 it will raise an error... right? So what is that?
L = [i:j]
Maybe if that were list[i:j] I could understand it, because it would be getting an slice of the list, but I haven't found what that means. What does that?
@EnderLook That looks like a syntax error
yes, [i][j] tries to take element j of the one-element list [i]
oh you meant the latter, sorry
@LemonPi "L = [i:j]" is a syntax error?
21:36
yes, [i:j] is
```
>>> i = 1
>>> j = 2
>>> L = [i:j]
File "<stdin>", line 1
L = [i:j]
^
SyntaxError: invalid syntax
```
Oh... thanks!
you'll have to look at the context to see if that makes sense
it's not out of the realm of possibility that the tutorial is merely horrible
What kind of tutorial is it?
there's an esoteric chance that j is a slice object...
Looking back the first one L = [i][j] also is a syntax error
Unless j is 0
not a syntax error
21:40
It's saying to make a list of the single element i and get the jth index of it
@AndrasDeak I've started a basic curse of Python last week in UTN to learn a more (better than just reading guides alone in home...) and he gave us a PDF as a summary of the class! Inside it there was some blank space to complete with information, that 2 thing are some of that blank spaces
Sorry not syntax error, but likely index out of range error
wim
wim
LookupError
IndexError...?
That tutorial doesn't seem helpful
wim
wim
21:42
>>> issubclass(IndexError, LookupError)
True
@EnderLook are the blank spaces such that you can write nested_list[i][j]?
that seems to make much more sense, but it's still a bit crappy as a source
@wim ah!
@AndrasDeak No
Sounds a bit abstract
21:42
That is the table
(in spanish)
@EnderLook ew. Whoever wrote it didn't think it through, just threw together a few syntactically valid lines
and [i:j], so not even syntactically valid...
The 7 and 8 lines are the two excersises
Exercises for what?
they need to interpret what it does
hey guys
is there a way to make a py3 program play a sound like the "\a" you can put in C code?
21:44
Oh I see you have to fill out the right side
wim
wim
interpretación: Errore di sintassi
perhaps the point is to realize it's syntax error...
@NickVen >>> print('\a')
@LemonPi I'm taking a course of Python to learn more and our teacher put that
i mean like a certain file
@NickVen winsound.Beep() maybe?
21:45
that i made
I think winsound can also read audio files
i'll check it out thanks
wonder if that is a typo....I've seen courses which assign i to a string then do L = i[j] to show that it will give you a Letter
@AndrasDeak a bit strange without telling us... maybe he just has a mistake, it wouldn't be its first time... XD! He has already mistaken before!!!
let me know when teachers become infallible (I'll probably be among the first to know)
21:47
@JGreenwell The tables is only about list, not string
^ see that's the point of the lesson (using a string as a list) ;)
@AndrasDeak I know, our Math teacher of 2nd year in high school had around 8 errors per day... our biology teacher was the best, he only had 3 errors (typos) in 4 years!
@JGreenwell xd
wim
wim
I was wrong once.
@wim Are you a teacher?
@wim you were wrong by being humble, but fortunately you're all better now?
wim
wim
21:49
Nov 30 '16 at 21:08, by wim
@AnttiHaapala :D I had thought I was wrong, but it turned out I was right after all
@wim How you quote something??
wim
wim
so if you hover on a message you see a thing appear on the left of it
click that dropdown and there's a permalink
@wim Ahh, I didn't know that permalink were quotes!
I wish I could say I didn't put out anything which had a bunch of typos on it but I've learned I need everything I write with to identify end marks (quotes, brackets, braces, whatever
I would see what you did there if it weren't for my clawing my eyes out
Get an IDE?
missing parens makes you an orpha
4
or grammar checker (or just a good editor) or setup gvim
wim
wim
:
^ orpha emoji
I knew a lambda that was missing parens... her name was Dolly.
23:04
Hey guys, I was curious if there was a place I could post a small project for critique? Beginner programmer.
@Parakoopa No idea, but in Code Review SE you can post an part of it to get advices and critics
neat, thanks!
You are welcome!
23:21
Another stupid question? Does exist the method por() for lists? (Not confuse with pop())
23:32
cbg. all
00:00 - 17:0017:00 - 00:00

« first day (2867 days earlier)      last day (2306 days later) »