Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
indentation tips
#1
I am not a programmer, that is easy to see. I have a lot of trouble with the indentation. I write little routines using the idle3 environment. I just got this working, to put photos in an excel file.

Idle3 is set to 4 spaces = 1 tab, but when I press tab, I often seem to get more than 4 spaces. This below works for me on my computer, in the idle3 shell and in a terminal. If I change it at all, my little routine does not run, or does not do what I want.

If you have a link to some advice on indentation, I would like to read it! Thanks!

for sheet in sheets:
	activeDirectory = pathToPhotos + sheet + '/'
	print('the active photo directory is ' + activeDirectory)
	for filename in os.listdir(activeDirectory):
			if not (filename.endswith('.jpg')):
				continue
			for rowNum in range(beginRow, wb[sheet].max_row + 1):
				getName = filename.split('.')
				if (getName[0] == wb[sheet].cell(row=rowNum, column=col).value):
					print('found the name! Name is: %s ' % (getName[0]))
					print('Putting pic in row ' + str(rowNum))
					img = Image(activeDirectory + filename)
					wb[sheet].add_image(img, 'A' + str(rowNum))
Reply


Messages In This Thread
indentation tips - by Pedroski55 - Sep-14-2018, 09:35 AM
RE: indentation tips - by Gribouillis - Sep-14-2018, 10:11 AM
RE: indentation tips - by gruntfutuk - Sep-14-2018, 01:24 PM
RE: indentation tips - by Pedroski55 - Sep-15-2018, 10:55 PM
RE: indentation tips - by Gribouillis - Sep-16-2018, 10:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Any tips to how to find out values? nevlindan 1 739 Apr-27-2023, 09:14 PM
Last Post: deanhystad
  coding improvement tips vaisesumit29 1 1,839 Mar-10-2019, 05:09 PM
Last Post: stullis
  Tips for CLI program with Keybinding system pedropessoa 2 2,609 Nov-21-2018, 09:59 AM
Last Post: Gribouillis
  Organizing tips Demini 1 2,239 Feb-10-2018, 05:32 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020