User Profile
Collapse
-
Very neat Michael -
That's what I thought ... since I don't anticipate anything more than a few thousands of files-lines (for the properties and not instances .....well, looking at about 10 to 20 instances at most). I'd probably go the 'class' way. I don't really plan to hold much in memory anyway, so the class object overhead shouldn't be significant.Leave a comment:
-
-
Modifying Sean's Code:
Code:#!/bin/python3 def countLetters(line, letter): ret = 0 for character in line: if character == letter: ret += 1 return ret alphabet = 'abcdefghijklmnopqrstuvwxyz' #you can automate this using ascii codes too for line in open("file.txt",'r'): line = line.strip() #remove trailing spaces print (line)
Leave a comment:
-
And what if you plan to do more than list the books? Say, be able to access each book's properties eg. chapters, publisher, author, genre, revisions. Would a dictionary still do?
Wouldn't it be better to have a list of object 'books' where the enumeration serves as a serial/key. eg book[1],book[2] ....book[n], each managing its own little db? or is SQL better off at this kind of thing?
Just thinking ...:o, Like I said, its...Leave a comment:
-
automatic python variables
I'm looking for ways to create variables in python3 as needed. E.g
book1 = book(name1) # book is a class
book2 = book(name2)
book3 = book(name3)
book4 = book(name4)
book5 = book(name5):book-n = book(name-n)
:
:
V
I have the names of the book in a list but want to load those into class instances to take advantage off OOP. I could assign five to ten class objects like above... -
-
Threading Or Multiprocessing???
This issue is probably discussed before. However, I can still use a little insight. I am a python beginner looking to develop a small client/server suite. The clients will reside in different PCs across a LAN and their job is to recieve a file (say, a .txt file) from the Server and open it with local copies of another application (say,Gnote ... I use Linux). The clients interact with their local Gnote and report states/progress to the Server....
No activity results to display
Show More
Leave a comment: