« first day (3093 days earlier)      last day (2080 days later) » 
03:00 - 19:0019:00 - 23:00

19:01
@MooingRawr The patterns from Motzkin numbets are like a restricted version of the patterns you get from Catalan numbers, which come up in all sorts of combinatorial things, and are related to Dyck words.
@WayneWerner I would hope that mere mortals end users never see a Traceback.
stderr is for elite hacker eyes only B-)
@PM2Ring Exactly... which is why I asked :P
End users get a nice GUI with all the sharp corners sanded off. No command prompts for them.
@WayneWerner Well, me, mostly, and any other dev. At the moment it takes input from CLI, eventually I (vaguely) plan to convert the UI to a webapp, but I don't think a user will ever see it, unless, as I said, they manage to pass something other than string.
@Kevin I am using 3.7.
Unpopular opinion: programmers that call my functions with bad values deserve to be subjected to my fiendish riddles
19:07
@PM2Ring They should not, unless I screw up. That said, the only current user is my wife, who obviously is no mere mortal ;)
@toonarmycaptain I wouldn't return a stack trace to a CLI, even if it was for me. I would write something like...
try:
    Student(name=3)
except ValueError:
    print("Student name must be str, got int instead")
Of course, one could always Student(name="3"), because that's a thing, but...
@PM2Ring I see... interesting read.
if your goal is to make sure that you're actually getting a string-ish thing, I would do something like that.
I allow stack traces to be dumped unceremoniously into the CLI, because I deserve to be subjected to the interpreter's fiendish riddles
Though, what I would actually do...
@Kevin This is Python, not Java
19:11
If I ran a program and the only thing it showed me was Student name must be str, got int instead before exiting, I would look at the ten thousand line code base and say, "... Well dang. Guess I better start looking for Student calls."
@WayneWerner I could do that, but that means I have to change it if I ever put a different front end on it, whereas currently I believe I have the UI and business logic sufficiently decoupled that I can switch it out without any changes.
class MyProgramError(Exception): pass
class StudentNameError(MyProgramError): pass

class Student:
    def __init__(self, name):
        if not isinstance(name, str):
            raise StudentNameError(f"Student name should be str, got ({type(name)}, {name!r}")

try:
    student = Student(name=input("What is your student name? "))
except StudentNameError:
    print("Uh... that's not a name, that's something completely different!")
Currently long as I handle potential errors on the UI end (you know, by intercepting, logging, saying "Oops, sorry, you should have paid your developers more money - then this would be more reliable.") they should never see a stacktrace.
Presently, however, if this condition is seen, then I screwed up, and the program should crash, although I suppose I could wrap everything so that it logs errors and returns to the home menu, but I haven't gotten there yet.
^^^ see above
@Kevin That's exactly what I see from your code on 3.7 too.
19:17
I must remember to test this out when I download 3.7
you can quite easily add a log = logging.getLogger(__name__) command, add a filehandler, and then in the exception(s), log.exception("User haxored the input") or something
@WayneWerner I've been meaning to implement logging on it. Recently I've been converting it from functional to OOP, so that will probably come afterwards. My wife ceased using it at the end of last semester anyway, but it's a decent learning project for me :)
I read that as

> My wife deceased

at first o.O
@JonClements Little long but maybe you want df.date - pd.offsets.MonthBegin(1) + pd.offsets.WeekOfMonth(week=0, weekday=0)
^ as the result for first_monday
19:48
@toonarmycaptain Yup, which made registration confusing because the interface kept indicating that I had selected two tickets even though I'd clearly entered 1. It turns out the second ticket was for the free after party.
20:00
@Dodge 3 if you got the shirt too. Yeah, that wasn't the most intuitive thing. I thought I'd registered twice somehow when I got two tickets.
@WayneWerner Shhh
Why did I choose to try answer a question on pandas and datetimes on a Friday night? Driving me bonkers :/
20:28
@PM2Ring my main point is that it surprises me less when a 20 yo person is an amazing artist.
20:50
Man i am becoming a killing machine! Now learning class inheritance
@ExoticBirdsMerchant required watching: Raymond Hettinger - super() considered super! --> youtube.com/watch?v=EiOglTERPEo
Thanks!!! I ll look into it
edited with link. its an awesome talk.
ya. if you don't know, Raymond Hettinger is one of the python core devs and he's a very good speaker. you can like binge all of his talks and learn a ton about Python.
20:54
And i wondered where will i look for new material when the documentation is finished
David Beazley also gives really good talks on Python. both are very entertaining but you learn a lot. Beazley will like break the language in real time at a talk, lol.
Like the paradigme he does with classes he explains them a items of a company from suppliers. Really neaty example. Thanks for Beazley i ll put it in my Python school links
 
1 hour later…
21:59
can anyone who uses pynput give me a simple one-liner for identifying a key pressed?
For example:
def on_press(key):
if key == "s":
I have search far and wide for the answer on google and in the documentation. I can't seem to work it out myself. Every example I ever see only checks special keys like Ctrl and Alt
Do you have it working without a one-liner?
sorry, I shouldn't have said "one-liner" I just meant something quick and simple.
if key == "s":
Doesn't work. The code returns ('s') without the parenthesis
so I tried:
if key == "\'s\'":
still nothing
Does it error?
Pandas Merging 101 is now officially my most upvoted question and answer :D
@coldspeed congrats! It does become so confusing
22:03
What is confusing? :P
The fact you needed to post a canonical might indicate something... :)
from pynput.keyboard import Key, Listener

def on_press(key):
	if key == "s":
		print("HALLELUJAH!")
	print('{0} pressed'.format(key))

def on_release(key):
	print('{0} release'.format(key))
	if key == Key.esc:
		# Stop listener
		return False

# Collect events until released
with Listener(
	on_press=on_press,
	on_release=on_release) as listener:
	listener.join()
@roganjosh yes... there might be a market for more "pandas xxxx 101" posts ;D
@roganjosh only returns this when I press the s key twice:
Key.enter release
's' pressed
's' release
's' pressed
's' release
Key.esc pressed
Key.esc release
notice there should be a couple of HALLELUJAH's in there
@DeeJayh have to be honest, this is totally out of my area so I don't think I'll be able to help here. However, I think what you've posted now is much easier for others to answer if they do know the library. Just note that it's going to be quieter because of the start of the weekend.
Though you could be doing print("Key I see is:", key) in on_press()
To try and understand why the if key == "s": check isn't firing. It could be in a different format: stupid suggestion, but maybe it's a tuple
22:13
makes sense, but the documentation clearly says it's a string
what it LITERALLY comes through as
But have you checked it?
in it's entirety, is this:
's'
not:
s
but:
's'
Not sure what you're highlighting with that, but next move on to print(type(key))
just did, funny enough
great minds and all that
s comes back as:
<class 'pynput.keyboard._win32.KeyCode'>
There we go :)
You presumably need to get the text version. dir(key) will give you some indication, but so will the documentation
22:17
yup I think I have an idea, testing it out
Putting imaginary money on .text
if key.from_char("s"):
solved
Thanks for helping me think that one out @roganjosh
No problem, glad it's solved :)
Shame I lost my imaginary money, though :/
03:00 - 19:0019:00 - 23:00

« first day (3093 days earlier)      last day (2080 days later) »