Current Events > ITT: Learning Python

Topic List
Page List: 1 ... 5, 6, 7, 8, 9, 10
SpiritSephiroth
11/11/21 10:58:39 PM
#401:


Okay I did some revision on old code I learnt and realised I've been sticking to old habits. I need to break out of it and try new things.

---
... Copied to Clipboard!
SpiritSephiroth
11/12/21 7:09:03 PM
#402:


Feeling burnt out right now. Might take a break for a while.

---
... Copied to Clipboard!
SomeLikeItHoth
11/13/21 3:38:08 AM
#403:


SpiritSephiroth posted...
Feeling burnt out right now. Might take a break for a while.
It happens. Take a break for a few days and then come back refreshed.

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/13/21 10:30:21 PM
#404:


Yeah I will. Had to do a presentation in class at my language school as well and I did an all-nighter for it. Not to mention some drama started between other classmates...

---
... Copied to Clipboard!
SpiritSephiroth
11/14/21 9:18:11 PM
#405:


Manage to write a bit of code. Gonna continue in the morning.

Also I have another monitor that I can set up. That'll be 3 monitors in total which will be useful. Just gotta buy a mount for it!

---
... Copied to Clipboard!
SomeLikeItHoth
11/15/21 6:06:51 AM
#406:


I only use one monitor! I may upgrade to two eventually.

Just spend the past 3 hours watching Python / HTML videos on Udemy.

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/15/21 9:46:03 PM
#407:


SomeLikeItHoth posted...
I only use one monitor! I may upgrade to two eventually.

Just spend the past 3 hours watching Python / HTML videos on Udemy.

How are they? I've still got a few to go through. Looking towards watching them whenever I travel or in my spare time.

---
... Copied to Clipboard!
SomeLikeItHoth
11/16/21 3:53:05 AM
#408:


Some of these books might be good.

https://www.humblebundle.com/books/python-programming-oreilly-books

SpiritSephiroth posted...
How are they? I've still got a few to go through. Looking towards watching them whenever I travel or in my spare time.
Quite a few of them are really good. I can recommend you some if you'd like.

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/16/21 7:57:10 PM
#409:


SomeLikeItHoth posted...
Some of these books might be good.

https://www.humblebundle.com/books/python-programming-oreilly-books

Quite a few of them are really good. I can recommend you some if you'd like.

I have a good amount from the free ones you posted from before. If its out of them, I'd probably go through the most useful one.

Also just got my mount and mounted my new screens, just need a cable to come in tomorrow and I can finally continue coding!

---
... Copied to Clipboard!
Gwynevere
11/16/21 8:18:14 PM
#410:


I've taken 3 semester's worth of Python, most of it focusing on the VPython/visual python library for Physics

You can get some pretty cool simulations of electromagnetic fields and mass+spring systems going that way

---
A hunter is a hunter...even in a dream
... Copied to Clipboard!
SomeLikeItHoth
11/17/21 6:41:33 AM
#411:


I have not used any of those free ones yet. I only got them cause they were free.

Nice. I've been thinking about dual monitoring now that you're talking about it more. Best Buy has some good deals for Black Friday next week.

---
FAM FOREVER.
... Copied to Clipboard!
ChocoboMog123
11/17/21 2:44:31 PM
#412:


I've been taking a class on scripting in Unix that covers Bash, Awk, Perl, and Python and I managed to find the first code I ever "published" online back in 2003.

x=1
while 1==1:
x=x+1
y=range(1,x)
z=0
q=9
for count in y:
q=x%y
if q==0:
z=z+1
if z<1:
print x

I was in middle school and teaching myself baby steps at the time. I really wish I had real programming classes then, or at least the online resources available now.

---
"You're sorely underestimating the power of nostalgia goggles." - adjl
http://www.smbc-comics.com/comics/20110218.gif
... Copied to Clipboard!
Questionmarktarius
11/17/21 7:10:36 PM
#413:


ChocoboMog123 posted...
while 1==1:
whut
... Copied to Clipboard!
ChocoboMog123
11/17/21 7:25:03 PM
#414:


Questionmarktarius posted...
whut
I was young and wanted to find the highest prime I could. I eventually modified it to search up to the square of the number I was testing. Obviously if I was writing it now, I'd do
while True
;)

---
"You're sorely underestimating the power of nostalgia goggles." - adjl
http://www.smbc-comics.com/comics/20110218.gif
... Copied to Clipboard!
SpiritSephiroth
11/17/21 7:26:41 PM
#415:


ChocoboMog123 posted...
I've been taking a class on scripting in Unix that covers Bash, Awk, Perl, and Python and I managed to find the first code I ever "published" online back in 2003.

x=1
while 1==1:
x=x+1
y=range(1,x)
z=0
q=9
for count in y:
q=x%y
if q==0:
z=z+1
if z<1:
print x

I was in middle school and teaching myself baby steps at the time. I really wish I had real programming classes then, or at least the online resources available now.

I'll be honest I have an idea of what the code means in practice. But the numbers are hurting my head lol

---
... Copied to Clipboard!
Questionmarktarius
11/17/21 7:30:55 PM
#416:


ChocoboMog123 posted...
while True
Infinite loop without a break, continue, or exit in there is pretty naughty.
... Copied to Clipboard!
SomeLikeItHoth
11/18/21 8:02:51 AM
#417:


ChocoboMog123 posted...
I was in middle school and teaching myself baby steps at the time. I really wish I had real programming classes then, or at least the online resources available now.
That's actually really impressive. You should start studying again. Way more resources exist now.

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/18/21 8:01:32 PM
#418:


... Copied to Clipboard!
SomeLikeItHoth
11/19/21 4:20:25 AM
#419:


Udemy is having a Black Friday sale.

https://www.udemy.com/course/the-web-developer-bootcamp/

This is supposedly one of the best courses. I recently have began working my way through it. On course 9 at the moment. I will say I'm enjoying it a lot so far.

---
FAM FOREVER.
... Copied to Clipboard!
1337toothbrush
11/19/21 4:52:06 AM
#420:


I haven't posted here in a while but I've been doing some learning of my own. I'm adding Rust to my repertoire and so far I'm loving it. I'm touched the language here and there in the past, but I've been getting more into it recently. It's such an amazingly well-designed language. It's just... *chef's kiss*. Makes it hard going back to C or C++, especially with with the conveniences of Cargo. I always hated setting up C or C++ projects and dependencies are just hell.

---
... Copied to Clipboard!
SomeLikeItHoth
11/19/21 6:27:53 AM
#421:


1337toothbrush posted...
I haven't posted here in a while but I've been doing some learning of my own. I'm adding Rust to my repertoire and so far I'm loving it.
What method are you using to learn Rust? I'd be interested in learning in the near future. @1337toothbrush

---
FAM FOREVER.
... Copied to Clipboard!
1337toothbrush
11/19/21 9:58:37 AM
#422:


SomeLikeItHoth posted...
What method are you using to learn Rust? I'd be interested in learning in the near future. 1337toothbrush
@SomeLikeItHoth

A mix of "the book": https://doc.rust-lang.org/book/
and
"Rust by Example": https://doc.rust-lang.org/stable/rust-by-example/

Of course a healthy mix of search engine use, too. The effort is mainly driven by me porting a bot written in Go to use Rust instead. Having a defined application with an end goal is extremely useful since it naturally draws out the features I'm looking to use. For example, if I'm working my way through error handling, I look up the section on error handing. From there, sometimes I'll stumble upon other features like pattern matching and enums.

---
... Copied to Clipboard!
SpiritSephiroth
11/19/21 8:07:37 PM
#423:


... Copied to Clipboard!
SpiritSephiroth
11/20/21 10:47:39 PM
#424:


Okay spent all day out today now will code a bit before bed.

---
... Copied to Clipboard!
SomeLikeItHoth
11/21/21 5:32:48 AM
#425:


I watched two lessons from Udemy now I'm going to play Animal Crossing a bit.

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/21/21 11:00:19 PM
#426:


Bump, been doing tutorials mostly too tbh. Will be a while until I have a working code but even then it'll be basic because I'm still terribly bad at this lol

---
... Copied to Clipboard!
toyota
11/22/21 4:25:23 AM
#427:


Anyone mind helping point out where im going wrong.

Im trying to use multiple classes together.

In the example in the book they are working with car batteries and they use the "Battery class" as part of the attributes for ElectricCar then using "my_tesla.battery.describe_battery()" etc to pull up info.


My understand is that "Battery()" allows me to pull up info from the Battery class?

But when I tried something similar in the assignment for admin privileges, I couldnt get the program going unless i put "self" in parentheses? Why doesnt it seem to work without adding 'self' when everything else seems to be written similar to the battery example in the book

When using just Privilege() instead of Privilege(self) i always get the following error:
line 50, in __init__
self.extra_privileges = Privilege()
TypeError: Privilege.__init__() missing 1 required positional argument: 'privileges'

I'm using "user.extra_privileges.show_privileges()" to pull up the info im wanting which im thinking is correct.


... Copied to Clipboard!
SomeLikeItHoth
11/22/21 6:59:05 AM
#428:


@toyota Ahh! Really wish I would have seen this earlier so I could ask you some questions. It has been a while since I've worked with Classes, and I'm a little confused by what it is exactly you're trying to do. But from your second photo on the bottom (and I may be wrong), it seems like you're trying to assign the admin class the entirety of the privilege class. There's a few things that stick out to me but I may be misunderstanding your code as you only posted a snipet.

https://www.reddit.com/r/learnpython/comments/q6pc3j/understanding_self_in_python/hgdbrbw/

I'm not sure if this is what you're looking for but try this

https://stackoverflow.com/questions/51233767/init-missing-1-required-positional-argument-python3?noredirect=1&lq=1

And I also found this.

https://stackoverflow.com/questions/69950513/python-typeerror-init-missing-1-required-positional-argument-privilege

See what those people did and see if it helps. It's from a few years ago but the syntax should be similar.

I also highly suggest reading up on python OOP programming.

https://www.youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc

That mini series helped me understand it a lot.

If you're still having trouble then post your entire code so I can copy it into my terminal and I'll see if I can figure it out.

I can tell you that I have not seen this syntax used before

self.battery = Battery()

so that part does confuse me. What source are you reading from?

---
FAM FOREVER.
... Copied to Clipboard!
1337toothbrush
11/22/21 9:17:08 AM
#429:


The "self" keyword is a way to reference the object itself. This is so that Python knows that you want to reference the object itself (as opposed to a global or function variable). Let me break down what you're doing with the key line: self.extra_privileges = Privilege(self)

Privilege(self) is a call to Privilege's __init__ function, the first parameter of which is self. The __init__ function is special because it indicates how you want objects of that class to be initialized, therefore the self parameter is required so that you can add all the attributes. HOWEVER, this is a parameter that Python automatically passes to that function call. What you're doing here is passing Admin's self, so here's how your function call is really working:

self.extra_privileges = Privilege(Privilege's self, Admin's self)

If you do this: self.extra_privileges = Privilege()
It's really calling: self.extra_privileges = Privilege(Privilege's self)

But you're missing the second parameter (which is privileges)

Since you are assigning privileges to a fixed value, you're not actually using the privileges parameter in __init__ anyway, so you can get rid of that.

---
... Copied to Clipboard!
1337toothbrush
11/22/21 9:30:06 AM
#430:


I'm separating this out to a different post so as to not add more information than necessary to the other one. I want to add something regarding the behavior of "self" and maybe this will help you understand.
After you write:
self.extra_privileges = Privilege()
You can then print out the privileges with:
self.extra_privileges.show_privileges()

As you can see, show_privileges also takes in self. So what's self in this case? It's self.extra_privileges and you can explicitly show this by calling:
Privilege.show_privileges(self.extra_privileges)

That is equivalent. Also, if you create an Admin object, you can call the same function like so:
admin = Admin("first name", "last name", 69, "username")
admin.extra_privileges.show_privileges()

Or, like shown before: Privilege.show_privileges(admin.extra_privileges)

---
... Copied to Clipboard!
toyota
11/22/21 9:31:21 AM
#431:


oic so the line

class Privilege:
"""Show privileges of an Admin account"""
def __init__(self, privileges):

didnt really need the privileges paramater there and could have been just written as
def __init__(self): ?

when i wrote it that way it seemed to work as i was expecting. Maybe the battery example in the main text book threw me off as it was actually being used.

This chapter is definitely the hardest so far and seems there are a lot of stuff i need to conceptualize better. Whats the best way to upload my code for the little assignments in the future if I need to ask more questions?

... Copied to Clipboard!
1337toothbrush
11/22/21 9:35:58 AM
#432:


In the battery example, they're actually using that parameter and (this is key), they give that parameter a default value (battery_size=75) so that's why you don't have to pass in your own value, it'll pass 75 for you.

---
... Copied to Clipboard!
Questionmarktarius
11/22/21 10:13:16 AM
#433:


SomeLikeItHoth posted...
I can tell you that I have not seen this syntax used before

self.battery = Battery()

so that part does confuse me. What source are you reading from?
Yeah, this. In most languages I know of, this statement says "assign a value to self.battery equal to whatever the Battery function returns."

Probably should be self.battery = new Battery(), which means "create a Battery object with default attributes and assign it to self.battery"

... Copied to Clipboard!
1337toothbrush
11/22/21 12:37:13 PM
#434:


Questionmarktarius posted...
Yeah, this. In most languages I know of, this statement says "assign a value to self.battery equal to whatever the Battery function returns."

Probably should be self.battery = new Battery(), which means "create a Battery object with default attributes and assign it to self.battery"
No, Python doesn't use the keyword "new" to instantiate an object. In fact, I don't think it uses "new" as a keyword at all.

---
... Copied to Clipboard!
SpiritSephiroth
11/22/21 8:21:15 PM
#435:


Thanks for those posts. Keeping these in my notes for future references.

---
... Copied to Clipboard!
1337toothbrush
11/22/21 11:33:24 PM
#436:


toyota posted...
didnt really need the privileges paramater there and could have been just written as
def __init__(self): ?
Correct.

toyota posted...
Whats the best way to upload my code for the little assignments in the future if I need to ask more questions?
http://codepad.org/

https://ideone.com/l/python-3

Either of those is fine.

---
... Copied to Clipboard!
SpiritSephiroth
11/23/21 10:15:35 PM
#437:


I can get python on phone and tablet right? Been trying to install it but I think my tablet is too damn old tbh. Need a new one.

---
... Copied to Clipboard!
SpiritSephiroth
11/24/21 9:28:16 PM
#438:


I need to stick to on course and stop moving about. I'll start writing notes again like I did last time and see how it goes.

---
... Copied to Clipboard!
1337toothbrush
11/25/21 2:41:37 AM
#439:


Why would you want to do Python development on a phone or tablet? Do you have keyboard for mobile devices? If it's just small tests, you could use an online Python interpreter like https://ideone.com/l/python-3

---
... Copied to Clipboard!
DarthDemented
11/25/21 2:52:14 AM
#440:


have you mastered a silly walk? have you been able to tell the diffirence between a dead parrot and on simply pining for the fjords? have you become an upper class twit of the year? then keep studying boy.

---
... Copied to Clipboard!
SomeLikeItHoth
11/25/21 8:59:01 PM
#441:


Happy Thanksgiving!

---
FAM FOREVER.
... Copied to Clipboard!
SpiritSephiroth
11/25/21 9:13:47 PM
#442:


1337toothbrush posted... Why would you want to do Python development on a phone or tablet? Do you have keyboard for mobile devices? If it's just small tests, you could use an online Python interpreter like https://ideone.com/l/python-3

Ohhh thanks! Yeah when I travel or commute I'd want to spend the time with something productive along with listening to Spotify.

SomeLikeItHoth posted...
Happy Thanksgiving!

Happy Thanksgiving to you guys!

---
... Copied to Clipboard!
SpiritSephiroth
11/26/21 8:32:20 PM
#443:


Got some code done, was playing with the random function. Been chilling.

---
... Copied to Clipboard!
SomeLikeItHoth
11/27/21 5:02:42 AM
#444:


I'm just continuing my Udemy courses. Haven't made anything interesting for a while. Hopefully that changes soon when I get farther in them.

---
... Copied to Clipboard!
SpiritSephiroth
11/27/21 8:49:49 PM
#445:


I should compile a document with all the sources shared here sometime before this topic reaches its end. Once I do I'll share it with anyone here who would like it too.

Edit: Or I'll just make a new topic with the document.

---
... Copied to Clipboard!
SomeLikeItHoth
11/28/21 3:38:38 AM
#446:


Could start on the document now and have it ready for the next topic, then post it in the first 1-2 posts.

---
... Copied to Clipboard!
SpiritSephiroth
11/28/21 9:26:11 PM
#447:


SomeLikeItHoth posted...
Could start on the document now and have it ready for the next topic, then post it in the first 1-2 posts.

Yeah I'll do that!

---
... Copied to Clipboard!
SomeLikeItHoth
11/29/21 5:56:55 AM
#448:


Just finished my nightly lesson. Took some NyQuil cause my throat hurts and now I'm getting sleepy.

---
... Copied to Clipboard!
SpiritSephiroth
11/29/21 8:49:40 PM
#449:


Got another interview today so I'll continue after that.

---
... Copied to Clipboard!
SpiritSephiroth
11/30/21 8:12:28 PM
#450:


Been having a lot of interviews lately. Everytime I focus on that my attention span suffers afterwards. I don't have anymore for now so I can concentrate on my own stuff.

---
... Copied to Clipboard!
Topic List
Page List: 1 ... 5, 6, 7, 8, 9, 10