[Tutor] data type conversion for print statement

2007-09-25 Thread Tim
Hello, I have a print statement where I use concatenation of variables with "+" to avoid extra whitespaces. The variables are mixed (float/int). How can I convert them all to strings to have a clean print statement? example print str(var1)+"and this "+str(var2)+"needs to check "+str(var3) how ca

[Tutor] function for removing all white spaces from a string

2007-10-01 Thread Tim
Hello, after reading the responses to athread in 2004 [1] I am wondering why there is no easy function in python to remove all white spaces from a string. Like: " i am very fine " to "iamveryfine" In IDL there's just one simple function which does this: STRCOMPRESS [2]. Is there really not yet

Re: [Tutor] Introspecting class and method names

2005-12-14 Thread tim
* Kent Johnson <[EMAIL PROTECTED]> [051214 16:00]: > Tim Johnson wrote: > > I was pleasantly surprised to notice in a previous thread that python > > can automagically retrieve a class name thru __class__.__name__ > > 1)Can someone point me to further documentation on th

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Tim Peters
[Dave S <[EMAIL PROTECTED]>] > OK I may be pushing it, ;-) Yup . > I need a script to sleep from any point to 8:05AM when in needs to > re-start. > > So I calculate the number of seconds with the following > > def secs_till_805(): ># Returns the number of seconds till 8:05AM > >s

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-07 Thread Tim Peters
[Brian van den Broek] ... > Or, so I thought. I'd first tried getting the alarm datetime by simply > taking the date component of datetime.datetime.now() and adding > to the day value. That works fine, provided you are not on the last > day of the month. But, when checking boundary cases before > p

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-07 Thread Tim Peters
[Dick Moores] ... > Brian, where did you learn about the ".seconds". And > the .year, .month,.day of > > "alarm_datetime = datetime.datetime(now.year + 4, now.month, > now.day, alarm_hour, alarm_minute)"? > > Does this come from a general knowledge of OOP, or is it > somewhere in the Pytho

Re: [Tutor] Complex roots

2004-12-09 Thread Tim Peters
[Dick Moores] > VERY helpful, Matt. Thanks. > > One question: This seems to not compute accurately at all > when the imaginary part of number=complex() is other than 0. That's just because the math was wrong . Starting with theta = 0.0 *assumed* the imaginary part is 0, although I can't guess wh

Re: [Tutor] Complex roots

2004-12-10 Thread Tim Peters
[Dick Moores] > Aw, that's just amazing. Well, complex numbers are amazing in many ways. The code is actually obvious, if you understand the motivation. Polar coordinates are more natural for complex * / and **. If you a view a complex number c as a vector in the complex plane (from the origin

Re: [Tutor] Complex roots

2004-12-12 Thread Tim Peters
[Dick Moores] >>> Actually, I'm trying to write a Python script that computes all 3 >>> roots of a cubic equation. Do you happen to have one tucked >>> away in your store of wisdom and tricks? (One for real coefficients >>> will do). [Tim Peters] >>

Re: [Tutor] turning a number into a formated string

2004-12-15 Thread Tim Peters
[Ertl, John] > I need to take a number and turn it into a formatted string. > The final output needs to look like when the X is the > integer part padded on the left and Y is the decimal part padded > on the right. > I figured I could split the number at "." and then use zfill or > some

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Tim Peters
[Brian van den Broek] > in Marc's check_range thread, I had proposed: > > def check_in_range(value): > > in_range = False > if 9 < value < 90: > in_range = True > return in_range > > and DogWalker suggested the better: > > def check_in_range(value): > return 9 < value < 90

[Tutor] Hooray! I finished the 'Learning Python for absolute beginners'

2010-01-09 Thread Tim Goddard
Ok, it's not a big deal, but once I learned enough I went off on a few tangents to create programs of my own design. Since I had to return the book to the public library, I finally got back to finishing the last chapter. Since the book is not current, I took the time to decipher the differences a

Re: [Tutor] Hooray! I finished the 'Learning Python for > absolutebeginners'

2010-01-10 Thread Tim Goddard
clipse with the PyDev plugin. Using other IDE installed as part of Python(x,y) i.e. Spyder, gave me insight into what I was missing with Eclipse. I'm missing a lot, I mean simply missing out on one aspect of Eclipse. Tim G ___ Tutor maillis

Re: [Tutor] SYS Long File Names?

2010-02-07 Thread Tim Golden
On 06/02/2010 21:36, FT wrote: I was looking at the sys.argv(1) file name and it is the short 8 char name. How do you place it into the long file name format? I was reading music files and comparing the name to the directory listing and always comes back as not found because the name was sho

[Tutor] distutils and the postinstallation script

2010-02-24 Thread Tim Brown
Hi, I've written an installation, for Windows, using distutils to produce a .exe setup file. When the setup.exe is run, can my postinstallation script can find out which folder the setup.exe is in ? Thanks Tim ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Cannot open SQLite database

2010-02-25 Thread Tim Golden
On 25/02/2010 15:18, Michael M Mason wrote: ALAN GAULD wrote on 25 February 2010 at 08:50:- So I think that was a red herring, sorry. It also looks like the Read Only check box in the main Explorer property dialog tab doesn't mean what it says... Doesn't the Read Only checkbox have a coloured

Re: [Tutor] browing windows registry

2010-03-17 Thread Tim Golden
On 17/03/2010 02:35, Jeff Peery wrote: hello, I want to browse the windows registry for the program ids listed under the categories: 63D5F430-CFE4-11d1-B2C8-0060083BA1FB 63D5F432-CFE4-11d1-B2C8-0060083BA1FB where might be the best way to learn how to do that with python? Hopefully this might

Re: [Tutor] Remote access from Windows PC to a Linux box

2010-03-31 Thread Tim Golden
On 30/03/2010 17:29, Mike Baker wrote: I'm trying to connect to a Linux box from my Windows machine and execute a series of commands I want a script to always execute the same series of commands without having to do so manually. I also have code that will execute a single command like cat a fi

[Tutor] Creating class instances through iteration

2010-04-15 Thread Tim Goddard
I came across a situation where what I thought I wanted to do was to create a class that was spawned from data in a .csv file. Where column 1 was the name I wanted to use for each instance. I had it all figured out and working except for how to write a statement where the left hand side could be

Re: [Tutor] Programming microsoft excel

2010-05-07 Thread Tim Golden
On 06/05/2010 17:51, hbu...@ovi.com wrote: Hi guys can i use python's win32com module to do the same tasks that i do with visual basic for applications (vba). I mean automating tasks for excel e.t.c and accessing Access databases. If win32com doesnt which module can i use? You want to look at t

[Tutor] Successfully trapping the [505 file not found] error

2010-05-26 Thread Tim Johnson
ng so that the entire download process is completed? -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Successfully trapping the [505 file not found] error

2010-05-26 Thread Tim Johnson
ught. :) Ain't it nice to have a second set of eyes! You are correct. I'm attempting to reconnect without the exception handling. Thanks -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com ___ Tutor maillist

Re: [Tutor] upgrade from 2.6.2 to 2.6.5?

2010-06-22 Thread Tim Golden
On 22/06/2010 13:40, Alex Hall wrote: Hi all, I am having problems with the Durus package, and I was told that changing Python versions might help. Most of the other dependencies of the project I have are 2.6 only, so I do not want to change versions from 2.6.x, but I would like to try upgrading

Re: [Tutor] (no subject)

2010-06-30 Thread Tim Golden
On 30/06/2010 17:20, Aaron Chambers wrote: I'm new to Python, and wanted to start messing around with it, but the computer I'm using is running Windows 7, so is there a version of Python that's compatible with 7? Yes. I'm running versions from Python 2.1 all the way up to the latest 2.x and 3.x

Re: [Tutor] Strange sqlite3 behavior

2010-07-17 Thread Tim Golden
On 17/07/2010 8:10 AM, Lang Hurst wrote: I just had the weirdest issue with sqlite3. I was trying to update a field to "Active". I have a little database of students and sometimes they get sent to juvi, or just check out for a couple of months and show back up. Anyway, I wanted to just have a

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Tim Golden
On 27/07/2010 15:22, Richard D. Moores wrote: Python 3.1 on Vista. Please see. I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? msvcrt.getch returns bytes on Python 3.1; you're comparing against

Re: [Tutor] how to do excel in python

2010-08-05 Thread Tim Golden
On 05/08/2010 15:08, invincible patriot wrote: hi, can any one tell me how can I access MS excel worksheet in python and how can I access itz individual cells..?? http://www.python-excel.org/ (First hit for python excel in Google) TJG ___ Tuto

Re: [Tutor] os.urandom()

2010-08-10 Thread Tim Golden
On 10/08/2010 15:33, Steven D'Aprano wrote: On Tue, 10 Aug 2010 02:24:00 pm Dave Angel wrote: [...] Any suggestions how to fix the Windows console to interpret utf8? There are several tracker issues relating to this one. The current position seems to be: it's not easy. I've done no more than

Re: [Tutor] Module for browsing Windows?

2010-08-11 Thread Tim Golden
On 11/08/2010 01:17, Chorn, Guillaume wrote: Hello, I'm pretty new to Python programming and it is my first programming language. I made a script that uses data from two different .csv files to make calculations and then spit the results out in a third .csv file. However, the process of typing

Re: [Tutor] os.access unreliable?

2010-08-25 Thread Tim Golden
On 25/08/2010 09:28, Albert-Jan Roskam wrote: Hi, Hi I'm using os.access to do a preliminary check to see if I have RW access, but it seems to be unreliable. In a dir for which I have only read access, os.access also says I have write access. This is under Windows 2000. I could of course use a t

Re: [Tutor] os.access unreliable?

2010-08-25 Thread Tim Golden
On 25/08/2010 11:15, Steven D'Aprano wrote: It also warns that os.access doesn't take into account network file sharing permissions. Heh. On Windows it doesn't take into account *any* file sharing permissions :) TJG ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Can't process all my files (need to close?)

2010-09-20 Thread Tim Golden
On 20/09/2010 16:19, aenea...@priest.com wrote: My Python script needs to process 45,000 files, but it seems to blow up after about 10,000. Note that I'm outputting bazillions of rows to a csv, so that may be part of the issue. Here's the error I get (I'm running it through IDLE on Windows 7):

Re: [Tutor] Windows printing

2010-09-23 Thread Tim Golden
t of names. the list also includes other items like network paths depending on the level of detail you specify in EnumPrinters. Tim has two possible ways to print. Tim shows how to use the win32api to pass a ShellExecute command that prints. The catch to this command is you have to print a file

Re: [Tutor] Windows printing

2010-09-23 Thread Tim Golden
On 23/09/2010 14:05, Rance Hall wrote: For the first roll-out and testing I figured plaintext was good enough. Future revisions will probably use the PDF library you also referred to on your page. Either way that is as printer ready as I expect I will be able to get it. One option you might w

Re: [Tutor] Windows Printing, Round 2

2010-09-23 Thread Tim Golden
On 23/09/2010 7:18 PM, Rance Hall wrote: 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

[Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
I've got a small function that I'm using to check whether a password is of a certain length and contains mixed case, numbers and punctuation. Originally I was using multiple "if re.search" for the patterns but it looked terrible so I've read up on list comprehensions and it's slightly improved

Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
set does seem to have what you want: isdisjoint() could do the trick. Eg: if set(punctuation).isdisjoint(password) or set(digits).isdisjoint(password) or set(ascii_uppercase).isdisjoint(password) or set(ascii_lowercase).isdisjoint(password): return False return True You co

Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
On 28/09/10 01:46, Jerry Hill wrote: The way you've written it obviously works fine. That being said, I'd probably do something like this: from string import ascii_lowercase, ascii_uppercase, digits, punctuation def complex_password(password): '''Checks to make sure a password is complex'

Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
On 28/09/10 01:50, Brian Jones wrote: On Mon, Sep 27, 2010 at 11:43 AM, Brian Jones mailto:bkjo...@gmail.com>> wrote: How about this: d = [digits, punctuation, ascii_uppercase, ascii_lowercase] s = 'asdf1234A' for c in d: if not [x for x in s if x in c]: print x, ' not in ', c Ju

Re: [Tutor] console output that is same in Python 2 and 3

2010-09-28 Thread Tim Golden
On 27/09/2010 17:11, Thierry Tung wrote: Hello tutor at python.org. How can I write strings to the console in a way that will give the same result in Python 3 and Python 2? I tried sys.stdout.write('hello') on Microsoft vista. with python 3.1.2 sys.stdout.write('hello') hello5 with py

Re: [Tutor] I am looking for a book on Beginners who never programmed before or have no experience in programming

2010-09-29 Thread Tim Golden
On 29/09/2010 12:20, Calle's Pyt(h)onkonto wrote: Or if you're like me (= Thinks reading a guide online is annoying since you have to switch between your browser and IDLE all the time), and would like to have a book that is easy to read and easy to understand, Merely from that perspective alone

[Tutor] 'module' object has no attribute (setting a class attribute)

2010-10-15 Thread Tim Johnson
1)Am I using the correct method to set a class attribute? 2)Is there a system configuration that would cause the AttributeError exception to print out the module name. (In this cause it was 'kbLib' not 'tmpl'. thanks -- Tim tim at johnsons-web.

Re: [Tutor] 'module' object has no attribute (setting a class attribute)

2010-10-16 Thread Tim Johnson
> that: Good trick. > > a = kbLib.templatepath > tmpl.Ttmpl.templatepath = a > > If the line that now gets the error had still been confusing, you could > try to refactor that in turn. thanks -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com _

[Tutor] Requesting restricted URL (further authentication requested)

2010-10-19 Thread Tim Johnson
ndler) urllib2.install_opener(opener) return opener.open(URL).read() # But, alas, any links in content 'beneath' the URL # require additional authentication. Any way around this? Thanks -- Tim tim at johnsons-web.com or akwebsoft.com http://ww

Re: [Tutor] Requesting restricted URL (further authentication requested)

2010-10-19 Thread Tim Johnson
* Vince Spicer [101019 12:25]: > On Tue, Oct 19, 2010 at 1:56 PM, Tim Johnson wrote: > > > Tim, > > Unless you are tied to the standard library I would recommend looking at > > httplib2 http://code.google.com/p/httplib2/ > > This handles your authentication a

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Tim Golden
On 21/10/2010 13:42, Richard D. Moores wrote: Traceback (most recent call last): File "c:\P26Working\test_urllib2_21a.py", line 148, in unchanged_count, higher_count, lower_count, secs = sleep_seconds_control(unchanged_count, higher_count, lower_count, secs) TypeError: 'int' object is not

Re: [Tutor] 2.6 vs 2.7: package compatibility?

2010-10-25 Thread Tim Golden
On 25/10/2010 02:20, Alex Hall wrote: Hi all, I want to run a certain program from source. One dependency, Durus, keeps giving me an error that no one can figure out. Someone said that it will work if I use 2.7 instead of 2.6, but a lot of packages I have installed work only on 2.6. I know I can

Re: [Tutor] 2.6 vs 2.7: package compatibility?

2010-10-25 Thread Tim Golden
It tells me that persistent_dict does not exist, when it clearly does. Another user had the exact same problem when running the source on 2.6, but he had no problem when running 2.7. If you had an msi to install Durus for 2.6 specifically, it would be interesting to see if the persistent_dict erro

[Tutor] possible to run a python script from non-cgi?

2010-10-30 Thread Tim Johnson
/http/, I have /home/http/php/test/index.php and I have run index.php as http://localhost/php/test/ (again with the correct .hataccess). Is it possible to run a python script this way? thanks tj -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com

Re: [Tutor] possible to run a python script from non-cgi?

2010-10-30 Thread Tim Johnson
work. > I also guess this question might be better answered on the forum > corresponding to your webserver (Apache?), since it appears to > deal more with the server setup than actually with Python. Understood. Thanks -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.

Re: [Tutor] possible to run a python script from non-cgi?

2010-10-30 Thread Tim Johnson
* शंतनू [101030 14:08]: > Hi Tim, Reply inline. Sorry, I don't understand the preceding line. > On 31-Oct-2010, at 1:02 AM, Tim Johnson wrote: > > > FYI: I am working in a linux environment with python 2.6.5 am an > > experienced web developer with 8 years in pytho

Re: [Tutor] possible to run a python script from non-cgi?

2010-10-30 Thread Tim Johnson
* Tim Johnson [101030 15:24]: I've taken this one step further: .htaccess => RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ ./index.py/$1 [L,QSA] now I get the response from http://localhost/reg/ cheers -- Tim tim at johnsons-web.com or akwebsoft.

Re: [Tutor] Displaying picture and Text

2010-11-04 Thread Tim Golden
On 04/11/2010 04:24, pa...@cruzio.com wrote: Hi - I am running Python 2.6.6 on my HP netbook with Windows 7. The default picture viewer is set to HP Photo Viewer. I am working on a part of my python program where a picture is supposed to display with a few lines of text below it. Ideally, I wou

[Tutor] Recommend a MVC framework

2010-11-14 Thread Tim Johnson
framework. One restriction: must *not* need an application server, I.E. works thru Apache and is adaptable to a shared server. TIA -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com ___ Tutor maillist - Tutor@python.org To unsubs

Re: [Tutor] Recommend a MVC framework

2010-11-14 Thread Tim Johnson
* Alan Gauld [101114 13:12]: > Not quite sure how you defione your terms there. > But all of the above can be used with Apache. Hi Alan. See my reply to Evert where I refer to situations where I would have neither SSH nor root access. thanks -- Tim tim at johnsons-web.com or akwebso

Re: [Tutor] Recommend a MVC framework

2010-11-14 Thread Tim Johnson
unning smoothly without root access to the server--something a lot of people do not have--and they actually expect their users to run TWO servers--one for Django and one for everything else, like image files. """ Thank you for the response. -- Tim tim at johnsons-web.c

Re: [Tutor] Recommend a MVC framework

2010-11-14 Thread Tim Johnson
* Tim Johnson [101114 11:45]: > > One restriction: must *not* need an application server, I.E. works > thru Apache and is adaptable to a shared server. > thanks for all of who responded. I should clarify: I have been considering django as a first choice for most of the deployment en

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Tim Golden
Alan Gauld wrote: Cut n paste of the path works, but you can also use tab to complete the file name which speeds things up considerably. And you can drag a file in from explorer to a Console window to get the full path pasted in automatically. Even on DOS F3 repeated the last command but on XP

Re: [Tutor] Difference in minutes between two time stamps

2009-03-03 Thread Tim Michelsen
import datetime s = '09:35:23' datetime.datetime.strptime(s, '%H:%M:%S') datetime.datetime(1900, 1, 1, 9, 35, 23) Can you figure out how to proceed from there? In case she doesn't know: import datetime as dt start="09:35:23" end="10:23:00" start_dt = dt.datetime.strptime(start, '%H:%M:

Re: [Tutor] Difference in minutes between two time stamps

2009-03-03 Thread Tim Michelsen
import datetime s = '09:35:23' datetime.datetime.strptime(s, '%H:%M:%S') datetime.datetime(1900, 1, 1, 9, 35, 23) Can you figure out how to proceed from there? In case she doesn't know: import datetime as dt start="09:35:23" end="10:23:00" start_dt = dt.datetime.strptime(start, '%H:%

[Tutor] creating a list of all imported modules

2009-03-09 Thread Tim Michelsen
Hello, how do I create a list of all modules imported by my module/script? I am looking for something like %who in Ipython. Thanks for your help in advance. Regards, Timmie ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/li

Re: [Tutor] How to connect to an email server?

2009-03-16 Thread Tim Golden
Eduardo Vieira wrote: Hello, I'm fairly new to programming and Python and am trying to explore Python's email libraries. But I am having trouble making a connection with an email server, I guess. I'm running Windows XP, in a server environment. I have administrator privileges to my machine (not t

Re: [Tutor] (no subject)

2009-03-17 Thread Tim Golden
Michael Connors wrote: So the extent of your effort is "Would anyone know how to Ctrl+c". That deserves an award. I think you meant ctrl-v, but good point, nonetheless :) (Took me a moment, because I thought you were referring to a KeyboardInterrupt-type ctrl-c!) TJG

Re: [Tutor] Trouble parsing email from Outlook

2009-03-20 Thread Tim Golden
over them directly; you have to loop over their count. Note that they are counted from 1 upwards, while the Python loop is 0-based: for i in range (len (ses.InfoStores)): info_store = ses.InfoStores[i+1] print info_store.Name If you already know the name of the one you want, eg "Mailbox - Tim Gol

Re: [Tutor] Trouble parsing email from Outlook

2009-03-20 Thread Tim Golden
Eduardo Vieira wrote: On Fri, Mar 20, 2009 at 2:29 PM, Eduardo Vieira wrote: On Fri, Mar 20, 2009 at 9:04 AM, Tim Golden wrote: Eduardo Vieira wrote: Thank you very much, Tim for the thorough explanation. Much more than I could expect. It will be specially useful for me a newbie python

Re: [Tutor] Opening a cmd.exe

2009-03-22 Thread Tim Golden
Alan Gauld wrote: "Sigga Sig" wrote I am writing a code that is supoesed to act as routers and i need to open a different cmd window for each one of them with it's name and so on. I do not know how to implement in mi Python cod a sentece that opens such a cmd. I know how to open a cmd.exe b

Re: [Tutor] Opening a cmd.exe

2009-03-22 Thread Tim Golden
Tim Golden wrote: Alan Gauld wrote: "Sigga Sig" wrote I am writing a code that is supoesed to act as routers and i need to open a different cmd window for each one of them with it's name and so on. I do not know how to implement in mi Python cod a sentece that opens such a c

[Tutor] Python Logo

2009-03-24 Thread Tim Johnson
Hi Folks: My company is setting up a new website, like to have a python logo on it. Can anyone recommed a logo that would be legal for us to use? Thanks Tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Logo

2009-03-24 Thread Tim Johnson
On Tuesday 24 March 2009, Kent Johnson wrote: > On Tue, Mar 24, 2009 at 4:45 PM, Tim Johnson wrote: > > Hi Folks: > > My company is setting up a new website, like to have a python logo > > on it. Can anyone recommed a logo that would be legal for us to > > use? > >

Re: [Tutor] Python Logo

2009-03-25 Thread Tim Johnson
e same, I was glad to see it. I never knew about webpy, and now I do. Have found django and turbogears way too big for me. Now I will check out webpy. thanks to all tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Trapping warnings from MySQLdb

2009-04-13 Thread Tim Johnson
ideas would be appreciated. This will be very useful to us. thanks tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Trapping warnings from MySQLdb

2009-04-13 Thread Tim Johnson
f trapwarnings: warnings.simplefilter("error", MySQLdb.Warning) return self._rdb.execute(s) ## and the interface: try: db.rcmd(cmd,0,1) except _mysql_exceptions.Warning,e: ## give user ad h

Re: [Tutor] Webpy vs Django

2009-04-20 Thread Tim Michelsen
I can recommend you web2py: http://www.web2py.com/ It has been designed for didactical needs and has a low learning curve. Look at the manual extarct for an idea: Free manual chapters - http://mdp.cti.depaul.edu/examples/static/web2py_manual_cut.pdf or check the docs: http://www.web2py.com/ex

Re: [Tutor] is it possible to traverse two lists simulatenously using python

2009-04-30 Thread Tim Johnson
ot;undisclosed recipients". It's really poor form and it screws up my mail filters. thanks - Tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Running subProcesses in parallel for mixed external Windows.exe and Python functions on specified CPUs.

2009-05-01 Thread Tim Golden
Ian Campbell wrote: Running subProcesses in parallel for mixed external Windows.exe and Python functions on specified CPUs. How does a newbie start to make this work? [... snip most stuff ...] p11 = subprocess.Popen("C:\myDdeServer.exe ") # loads DDE Serverp12 = sub

[Tutor] how to reference a function itself when accessing its private functions?

2009-05-04 Thread Tim Michelsen
Dear Tutors and fellow pythonistas, I would like to get access to the private methods of my function. For instance: Who can I reference the docstring of a function within the function itself? Please have a look at the code below and assist me. Thanks and regards, Timmie CODE ### s = 'hel

Re: [Tutor] how to reference a function itself when accessing its private functions?

2009-05-05 Thread Tim Michelsen
Thanks a lot! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need help with registry access

2009-05-08 Thread Tim Golden
ALAN GAULD wrote: The _winreg module is part of the standard library and provides functions for accessing the Windows registry. There's some (incomplete) help here, but as Alan said, you need to learn Python to some extent before trying to do this. http://timgolden.me.uk/python-on-windows/pro

Re: [Tutor] performance loss -- profiling

2009-05-19 Thread Tim Golden
Kent Johnson wrote: The Python profiler is not hard to run. Interpreting the results is more difficult :-) See the docs to get started: http://docs.python.org/library/profile.html Also, it's quite useful to run it as a module: python -mcProfile You have a certain amount of configurability v

Re: [Tutor] Getting file properties on winodws

2009-05-20 Thread Tim Golden
vishwajeet singh wrote: Hi, I am trying to read properties of file on windows like there is a property call Keywords on file; I am to read this property independent of file type. There's an unpolished (indeed, unfinished) example here: http://timgolden.me.uk/python/win32_how_do_i/get-documen

Re: [Tutor] Getting file properties on winodws

2009-05-21 Thread Tim Golden
[Rearranging for reading order] [vishwajeet singh wrote] I am trying to read properties of file on windows like there is a property call Keywords on file; I am to read this property independent of file type. [Tim Golden wrote:] There's an unpolished (indeed, unfinished) example here:

Re: [Tutor] Getting file properties on winodws

2009-05-21 Thread Tim Golden
Tim Golden wrote: It would probably help if you specified what "does not seem[s] to be working" meant. But I assume that you mean: if you add a Title into the Summary on a JPEG then it doesn't get picked up by the script. What's happening here (I think) is that for media typ

Re: [Tutor] Getting file properties on winodws

2009-05-21 Thread Tim Golden
Tim Golden wrote: Tim Golden wrote: It would probably help if you specified what "does not seem[s] to be working" meant. But I assume that you mean: if you add a Title into the Summary on a JPEG then it doesn't get picked up by the script. What's happening here (I think) is

Re: [Tutor] file enigma

2009-06-11 Thread Tim Golden
spir wrote: Hello, text = file(filename).read() (or: open(filename).read()) How do you close() the file? ;-) Well, in any version of Python, you can do this: f = open (filename) text = f.read () f.close () or, slightly more robsustly: f = open (filename) try: text = f.read () finally:

Re: [Tutor] file enigma

2009-06-11 Thread Tim Golden
spir wrote: Thank you, Tim, this really answers my question. Glad to be of help :) * I intended to write a helper func "filetext(filename)" to open/read/close/return (or equivalent using the with idiom). This is one of those tricky things in Python: when the "raw"

Re: [Tutor] how to manage an encrypted file?

2009-06-20 Thread Tim Golden
Robert Lummis wrote: Could you recommend a module or methods I should use to manage an encrypted text file? I want to store passwords and associated contact information in a file and feel confident that if the file is stolen the information couldn't be read. If you're on Windows, just encrypt

Re: [Tutor] Floor and modulus for complex arguments

2009-07-03 Thread Tim Peters
[Angus Rodgers] > I'm a little confused by: (i) the definition of the modulus and > floor division functions for complex arguments; Perhaps you're confused by the current definitions simply because they don't make good sense. > (ii) the fact that these functions for complex arguments are > now "

Re: [Tutor] Floor and modulus for complex arguments

2009-07-03 Thread Tim Peters
[Angus Rodgers] > ... > If I started to agitate for changes to a marginal and little-used > feature of the language within days of starting to learn it, might > I not quickly earn a reputation as a crank?  8-P If that's your /goal/, it would be easier to rant about some imagined flaw in the ring o

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-05 Thread Tim Peters
[Angus Rogers, suffering eval-angst] > ... > On the other hand, so long as I AM only executing the function > myself, I am no more at risk than I already am every single time > I type a command into a Python interpreter, of any description. > (A somewhat Existentialist thought, perhaps!  Virtual su

Re: [Tutor] Popen problem with a pipe sign "|"

2009-07-06 Thread Tim Golden
hyou wrote: Thanks for the answer! I found the problem was because I put the 2nd argument to Popen with Shell = true. Though I'm not sure why it doesn't work with Shell = true while the same setting works for other commands. There's a long-outstanding bug when shell=True is passed to subproces

Re: [Tutor] renaming files within a directory

2009-07-26 Thread Tim Golden
davidwil...@safe-mail.net wrote: Hello, I have a directory containing svg/Flag_of_United_States.svg etc... Flag_of_the_Seychelles.svg Flag_of_the_Solomon_Islands.svg Flag_of_the_United_Arab_Emirates.svg Flag_of_the_United_Kingdom.svg Flag_of_the_United_States.svg Flag_of_the_Vatican_City.svg

Re: [Tutor] renaming files within a directory

2009-07-26 Thread Tim Golden
davidwil...@safe-mail.net wrote: Here is what I have so far, but I get stuck on the mapping of the filename with the csv file. import os files = [file for file in os.listdir(os.getcwd()) if file.endswith('svg')] files ['Flag_of_Abkhazia.svg', 'Flag_of_Afghanistan.svg', 'Flag_of_Albania.svg',

Re: [Tutor] renaming files within a directory

2009-07-26 Thread Tim Golden
davidwil...@safe-mail.net wrote: OK I am lost ;( I changed the code to: reader = csv.reader(open("countries.csv"), delimiter=";") for row in reader: ... print row ... ['bi', 'Burundi'] ['km', 'Comoros'] ['dj', 'Djibouti'] ['er', 'Eritrea'] ... Now each row is a list with two items ea

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Tim Golden
davidwil...@safe-mail.net wrote: Here is what I have so far: import os import csv countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in os.listdir(os.getcwd()) if file.endswith('svg')]) You d

[Tutor] regex problem with colon

2009-08-06 Thread Tim Johnson
res [] ## Darn! I'd hope that the 'cc:' and 'CC:' substrings would be found. So how to compose the expression correctly? TIA -- Tim t...@johnsons-web.com http://www.akwebsoft.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] regex problem with colon

2009-08-06 Thread Tim Johnson
* Kent Johnson [090806 18:31]: > On Thu, Aug 6, 2009 at 8:47 PM, Tim Johnson wrote: > > using python 2.5. > > I'm having a problem with including a colon as part of a substring > > bounded by whitespace or beginning of line. > > Here's an example: > &

[Tutor] Overriding MySQLdb.cursors.DictCursor.execute()

2009-08-07 Thread Tim Johnson
Error: 'module' object has no attribute 'cursors' # say what? MySQLdb has been imported... I would welcome both comments on why I am getting this error message and whether my original thinking is correct. thanks -- forever and always a noob -- -- Tim t...@johnsons-web.com

Re: [Tutor] Overriding MySQLdb.cursors.DictCursor.execute()

2009-08-08 Thread Tim Johnson
* Kent Johnson [090808 05:06]: > On Fri, Aug 7, 2009 at 10:18 PM, Tim Johnson wrote: > > If you use the two argument form of cursor.execute - passing the > parameter values in a sequence, rather than substituting them yourself > - then you have to worry about injection attacks. Th

Re: [Tutor] Pack/Unpack hacking

2009-09-06 Thread Tim Golden
Hope the people in the US are having a nice Labor Day! I am looking for the source code for the pack/unpack functions found in the struct package. As of this email, I have tried a strings on the struct.pyc file. The inspection of the pyc file was hoping that I could find a stub to the source.

Re: [Tutor] Invitation to connect on LinkedIn

2009-09-15 Thread Tim Golden
Kent Johnson wrote: I'm going to be charitable and assume this is a mistake. This is completely inappropriate to post to the tutor list. I assume -- having seen a few of these go past -- that such services say on joining: do you want me to email every one in your address book to ask them to li

  1   2   3   4   5   6   >