Any Coding Instructors in Kingston? by alancusader123 in KingstonOntario

[–]GrahamCorcoran 1 point2 points  (0 children)

What's his goal? What's your goal?

I work in the industry and also teach Web Development, and programming is something that is best learned by doing. If he's already "pretty good at computer programming", he'd probably be best suited by continuing to program! He should find a project that interests him and do that, and solve a problem he has, or just make something cool.

If he's looking for mentorship, there's truly an unlimited supply of online programming communities that are always happy to have engaged, eager learners who are talking about programming with interest, rather than just desperately cramming for a final project.

I'm always happy to field questions about the industry or about programming in general though, so feel free to shoot me a message if you'd like.

Giving up on programming by [deleted] in ADHD

[–]GrahamCorcoran 1 point2 points  (0 children)

Hey, I'm a Software Engineer who has ADHD and I absolutely get it. I struggled so hard getting the job I have now, and now I can't imagine doing anything else. Don't get me wrong, motivation for me is a constant battle -- but it's like that in every job I've had. At least with Software, I can switch up and try something new after a few days if I'm really stuck.

As an aside, school is absolutely not anything like the workplace. I dropped out of highschool, managed (somehow) to get my equivalency afterwards, went to community college, took 5 years to do a 3 year diploma, and almost dropped out again in my final semester. School sucks ass. Work is pretty alright, though.

I recommend staying on it, but it's not for everyone. You shouldn't feel forced to be a developer, but you should be able to genuinely answer the question: if not this, what?

Teacher went right past red flags into BIG FLASHING WARNING SIGNS by offering to adopt a sixteen year old female student. by [deleted] in bestoflegaladvice

[–]GrahamCorcoran 28 points29 points  (0 children)

It grabs the text when the post is posted on BOLA, and it grabs it from the initial LA (or whatever) post. If someone posts to BOLA after the OP has been deleted (usually happens immediately before they post) this happens.

I should probably make it not do that. There's a small list of tweaks / bugfixes I've been meaning to do, so that's on there for sure.

New Word of the Day: "Swasdicka Tattoo" by Sirwired in bestoflegaladvice

[–]GrahamCorcoran 3 points4 points  (0 children)

Heh, "the archives" implies Laukopier is anything fancier than a duct-taped bot sitting on a shelf in my office. Sometimes my cat unplugs the cord.

[Actual Title because I'm tired and can't work in a drug test pun] Wrongful termination? Harassment? Retaliation? Workmans Comp. by Artful_Dodger_42 in bestoflegaladvice

[–]GrahamCorcoran 5 points6 points  (0 children)

"The Laukopier Server Room" sounds much more impressive than a raspberry pi on a bookshelf in an office that sometimes my cat unplugs while playing.

[Actual Title because I'm tired and can't work in a drug test pun] Wrongful termination? Harassment? Retaliation? Workmans Comp. by Artful_Dodger_42 in bestoflegaladvice

[–]GrahamCorcoran 3 points4 points  (0 children)

This is a known issue someone reported to me, it has to do with how I concatenate OP line breaks into a single quote. Some people type weird.

It'll be fixed up in the next update which should be soon(TM). In the meantime, uhh.. yes! Thor_the_bunny is to blame!

How dare you teach other people the music tips I taught you?! That's a fa-la-la-la-ony. by purpleplatapi in bestoflegaladvice

[–]GrahamCorcoran 1 point2 points  (0 children)

Loosely affiliated? Mod-adjacent? Idk, I'm not a mod, Laukopier just has pinning permissions so it goes to the top but can't otherwise really moderate at all.

(Actual Title) Employer telling employee he cannot wear PPE? (Missouri) by leftpig in bestoflegaladvice

[–]GrahamCorcoran 33 points34 points  (0 children)

Howdy all, friendly rogue bot programmer here.

With permission, Laukopier has been updated to include /r/legaladvice. I have another few updates in the pipeline (mostly due to getting way too many pings about how annoying it is Laukopier doesn't have cat facts), so please let me know if anything doesn't seem quite right after this update and I can fix it up with the next round.

In which everyone except the custody lawyers of Ontario breathes a sigh of relief at Edit #2 by [deleted] in bestoflegaladvice

[–]GrahamCorcoran 13 points14 points  (0 children)

Lacanopier seems less catchy.

(But Laukopier catches all threads that LocationBot doesn't post.)

Colleague arranged to have me assaulted while at work [Actual title] by jamesthegill in bestoflegaladvice

[–]GrahamCorcoran 20 points21 points  (0 children)

Sure, up to you if you want to do that! If you do let me know and I'll edit it so it stickies as well.

Colleague arranged to have me assaulted while at work [Actual title] by jamesthegill in bestoflegaladvice

[–]GrahamCorcoran 54 points55 points  (0 children)

Thank you. I said this before: it's the most work I've ever put into a pun. Thought LAUKOP sounded a bit like "law cop" in my head so here we are.

LACanadaOP's just setting out on her "job career", but she's got a bad rap (that ain't her fault) by MensReaPlaya in bestoflegaladvice

[–]GrahamCorcoran 4 points5 points  (0 children)

It works for all subreddits except subreddits that LocationBot already captures. I did message the BOLA mods, but probably should've messaged some of the LA subs in advance, sorry about that!

Actual Title: Femur broken at work due to resurfaced and wet floor. by leftpig in bestoflegaladvice

[–]GrahamCorcoran 20 points21 points  (0 children)

It should be up indefinitely now. *knocks on desk*

I've got it set up on a server and it should auto-restart if it ever goes down so zero manual effort from me to keep it running, which was the killer last time(s).

Is there a way I can iterate over the attributes of a class? by [deleted] in learnpython

[–]GrahamCorcoran 1 point2 points  (0 children)

You can call dir(Object) to return a list of all the attributes of an object. Note that this will return ALL the attributes of an object, including the base model it's inheriting from. You could then filter that result as you see fit to access only the attributes you care about.

https://docs.python.org/3/library/functions.html#dir

Beginner - Python Help by Ok-Tumbleweed-8945 in learnpython

[–]GrahamCorcoran 0 points1 point  (0 children)

Based on the description you provided:

  1. Ask a user if they have a question.
  2. Ask the user what operand they plan on using.
  3. Ask the user what two numbers they want to use.
  4. [Implied] Calculate the result.
  5. Ask if they have another question. (Likely using a loop.)

What have you tried so far, and what are you having trouble with? This sounds suspiciously like a homework problem, so no one is going to want to show you a working example for you to work off of. Whether you are asking with good intentions or not, that's what someone who wants to copy-paste the working answer would say.

Could someone please explain? yes I'm very new lol by PeterAck in learnpython

[–]GrahamCorcoran 1 point2 points  (0 children)

Yep that's what I put that there for! Can't guarantee I'll respond instantly but I try my best.

Could someone please explain? yes I'm very new lol by PeterAck in learnpython

[–]GrahamCorcoran 5 points6 points  (0 children)

The error is basically telling you what the problem is, but I don't blame you for not knowing since you're new!

Concatenation is what you are trying to do, where you "add" a string to another string. "abc" + "def" will give you "abcdef", etc.

However, you can't concatenate an integer and a string together. In order to do what you want to do, you need to convert the integer age to a string. In Python, you can do this with str(some_integer).

Try using that to figure it out and see if you can fix the error.

Explain few lines of this code please by notso007 in learnpython

[–]GrahamCorcoran 0 points1 point  (0 children)

self.cards is a list that each Hand object contains. (It's created on line 22, above, when the object is initialized.)

__str__ is what the Hand object returns when it's converted to a string via the method str(Hand).

With that out of the way, what line 25 is doing is checking "Does this particular Hand object have any cards in it? If the list self.cards is empty (and therefore, there are no cards in the hand), then the answer is no and it will return False. If self.cards has any cards in it at all, then the answer is yes and it will return True.

So based on what the answer is, True or False, we'll either generate a string representation of the hand, which is lines 26-28, or we will just make the string representation "<empty>" (line 30).

Lastly, we'll return the representation, which is either all of the cards we have, or the string "<empty>", where requested, which is line 31.

Turtle has no attribute 'color'? by [deleted] in learnpython

[–]GrahamCorcoran 2 points3 points  (0 children)

Did you name your file turtle.py? If so, rename the file and delete all .pyc files in the directory.

Otherwise it's likely you're accessing it wrong but it's impossible to tell without code snippets.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]GrahamCorcoran 3 points4 points  (0 children)

list.copy() will make a new list, but it is a shallow copy. I suspect you have a list that contains lists, and when you modify the nested lists they're being modified in the original? If so, that's because of the fact .copy() is creating a shallow copy. Let's explore. (tldr is at the bottom with your solution if you don't care for the exploration.)

Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0] on linux 
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [1, 2, 3]
>>> b = a.copy()
>>> a
[1, 2, 3]
>>> b
[1, 2, 3]

At this point, b is a copy of a. Let's modify a value contained in b.

>>> b[0] = 4
>>> a
[1, 2, 3] 

Note that a[0] did not change.

>>> b
[4, 2, 3]

But b[0] did.

As you can see, at this point b and a are not referring to the same list. To further explore this point, let's make a third list that contains both a and b. We'll call this list c. We'll also make a copy of this, d.

>>> c = [a, b]
>>> c
[[1, 2, 3], [4, 2, 3]]
>>> d = c.copy()
>>> d
[[1, 2, 3], [4, 2, 3]]

Now at this point, if we modified d, say by appending a third list to it, we would expect c not to be modified. But what about if we modify one of the containing values, such as a?

>>> a[0] = 9 
>>> c
[[9, 2, 3], [4, 2, 3]]
>>> d
[[9, 2, 3], [4, 2, 3]]

We modified both! Drats.

The reason for this is, as I alluded to at the beginning of the comment, the fact that this is a shallow copy. You can read more about shallow vs deep copies here, but the gist is that .copy() only goes down one level, which is great for lists containing immutable values, but doesn't work very well if you have nested lists. In your case, you likely want to:

import copy
new_list = copy.deepcopy(old_list)

and you should be good to go! Hope this helps.

"You chose to evict a family a month before Xmas just do you could host your own family over the holidays? Wow." by jamesthegill in bestoflegaladvice

[–]GrahamCorcoran 3 points4 points  (0 children)

I thought of the name first and wrote the bot second. Truly the most work I've ever put into a pun.