Re: [Tutor] How to skip a single file when using shutil.make_archive()

2015-08-14 Thread Peter Otten
Anthony Papillion wrote: > I'm creating an archive of a directory using shutil.make_archive and need > to skip a single file if it is present in that directory. Is there a way > to do this or should I be looking to ZipFile to meet this need? I should not post this, especially on a tutor list, but

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Bill Allen
On Fri, Aug 14, 2015 at 3:06 PM, Alan Gauld wrote: > > That's the problem right there. You should never kick of an event handler > that takes a long time to run. Either: > 1) Kick of a separate thread to do the back end processing > 2) break the function into short chunks and use a timer > (after

Re: [Tutor] try and file existence

2015-08-14 Thread Steven D'Aprano
On Fri, Aug 14, 2015 at 06:28:09PM -0700, Clayton Kirkwood wrote: > try: > fp = open( user_preferences ) > except( PermissionError ): > else: > with open(user_preferences ) as f: try: fp = open(user_preferences) except (IOError, OSError) as e: handle_error() else: with fp as f

Re: [Tutor] try and file existence

2015-08-14 Thread Mark Lawrence
On 15/08/2015 02:28, Clayton Kirkwood wrote: try: fp = open( user_preferences ) except( PermissionError ): You need a pass statement here if you don't intend doing anything with the error, but see my comments at the bottom. else: with open(user_preferences ) as f: I originally on

Re: [Tutor] try and file existence

2015-08-14 Thread Cameron Simpson
On 14Aug2015 18:28, Clayton Kirkwood wrote: try: fp = open( user_preferences ) except( PermissionError ): else: with open(user_preferences ) as f: I originally only had the bottom open statement. Ran but file didn't exist, and my run failed with file doesn't exist. I figured I'd check to

[Tutor] try and file existence

2015-08-14 Thread Clayton Kirkwood
try: fp = open( user_preferences ) except( PermissionError ): else: with open(user_preferences ) as f: I originally only had the bottom open statement. Ran but file didn't exist, and my run failed with file doesn't exist. I figured I'd check to see if the file existed. This is one of those

Re: [Tutor] SQLite, Python and SQL injection attacks

2015-08-14 Thread Cameron Simpson
On 14Aug2015 13:40, boB Stepp wrote: I was just looking at the sqlite3 docs at https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3 and found the following cheery news: "Usually your SQL operations will need to use values from Python variables. You shouldn’t assemble y

Re: [Tutor] How to skip a single file when using shutil.make_archive()

2015-08-14 Thread Anthony Papillion
Many thanks Ben! That is exactly what I was looking for and it's super easy. Thanks again! On Fri, Aug 14, 2015 at 5:36 PM, Ben Finney wrote: > Anthony Papillion writes: > > > I'm creating an archive of a directory using shutil.make_archive and > > need to skip a single file if it is present in

Re: [Tutor] How to skip a single file when using shutil.make_archive()

2015-08-14 Thread Ben Finney
Anthony Papillion writes: > I'm creating an archive of a directory using shutil.make_archive and > need to skip a single file if it is present in that directory. Is > there a way to do this or should I be looking to ZipFile to meet this > need? You can create a hierarchy of files the way you wan

[Tutor] How to skip a single file when using shutil.make_archive()

2015-08-14 Thread Anthony Papillion
Hello Everyone, I'm creating an archive of a directory using shutil.make_archive and need to skip a single file if it is present in that directory. Is there a way to do this or should I be looking to ZipFile to meet this need? Thanks ___ Tutor maillist

Re: [Tutor] SQLite, Python and SQL injection attacks

2015-08-14 Thread Emile van Sebille
On 8/14/2015 11:40 AM, boB Stepp wrote: I was just looking at the sqlite3 docs at https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3 and found the following cheery news: "Usually your SQL operations will need to use values from Python variables. You shouldn’t assemb

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Alan Gauld
On 14/08/15 17:50, Alex Kleider wrote: Might it be possible to insert the code that posts the 'label' into the beginning of the function's code block? That doesn't work because the GUI won't redraw itself until the event handler finishes and returns control to the Tkinter event loop. That's wh

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Alan Gauld
On 14/08/15 17:32, Bill Allen wrote: I am working in Tkinter. The scenario is that I click a button that starts a function running. No problem there. However, the function may take some time to run That's the problem right there. You should never kick of an event handler that takes a lon

Re: [Tutor] SQLite, Python and SQL injection attacks

2015-08-14 Thread Alan Gauld
On 14/08/15 19:40, boB Stepp wrote: "Instead, use the DB-API’s parameter substitution. Put ? as a placeholder wherever you want to use a value, and then provide a tuple of values as the second argument to the cursor’s execute() method..." This is not a Sqlite issue its true of any database.

[Tutor] SQLite, Python and SQL injection attacks

2015-08-14 Thread boB Stepp
I was just looking at the sqlite3 docs at https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3 and found the following cheery news: "Usually your SQL operations will need to use values from Python variables. You shouldn’t assemble your query using Python’s string operat

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Laura Creighton
In a message of Fri, 14 Aug 2015 11:32:59 -0500, Bill Allen writes: >I am working in Tkinter. The scenario is that I click a button that >starts a function running. No problem there. However, the function may >take some time to run and I do not want the user to be worried. I am >wanting to

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread boB Stepp
On Fri, Aug 14, 2015 at 11:32 AM, Bill Allen wrote: > > I am working in Tkinter. The scenario is that I click a button that > starts a function running. No problem there. However, the function may > take some time to run and I do not want the user to be worried. I am > wanting to immediate

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Alex Kleider
On 2015-08-14 09:32, Bill Allen wrote: I am working in Tkinter. The scenario is that I click a button that starts a function running. No problem there. However, the function may take some time to run and I do not want the user to be worried. I am wanting to immediately set a label when

[Tutor] cannot get a label message to display immediately

2015-08-14 Thread Bill Allen
I am working in Tkinter. The scenario is that I click a button that starts a function running. No problem there. However, the function may take some time to run and I do not want the user to be worried. I am wanting to immediately set a label when the function starts to say "Please Wait".

Re: [Tutor] Does composition only work with particular instances of objects?

2015-08-14 Thread boB Stepp
On Fri, Aug 14, 2015 at 2:50 AM, Alan Gauld wrote: > > So, unless the book explains why this is bad practice and > goes on to show a good example, I must conclude its a very > bad example. I found the errata pages for the book (http://www.oreilly.com/catalog/errata.csp?isbn=0636920028659) and a J

Re: [Tutor] How to effectively use a Student class with SQLite [Was Re: How to design object interactions with an SQLite db?]

2015-08-14 Thread boB Stepp
On Fri, Aug 14, 2015 at 4:49 AM, Laura Creighton wrote: > You've found the 'variety of parents' problem. Listing the parents' > names will only let your wife know she has the correct student if she > habitually thinks of the parent names when she thinks of the student. This came to mind because

Re: [Tutor] Searching through files for values

2015-08-14 Thread Alan Gauld
On 14/08/15 05:07, Jason Brown wrote: for file_list in filenames: with open(file_list) as files: for items in vals: for line in files: Others have commented on your choice of names. I'll add one small general point. Try to match the plurality of your names to the nat

Re: [Tutor] How to effectively use a Student class with SQLite [Was Re: How to design object interactions with an SQLite db?]

2015-08-14 Thread Laura Creighton
In a message of Thu, 13 Aug 2015 23:42:33 -0500, boB Stepp writes: >Many of my wife's students do have their own email accounts, but, >alas, not all of them. I have not totally thought this through yet, >but the student data will include their parents' names and some of >their data. But it will b

Re: [Tutor] Searching through files for values

2015-08-14 Thread Peter Otten
Jason Brown wrote: > (accidentally replied directly to Cameron) > > Thanks, Cameron. It looks like that value_file.close() tab was > accidentally tabbed when I pasted the code here. Thanks for the > suggestion > for using 'with' though! That's will be handy. > > To test, I tried manually spec

Re: [Tutor] How to effectively use a Student class with SQLite [Was Re: How to design object interactions with an SQLite db?]

2015-08-14 Thread Alan Gauld
On 14/08/15 03:16, boB Stepp wrote: Yes, that's a standard problem in any HR type application. Names suck as database keys. But names are how humans interact. HR = Human Resources? Sorry, yes. Anything involving people. the case of students with duplicate names, she might forget to enter o

Re: [Tutor] Does composition only work with particular instances of objects?

2015-08-14 Thread Alan Gauld
On 14/08/15 05:31, boB Stepp wrote: I was looking at an example illustrating composition from the book, "Introducing Python" by Bill Lubanovic on p. 140: class Bill: def __init__(self, description): self.description = description class Tail: def __init__(self,

Re: [Tutor] Searching through files for values

2015-08-14 Thread Jason Brown
(accidentally replied directly to Cameron) Thanks, Cameron. It looks like that value_file.close() tab was accidentally tabbed when I pasted the code here. Thanks for the suggestion for using 'with' though! That's will be handy. To test, I tried manually specifying the list: vals = [ 'value1',