[Tutor] cut all decimal places with zeros

2008-04-14 Thread Tim Michelsen
Hello, how can I suppress the decimal places for (only those) numbers whos decimal places are zero (0)? Example: CODE In [1]: m = 2.0 In [2]: n = 2.56789080 In [3]: n_format = '%.4f' %n In [4]: n_format Out[4]: '2.5679' In [5]: m_format = '%.4f' %m In [6]: m_format Out[6]: '2.00

Re: [Tutor] setting program configuration for all files and modules ofa program

2008-04-14 Thread Tim Michelsen
> Yes, thats the way I'd recommend. >> Is there a more decent and elegant way? I don't know. I was just asking how other programmers achive this efficiently. > Another option is to have the config settiongs in a normal > Python module and just import it. That is less appealing if > the config fi

Re: [Tutor] setting program configuration for all files and modules ofa program

2008-04-15 Thread Tim Michelsen
>>> Another option is to have the config settiongs in a normal >>> Python module and just import it. > >> I think that the cfg-files are much more readable for others. > > More readable than: > > # Section Heading > variable = value > > It looks pretty easy to read to me! :-) > > If its very

Re: [Tutor] setting program configuration for all files and modules ofa program

2008-04-15 Thread Tim Michelsen
>>> But to my optinion Config Parser offers the following advantage: >>> - Readable >>> - All are strings => no strange 'mysetting' is needed. >> I'm not sure what you mean. The Python variables and dictionary >> is all strings too. mysetting is just a string... > > He means, with ConfigParser st

Re: [Tutor] cut all decimal places with zeros

2008-04-15 Thread Tim Michelsen
>> how can I suppress the decimal places for (only those) numbers whos >> decimal places are zero (0)? > > I don't know how to do this with just string formatting but I think > ('%.4f' % n).rstrip('.0') > will do what you want. No. I tested with n = 10.0 You code returns '1' My code returns '10'

Re: [Tutor] Arguments ina separate file

2008-04-21 Thread Tim Michelsen
> I have a big list of arguments, which I would like to > keep in a separate file. How do I pass arguments that > are in a separate file? do you mean like setting? do something like this write them in the file myargs.py import myargs call_my_function(myargs.argument1, myargs.argument2) see a

Re: [Tutor] Using Queue

2008-04-23 Thread Tim Golden
bob gailer wrote: Kent Johnson wrote: On Wed, Apr 23, 2008 at 9:46 AM, bob gailer <[EMAIL PROTECTED] > wrote: Evey time someone recommends Queue I think "oh boy this will really help me". Then I go to the Library Reference, read the Queue docs and think "o

Re: [Tutor] 6x6 word square solver too slow

2008-04-28 Thread Tim Peters
[Jeff Younker] >> I'd suggest googling for 'trie'. Tries are method of >> indexing sets of strings by prefix. [R. Alan Monroe] > Ah, will look it up. Or you can puzzle it out from the attached program ;-) > ... > In the meantime, my current version is > much improved - it caches rejects, so

[Tutor] converting all files in a directory with subprocess

2008-05-08 Thread Tim Michelsen
Hello, I am working on a automatic documentation program to convert my txt2tags based documentations sources into HTMl files. I want to use txt2tags via command line. Here's my code: # #!/usr/bin/env python # -*- coding: utf-8 -*- import os import subprocess import fnmatch documentation

Re: [Tutor] converting all files in a directory with subprocess

2008-05-08 Thread Tim Golden
Tim Michelsen wrote: Hello, I am working on a automatic documentation program to convert my txt2tags based documentations sources into HTMl files. I want to use txt2tags via command line. Here's my code: # #!/usr/bin/env python # -*- coding: utf-8 -*- import os import subprocess i

[Tutor] Open a directory in the default file manager

2008-05-15 Thread Tim Michelsen
Hello, is there any function/module that allows me to open a directory in the default file manager of a operating system? Here I a piece of code how to open a URL in the default webbrowser: http://www.python.org/doc/lib/module-webbrowser.html import webbrowser myurl = 'http://www.python.org'

Re: [Tutor] Open a directory in the default file manager

2008-05-19 Thread Tim Michelsen
Hi! > is there any function/module that allows me to open a directory in the > default file manager of a operating system? On Windows you can use os.startfile(). On "pure" Unices there's no such thing as filetype associations However, if you use a desktop environment, you can spawn xdg-open

Re: [Tutor] converting all files in a directory with subprocess

2008-05-19 Thread Tim Michelsen
Hello, just for the records: below is some code that works ### convert all t2t docs in a directory. #!/usr/bin/env python # -*- coding: utf-8 -*- import os import subprocess import fnmatch documentation_directory = './doc/' for file in os.listdir(documentation_directory): if fnmatch.fnmat

Re: [Tutor] Python-windows command prompt interaction?

2008-06-11 Thread Tim Golden
Trey Keown wrote: Hey all, I'm creating a program that will copy a user's internet history from Internet Explorer, and I'm having a bit of trouble. I need to get python to either initiate a command via the command prompt, or open a file with its default program (in this case, a .bat file with

Re: [Tutor] when is object relational mapping for Python warranted?

2008-06-11 Thread Tim Golden
Che M wrote: I'm curious whether I should consider learning either SQLObject or SQLAlchemy, and whether my needs would be worth it. I am learning to use SQlite databases for fairly simple storage and later search, and have only recently learned about object relational mapping (ORM). "Fairly si

Re: [Tutor] Pinging a service

2008-06-13 Thread Tim Golden
Greg Lindstrom wrote: Hello, I would like to write a routine to monitor services running on a remote box. My initial thought is to "ping" the remote box to monitor latency and then execute a query on the remote machine to monitor the database. What I would like is to gather data points and graph

Re: [Tutor] Moving a window... on windows?

2008-06-16 Thread Tim Golden
W W wrote: I'm not even sure if this is possible... and so far a google search of "python move windows xp" has failed to yield any helpful looking results. I'm trying to create a script that will move a program window around on the desktop, and other than that search I'm not sure where to look.

Re: [Tutor] Python to exe--how much work?

2008-06-26 Thread Tim Michelsen
> I've had some success generati ng .exe files using pyinstaller for a few simple python programs i've written (less than 100 lines of code, that just use the os module). How much harder will this be for longer code with more modules imported? you may also try GUI2exe http://xoomer.alice.it/i

Re: [Tutor] random.choice()

2008-07-01 Thread Tim Golden
Dick Moores wrote: So I want to randomly choose between them. I thought that I might be able to use choice() to do that. So, (bunch of functions here) if __name__ == '__main__': choice([use_for_float_demo(), use_for_integer_demo()]) I find that what's gets run each time is BOTH of

Re: [Tutor] random.choice()

2008-07-01 Thread Tim Golden
Dick Moores wrote: At 05:43 AM 7/1/2008, Tim Golden wrote: Dick Moores wrote: So I want to randomly choose between them. I thought that I might be able to use choice() to do that. So, (bunch of functions here) if __name__ == '__main__': choice([use_for_

Re: [Tutor] General design question

2008-07-02 Thread Tim Golden
Paul Melvin wrote: If I have a set of numbers, or strings etc. which have been generated and I then want to do something with them, for example a sum function call. Is the best way to put those items in a list, or similar container, before applying the function. Not only "best" but "necessar

Re: [Tutor] Exploring the Standard Library

2008-07-08 Thread Tim Golden
Hansen, Mike wrote: [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Farrar Sent: Saturday, July 05, 2008 12:24 PM To: Python Tutor Subject: [Tutor] Exploring the Standard Library I'd like to spend some time exploring the standard library. I'm running python on Ubuntu. How would I find the locat

Re: [Tutor] build list of non-empty variables

2008-07-09 Thread Tim Golden
Alan Gauld wrote: In fact I guess you could say that the new definition of a list comprehension is [ generator expression] Well, not if sure if you meant that literally, but it's certainly not: that would be a list whose one item was a generator expression: squares = (x * x for x in range (1

Re: [Tutor] build list of non-empty variables

2008-07-10 Thread Tim Golden
Alan Gauld wrote: "Tim Golden" <[EMAIL PROTECTED]> wrote In fact I guess you could say that the new definition of a list comprehension is [ generator expression] Well, not if sure if you meant that literally No I meant in syntactic terms. I imagined that that was what yo

Re: [Tutor] how can I use the functions inside ITfInputProcessorProfiles

2008-07-11 Thread Tim Golden
Dror Cohen wrote: I'm trying to use the these functions which are in isnide of ITfInputProcessorProfiles http://msdn.microsoft.com/en-us/library/ms538984(VS.85).aspx I think that its registry key is {892F230F-FE00-4A41-A98E-FCD6DE0D35EF} (though I don't know if I even need this) How can I us

Re: [Tutor] CD ROM Drive

2008-07-16 Thread Tim Golden
Neven Goršić wrote: Hi! I am using Python 2.5.2 on WinXP Pro and I want to detect all disk drives. I have C:, D: and E: hard disks and F: DVD ROM. Use WMI: http://timgolden.me.uk/python/wmi_cookbook.html#find-drive-types (mutatis mutandis) When I try to use os.access method with writing c

Re: [Tutor] CD ROM Drive

2008-07-16 Thread Tim Golden
Neven Goršić wrote: That is OK. But when I run program with that single command from Windows Explorer I get Windows alert Window: "No disk! Please insert a disk into drive F:" That alert stops program and I must respond with: Cancel, Try again or Continue. The alert remains even with try, excep

Re: [Tutor] List installed python modules

2008-07-21 Thread Tim Golden
Eli Brosh wrote: Hello, Is there a way to get a list of installed python modules and their versions ? i.e. I would like to know if matplotlib is installed on my computer and what version is it. And so with other modules. You've got two slightly different requirements there: 1) List all mod

Re: [Tutor] checking if data files are good, readable, and exist

2008-07-22 Thread Tim Golden
Bryan Fodness wrote: I would like to check to see if the data files are good, readable, and exist. I have checked to see if they exist, but their is a possibility that the data file might be binary, and I would like to have a sys.exit for that as well. You're going to be asked a lot of quest

Re: [Tutor] Unable to Reconfigure IDLE

2008-07-27 Thread Tim Golden
Thomas Corbett wrote: On Jul 26, 2008, at 9:02 AM, Alan Gauld wrote: "Thomas Corbett" <[EMAIL PROTECTED]> wrote Configured shell window to wrong size, now can't seem to find the menu (Options > Configure) to resize the shell. Don't you just resize it then close it and the next time it op

Re: [Tutor] Creating a unicode string from bytes and % opperator

2008-07-28 Thread Tim Golden
Wesley Brooks wrote: I'm trying to create a unicode character from two bytes. Unfortunatly I'm getting a "UnicodeDecodeError". Can some one please suggest an alternative way of doing what's bellow? In the example bellow the two bytes have been converted into a string hex value, but they could jus

Re: [Tutor] Creating a unicode string from bytes and % opperator

2008-07-28 Thread Tim Golden
Wesley Brooks wrote: Thanks Tim Golden, That'll do the trick! Thought there must have been something simple for it! To be perverse, you *could* have done it like this: eval ("u'\u" + "%s%s'" % ("0d", "fe")) But please don't :

Re: [Tutor] (no subject)

2008-07-29 Thread Tim Golden
Noufal Ibrahim wrote: Morgan Thorpe wrote: Hello. I'm am very new to the whole programming sence. Welcome. :) I am trying to catch on but as soon as i want to write a program i've been told to use like 'notepad' in windows XP and save it as a .py file i have gotten this far. Am i wrong so

Re: [Tutor] key/value order in dictionaries

2008-07-31 Thread Tim Golden
Steve Poe wrote: Hi tutor list, In dictionaries, I know that the keys are immutable, and the values can change What about the place/order of the key/order? I thought that they were sequential and they do not change. You were wrong :) A lot of electronic ink has been spilt on this subject ov

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-13 Thread Tim Johnson
On Tuesday 12 August 2008, Jaggo wrote: > Hello. > > I haven't much experience with programming. > > I'd like to point this question to programmers who write in editors other > than the default PyWin32: > > Why do you use your editor rather than using Pywin? What feature has editor > X got that PyW

Re: [Tutor] Calling Python Programs from Word, pdfs, etc

2008-09-05 Thread Tim Golden
Jim Morcombe wrote: 1. Is it possible to invoke a Python Program from some kind of link in a Word document, similar to the way a Java Applet is run from a Web Page. Obviously I am thinking about a Windows enviroinment only. (I guess I'm probably asking if an exe file can be launched from Win

[Tutor] Sending email as html

2008-09-05 Thread Tim Johnson
ument to the contrary of sending email with embedded html. Thanks Tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sending email as html

2008-09-05 Thread Tim Johnson
On Friday 05 September 2008, Alan Gauld wrote: <...> > The argument to the contrary is simple enough - its not secure and > vulnerable to 'virus' type attack. For that reason many corporate > firewalls > trap or even prevent its delivery. (This is due to the ability to > embed > script tags with V

Re: [Tutor] Sending email as html

2008-09-05 Thread Tim Johnson
On Friday 05 September 2008, Tim Johnson wrote: > Sounds like nothing much has changed in 5 years. I did a project like > this in 1993 with another programming language despite my reservations > and had the client sign a "Hold Harmless" doc before I proceeded. Erratum: Sh

Re: [Tutor] Sending email as html

2008-09-05 Thread Tim Johnson
On Friday 05 September 2008, Kent Johnson wrote: > On Fri, Sep 5, 2008 at 8:30 PM, Tim Johnson <[EMAIL PROTECTED]> wrote: > > On Friday 05 September 2008, Alan Gauld wrote: > > <...> > > > >> The argument to the contrary is simple enough - its not secure

Re: [Tutor] Sending email as html

2008-09-06 Thread Tim Johnson
nvoices just changing a 1 to a 7 or vice > > versa can make a big difference to the money owed! And very > > little difference to the layout. > > Well if it's just a matter of changing one digit this isn't so hard, > since PDF files are not

Re: [Tutor] Sending email as html

2008-09-07 Thread Tim Johnson
On Saturday 06 September 2008, Alan Gauld wrote: > "Tim Johnson" <[EMAIL PROTECTED]> wrote > > >> since PDF files are not very hard to edit with a simple text > >> editor. > >> (Never have really.) > > > > Looks like I could make up a P

Re: [Tutor] Sending email as html

2008-09-07 Thread Tim Johnson
On Sunday 07 September 2008, you wrote: > On Sun, Sep 7, 2008 at 11:27 AM, Tim Johnson <[EMAIL PROTECTED]> wrote: > > On Saturday 06 September 2008, Alan Gauld wrote: > >> There is an interersting looking link here: > >> > >> http://www.python.org/workshop

Re: [Tutor] Having Python check a program in win32.

2008-09-08 Thread Tim Golden
Rick Rune wrote: I'm looking to create a Python timed infinite loop (run foo, wait 1min, run foo) that will monitor if a particular program is running under Win32, and if it is not running to execute it. Can someone point me in the right direction to look? WMI. Example of sort here: http://

Re: [Tutor] Releasing a File for Access

2008-09-12 Thread Tim Golden
Wayne Watson wrote: Enclosed is a segment of a program which copies a txt file, but replaces the first line with a new one. The new one has a suffix of tmp. After it executed the code and exited the program normally (running out of code), I couldn't access the new tmp file. It was listed by Win

Re: [Tutor] How Fix Misdirected Posts to Tutor

2008-09-12 Thread Tim Golden
Wayne Watson wrote: Thanks. That seems to work. However, I thought I had experimented with it and found otherwise. Now to remember to do that. It's the only list I have that requires Reply All. It's certainly working now! There has been much debate on this in the past. (About every six months

[Tutor] Listing imported modules

2008-09-12 Thread Tim Johnson
ard python distribution. I can get a list of what appears to be all modules by starting the python interperter, invoke help() and then modules , but I'm looking for some way to do it programmatically. Using Python 2.5.1 on ubuntu 7.10 thanks tim ___

Re: [Tutor] Listing imported modules

2008-09-13 Thread Tim Johnson
On Friday 12 September 2008, you wrote: > On Fri, Sep 12, 2008 at 8:42 PM, Tim Johnson <[EMAIL PROTECTED]> wrote: > > If I execute the following code: > > > > imported = sys.modules.keys() > > > > print imported > > > > Do I indeed get a list of _

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: (struggling to make an informative subject line) [ struggling to understand exactly what the problem is... :) ] I'm quite willing to help on this, but it's just not quite clear enough what's happening. Can I suggest that you post a *really small, self-contained* example which demo

Re: [Tutor] WMI

2008-09-16 Thread Tim Golden
Spencer Parker wrote: Has anyone here had any experience with WMI extensions in Python? I am trying to remotely change the IP, Subnet, and gateway of a windows machine, but I cannot figure out what it needs to change this. You'll need the Win32_NetworkAdapterConfiguration class and, for ease

Re: [Tutor] WMI

2008-09-16 Thread Tim Golden
Spencer Parker wrote: It does of course help to spell IPAddress correctly to get this to work in the first place. LOL. It is working...thanks again for the help and the wonderful module! Glad it was useful. Thanks for the update. TJG ___ Tutor ma

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: [... snip solution around mis-handling a string split ...] Glad you solved it. Thanks for coming back with an update. Depending on your circs, you might want to try a more general solution to that problem, like: s = "This, is,a, string, with, varying, amounts, of,space" print

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: [... snip solution around mis-handling a string split ...] Glad you solved it. Thanks for coming back with an update. Depending on your circs, you might want to try a more general solution to that problem, like: s = "This, is,a, string, with, varying, amounts, of,space" print

Re: [Tutor] WMI

2008-09-17 Thread Tim Golden
Spencer Parker wrote: Is there a way to create new users in WMI? I was trying to research this on MSDN, but couldn't find it anywhere... Not possible as far as I know. Do you need a domain user or a local user? TJG ___ Tutor maillist - Tutor@pyth

Re: [Tutor] WMI

2008-09-17 Thread Tim Golden
Spencer Parker wrote: I just need to create a local user. [copying back to the list in case it helps others] See if this sets you on the way: http://timgolden.me.uk/python/win32_how_do_i/create-a-local-group-with-a-new-user.html TJG ___ Tutor maill

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-02 Thread Tim Peters
[Alec Henriksen] > How trustworthy is the "randomness" generated by the random module? Python uses the Mersenne Twister algorithm for generating pseudo-random numbers, and that's one of the highest-quality methods known. You can read more about it, e.g., here: http://en.wikipedia.org/wiki/Me

Re: [Tutor] Delete file before function ends

2008-10-06 Thread Tim Golden
Adrian Greyling wrote: Not sure if this is possible, but I'll ask anyway. Below is a code snippet that creates my "problem"... What I'd like to do, is create a plain text file, use the associated program to open said textfile, (using os.startfile) and after the associated program has what it ne

Re: [Tutor] Delete file before function ends

2008-10-06 Thread Tim Golden
Adrian Greyling wrote: path = "c:\MyFolder\mytextfile.xyz" BTW, I hope you're using raw strings in your real code, or else you're going to come a cropper one day when a filename begins with "t". TJG ___ Tutor maillist - Tutor@python.org http://ma

Re: [Tutor] Batch searches on Googlescholar

2008-10-08 Thread Tim Golden
Alan Gauld wrote: "W W" <[EMAIL PROTECTED]> wrote my aim is to identify how many times each publication got cited on google Scholar. You can use the urllib builtin module and beautiful soup for parsing HTML. I don't know if the Googlescholars page allows python connections, I know regular

Re: [Tutor] Printing concatenated unicode strings

2008-10-20 Thread Tim Golden
Siim Märtmaa wrote: i would like to do this print u'\u30fa' ヺ with a method like this b = "30fa" uni = u'\u' + b + '\'' but it prints this UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-1: end of string in escape sequence so how to concatenate properly to print

[Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Tim Brown
ome way to stop codecs from doing this or is there a better way to create and add data to a utf-16 text file? Thanks Tim. Send instant messages to your online friends http://uk.messenger.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.pyt

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Tim Golden
Tim Brown wrote: Hi, I'm trying to create and append unicode strings to a utf-16 text file. The best I could come up with was to use codecs.open() with an encoding of 'utf-16' but when I do an append I get another UTF16 BOM put into the file which other programs do not expect

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-22 Thread Tim Golden
Mark Tolonen wrote: "Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Tim Brown wrote: Hi, I'm trying to create and append unicode strings to a utf-16 text file. The best I could come up with was to use codecs.open() with an encoding of 

[Tutor] Multi-threading IO and the GIL

2008-10-28 Thread Tim Kelsey
blocking on the DB connection? Im using MySQLdb module and the application is purely written in python. Thanks for any information, Tim Kelsey This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. No communication sent by e

Re: [Tutor] Multi-threading IO and the GIL

2008-10-28 Thread Tim Kelsey
- Original Message - From: "Kent Johnson" <[EMAIL PROTECTED]> To: "Tim Kelsey" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, October 28, 2008 12:45 PM Subject: Re: [Tutor] Multi-threading IO and the GIL On Tue, Oct 28, 2008 at 7:27 AM, Tim Kelsey <

Re: [Tutor] How to check online status

2008-11-03 Thread Tim Golden
Timmie wrote: Dear fellow Pythonistas, is it possible to check with Python whether a computer is connected to the internet or not? You've got several options. The simplest, cross-platform solution is to connect a socket to a known port on a known server with a timeout and see if it connects. Bu

Re: [Tutor] cgi scripts

2008-11-09 Thread Tim Johnson
effective way to catch errors otherwise obfuscated by the browser. Although I don't use windows any longer, I recall that pythonwin was a nice IDE to use and it probably has a syntax checker. tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] import data (txt/csv) into list/array and manipulation

2008-11-10 Thread Tim Michelsen
filetype(2) The other file contains signal data in three columns, column one is a unique identifier type int, and the other two columns contain two type int values (genomic location reference values) ** import this as array/list I want to map the location of filetype(2) with respect to filety

Re: [Tutor] Dictionary of dictionaries issue

2008-11-13 Thread Tim Golden
Kent Johnson wrote: On Thu, Nov 13, 2008 at 10:01 AM, A.T.Hofkamp <[EMAIL PROTECTED]> wrote: d3 = dict(( (rv, dict.fromkeys(c)) for rv in r )) You don't need the double parentheses, this works just as well: d3 = dict( (rv, dict.fromkeys(c)) for rv in r ) A generator expression just has to be

Re: [Tutor] what do you use @staticmethod for?

2008-11-20 Thread Tim Golden
spir wrote: Good night, I have not yet found any use for this feature. Also, I do not really understand the difference with @classmethod, from the programmer's points of view (even if I get the difference on the python side). As I see it, a classmethod is a very ordinary method, except its 'o

[Tutor] using windows wide proxy settings

2008-12-03 Thread Tim Michelsen
Hello, is there any possibility in python to retrieve the system wide internet connection settings? I would like to access the proxy settings stored in Internet Explorer -> Extras -> Options -> Connection -> LAN settings. This would later be used by urllib. My aim is not to bother the user wi

Re: [Tutor] Looping, and Win32com.client

2008-12-19 Thread Tim Golden
Eduardo Vieira wrote: Hello, this is my first post in this list and I'm not a programmer, but am enjoying learning python. I'm trying to make a script to add worksheets to excel files: I managed to implement this code: import os folder = 'C:\\Personal\\oldxlsformat\\' from win32com.client import

Re: [Tutor] Looping, and Win32com.client

2008-12-19 Thread Tim Golden
Tim Golden wrote: Eduardo Vieira wrote: Hello, this is my first post in this list and I'm not a programmer, but am enjoying learning python. I'm trying to make a script to add worksheets to excel files: I managed to implement this code: import os folder = 'C:\\Personal\\oldxl

Re: [Tutor] What does OP stand for?

2009-01-09 Thread Tim Golden
Eduardo Vieira wrote: Hello, I'm new to this list, and am enjoying it. I just wonder what "OP" stands for, as I have seen quite a few mentions in the python lists Original Poster - ie whoever it was who first raised the question we're discussing now. In the case of this thread, you're the OP.

Re: [Tutor] What does OP stand for?

2009-01-09 Thread Tim Golden
Eduardo Vieira wrote: Hello, I'm new to this list, and am enjoying it. I just wonder what "OP" stands for, as I have seen quite a few mentions in the python lists Original Poster - ie whoever it was who first raised the question we're discussing now. In the case of this thread, you're the OP.

Re: [Tutor] The better Python approach

2009-01-21 Thread Tim Golden
Robert Berman wrote: Given a string consisting of numbers separated by spaces such as '1234 5678 1 233 476'. I can see I have two obvious choices to extract or parse out the numbers. The first relying on iteration so that as I search for a blank, I build a substring of all characters found befo

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Tim Golden
Alan Gauld wrote: "Wayne Watson" wrote Just using the standard Win XP Pro folder search. I target the folder with my py programs, use *.py to search, and specify I'm looking for angle in the files it finds. Yes, I get the same behaviour! I tried searching for 'import' which should be almost

Re: [Tutor] Recycle bin Windows XP - List or empty the bin

2009-01-31 Thread Tim Golden
Dominique wrote: Googling around this led me to try the following (to empty the bin): from win32com.shell import shell shell.SHEmptyRecycleBin() Unfortunately, this doesn't work. The traceback gives me : TypeError: SHEmptyRecycleBin() takes exactly 3 arguments (0 given) So, I tried something I

[Tutor] Is instance of what?

2009-01-31 Thread Tim Johnson
question will help me answer some bigger questions, pointers to relevant docs and discussions is invited. FYI: preparing to migrate to python 3.0 thanks tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread Tim Johnson
On Saturday 31 January 2009, Andre Engels wrote: <...> > > o=a <> > Actually, it is false. To make it true, you have to do o=a() rather than > o=a You're correct. That was my typo. > > Is there a function that takes one > > > > argument and returns the class? > > > > Example: > > > > class =

[Tutor] Installing python via ftp in virtual domain

2009-02-02 Thread Tim Johnson
wants me to try this initially. Thanks tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Installing python via ftp in virtual domain

2009-02-02 Thread Tim Johnson
On Monday 02 February 2009, John Fouhy wrote: > 2009/2/3 Tim Johnson : > > I have a client who is hosting under virtual domain services that do not > > provide python. > > He has unlimited disk space available ( or so the hoster says) and they > > would allow inst

[Tutor] temporarily modifying sys.path

2010-11-28 Thread Tim Johnson
tation on sys.path that I have found does not address *removing* items from sys.path or completely changing it. Any caveats or comments on this procedure? TIA -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com ___ Tutor maill

Re: [Tutor] temporarily modifying sys.path

2010-11-28 Thread Tim Johnson
bove route first. I'll be darned. I never even heard of that module, but I just did an import and looked at the docs. I *will* give that a try. Thanks for the tip! cheers -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com _

Re: [Tutor] temporarily modifying sys.path

2010-11-28 Thread Tim Johnson
* Alan Gauld [101128 15:17]: > > "Tim Johnson" wrote > >>> Just curious, but could the imp module help you? imp.find_module > >> I'll be darned. I never even heard of that module, but I just >> did an import and looked at the docs. I *will* g

[Tutor] Code evaluation inside of string fails with __get_item

2010-12-10 Thread Tim Johnson
posed with matching keywords. This is probably the most difficult to resolve problem I've ever run into in python. My lack of understand of the underlying code in the Eval classes is probably a contributing factor. TIA -- Tim tim at johnsons-web.com o

[Tutor] Code evaluation inside of string fails with __get_item

2010-12-10 Thread Tim Johnson
k of understand of the underlying code in the Eval classes is probably a contributing factor. TIA -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-11 Thread Tim Johnson
legal "%(...)s"-style format expressions. 3)*But* (and here is the kicker), if the composed format string is then dumped to a pickle file and then loaded from that pickle file it is then evaluated. :) As near as I can see. And that suggests a workaround. Unfor

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-12 Thread Tim Johnson
* Steven D'Aprano [101211 17:20]: > Tim Johnson wrote: > >> I've never had the occasion to use assert() or any other >> python - shooting tools, any thoughts on that? > > > Assertions are a great tool, but never ever, under pain of great pain, > use a

[Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
_doc__': None} Given that I have a text file as input with names and values with a seperator (TAB, for instance) I could initialize variables in a local scope, or I could build a dictionary. Actually the dictionary is preferable for the targeted application. However, for the sake of

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Steven D'Aprano [110103 15:03]: > Tim Johnson wrote: >> I'm just have a little fun here, but I bet that comments will help >> further elighten me on the subtleties of python. >> >> consider the following console session: >>>>> L = ['foo

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Alan Gauld [110103 14:47]: > > "Tim Johnson" wrote > >> consider the following console session: >>>>> L = ['foo','bar'] >>>>> locals()[L[0]] = L[1] >>>>> foo >> 'bar' >>>

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Hugo Arts [110103 17:12]: > On Tue, Jan 4, 2011 at 2:06 AM, Alan Gauld wrote: > > > > "Tim Johnson" wrote > > > >>  Now, Alan, do you know anything about PHP? If you do, can you > >>  comment on the PHP extract() function? > > > > I

[Tutor] Named-value formatting fails

2011-01-08 Thread Tim Johnson
self.globals = globals def __getitem__(self,key): return eval(key,self.globals,self.locals) the implementation looks like this: self.content = content % Evalx() I would really appreciate some insights on this issue. I don't really know how to debug this, except for t

Re: [Tutor] Named-value formatting fails

2011-01-09 Thread Tim Johnson
erent approach would be safer. 2)Can you recommend a *simple* templatting module? thanks -- 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] Named-value formatting fails

2011-01-09 Thread Tim Johnson
* Steven D'Aprano [110109 13:23]: > Tim Johnson wrote: <...> >>> Are you aware that this is non-portable and subject to change without >>> notice? >> No! 1)Can you explain further? <.> Wow! You've given me a huge amount of technical infor

Re: [Tutor] Change Font Size when print to screen

2011-01-11 Thread Tim Golden
On 11/01/2011 09:03, tee chwee liong wrote: When I do print "Hello World", it will print to the cmd window with the standard font size. Is there a way we can increase the font size to larger when print out to the cmd window? I'm going to assume that you're using Windows, since you refer to the

Re: [Tutor] Writing Python Script to read battery level

2011-01-17 Thread Tim Golden
On 17/01/2011 03:01, FT wrote: Is there a way to read the battery level using Python? I am totally blind and want to write a script to capture the battery level and send it through the voice activeX so I can speak it... WMI should be able to query the battery information: import wmi c = wmi

Re: [Tutor] Writing Python Script to read battery level

2011-01-17 Thread Tim Golden
On 17/01/2011 18:35, Bill Allen wrote: Tim, Thanks for posting this. I have several uses for this WMI module at my work. Glad it's useful... TJG ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

[Tutor] Class Docs - how much is too much?

2011-01-26 Thread Tim Johnson
this and a link to such a PEP would suffice. thanks -- 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

<    1   2   3   4   5   6   >