Re: [Tutor] threading in python 2.7 - 2nd version

2015-01-05 Thread Rance Hall
Simpson wrote: > On 04Jan2015 23:19, Rance Hall wrote: > >> Thanks to the advice from Joseph and Alan, I hacked a quick python script >> which demonstrates my problem more accurately. >> Its not board specific as was my last code. This sample works the same on >&g

[Tutor] threading in python 2.7 - 2nd version

2015-01-04 Thread Rance Hall
Thanks to the advice from Joseph and Alan, I hacked a quick python script which demonstrates my problem more accurately. Its not board specific as was my last code. This sample works the same on my pcduino as it does on my desktop. #threading problem example import threading import sys impor

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
On Fri, Jan 2, 2015 at 3:18 PM, Alan Gauld wrote: > On 02/01/15 20:17, Rance Hall wrote: > >> I bought myself a pcduino 3 nano development board for Christmas and >> started picking up python again after a long forced hiatus. The board >> runs >> Ubuntu Preci

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
First, thanks Joseph for taking the time to reply. My comments interspersed below: On Fri, Jan 2, 2015 at 2:39 PM, Joseph Lee wrote: > Hi, > Answers are below. > > -Original Message- > From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On > Be

[Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Working with development boards has me navigating the inner working of python threading and I find myself at a loss. My current project i

Re: [Tutor] going big (in terms of code base)

2011-11-14 Thread Rance Hall
On Mon, Nov 14, 2011 at 5:01 PM, Wayne Werner wrote: > On Mon, Nov 14, 2011 at 2:49 PM, Rance Hall wrote: >> >> GUIs add a lot of code bloat and lots of chances for bugs that have >> nothing to do with the logic of your program. > > I'm not sure that I would en

Re: [Tutor] interesting behaviour with postional output

2011-11-14 Thread Rance Hall
On Mon, Nov 14, 2011 at 3:16 PM, Joel Goldstick wrote: > So, as was stated, best to use mono space if you are writing to a terminal. > If you are writing web pages, of course you have lots of formatting options > > -- > Joel Goldstick One option I've used in the past for issues such as this is e

[Tutor] going big (in terms of code base)

2011-11-14 Thread Rance Hall
Ive just finished a major project with python and database connectivity. It was cool, and the friend I wrote it for was happy. It was strictly a terminal based app. To GUI of any sort. Because I like to write cross platform apps as much as possible, tools like python and os common widget sets l

[Tutor] Fwd: sifting through a long program

2011-11-10 Thread Rance Hall
I accidentally replied just to the OP, so I'm forwarding my comments to the list for the record. -- Forwarded message -- From: Rance Hall Date: Thu, Nov 10, 2011 at 1:36 PM Subject: Re: [Tutor] sifting through a long program To: Nathaniel Trujillo On Thu, Nov 10, 2011

Re: [Tutor] Progress Bar

2011-11-08 Thread Rance Hall
On Tue, Nov 8, 2011 at 9:42 AM, Nikunj Badjatya wrote: > Hi All, > I am writing an installer in Python and Powershell which will be used to > install Virtual Machines at specific locations. > The main script is in Python and main.py inturn calls Powershell scripts > (.PS1). > It is complete consol

[Tutor] OT: Drag and Drop GUI IDE ideas

2011-07-21 Thread Rance Hall
I know this is OT and I am sorry, but the readers of the list are some of the best to judge my problem. And it is about learning to code, just not python specifically. The MIS department at UNK is looking to create a course in business app development. The course will be about the app life cycl

Re: [Tutor] Graphic interface

2011-05-10 Thread Rance Hall
On Tue, May 10, 2011 at 7:41 AM, louis leichtnam wrote: > Hello, > I'm trying to build a graphic interface, with button, radiobutton, enter > text area etc. > Does anyone have an idea or a source code for this? > Thank you, > Louis How you do this exactly depends on a number of things you don't s

Re: [Tutor] validating user input

2011-04-23 Thread Rance Hall
On Sat, Apr 23, 2011 at 6:38 PM, Alan Gauld wrote: > > "Rance Hall" wrote > >> Ok, so I have this code that is working, but does little to validate >> user input and I don't quite yet understand that process yet. >> >> so given the following functi

[Tutor] validating user input

2011-04-23 Thread Rance Hall
Ok, so I have this code that is working, but does little to validate user input and I don't quite yet understand that process yet. so given the following function: def buildmenu(menuchoices): for i, option in enumerate(menuchoices, 1): print('%s. %s' % (i, option)) menuchoice = in

Re: [Tutor] working with strings in python3

2011-04-19 Thread Rance Hall
On Mon, Apr 18, 2011 at 9:50 PM, Marc Tompkins wrote: > On Mon, Apr 18, 2011 at 6:53 PM, Rance Hall wrote: > >> >> I'm going to go ahead and use this format even though it is deprecated >> and then later when we upgrade it I can fix it. >> > And there you ha

Re: [Tutor] working with strings in python3

2011-04-18 Thread Rance Hall
On Mon, Apr 18, 2011 at 8:10 PM, Marc Tompkins wrote: > On Mon, Apr 18, 2011 at 5:17 PM, Rance Hall wrote: >> >> Ok so I know what I am doing is deprecated (or at least poor form) but >> the replacement must be awkward cause I'm not getting it. >> >> >>

[Tutor] working with strings in python3

2011-04-18 Thread Rance Hall
Ok so I know what I am doing is deprecated (or at least poor form) but the replacement must be awkward cause I'm not getting it. so this is in a cli based program designed to print status messages to the terminal on a linux box. pseudo code: message = "Bah." if test: message = message + "

[Tutor] data validation logic

2011-04-16 Thread Rance Hall
Hey gang: I need some help trying to pythonize (sp?, if this is even a word?) an idea. I'd like to define a datavalidation function that returns true if data is valid, and false if it isn't. Here is the clincher. the logic of the data validator needs to be able to handle different types of dat

[Tutor] finding directory of self

2011-03-28 Thread Rance Hall
I had been doing this under windows: import os import sys osname = os.name pathtocfg = os.path.dirname(sys.argv[0]) configfileloc = os.path.abspath(pathtocfg) os.chdir(configfileloc) to set the directory of all subsequent file lookups in a script. It worked underwindows because the shortcuts ha

[Tutor] Installing python3.2 from source on Centos 5.5

2011-03-26 Thread Rance Hall
I thought I had successfully installed python3.2 parallel to the python2.x that is required by Centos. Im getting error messages from python scripts indicating that the _ssl module is not installed. I thought that this would be installed by default, but apparently you need to have -with-ssl in th

Re: [Tutor] script conversion windows -> linux error

2011-03-25 Thread Rance Hall
On Fri, Mar 25, 2011 at 1:54 PM, Walter Prins wrote: > > > On 25 March 2011 18:26, Rance Hall wrote: >> >> config_version =  config.get('versions','configver',0) >> >> This line fails under 3.2 Linux with the error message: >> >>

[Tutor] script conversion windows -> linux error

2011-03-25 Thread Rance Hall
I wrote a script on a windows box for python 3.1 after a meeting with the client for this project we agreed to port it to Linux so that I could make use of enscript and ps2pdf to email customers documents right from the script. Client uses a Centos server so I did some reading and installed pytho

Re: [Tutor] SMS to URL

2011-02-10 Thread Rance Hall
On Wed, Feb 9, 2011 at 4:08 AM, Dipo Elegbede wrote: > Hi peeps, > I am trying to write a code such that i can send an sms to a specific url > from my phone and get a reply back from the url. > I want the reply to be the content of the url I send to; what modules would > you advice. > I am testing

Re: [Tutor] Homework and the Tutor list

2011-02-02 Thread Rance Hall
On Wed, Feb 2, 2011 at 10:53 AM, Jerry Hill wrote: > > I don't think that's true at all.  I think people here are happy to > help, including by posting working, efficient, code.  What we try to > avoid is having students come here with their assignments and have us > do their schoolwork for them.

[Tutor] gui coding

2010-12-13 Thread Rance Hall
When I learned FORTRAN years ago they didn't teach us OOP or what I like to call Class based programming. since then I've sort of always fallen back to be a procedural programmer with lots of functions. Python and the tkinter (Tkinter on Versions < 3) seem like a great way to write cross platform

[Tutor] updating databases with null values

2010-12-09 Thread Rance Hall
I have a set of questions that ask about a customers name, address, email, etc. some of these values are allowed to be null, and others aren't. Some are required to have specific formats when they aren't null. I'm happy with the code Ive written and its question asking routine, but I need help u

Re: [Tutor] Newline

2010-12-03 Thread Rance Hall
Ava: On an old typewriter when you slapped that mechanical arm two separate but related things happened. 1) the page advanced to the next line of text. 2) the carriage was returnedt to the beginning of the line of text. If you were careful about the way you slapped that mechanical arm, you could

[Tutor] printing in python 3.x

2010-12-02 Thread Rance Hall
I've been working on this cli based python 3.x app for a friends shop. So far, everything is working well. We are now ready to start development on a new module of my code. The shop is a repair shop, and I've already done the code for client management and employee management and all the framewo

Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread Rance Hall
On Mon, Nov 29, 2010 at 8:21 PM, John Smith wrote: > > On 11/29/2010 5:56 PM, Emile van Sebille wrote: > (snip) >> >> Hmmm... any chance you don't have administrative rights on the account >> performing this? I never got to Win7 (having stopped at XP) but I know >> it's got a reputation for excess

[Tutor] string case manipulation in python 3.x

2010-11-27 Thread Rance Hall
I need to do some case manipulation that I don't see in the documented string functions. I want to make sure that user input meets a certain capitalization scheme, for example, if user input is a name, then the first letter of each word in the name is upper case, and the rest are lower. I know ho

[Tutor] for loops when there is only one row in the result - is there an alternative?

2010-11-25 Thread Rance Hall
Im using the py-postgresql module (docs here: http://python.projects.postgresql.org/docs/1.0/) in a python 3.1 environment to connect to my database. so far everything is working, but I'm having trouble understanding the structure of the variable returned by a select statement Generally you have

[Tutor] if syntax expression help

2010-11-25 Thread Rance Hall
I have a user entered variable that I need to check to see if they entered one of the two legal values. But I only need to check this if one other fact is true. we have a variable called "mode" whose value is either "add" or "edit" based on how we where called. we have a userentry variable tie

[Tutor] validating user input for cli app

2010-10-07 Thread Rance Hall
I have the following scenario, during a cli app a function is called whose purpose is to get enough info from user to create a database record. Clearly the input values need to be validated. How do I handle the situation where validation fails, but the answer to the question is required. so far

Re: [Tutor] Operating in Place

2010-09-28 Thread Rance Hall
On Tue, Sep 28, 2010 at 3:03 PM, Corey Richardson wrote: >  Hello tutors. > > I hate doing this: >            string = string.lower() > > Is there a way to do it without the "string =" part? Thanks. > I suppose the best answer is it depends on what you are doing with string after you do string.lo

[Tutor] generating formatted output

2010-09-26 Thread Rance Hall
My app will be printing a series of documents that are the same each time the doc is printed with the exception of the variables. Sort of a MailMerge if you will. It seems to me that the easiest approach is to create a series of text files with the layout and placeholders I need (again much like

[Tutor] Windows Printing, Round 2

2010-09-23 Thread Rance Hall
Again I'm referencing Tim Golden from http://timgolden.me.uk/python/win32_how_do_i/print.html This code block is relevant: import os, sys import win32print printer_name = win32print.GetDefaultPrinter () # # raw_data could equally be raw PCL/PS read from # some print-to-file operation # if sy

Re: [Tutor] Windows printing

2010-09-23 Thread Rance Hall
On Thu, Sep 23, 2010 at 3:40 AM, Tim Golden wrote: > On 23/09/2010 07:30, Rance Hall wrote: >> >> >> Tim's how-to is likely not for my version of python (mine is 3.1) >> since some of his command fail on my system because mine wants options >> or paramet

[Tutor] Windows printing

2010-09-22 Thread Rance Hall
I'm using this page as a reference: http://timgolden.me.uk/python/win32_how_do_i/print.html I'm able to print to the default printer ok, but I can't seem to find out how to get to pick the printer I want to use. This is from a CLI app, so there is no gui. win32print seems like it has everything

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Thu, Sep 16, 2010 at 11:21 AM, Joel Goldstick wrote: > > > On Thu, Sep 16, 2010 at 11:46 AM, Rance Hall wrote: >> >> On Thu, Sep 16, 2010 at 9:24 AM, Joel Goldstick >> wrote: > This line is illustrative: > >>  13 for i in list[start:start+pagesiz

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Thu, Sep 16, 2010 at 9:24 AM, Joel Goldstick wrote: > I typed in this: > > >   3 l = [] >   4 >   5 for i in range(0,10): >   6 l.append(i+1) >   7 >   8 for i in range(0,10): >   9 print ('%s. %s' % (i, l[i])) >  10 >  11 def paginate_stuff(list, start): >  12 pagesize = 2 >  13   

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Wed, Sep 15, 2010 at 11:33 PM, bob gailer wrote: >  On 9/16/2010 12:05 AM, Rance Hall wrote: >> Thanks guys for replying, looks like I do have a bug in my code, but its not where I thought it was. Must have been up too late last night. The code I provided in my OP does work (w

[Tutor] working with empty lists

2010-09-15 Thread Rance Hall
Im working on a little piece of test code to test an idea for a larger script. Here is what I've got so far: l = [] for i in range(0,10) l.append(i) for i in range(0,10) print('%s. %s' % (i, l[i]) This gives me: 0. 0 1. 1 2. 2 etc which is what I expect, but what I want is to g

Re: [Tutor] how best to implement paginated data in CLI

2010-09-14 Thread Rance Hall
On Tue, Sep 14, 2010 at 7:15 PM, Alan Gauld wrote: > > "Rance Hall" wrote > >> I'm using python 3.1 with py-postgresql (located at >> http://python.projects.postgresql.org/ >> >> I need to work through how best to paginate larger sql result sets.

[Tutor] how best to implement paginated data in CLI

2010-09-14 Thread Rance Hall
I'm using python 3.1 with py-postgresql (located at http://python.projects.postgresql.org/ I need to work through how best to paginate larger sql result sets. my SELECT statement returns a list, I can get its len() to find out that X records were returned What I want to do is print the first N r

Re: [Tutor] py-postgressql v1.0.1 question

2010-09-12 Thread Rance Hall
On Sun, Sep 12, 2010 at 4:54 PM, Luke Paireepinart wrote: >> >> Thanks for the tip.  I'll do some more research but this sounds promising. >> >> Rance >> > Just be aware that some methods of list building will iterate over the list > and evaluate it. So if you only want to retrieve the first 10 r

Re: [Tutor] py-postgressql v1.0.1 question

2010-09-12 Thread Rance Hall
On Sun, Sep 12, 2010 at 3:53 PM, Bill Allen wrote: > Rance, > > I was doing something similar, except I was querying an Oracle database, > using the cx_Oracle module.  I wanted the non-duplicated count of parts in > my database that met certain criteria.  All the output that met the criteria > of

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Rance Hall
On Sun, Sep 12, 2010 at 2:29 PM, Dave Angel wrote: >  On 2:59 PM, Rance Hall wrote: > Convert the string to bytes.  If the string is ASCII, you can simply use the > bytes() function.  If not, you may need to specify an encoding. Thanks Dave, this is what I needed, I looked in the

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Rance Hall
o the hashing function. On Sun, Sep 12, 2010 at 1:47 PM, Luke Paireepinart wrote: > This is how I use it (untested) > Import hashlib > Print hashlib.md5("somestr").hexdigest() > > Works fine without using binary string. > > > On Sep 12, 2010, at 1:19 PM, Rance Hall

[Tutor] forcing hashlib to has string variables

2010-09-12 Thread Rance Hall
Everybody knows you don't store plain text passwords in a database, you store hashes instead consider: userpass = getpass.getpass("User password? ") encuserpass = hashlib.md5() encuserpass.update(userpass) del userpass Now the documentation clearly states that if you are hashing a string you

[Tutor] py-postgressql v1.0.1 question

2010-09-12 Thread Rance Hall
I'm not sure if this is the right forum for this or not, if there is a better place to ask this question please let me know and I'll re-post elsewhere. I'm using python v3.1 and the py-postgresql v1.0.1 module located at http://python.projects.postgresql.org/docs/1.0/ I'm using prepared sql state

Re: [Tutor] changing list index start

2010-09-11 Thread Rance Hall
On Sat, Sep 11, 2010 at 10:40 AM, Joel Goldstick wrote: > > I think the first message in the original post is instructive: > > "I'm using the following function style I found on the net to create > menus for a command line python script:" > > I (sometimes!) love looking at other peoples code to

Re: [Tutor] changing list index start

2010-09-11 Thread Rance Hall
On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan wrote: > On 09/11/10 07:36, Rance Hall wrote: > In most cases in Python, you would almost never need to reference the > list's index directly since python makes it easy to use iterators; > however in your particular case, which is

[Tutor] changing list index start

2010-09-10 Thread Rance Hall
I'm using the following function style I found on the net to create menus for a command line python script: def mainmenu(): # the main menu todolist() mainmenuoptions = ['Clients','Jobs','Billing','Quotes','To Do Items','Employee','Exit'] mainmenucalls = [clientsmenu, jobsmenu, bil

Re: [Tutor] hashlib problems

2010-09-10 Thread Rance Hall
On Fri, Sep 10, 2010 at 3:12 PM, Luke Paireepinart wrote: > In general, you shouldn't even hint at the possibility of there being a bug > in the code unless you have test cases and a patch handy. Especially > something as widely used as hashlib. It  gives An air of arrogance about your > post,

[Tutor] hashlib problems

2010-09-10 Thread Rance Hall
Im wanting to use the builtin hashlib functions to encrypt passwords before storing them in a database. According to documentation on the python.org site it should be as simple as import hashlib hashname = hashlib.sha234 (or whatever other hash method you want like md5 or whatever) hashname.up