Re: Interface Implementation in Python

2007-03-06 Thread Larry Bates
erfaces. http://wiki.zope.org/zope3/FrontPage http://wiki.zope.org/zope3/programmers_tutorial.pdf -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: catching exceptions from an except: block

2007-03-07 Thread Larry Bates
# else: raise ValueError If they are different functions based on type do something like this: # # Set up a dictionary with keys for different types and functions # that correspond. # fdict={type(''): a, type(1): b, type(1.0): c} # # Call the appropriate function based on type # fdict[type(x)](x) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Creat a DLL File from python code, and use that DLL file in other Platform (Labview, Java .NET etc)

2007-03-09 Thread Larry Bates
k in advance > > AMMS > Do you absolutely need .DLL? You can make a class into a COM object that nearly every language on the planet can dispatch with ease. Here is some info: http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html Calling an existing .DLL? Use ctypes module. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: about application deployment

2007-03-09 Thread Larry Bates
hoice is py2exe to bundle and then Inno Installer to make a setup.exe distrubution program that handles the install and uninstall. Others can chime in on linux, mac, etc. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Are Lists thread safe?

2007-03-09 Thread Larry Bates
utation-are-thread-safe.htm -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with a string plz! (newbie)

2007-03-09 Thread Larry Bates
IMHO Python programmers would never use s=c+s on strings as it is quite inefficient. The methods and functions he uses reversed(), .join(), list() are very powerful Python constructs that you will need to learn how to use. The slicing word[-1::-1] is also something that will come in handy later if you learn how to use it. This is a simple example that you can learn a lot from if you will study Grant's responses. Just my two cents. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Formatted Input

2007-03-12 Thread Larry Bates
Deep wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign these numbers to my variables?? > Or with list comprehension: n1, n2 = [int(n) for n in raw_input().split()] Neither of these methods checks for errors (e.

Re: How to test if a key in a dictionary exists?

2007-03-12 Thread Larry Bates
to do something with the key if it exists and the best method is: try: names['name_key']+=1 except KeyError: # # Key doesn't exist, create it, display error, or whatever you want # to do if it doesn't exist. # -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL: reading bytes from Image

2007-03-12 Thread Larry Bates
take. >> >> Sparklines shows this in action: >> >> http://bitworking.org/projects/sparklines/ >> >> max > > If it hasn't already bitten you it will: It is a BAD idea to use 'file' as a variable name. If you do, you mask the built-in file function. That is why most people use fp or something else. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question : "grep"

2007-03-12 Thread Larry Bates
it()[4]).split("_")[1] if gate in line: return "i_a/i_b/ROM/%s %s LOC =%s" % (gate, index, pos) return "Error" search_gates=[('B6', '[1:0]'), 'B10', '[3:2]'), 'B14', '[5:4]'), 'B17', '[7:6]')] for line in lines: print search(search_gates, line) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question : "grep"

2007-03-12 Thread Larry Bates
t > intellectual curiosity as the current solution obviously does the job. > > Steven > You can certainly get it down pretty small if you turn it into a function as I did, and use a list comprehension, but I think it is hard to read. def search(line): global search_gates for gate, index in search_gates: pos = (line.split()[4]).split("_")[1] if gate in line: return "i_a/i_b/ROM/%s %s LOC =%s" % (gate, index, pos) return "Error" search_gates=[('B6', '[1:0]'), 'B10', '[3:2]'), 'B14', '[5:4]'), 'B17', '[7:6]')] print '\n'.join([search(line) for line in lines]) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: CD insert/eject detection

2007-03-13 Thread Larry Bates
Mark Bryan Yu wrote: > Hi, > > I'm trying to make a Audio CD ripper using python. > > is there a way (library, module, etc) to detect when a CD was inserted > or ejected? > That is going to be OS dependent, so please share with us what OS you are on? -Larry -- http

Re: struct.pack oddity

2007-03-13 Thread Larry Bates
Erik Johnson wrote: > "Dave Opstad" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Is the lack of a struct.error when the byte-order mark is at the start >> of the format intentional? This seems like a bug to me, but maybe >> there's a subtlety here I'm not seeing. > > I am b

Re: Tools for GUI/graphics

2007-03-13 Thread Larry Bates
rom a 1st sight > I couldn't see if it allows for easy graphic > charts - may be with svg ... > > Thanks for any suggestions. You can use ReportLab Graphics to generate the graphs as .JPG files and display them in a browser window with simple HTML. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Larry Bates
rong. If hint='n' hint !='n' is False hint !='y' is True False or True equals True I think you want something like: hint = raw_input("\nAre you stuck? y/n: ") hint = hint.lower() while hint not in ['y', 'n']: hint = raw_input("Please specify a valid choice: ") -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem in importing fipy

2007-03-13 Thread Larry Bates
that the place where you installed fipy isn't on your PYTHONPATH so python can't find the module. If you haven't already, take a look at: http://www.ctcms.nist.gov/fipy/installation.html Manual looks quite good and covers installation well. It appears you can go here and

Re: IronPython and COM Interface

2007-03-14 Thread Larry Bates
IDispatch (COM) object # so I can pass it to my COM object. # idCallback=win32com.server.util.wrap(cb) # # Call the COM interface and pass it the callback function # r=oC.WSset_callback(idCallback) In my case the COM object was also written in Python so to get to the python object I do following: def WSset_callback(idCallback) self.callback=win32com.client.Dispatch(idCallback) Now I can call .progress method of callback class from the COM object. self.callback.progress(total, number) Hope this helps in some way. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.basename() - only Windows OR *nix?

2007-03-14 Thread Larry Bates
tory. Files get timestamped and then put > into the corresponding directory. It is just that having > 'C:\a\very\long\path\file.ext' as a filename on the server is not nice. > > Thomas > You will need to write some Javascript and assign something to a hidden field that gets posted. Here is some Javascript to get you started: http://www.javascripter.net/faq/operatin.htm -Larry -- http://mail.python.org/mailman/listinfo/python-list

Python COM called from VB/Delphi

2007-03-14 Thread Larry Bates
ions but the VB one has got me stumped. Thanks in advance for any assistance. Regards, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiline code - trailing slash usage

2007-03-15 Thread Larry Bates
') Python knows you aren't done because you haven't provided the closing parenthesis. I do this in list comprehensions also: n=[(variable1, variable2) for variable1, variable2 in something if variable1.startswith('z')] You do need it in your first example, but not in your second. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle Problem

2007-03-15 Thread Larry Bates
o get an instance. What you got was a pointer (x) to the DemoClass not an instance of DemoClass. 2) Same for WriteToFile() 3) Probably best to move the path to main and always pass it into WriteToFile. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with str()

2007-03-15 Thread Larry Bates
ost recent call last): > File "test1.py", line 23, in ? > print str(getattr(obj, methodList[0]).__doc__) > TypeError: 'str' object is not callable > > This is part of some code in Diving Into Python,Chapter 4. In case a > function doesn't have a __doc__

Re: screen size/resolution in win32 in python

2007-03-19 Thread Larry Bates
do anything with this that would stretch your application across all 2 (or 3) monitors. I think screensize isn't going to give you enough information to automatically size or position a window. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: SQLObject 0.8.1

2007-03-19 Thread Larry Bates
ed and simplified DatabaseIndex.get(). > > * Fixed ConnectionHub.doInTransaction() - close low-level connection on > commit() to prevent connections leaking. > > For a more complete list, please see the news: > http://sqlobject.org/News.html > > Oleg. WOW! Went from 0.7.4 to 0.8.1 in the span of only 23 minutes! -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Zip file writing progress (callback proc)

2007-03-27 Thread Larry Bates
7;c:\Library\TurboDelphi\TurboDelphi.exe') At least by doing it this way you won't break anything if you get a new zipfile module. It just won't show progress any more and then you can patch it. Hope info helps. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Auto execute python in USB flash disk

2007-03-27 Thread Larry Bates
ith encryption included. They are REALLY cheap. http://www.kingston.com/flash/DataTravelers_enterprise.asp -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: newbi question on python rpc server, how it works?

2007-03-28 Thread Larry Bates
://www.oreilly.com/catalog/twistedadn/ I'll bet it will be worth the purchase price if you choose to go this direction. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a new data structure while filtering its data origin.

2007-03-28 Thread Larry Bates
>>the easier way to get that final output. > > Thanks in advance. > > d={} for a, b, c in lista: if d.has_key(b): if d[b].has_key(c): if a not in d[b][c]: d[b][c].append(a) else: d[b][c]=[a] else: d[b]={c:[a]} print d -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: how can I clear a dictionary in python

2007-03-28 Thread Larry Bates
[EMAIL PROTECTED] wrote: > Hi, > > I create a dictionary like this > myDict = {} > > and I add entry like this: > myDict['a'] = 1 > but how can I empty the whole dictionary? > > Thank you. > just point myDict to an empty dictionary again myDict=

Re: how can I clear a dictionary in python

2007-03-29 Thread Larry Bates
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Larry Bates <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> I create a dictionary like this >>> myDict = {} >>> >>> and I add entry like this: >>> myDict['a'

Re: how can I clear a dictionary in python

2007-03-29 Thread Larry Bates
Bruno Desthuilliers wrote: > Larry Bates a écrit : >> Aahz wrote: >>> In article <[EMAIL PROTECTED]>, >>> Larry Bates <[EMAIL PROTECTED]> wrote: >>>> [EMAIL PROTECTED] wrote: >>>>> I create a dictionary like this >>>

Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread Larry Bates
27; character in front of all their choices, so I was thinking of > accepting the string input first, then adding in the '-' character > myself. > > So my qusetion is, how do I change: > > "2a 3ab" into "-2a -3ab". > > Regular expressions? :/ > s="2a 3b" s="-%s -%s"% tuple(s.split()) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Is any way to split zip archive to sections?

2007-04-02 Thread Larry Bates
= zipfile.ZipFile('/zips/archive%s.zip' % archive_num, "w") outfile.write(full_name_path,full_name_path,zipfile.ZIP_DEFLATED) There is still a couple of "issues": 1) Files larger than 15Mb may not be able to be compressed to fall below the limit. 2) If you are near the 15Mb limit and the next file is very large you have the same problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Based API

2007-04-02 Thread Larry Bates
to be pretty easy). I was easily able to call from VB, Delphi and Python COM. I haven't tried C/C++ yet, but expect no problems. I think COM is now the way to go (unless you do .NET). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: doing standart window icons unvisible in python

2007-04-02 Thread Larry Bates
what you mean by close-minimize icons unvisible, but I can answer the .exe question. Take a look at py2exe which allows you to bundle up python program as .exe for distribution. You can see it a www.py2exe.org. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie - needs help

2007-04-04 Thread Larry Bates
> Thanks in advance. > > Anbeyon > If you are on Windows take a look at PyScripter: http://mmm-experts.com/Products.aspx?ProductId=4 I would also recommend a copy of Python Cookbook which has LOTS of example code you can look at and use. -Larry Bats -- http://mail.python.org/mailman/listinfo/python-list

Re: How to open a txt file from the same folder as my module (w/out changing the working dir)

2007-04-04 Thread Larry Bates
. Am I? > > Thanks a lot, > Sergio The problem is that C:\Python25\Lib\site-packages\spam is not the current working directory when you run the program. If it were, and if configuration.txt is in that directory it WILL find it. If you are running this from a shortcut make the working directory C:\Python25\Lib\site-packages\spam -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Looping issues

2007-04-05 Thread Larry Bates
s of: import difflib correct_lines=open(r"C:\Python25\Scripts\Output" \ "\correct_settings.txt", "r").readlines() current_lines=open(r"C:\Python25\Scripts\Output\output.txt", "r").readlines() delta=difflib.unified_diff(correct_lines, current_lines) diffs=''.join(delta) print diffs Will show you the lines that are different and some lines around it for context. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: ipython env

2007-04-05 Thread Larry Bates
t; But then when try to access the information in the dictionary it > doesn't seem to exist: > > In [2]: env['EDITOR'] > --- > exceptions.NameError Traceback (most > recent call last) > > /Users/destiney/ > > NameError: name 'env' is not defined > > > Thanks, > > In Cpython you get this with: import os os.environ['EDITOR'] -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Crypto Suggestion/Help

2007-04-09 Thread Larry Bates
way to do, like MD5 or similar, please let me know. > > > Thanks, > Jimmy Put the private key on a USB key and read it from there to create the logs. When you unplug the USB key, the private key is gone from the machine. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Hosting Companies: Help for Python Users?

2007-04-09 Thread Larry Bates
't > guarantee that this will happen overnight, but I'd like to make a start. > > regards > Steve Apollo Hosting has this available (www.apollohosting.com). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: recursively archiving files

2007-04-09 Thread Larry Bates
le line, as it is often more prone to error. > > Thanks > bahoo > Use os.walk to talk your branch of directories. Use glob.glob to find only those files that match your mask. Use zipfile or tarfile module (depending on if you want .gz or .zip compressed file) to add each file to the comp

Re: Problem with getting an option value

2007-04-10 Thread Larry Bates
-- > Protect yourself from spam, > use http://sneakemail.com Use a dispatch dictionary: dispatch={'int': getint, 'bool': getboolean} then call it: dispatch(t)(*args) Note: You should NOT use type as a variable name because it will shadow the built-in type function. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: convert html entities into real chars

2007-04-10 Thread Larry Bates
; > Laszlo > You can use htmlentitydefs module to help with this. import htmlentitydefs chr(htmlentitydefs.name2codepoint['gt']) and (to go the other way) htmlentitydefs.codepoint2name[ord('>')] -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: descriptor object for an attribute?

2007-04-11 Thread Larry Bates
of a parent). > Having a handle on any of the links in the graph would be a useful > thing. > I believe you are looking for setattr(obj, attr, value) and getattr(obj, attr) functions. Since everything in python its a pointer to an object, I wasn't able to understand EXACTLY what you were asking (an example would help). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading the first line of a file (in a zipfile)

2007-04-11 Thread Larry Bates
27;, len(bytes), 'bytes' > print 'and', count, 'lines' > > The first line in the file I am examining will be a number followed by > more whitespace. Looks like I cannot split by whitespace? > You have told split to split on single blank space not whitespace. To split on whitespace use .split() (e.g. no arguments) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating an EXE for XLRD + WIN32COM + wxWidgets application - Help request

2007-04-12 Thread Larry Bates
on many different pieces. I have not experience with XLRD but the other pieces you use work just fine. Check on www.py2exe.org for docs an wiki. There is also a newsgroup at gmane.comp.python.py2exe that you can submit questions to if you like. I know that it is monitored by Mark Hammond, Thomas Heller, and other users of py2exe that can help you. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: moving multiple directories

2007-04-16 Thread Larry Bates
le method that just moves the directory entries around. >From Win32 Documentation: win32api.MoveFile MoveFile(srcName, destName) Renames a file, or a directory (including its children). Parameters srcName : string The name of the source file. destName : string The name of the destin

Re: looking for library to read ppt files

2007-04-16 Thread Larry Bates
peg-jpg-tiff-bmps-converter.htm http://www.print-driver.com/howto/converting/convert_microsoft_powerpoint_presentation_to_jpeg.htm -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Passs NULL as a IDispatch Pointer to method?

2007-04-17 Thread Larry Bates
# def somemethod(self): # # Put this method's code here # pass # # In your program # id=win32com.server.util.wrap(who()) x.AddShapeInfo("who",0,id) I could be way off base here, but I hope that this helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: python - dll access (ctypes or swig)

2007-04-17 Thread Larry Bates
=win32com.client.Dispatch("typelib name"). You need to find out the COM dispatch typelib name and make sure the DLL is registered (regsvr32 your.dll). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Python COM iterator

2007-04-17 Thread Larry Bates
e to write something like (VB): oFOO=foo() for each n in oFOO ' ' Do something with n ' next Seems like there should be a way. Hope explanation is clear enough. Regards, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: python - dll access (ctypes or swig)

2007-04-18 Thread Larry Bates
Alex Martelli wrote: > Larry Bates <[EMAIL PROTECTED]> wrote: > >> recently learned that you can ship COM as either an .EXE or a .DLL (nobody >> has yet let me know why). > > The "why" is pretty obvious -- you may want to be able to instantiate a >

Re: How to Passs NULL as a IDispatch Pointer to method?

2007-04-18 Thread Larry Bates
Yingpu Zhao wrote: > Thanks to Larry. > I want to pass the IDispatch pointer of other COM object to > AddShapeInfo or pass null to tell x do nothing. > for example. > > Rect= Dispatch("Rect.Document") > ShapeSet = Dispatch("xxx.Document") > Sha

Re: Newbie: import

2007-04-18 Thread Larry Bates
't find any relevant > environment variables. > > Thanks from a newbie for any insight. > PYTHONPATH environment variable is next in line to be searched. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: "once" assigment in Python

2007-09-17 Thread Larry Bates
Lorenzo > IMHO variables like what you describe are really data not program variables. You might consider putting variables like these in a dictionary and then check to see if the keys exist before assignment: var_dict={} # # See if 'varname' initialized, if not it needs to be # if 'varname' not in var_dict: var_dict[varname]=somevalue -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing problems: A journey from a text file to a directory tree

2007-09-17 Thread Larry Bates
Since you are going to need to do a dialog, I would use wxWindows tree control. It already knows how to do what you describe. Then you can just walk all the branches and create the folders. -Larry Martin M. wrote: > Hi everybody, > > Some of my colleagues want me to write a script

Re: Processing drag & drop on the desktop

2007-09-17 Thread Larry Bates
on the desktop, when you drop any file on it in Windows it is passed into the program via the sys.argv list as the second (e.g. sys.argv[1]) argument. If you drop multiple files, they are passed in sys.argv[1] sys.argv[n]. All you need to do is to pick up the filename and do your processing. -

Re: Using python to create windows apps that everyone can use?

2007-09-19 Thread Larry Bates
t; > matt Might want to take a look at wxGlade (http://wxglade.sourceforge.net), you will need wxWindows and py2exe to complete the toolkit. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Google and Python

2007-09-19 Thread Larry Bates
wondering what is done at Google with > Python and which Python "environments/applications" (Zope, TurboGears, > mod_python ...) are in use, and what is done with other languages, and > which other languages are they using. > Have you tried Google "google python&qu

Re: Converting numbers to unicode charaters

2007-09-24 Thread Larry Bates
How about: ord=''.join([unichr(int(x,16)) for x in hexs]) I don't know if its faster, but I'll bet it is. -Larry [EMAIL PROTECTED] wrote: > Here's how I'm doing this right now, It's a bit slow. I've just got > the code working. I was wondering if

Re: HTTPS request

2007-09-25 Thread Larry Bates
p. > L. > Depends on what the server requires. You can do basic authenticate to a https: site if it supports it. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing elements of a list with a string

2007-09-25 Thread Larry Bates
Here is how you would do it if all your backup files begin with fstab. import glob list_of_backup_files=glob.glob('/home/shriphani/backupdir/glob*') If "fstab" can appear anywhere in the filename, this might not work for you. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for volunteer to help debug SpamBayes problem

2007-10-04 Thread Larry Bates
using SpamBayes with Outlook/IMAP for about 6 months without any problems. One "issue" is that it doesn't seem to filter my mail when I first start up each morning. I have to manually run the filtering process. I've never seen UnicodeDecodeError. I'd be happy to test something for you. FYI, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Import PY file not included in py2exe executable

2007-10-04 Thread Larry Bates
es (if needed), create shortcuts, etc. The time I spend installing and learning Inno has paid for itself many times over. FYI, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Editing particular lines of a text file.

2007-10-09 Thread Larry Bates
if line.startswith('msgid'): parts=line.split(' ') try: parts[1]=xlate[parts[1]] except: # # Handle exception if your translation dictionary does # not have the string you are looking for here. # raise KeyError newline=' '.join(parts) fp2.writeline(newline) fp1.close() fp2.close() -Larry -- http://mail.python.org/mailman/listinfo/python-list

Drop folder and race conditions

2007-10-09 Thread Larry Bates
folder that make the deletion of folders impossible. This project has become significantly more complex than it appeared at first. Anyone out there have any "sage" advice on how to tackle this beast? Thanks in advance for any pointers. Regards, Larry Bates -- http://mail.python.o

Re: Exceptions: Logging TB and local variables?

2007-10-10 Thread Larry Bates
gram # aborts"as well as some information about what caused the program to # abort. # import traceback # # Get traceback lines # tblines=traceback.format_exception(type, value, tb) # # Write some lines to log # log_error_to_file() #

Re: for loop question

2007-10-10 Thread Larry Bates
gt; A "works-for-me": > > >>> pairs = (test[i:i+2] for i in xrange(len(test)-1)) > >>> for a,b in pairs: > ... print a,b > ... > H e > e l > l l > l o > o > w > w o > o r > r l > l d > >>> > > -tkc > > > import itertools test = u"Hello World" ltest=["'%s'" % c for c in test] for a, b in itertools.izip(ltest, ltest[1:]): print x, y 'H' 'e' 'e' 'l' 'l' 'l' 'l' 'o' 'o' ' ' ' ' 'W' 'W' 'o' 'o' 'r' 'r' 'l' 'l' 'd' -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: if then elif

2007-10-10 Thread Larry Bates
then the total number of > calories. Boolean problem: if cal or fat <= 0 That may be the way you say it or "think" it but it won't work. 'cal or fat' is evaluated first. Since they both have values this ALWAYS evaluates to 1 which is NEVER less than or equal

Re: howto add a sub-directory to the searchpath / namespace ?

2007-10-10 Thread Larry Bates
find a way. > > Is there a way to make f1.py and f2.py available as if they were located > in the base directory, > without knowing their names (so in general all py-files in the subdir1) ?? > > thanks, > Stef Mientki > > Put basedirectory\subdir in t

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Larry Bates
lasses are classes can be stored in lists or dictionaries. In lists you reference them via their index (or iterate over them) and in dictionaries you can give them a name that is used as a key. Hope this helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with wxPanel derivation class

2007-10-11 Thread Larry Bates
t;, line 13, in __init__ > self.panel = Panel(self, -1) > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 48, in __init__ > self.staticbox = wx.StaticBox(self, -1, "StaticBox") > File > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_controls.py

Re: Problem with global

2007-10-12 Thread Larry Bates
sql, *args): global db try: import pdb; pdb.set_trace() cursor = db.cursor() # db is . [...] except: print "Problem contacting MySQL database. Please contact root." sys.exit(-1) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Organizing Sequential Data (TimeStamps) Overthinking?

2007-10-19 Thread Larry Bates
e talking about. Certainly if you have a lot (millions), you should implement binary search, but I would write code first and if it is too slow, fix that part. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the instance name from a list by Reflection

2007-10-22 Thread Larry Bates
__, elem, isSame) >... >['.aList[0]', '.elem', '.a1'] >['.aList[1]', '.elem', '.a2'] >>>> > > Don't see how this could help, > > Jean-Paul If you want to accomplish something like this use the following: class A(object): def __init__(self, name=None): self.name=name aList=[] aList.append(A(name='a1') aList.append(A(name='a2') for elem in aList: print elem.name -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Mouse hover event in wxpython

2007-10-26 Thread Larry Bates
ter replies to wxPython specific questions. Looks like you might want OnEnter(self, x, y, d) and OnLeave(self) methods of wxDropTarget class -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples within tuples

2007-10-26 Thread Larry Bates
> First of all [A,B,C,D] is a list not a tuple. (A,B,C,D) is a tuple. Without a better example or explanation of what you are trying to do it is difficult, but I'll give it a try: myTuple=(A,B,C,D) for n, item enumerate(myTuple): if n in (0,2): myList.append(item) -Larry -

Re: a few questions.

2007-10-31 Thread Larry Bates
i in xrange(0,5): x=raw_input("input number for store=%i ?" % i) stores.append(int(x)) for i in xrange(0,5): hundreds, remainder=divmod(stores[i], 100) print "Store: %i %s" % (i+1, hundreds*"*") -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary help

2007-10-31 Thread Larry Bates
can simply open LPT1, LPT2 or LPT3 as a file and write to it (for simple printing). For more complex "Windows" printing you must use Win32 extensions or something like wxWindows. -Larry -- http://mail.python.org/mailman/listinfo/python-list

How to use Mercurial for local source code management with a public Subversion server

2007-01-10 Thread Larry Hastings
the message would be happily received by its subscribers. Cheers, /larry/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python - C# interoperability

2007-01-11 Thread Larry Bates
or basically ANY other language that can call COM objects) quite easily and compile them with py2exe for distribution without python itself. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question: SMTP -> SQL Server

2007-01-11 Thread Larry Bates
Steve Holden wrote: > jrpfinch wrote: >> Thank you. I have just realised I completely misunderstand how SMTP >> servers work. From what I can tell, when you run the cookbook script >> it listens locally on port 8025. >> >> You then have to configure a Linux (in my case) account with a username >>

Re: Is there a good example on instantiating, calling, using, an API from Python on Windows?

2007-01-11 Thread Larry Bates
hanks, > When you say API what EXACLY do you mean. Is it a .DLL that you need to call (if so see ctypes module) or a COM API (if so see win32 module)? Other APIs could use sockets, pipes, etc. you will need to give us more to be able to help. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Watch log

2007-01-15 Thread Larry Bates
le, seek to the old length and read bytes up to the new length and close the logfile. What is read will be the new log entry (or entries). Reset the logfile length high water mark and loop. Hope information helps. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone has a nice "view_var" procedure ?

2007-01-15 Thread Larry Bates
t an integer as the third element a float as the third element a dictionary as the fourth element a class instance as the fifth element The tutorial is a good place to start if you haven't already looked at it. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a simple script standalone

2007-01-16 Thread Larry Bates
s on an - easy and clear - path to follow ? > > I use py2exe and inno installer. Works great. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: module check

2007-01-22 Thread Larry Bates
Victor Polukcht wrote: > Can anybody suggest a correct way of checking in python module exists > and correctly installed from python program. > Not sure I understand the question, but I'll try: try: import yourmodule except: print "Can't import yourm

Re: difflib qualm

2007-01-25 Thread Larry Bates
s searchable via an index. If you REALLY need speed you can consider an in-memory database. Create soundex keys for each name in your small list and query the database with this key into the table in the DB that is indexed on soundex keys. If you get a hit, the key is sufficiently "alike" to be a candidate. I'll leave the remainder to you. Perhaps there is other information that will help determine if there is a match? -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: data design

2007-01-30 Thread Larry Bates
ds of lines of config data is extremely small. I use it a LOT and it is very flexible and the format of the files is easy for users/programmers to work with. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: data design

2007-01-30 Thread Larry Bates
Imbaud Pierre wrote: > Larry Bates a écrit : >> Imbaud Pierre wrote: >> >>> The applications I write are made of, lets say, algorithms and data. >>> I mean constant data, dicts, tables, etc: to keep algorithms simple, >>> describe what is peculiar,

Re: DCOP memory leak?

2007-01-30 Thread Larry Bates
something after each loop or do you really want to peg the CPU checking forever? Q: How do you ever get out of this infinite loop? Note: while 0=0 is better written as while 1: and you need a break somewhere to get out of the loop. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting a List of Lists

2007-01-30 Thread Larry Bates
t; list2): > x = list1[2] > y = list2[2] > if > x>y: > return > 1 > elif > x==y: > return > 0 > else: # > x return -1 > > But as before sorting with this function returns None. > > What have I ov

Re: Help needed on config files

2007-01-31 Thread Larry Bates
rt ConfigParser cfg = ConfigParser() cfg.read("proj.cfg") projectSections=[section for section in cfg.sections() if x.startswith('PROJECT')] # # Note: sections are case sensitive # for project in projectSections: # # Do your work # -Larry This seems to work quite well. I hope information helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: how to make a python windows service know it's own identity

2007-02-01 Thread Larry Bates
-i", "--identifier", dest="identifier") > (opts, args) = parser.parse_args() > if opts.number is not None: > MyService._svc_name_ += opts.identifier > MyService._svc_display_name_ += opts.identifier > MyService._provider_id

Re: Recursive zipping of Directories in Windows

2007-02-01 Thread Larry Bates
Double check me on that. I don't see anything that references C:\\aaa\temp in your code. Does it exist on your hard drive? If so does it maybe contain temp files that are open? zipfile module can't handle open files. You must use try/except to catch these errors. Hope info helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: python executing windows exe

2007-02-01 Thread Larry Bates
Kiran wrote: > Hi everybody, > I am making python run an executable using the os module. Here is > my question. The executable, once it is running, asks the user to > input a filename that it will process. Now, my question is how do i > automate this. let me make this clear, it is not an argu

Re: how to make a python windows service know it's own identity

2007-02-01 Thread Larry Bates
Chris Curvey wrote: > On Feb 1, 2:10 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> Chris Curvey wrote: >>> Hi all, >>> I have used the win32com libraries to set up a service called >>> MyService under Windows. So far, so good. Now I need to run mult

Re: newbie/ merging lists of lists with items in common

2007-02-02 Thread Larry Bates
a[0] == n[0]: > a.append(n[1:]) > del alist[i+1] > > Sorry about the lengthy message and thanks for your suggestions - I'm > trying to learn... > One solution: l=[['a', '13'], ['a', '3'], ['b', '6'], ['c', '12'], ['c', '15'], ['c','4'], ['d', '2'], ['e', '11'], ['e', '5'], ['e', '16'], ['e', '7']] d={} for k, v in l: if d.has_key(k): d[k].append(v) else: d[k]=[v] print "d=", d l=[x for x in d.items()] print l -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Watch folder for new file and execute extern program

2007-02-05 Thread Larry Bates
hon/win32_how_do_i/watch_directory_for_changes.html BTW-It helps us out here if you let us know what platform you are running on (e.g. Windows, Linux, Mac, etc.). -Larry -- http://mail.python.org/mailman/listinfo/python-list

<    8   9   10   11   12   13   14   15   16   17   >