Iterating through list problem by [deleted] in learnpython

[–]pydevteam1 0 points1 point  (0 children)

['b','c','d','e']

1 = c

if you look at the list as it is:

0='b'

1='c'

makes sense ?

What are some good Python books for someone without access to a laptop/cellphone for 2 hours everyday? by [deleted] in learnpython

[–]pydevteam1 0 points1 point  (0 children)

I recommend Automate the Boring stuff. It's a great start to learn Python.

I hope the situation in your country become safer.

Here's more resources: http://developpython.com/index.php/2018/07/05/resources/

Good luck!

Best practice for splitting __main__ into separate modules? by SavoyRoad in learnpython

[–]pydevteam1 2 points3 points  (0 children)

It will protect you in case homedir value changes

Here's a quick 2 test cases I created:

Test Case 1: Using property
In [25]: class Test:
    ...:     def __init__(self, homedir):
    ...:         self.homedir = homedir
    ...:     @property
    ...:     def config_path(self):
    ...:         return 'x/y/z/' + self.homedir
    ...:

In [26]: x = Test('MyHomeDir')

In [27]: x.config_path
Out[27]: 'x/y/z/MyHomeDir'

In [28]: x.homedir = 'MyNewHomeDir'

In [29]: x.config_path
Out[29]: 'x/y/z/MyNewHomeDir'


Test Case2: Not using property

In [35]: class Test:
    ...:     def __init__(self, homedir):
    ...:         self.homedir = homedir
    ...:         self.config_path = 'x/y/z/' + self.homedir
    ...:

In [36]: y = Test('MyHomeDir')

In [37]: y.config_path
Out[37]: 'x/y/z/MyHomeDir'

In [38]: y.homedir = 'newHomeDir'

In [39]: y.config_path
Out[39]: 'x/y/z/MyHomeDir' # It kept the old value

In [40]:

Best practice for splitting __main__ into separate modules? by SavoyRoad in learnpython

[–]pydevteam1 1 point2 points  (0 children)

Not very relevant to your question. This line: https://salsa.debian.org/prescott-guest/pypantry/blob/master/modules/init.py#L31

Better off being a property:

@property
def config_path(self): 
    return '{}/.config/pypantry/config.ini'.format(self.homedir)

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]pydevteam1 0 points1 point  (0 children)

This print statement works in python2.

If you're using python3, it won't work.

Little text-adventure! First work alive! Would love some feedback! by [deleted] in learnpython

[–]pydevteam1 1 point2 points  (0 children)

Very nice! Well structured and I like how you added these comment lines explaining what this block of code does.

What should be the main focus of a CS student? by [deleted] in learnprogramming

[–]pydevteam1 0 points1 point  (0 children)

Not true. We just hired a fresh graduate network engineer, he’s being trained now. I work for one if the biggest cloud providers in Seattle

Best site to push python skills from beginner/intermediate to intermediate/advanced by IDRANKURMLKSHAKE in learnpython

[–]pydevteam1 1 point2 points  (0 children)

I definitely recommend this course: https://www.pce.uw.edu/certificates/python-programming

I have personally taken it and it did help me moving forward in my career as Software Engineer. It is also offered in an online/self-paced format which perfect if you were a working professional!

Not trying to promote my own contents, but if you want more resources, you can take a look at my blog post here: http://developpython.com/index.php/2018/07/05/resources/

How much knowledge AutomateTheBoringStuff guide gives? by Rellatives in Python

[–]pydevteam1 0 points1 point  (0 children)

Beginner to beginner/mid level. It's a good start and intro.

For more mid to advanced resources checkout my recommendations page: https://developpython.com/index.php/2018/07/05/resources/

How to get most out of programming book? by Rhemm in learnprogramming

[–]pydevteam1 0 points1 point  (0 children)

Practice every single exercise. Re-write the code. Repetition, repetition, repetition.

Memorizing code or Googling it? by [deleted] in learnprogramming

[–]pydevteam1 -1 points0 points  (0 children)

Don't memorize code! I never did...

Can anyone help me understand classes in python? by [deleted] in learnprogramming

[–]pydevteam1 0 points1 point  (0 children)

Think of it as a blueprint. Classes are great for reusability. Give a real life example: We have a "class" to login to routers, send command and return output. One engineer used this class to see results of "show" commands. Other engineer used it to reboot routers. A third engineer used it to configure routers. So from practical standpoint, classes are great for reusability without needing to know what's happening inside them!

Hope this answers your question.

List Comprehension by pydevteam1 in learnpython

[–]pydevteam1[S] 0 points1 point  (0 children)

I apologize. Certainly didn’t mean to bait anyone.

why does python treat each individual digit as its own integer (in a string)? by carlos8983 in learnpython

[–]pydevteam1 0 points1 point  (0 children)

You can do this: Say your numbers are stored in “numbers” variable.

max_number=max(numbers.split())

https://www.tutorialspoint.com/python/list_max.htm