« first day (1988 days earlier)      last day (3184 days later) » 

00:00
k i got it to a simpler version, whats the best to put in a code block in chat? fine to just copy and paste? its like 5 ish lines
5ish lines is OK, I think
but you can always drop it in a github gist or something if you're worried
ill do a gist just cuz i know chat formatting is a little screwy...
yup (you can make it work, but it's cleaner with a gist)
thanks, I'll look now
00:04
that is the code, it gives me the error:
`ZeroDivisionError: integer division or modulo by zero`
are you aware that you can use a lambda inside the call to PiecewisePolynomial?
yes, it is just because the actually structure of the code is lot more like this
ie the function is being used elsewhere as well
OK, just wanted to note:)
so
despite the manual saying that an array_like is OK, it seems to want a list of arrays after all
try
func = interpolate.PiecewisePolynomial(x,some_function(x).reshape(x.size,1))
even better:
func = interpolate.PiecewisePolynomial(x,some_function(x)[:,None])
this will just transform your 1d array into a 2d column vector
yes, it worked!
thaaaank you so much
which is understood as you want it: some_function(x)[k,None] is the zeroth derivative of your polynomial at point k
no problem:)
this is probably a bug, though
it should either complain about the input shape, or not throw an error
00:12
yeah i was really surprised by it because the documentation seemed to say it was okay
yeah, it does that sometimes
I've used griddata multiple times, and its documentation seems to contradict its behaviour
again in terms of input shapes
wait, I can do blatant self-promotion with that one --> done:D
niiice haha
I should get myself to test that odd behaviour properly, and file a report if it seems to be a bug and not just unstable behavior in interp2d
ehgad
I went with unclear
"you want us to write your code....and don't even know where your input is???"
noooo why does it have an answer?
it's not an answer dump at least....just explains a few things. Not horrible.
meh
would've fitted in a comment
tempted to downvote
I won't, I guess... but meh.
hehe :) I had a lengthy conversation with someone today with an answer dump over a similar low quality question
they ended up deleting it
I might get to go to Austin for the Openstack summit. Kinda excited! :)
have fun if you do:)
sounds exciting
00:49
I need votes! Badge is soooo close!
"Hey, buddy, can you spare an up-vote?"
*flags for mod attention*
*goes to meta about odd voting patterns in the python room*
which badge?
Silver iterators.
your account says bronze?
and 2 answers needed?
is caching this bad?
D'oh. Bronze it is.
you need 2 more answers
00:51
The refiner is silver, but I'm farther away from that.
votes are not the bottleneck at all
I've written a bunch, I think they just need some up-votes.
you already have 187 votes out of 100
just look at your profile... :P
iterator
187/100 score --> check
18/20 answers --> nocheck
Oh? I'm not sure what it takes for an answer to count, but if you do a search on
user:208880 [iterator] is:answer
you'll see I have 28 answers.
hmm
blame caching?
wait, are any of those community wikis?
no, none
I guess it's caching, then
meta is full of this issue
oh hey, I've just realized: aren't you the Enum Guy?:P
yeah, you should have the badge by now
00:59
Depends -- do you like Enum? ;)
@EthanFurman to be honest, I've never used it:P
but I'm a python noob
If you do, then Yes! Enum, enum34, and aenum (for the really esoteric stuff).
@EthanFurman it's so esoteric that google fixes it for me:D
sounds fun
nice to meet you, anyway
cool!
Thank you, pleasure meeting you as well. :)
01:02
:)
so far from 1000 for the golden hammer of dupe
Yeah, I finally got the Python hammer, but it's gonna be ages before I get the Python-3 one.
but shouldn't all python-3 tags be tagged python
just for hammering:P
and not necessarily
if it's very python3-specific, the interested peeps will be following the tag anyway
It's a mixed bag. And if I add the [python] tag myself I don't get to hammer it. :(
01:05
@EthanFurman you sure?
some gold badger told me they sometimes add matlab to octave posts if it applies, to hammer
are we supposed to add the python tag to python 3 tags?
as part of our contribution to upkeep in the community?
ok
I'm sure it's been asked on meta btw
Well, the one time I tried it I got a message that said I couldn't use my hammer because I added the tag.
01:08
I was about to ask that
was curious how that got controlled
that totally makes sense
It does.
0
A: What's the best way of skip N values of the iteration variable in Python?

Ethan FurmanThere are a few ways to create iterators, but the custom iterator class is the most extensible: class skip_if: # skip_if(object) for python2 """ iterates through iterable, calling skipper with each value if skipper returns a positive integer, that many values are skipped ""...

Speaking of esoteric...
How ironic -- I just got the bronze [enums] badge a couple days ago. :/
we should have a python-enum tag, and you could kick ass:P
ah.
but then again, mass tag-only edits are frowned upon
I vaguely remember this months ago now that I'm reading this, it's starting to ring a bell.
01:17
I guess if you already edit something and it's missing the generic, feel free to add
but don't get out of your way to retag them, I think
yeah..I wasn't planning on going on a witch hunt
01:37
A bunch of code, but none of it runs. it should be closed.
0
Q: KeyError when using Iterator class to Iterate through a DictSet

BrxttBI've created a Set class that has the set types, ListSet and DictSet which are represented by a list and dictionary respectively. Both sets need to be iterable which I've created a SetIterator class to do so, however when I try testing DictSet, I get the following errors: Traceback (most recent ...

DSM
DSM
02:36
@idjaw: in Python 3 the print function will capture what's inside the parentheses as arguments and return None, so OP is doing None % a_tuple
That explains it. I am on my work laptop and running it on 2.7.10
thanks I'll delete my comment
ugh......a glass of water spilled on my trackpad....this is so %$#&&*
...
03:43
Oh thank god. Almost forgot to load the site and I'm 64 days into fanatic. :P
Only 36 days to go! :)
 
2 hours later…
05:19
Anybody willing to answer a quick question?
@Aaron3468 just ask it
05:36
I'm working on an emulator. At the moment, I'm making the interpreter. It's basically a long if/else construct. LD A, NN is similar to LD NN, MM in the sense that set(constantA, value) is likeset(address, value) with one parameter predefined. How can I keep the function logic outside of the lookup table in order to exploit these similarities in operations?
Ideally, I'd have something like a dictionary that returns the functions with prebaked parameters so that I could avoid re-implementing the same logic in slightly different ways, spread throughout the if-statement.
Of course, I could write a 500+ element if/else statement of if opcode == number : do function; return cyclesTaken... I feel that there might be a more legible way, but I can't think of it
I don't think a dictionary could do something like '43' : ldFunc('B', 'E'), '06' : ldFunc('B', fetchValue())
06:23
I was facing a similar problem: stackoverflow.com/questions/15182336/… . Any suggestions :)?
 
1 hour later…
07:52
Cabbage
Hey, @idjaw, that How to split a python dictionary for its values on matching a key question is a follow-on to a very similar question; I linked to the original with my comment.
 
1 hour later…
08:57
@Aaron3468: You can probably do this with a dictionary. If you write a small example using if/else logic, I'll show you a dict-based equivalent. If the example is under a dozen lines or so you can paste it here (use the Fixed Font button to preserve formatting), otherwise put it on an external site and link it.
09:29
Hi every body!
I have Query about python? any one can guide me
@Afnanalam just ask.
And read sopython.com/chatroom before you do.
I am new in python , previously I work on JAVA , so python is good for me or not?
Its better for me that I change tech java to python?
@Afnanalam we can't answer that for you.
That is such an open-ended question that has so many different factors (that we have no information on) that anyone who tries to answer it is doing you a disservice.
@Afnanalam Even though they are both OO languages there are some major differences between Java & Python. It will take a while to get used to Python's more "relaxed" approach. But why do you feel that you want to change?
Once you get used to it, you'll probably find that Python is faster to develop in than Java. OTOH, Java uses a JIT compiler, so it runs faster than standard Python. And Java is certainly more useful than Python if you want to develop Android apps, although there are now some ways to deploy Python code on Android.
09:42
@Aaron3468 Ok. Give me a few minutes. I have to go & do something away from the computer.
@Afnanalam I used Java for a while and transitioned to python. As PM 2Ring says, Python is faster to develop and isn't as strict as Java; you don't need to double/triple check variables, and it's easier to do a lot of things. Python's fun and fast, Java's effective and makes secure code.
@PM2Ring Syntax isn't perfect (I forgot self.), but it's a good representative of what I've got so far
09:57
@Aaron3468 You can condense loadOp() like this:
op_reg = {
    '06': 'B',
    '0e': 'C',
    '16': 'D',
    #etc
}

def loadOp(self, op):
    self.setReg(op_reg[op], self.nextByte())
If op isn't guaranteed to be valid you may want to wrap that in a try...except, but I assume you've already validated the opcodes before calling loadOp.
Of course, my code assumes that all the opcodes load a byte using self.nextByte. If that's not the case, eg some load larger values using other functions, we can deal with that by storing additional info in the op_reg dict.
@PM2Ring That's definitely better than my list, and I can still do for c in op_reg: if opcode == c : to validate before calling :) Because I'm using numpy.uint values, the code is fairly bulletproof. Because I'm reading binary, so numpy is fed integers anyways.
For longer sets of parameters, I can just start using tuples as the values in the dictionary. Then I just unwrap those values into a function call once I find the key! So it's the perfect wrapper I knew existed, but couldn't puzzle out myself. I have functions to deal with longer byte values
You can just do if opcode in op_reg:; testing dict membership is very fast.
@PM2Ring Haha, I haven't quite gotten used to how expressive python can be. Using a dict means I don't need as much helper code.
To deal with the various byte loading functions, you can either store the loading function directly in the dict. Or make a list (or tuple) of the functions and just store the list index in the dict. That would be less typing, but harder to read. And it won't save any RAM, since a list index takes up the same room as a function pointer.
Anonymous
does python has a package management like Composer for PHP?
10:10
@Aaron3468 We can do a similar thing with decodeAndExecute().
Anonymous
I think pip install on command only, what I am looking for is a simple company to install dependencies automatically.
@samayo PHP code is generally running in an environment that provides Web access; that's not always the case for Python code. So install-on-demand is generally not a suitable strategy for Python.
btw, is there a way to return the matching key in the dict while checking membership? That way I don't need to loop once to see if the key exists, and a second time to execute a function with the arguments mapped to that key
Anonymous
@PM2Ring I don't know how that makes it different, for example when I work on local and push to prod, I have to always manually install requests library, among many others. I think a solution to write those library in a json file and install them at once is a very good idea.
What do you mean "write those library in a json file"? Bear in mind that Python packages can contain plain Python source, but they may also contain other resources, eg, C source that needs to be compiled. For people on Windows, packages containing pre-compiled binaries instead of C source are available, (but not via pip, AFAIK).
10:20
facepalm I can literally just call dict[value] if I've already called if value in dict and it returned true
@Aaron3468 Yes. :)
Anonymous
@PM2Ring Like this json file for example. It contains all the dependencies for that library.
@Aaron3468 Another option is to use mydict.get(key, default_value) which returns default_value if mydict doesn't have an entry for that key. If you don't supply a default_value you get None as the default.
@Aaron3468 For future reference, if you find yourself looping over a dict to see if it has a given key, you're doing something wrong. :)
@PM2Ring I didn't switch my code over from when it used lists ^^;
Here's the much cleaner, and much more maintainable code: pastebin.com/GCRFgvFm
@Aaron3468 Ah, that explains it.
10:35
And the next function's dictionary so far:
self.registerloads =    {'7f' : ('A', 'A'), '78' : ('A', 'B'), '79' : ('A', 'C'),
                             '7a' : ('A', 'D'), '7b' : ('A', 'E'), '7c' : ('A', 'H'), '7d' : ('A', 'L')}
Anonymous
@PM2Ring thanks, this is the one I have been searching for. Is there a good tutorial of the usage, like where to store or call the it after listing all the requirements?
@samayo Try Googling python pip tutorial
Anonymous
Oh, I thought it was more complicated than that, it is almost equivalent to a bash script, as $ yum install -y example
@Aaron3468: BTW, defining self.onebyteloads outside a method is a bit odd. Either define it inside the class's __init__ method. OR define it as a class attribute, as onebyteloads without the self. stuff.
Also, I'm not quite sure why you bother doing opcode = format(opcode, '02x'). You can write the opcodes in hex form eg 0x2e, it's still only 4 keystrokes, and small integers use less RAM than small strings.
@PM2Ring Sssh ;) Really, it's because the opcodes are read from a binary file. I'm not the one writing them into the code. All documentation for the device I'm emulating uses hex notation for opcodes, so using hexadecimal in the lookup function makes it readable for anybody looking at my implementation
10:51
Well, 0x2E is just as readable as '2E' to me. :)
True, but it's more of an aesthetic choice between format(int, '02x') with padding and hex(int) being the shorter command
But it doesn't make much difference really. And Python caches or interns small strings and small integers, so if you have 0x2E or '2E' in multiple places through your script only one integer or string object is actually created.
@Aaron3468 I think you're missing my point: I'm saying there's no need to convert the opcodes from int to string: you can just use the raw int opcodes. 0x2E is an integer.
@PM2Ring Yeah, it's pretty late so I'm not thinking straight. I realized what you meant a moment before you responded and you're right. It's more efficient to just if opcode == 0x2e. I was wondering why you'd suggested (or so I thought) if hex(opcode) == 0x2e instead of the `if format(opcode, '02x') == '2e' that I already had.
Thanks for the great help nonetheless. Program logic is fairly easy for me, but common sense and refactoring are entirely different beasts ^^;
Fair enough. FWIW, I agree that using format(opcode, '02x') is generally superior to hex(opcode), since the latter gives you no way to control the length of the string. Also, hex() gives you that pesky leading 0x in the returned string.
@Aaron3468 Not a problem!
After a while, refactoring becomes semi-instinctive. But I guess it helps to read and (play with) lots of examples of good code.
11:18
FWIW, I enjoy reading Martijn Pieters' answers, even to fairly simple questions. His code is almost always clear and tight, and generally impossible to improve. :)
To be honest, I'd been putting off the interpreter because I knew if/else wasn't robust enough and one dict couldn't handle every case. Using multiple dictionaries actually makes it easy enough to be a bit fun.
I'll check them out
Oh! I've already seen maybe two or three by him and thought the same each time xD
On a related note: using dictionaries to pass &/or accept keyword args using the ** "double-splat" operator.
Oh no! We're surrounded by Finns :hums "Jaws" theme tune:
hmm?
2 now?
"surrounded"
11:31
Before I posted my last comment, You & Rainer were on either side of Aaron and me in the avatar panel. :)
bbq
we're at a bar with Antti
They're circling! Blegh, I should really redouble my efforts to learn Finnish. About all I remember is "Pete rakasta Annaa" and "suomalainen"
as usual
that's not bad
a couple of redoublings and you know all of Finnish
:)
でも、日本語ならよくわかっていますよ
Oh man, is it really that easy a language? redoubling intensifies
日本語すこしはなします、でも まだじょうずじゃありませ
11:43
悪くない!
at least with Finnish you don't have to learn 3000 new runes for alphabet... :D
lol, the runes are combinations, so it's actually only ~200 that are combined to make that 3000 ^^
I know, I tried the Heisig method for a while
but it's still a lot of work
and you have to remember the order of the combinations, and there are special cases and whatnot
@PM2Ring So, with that in mind, vote to re-open?
translate: でも、日本語ならよくわかっていますよ
(from Japanese) However, Japan English you know.
11:49
Now that I'm intermediate with Japanese, I'm getting ready to take on another language and maybe visit Japan for a while to practice. I've got Chinese, Finnish, German, and French on my list
Ahh... looks cool though
\0 ninja pup! :) How's it going
@JonClements literal translation: but, if it's japanese (I) understand well (emphasis)
@idjaw Maybe. It's weird that the OP didn't link to the previous question themself.
@PM2Ring would have been a totally different story if they did! I'll vote to re-open
thanks
11:51
@idjaw Aye Aye Cap'n - not too bad - stomach bug - so will be to and fro'ing from keyboard... just about to fro' right now for a bit... so bbiam :p
:)
poor pup
bad scooby snacks....sounds like a good chapter to add in the book
@idjaw Rightio. I've also voted to re-open. And I've pinged the author of the accepted answer to the previous question, although he doesn't have enough re to cast a re-open vote.
It's also weird that Suren hasn't tried to use the logic of that answer to the previous question in his new question. I guess that maybe he doesn't actually understand it.
If anyone's curious as to what idjaw & I are talking about, please see stackoverflow.com/questions/36198540/… and stackoverflow.com/questions/36227574/…
I get the feeling he speaks a different language, hence describing the previous answers as cryptic, but I'd expect him to at least have copied code and tried messing with it
I KNEW IT!!!
I was right
this I closed yesterday and OP just re-created the same question again here
what's the fastest way to get this shut down
I voted as too broad but I should have duped it
flag to mod?
@idjaw Well, it is a little bit different. And a dupe target should actually have an answer, unless it is an exact dupe by the same poster. AFAIK. But it does sound like the OP just wants code he can use without understanding it, and I hate helping cargo-culters.
12:06
yes...this is why I'm being a pest about this
I had a LONG conversation with OP yesterday and they just did not want to provide code
and, yes, it is a bit better, and it suddenly sounds like this is for school and not work :P (although that doesn't matter, just funny)
things I hate: coding with someone who has keyboard repeat rate set to 1/second
plebs don't know 'bout set -o vi
haters gonna hate, and I am hater for sure!
@AnttiHaapala I think it's permissible to punch people who do that. :)
The Tao of PM - punch people who do that
12:30
is it just me or is this more about the answer I provided? Is OP asking how to use the Yahoo API as well? I'm realizing that this might be an even worse question than I originally thought.
deleted answer for now as it seems like they want to know how to use the Yahoo API. unclear.
It won't be long until I finish my emulator now that it works on about 1/4 of the machine codes. For now, it's time to sleep, so have a good night/day everybody!
Night, Aaron.
12:50
:( is it really worse than others?
Some insane Boogie Woogie keyboard work by Dona Oxford
BOOGIE WOOGIE!
13:08
yet another learning how to program with bad data structures ... ugh....sometimes I feel bad for students.
13:22
Just came across this error
*** AssertionError: <could not determine information>
Any idea why is that happening?
...
with all due respect, how would anyone know what is happening with just providing a vague error and absolutely no context.
Not trying to be rude, but really. How?
for val in b'', None:
rv = field.deserialize_value(val, pad=pad)
assert isinstance(rv, MarkdownDescriptor)
rv = rv.__get__(source)
> assert not rv
E assert not <lektor.markdown.Markdown object at 0x7fd616e6d0f0>
My bad. Posted traceback
I am trying to port lektor to python 3 and a test is failing here github.com/lektor/lektor/blob/master/tests/test_types.py#L39
14:12
Hey guys
hi
does anyone know how to disable PhantomJS console window ?
@JustasSame detonate an EMP? :p
DSM
DSM
14:30
Morning cabbage for all.
cbg
@DSM looks like you got the invite key okay :)
DSM
DSM
For some reason, people who say "I'm trying to write a function" when they show no code and really mean "I'm trying to get other people to write a function" infuriate me, but commenting snarkily enough so they get the point would be nonconstructive and so I'd have to flag my own comment..
hello
@DSM well, they are trying. They try to make others write it for them:D
@DSM Our buddy came back with a re-post :)
maybe you should post your rust solution in the comment :P
Cabbage!
14:41
hey!
DSM
DSM
It's been too long now and I don't interact with students nearly as much as I used to, so I no longer have a good feeling for what parts of programming beginners find hard.
@Jon You around?
@poke wassup?
Can you do me a favor and clean up the comments here (basically delete all but the last two)?
No - because you spelt "favour" wrong :p
14:44
cbg
Oh lol, just as I posted it, I was wondering in my head if I should add “Or do I need to spell it favour”… xD
@ChillarAnand __nonzero__ -> __bool__?
favour is the only way to spell favour.
Thank you @Jon :)
Captain Canuck approved
14:46
@JonClements If we're going to be pedantic re: American vs British spelling, then perhaps we should also be pedantic about using an adjective "wrong" where an adverb "wrongly" is required. :)
"I am Captain Canuck, and I approve this message"
DSM
DSM
@AnttiHaapala: yeah, that was my thought too re: the assertion.
/puts paws in ears - woof woof woof - can't hear you!
Grammar-served.
14:52
unclear / dupe / OP not responding stackoverflow.com/questions/36236486/…
@PM2Ring found this "Wrong" and "slow" didn't become adverbs recently, they have always been adverbs and are listed as such in dictionaries without any reference to slang or colloquial use.
cabbage
DSM
DSM
Serve returned!
So, that guy I was helping last night with Git stuff wanted to thank me and randomly upvoted 10 answers of mine. Not surprisingly, I have a -60 “Voting corrected” today… *sigh*
14:54
@AnttiHaapala [citation needed] :P But I wasn't being (very) serious; I say "spelt wrong" myself, although my mother never would.
As for "slow" as an adverb: Goin' Down Slow - guitar and vocals by Duane Allman
I've not decided whether I should use spelt or spelled
Firefox spell-checking seems to accept both
favor is rejected, of course.
though of course "But when spell carries the sense to temporarily relieve (someone) from work, spelled is the preferred form throughout the English-speaking world. This is a minor point, though, as this sense of spell is rarely used outside the U.S., where it is most common."
@AnttiHaapala Did you want to edit that? ;P
@poke perhaps :d
I’m curious!
ah something about the serial voting wrongness corrected.
I forgot already

« first day (1988 days earlier)      last day (3184 days later) »