Re: Where can I suggest an enchantment for Python Zip lib?

2007-06-09 Thread Larry Bates
durumdara wrote: > Hi Larry! > >> durumdara wrote: >> You can easily find out roughly how many bytes are in your .ZIP archive >> by using following: >> >> zipbytes=Zobj.fp.tell() >> > > The main problem is not this. > I want to write a backup s

Re: urllib2 - iteration over non-sequence

2007-06-09 Thread Larry Bates
in get_type raise ValueError, "unknown url type: %s" % self.__original ValueError: unknown url type: www.google.com Note the traceback. you need to call it with type in front of the url: >>> import urllib2 >>> urllib2.urlopen('http://www.google.com') > Python's interactive mode is very useful for tracking down this type of problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations

2007-06-10 Thread Larry Elmore
Twisted wrote: > On Jun 9, 8:21 pm, "BCB" <[EMAIL PROTECTED]> wrote: >> "Paul McGuire" <[EMAIL PROTECTED]> wrote in message >> >> news:[EMAIL PROTECTED] >> >>> On Jun 9, 6:49 am, Lew <[EMAIL PROTECTED]> wrote: > In particular, Perl code looks more like line > noise than like code from any k

Re: Forgetting an import

2007-06-12 Thread Larry Bates
e there may be ways of doing this, I have found that you are much better off opening another window and run your script from the bare OS. It will help you catch problems that you may miss in the interpreter shell. It also solves this problem completely. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: how to kill a process

2007-06-12 Thread Larry Bates
; thanks very much.- > Wouldn't it be better to make the process that you start respond gracefully to some signal? Either a command over a socket or some other signal? -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: one-time initialization of class members

2007-06-13 Thread Larry Bates
all the class instances. If you reset it based on param it will be reset every time you create a new instance of the Base class with a different param. Is that really what you want to do? If so just use: class Base(object): dataset = None def __init__(self, param): if self.d

Re: Transfer file name input from one .py to another

2007-06-20 Thread Larry Bates
log class main: def getfilefromdialog(self): self.filenamefromdialog=... -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to hide a program?

2007-06-20 Thread Larry Bates
teProcess(execute_target, commandLine, processAttributes, threadAttributes, bInheritHandles, dwCreationFlags, newEnvironment, currentD

Re: Reading multiline values using ConfigParser

2007-06-21 Thread Larry Bates
Then it is pretty easy to do something in my code like: section='Testcases' cases=[x for x in INI.options(section) if x.startswith('case_')] for case in cases: casefile=INI.get(section, case) # # Process each casefile here # -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Conceptualizing Threading

2007-06-21 Thread Larry Bates
king), but I thought I should > check here first and see if someone could help me wrap my brain around > this problem. You'll never learn if you never try, right? > Just use a database with an auto-incrementing column. It will handle all the "threading" that you think you require and each call will return the next number you need. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding Python to the path in Windows

2007-06-21 Thread Larry Bates
f your users aren't programmers, then why not just run Python over > the network? That's what we do at my place of employment. The only > machines that have Python actually installed are development machines. > > Mike > Another solution is to use py2exe to convert your python program into an .exe file that you can distribute. Then they require no Python installation at all. I use py2exe and Inno Installer to do just that and it works great. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a file with read access rights

2007-06-21 Thread Larry Bates
Johny wrote: > Is it possible to create a file on Linux with access rights? > For example > owner can read and write into the file > others can only read from the file > Thanks for replies > L. > See os.chmod() -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-21 Thread Larry Bates
gain depending on access required). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create new files?

2007-07-12 Thread Larry Bates
en creates files for me, so I'm uncertain why you think it isn't for you. the .read() method accepts the number of bytes not the buffer to store bytes read. data=self.m_file.read(4) would read 4 bytes into string object pointed to by data. sizeof() in Python is len() -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Function parameter type safety?

2007-07-12 Thread Larry Bates
explicit requirement: def foo(arg1): if isinstance(arg1, (basestring, unicode): print "is string" else: print "is NOT string" return -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: shutil.copyfile problem for GIS data

2007-07-18 Thread Larry Bates
act nature of your problem I can tell you that the src string you have defined won't work becaust \t is a tab character. To make shutil.copyfile work you need to do: src = r"c:\mydata\test\mygeo.mdb" dst = r"v:\updated\data\mygeo.mdb" or src = "c:\\mydata\\test\\mygeo.mdb" dst = "v:\\updated\\data\\mygeo.mdb" -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Open HTML file in IE

2007-07-18 Thread Larry Bates
re filename.html") (at least this works on my system). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Python COM iterator

2007-04-18 Thread Larry Bates
Carsten Haese wrote: > On Tue, 2007-04-17 at 16:54 -0500, Larry Bates wrote: >> Does anyone know if there is a way to make a Python COM object >> act like a proper iterator in VB/Delphi? > > I don't use COM, VB, or Delphi, but Google turned up these two > references

Re: Python COM iterator

2007-04-19 Thread Larry Bates
Carsten Haese wrote: >> [...] >>> On Tue, 2007-04-17 at 16:54 -0500, Larry Bates wrote: >>>> Does anyone know if there is a way to make a Python COM object >>>> act like a proper iterator in VB/Delphi? >> [...] > > After more googling, starin

Re: NFS Help

2007-04-19 Thread Larry Bates
Clement wrote: > how to get the file from NFS share in python.. > NFS share is mounted on your local directory, you get to it the same way you would any other file (e.g. go to the mount point and get the file). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating search engine in Python Good or Bad [in performance]

2007-04-19 Thread Larry Bates
LAN bandwidth C won't help at all. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: NFS Help

2007-04-19 Thread Larry Bates
Clement wrote: > On Apr 19, 11:44 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> Clement wrote: >>> how to get the file from NFS share in python.. >> NFS share is mounted on your local directory, you get to it >> the same way you would any other file (e.g.

Re: Significance of "start" parameter to string method "endswith"

2007-04-19 Thread Larry Bates
e a real use > case when we would test for endswith like this? (knowing that it must > return false?) > > Thanks for any ideas/experience. > Boris > Seems like a convenience I've never used. >>> a="abcdef" >>> a.endswith('cd',2,4) True >>> a[2:4].endswith('cd') True -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Better dict of dicts

2007-04-19 Thread Larry Bates
gt; in case of a collision, so when you lookup a key they can tell which > you're really looking for. Maybe this will help: http://wiki.python.org/moin/DictionaryKeys -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast and capable XML parser?

2007-04-20 Thread Larry Bates
x27;t support XML Schema validation.) > > Any suggestions? I don't know if it meets ALL of your requirements but this might help: http://www.reportlab.org/pyrxp.html -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: When to clear a dictionary...

2007-04-20 Thread Larry Bates
2,4:3} >>>> a = b > Syntax error in the first example but if you fix that the first two are equivalent (but I would suspect that the second would be faster for large dictionaries). The third example both a and b point to the same dictionary after the a=b which you can see from: >>> a is b True >>> id(a) 31760224 >>> id(b) 31760224 >>> -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: When to clear a dictionary...

2007-04-20 Thread Larry Bates
Gabriel Genellina wrote: > En Fri, 20 Apr 2007 14:28:00 -0300, Larry Bates > <[EMAIL PROTECTED]> escribió: > >> Bill Jackson wrote: >>> What is the benefit of clearing a dictionary, when you can just reassign >>> it as empty? >> >> If you have o

Re: Launch another application

2007-04-23 Thread Larry Bates
and is intended to replace popen (which still works if you prefer to use it). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: getting scancodes

2007-04-24 Thread Larry Bates
gt;>> What hardware? What OS? >> Debian Sarge/Etch, i386.. >> >> :P > > Gret. Now we only need to guess what scan code reader you use > > > I believe he his referring to keyboard scancodes not a scanner. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Python not giving free memory back to the os get's me in real problems ...

2007-04-25 Thread Larry Bates
application, you should contact their tech support for a solution. The problem isn't specifically a Python problem but rather an implementation problem with their app. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: File not read to end

2007-04-25 Thread Larry Bates
e some chance of figuring out why this working code stops. There's nothing wrong with this code, the problem is somewhere else. Suggestion: lineCount = 0 for line in sysFile: lineCount +=1 print str(lineCount) + " -- " + line can be written: for lineCoun

Re: My python annoyances so far

2007-04-25 Thread Larry Bates
s in VB, Delphi, and Python I am once again reminded why I love Python. I have more lines of declarations in the Delphi version than in the Python program for some tests. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Store variable name in another variable

2007-04-26 Thread Larry Bates
ar!!! > > How can I do this? > Use a dictionary. Example: var1=10 var2="abc" var2=1.2 vardict['var1']=var1 vardict['var2']=var2 vardict['var3']=var3 print vardict['var1'] print vardict['var2'] print vardict['var3'] -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrupting ftplib.storbinary()

2007-04-26 Thread Larry Bates
t the interruption as > cleanly as possible? > > thanks! > I suspect that you would make a file-like object that has a read method and pass it to storbinary instead of your normal fp argument. Then you can signal it to stop gracefully. Haven't tested, but it shoul

Re: Python keywords

2007-04-26 Thread Larry Bates
27;a','b','c','y','z'] key in {'key1':1, 'key2': 2} The in you see with a for isn't associated with the for loop but rather the sequence you are iterating over for i in range(10): -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: use urllib library to have an upload status bar

2007-04-27 Thread Larry Bates
of the same. Keep up the good work. Cheers! > the generic http browser upload doesn't give you any opportunity to have a callback so you can update the screen with any progress. There are some Java solutions available, but IMHO it will take a major change to browser's http upload imp

Re: python and COM

2007-04-27 Thread Larry Bates
uch. Normally you define a Python class that has methods that ADxList.OnUpdate is expecting to be able to call. Then depending on implementation you either call it with an instance of that class or you may have to wrap the instance in a COM IDispatch object by calling win32com.server.util.wrap() around an instance of the function. Sorry I can't be more helpful. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert float to sortable integer in Python

2007-04-30 Thread Larry Bates
way the remainder. 3) You can sort on float just fine, so why do you need int()? -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Want to build a binary header block

2007-05-01 Thread Larry Bates
rn ''.join(rtnvals) Then in your main program bS=blockStruct() bs.hstring='this is a test'.ljust(240, ' ') bs.W=12 bs.X=17 bs.Y=1 bs.Z=0 print bS Seemed to be a good way that made debugging and understanding easy for me. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: __dict__s and types and maybe metaclasses...

2007-05-02 Thread Larry Bates
haven't found any setup that works. > I think that most people accomplish this by: class blah: __initial_values={'a': 123, 'b': 456} def __init__(self): self.__dict__.update(self.__initialvalues) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Cannot execute Windows commands via Python in 64-bit

2007-05-02 Thread Larry Bates
n my 32-bit windows machines. > Thanks. > Sounds like system can't find defrag. Usually this is because of a path issue. Are you running the script in the foreground or scheduled? Can you open a command prompt and enter the command and have it work? If you give full path, this shouldn't be the problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Python COM and Delphi callback

2007-05-02 Thread Larry Bates
nt. I have the // callback working perfectly in pure-Python code. // oC.WSset_callback(@Callback); When I compile I get: [Pascal Error] wsAPICOM.dpr(151) E2281 Type not allowed in Variant Dispatch call. Thanks in advance for any assistance. Regards, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Cannot execute Windows commands via Python in 64-bit

2007-05-02 Thread Larry Bates
minitotoro wrote: > On May 2, 3:07 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> I have a script that runs fine in Windows 2003 (32-bit). It basically >>> calls the Windows defrag command. When I try the exact same code on >>>

Re: passing an array of variant in vb to a python COM object = win32com bug ?

2007-05-03 Thread Larry Bates
hon code is now : > > def SqVal(self,val): > ##volr=[val[0][0][i] for i in range(size(val,2))] > ##voli=[val[0][1][i] for i in range(size(val,2))] > ##mat1=mat(volr)+1j*mat(voli) > ##up=linalg.pinv(mat1) > ##out=up.real.tolist() > ##out.extend(up.imag.tolist()) > return val > > By the way Do you have any idea to debug the com server script ? ( I > would like to know if a can access the value in the function while > calling it from vb 6) > > > > > tahnks a lot ! > > Debugging COM objects is best done using logging module or at least writing to a file during processing. You can review the log file to see what was going on. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: pyscripter to slow

2007-05-03 Thread Larry Bates
to a function. You should probably post back to their website instead of here. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: _csv.Error: string with NUL bytes

2007-05-03 Thread Larry Bates
#x27;t see any empty values in any fields or anything... > You really should post some code and the actual traceback error your get for us to help. I suspect that you have an ill-formed record in your CSV file. If you can't control that, you may have to write your own CSV dialect parser.

Re: how to find a lable quickly?

2007-05-04 Thread Larry Bates
e different sections [section] with labels under each section. Use configParser to read this and then get options with geting(section, option). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check if a string is empty in python?

2007-05-04 Thread Larry Bates
t;"" > Depreciated is often confused or used as a stand-in for "deprecated"; > see deprecation for the use of depreciation in computer software > """ > > > Alex Isn't deprecated like depreciated but not quite to zero yet? -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I use the config parser?

2007-05-07 Thread Larry Bates
hanks > The best place to start is always: import ConfigParser help(ConfigParser) Example: section='INIT' option='logfile' logfile=configdict.get(section, option) most of the methods are self explanitory. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: changing a var by reference of a list

2007-05-08 Thread Larry Bates
to use a class to pass everything: class _vars: def __init__(self, vars=None): if vars is not None: for varname, value in vars.items(): setattr(self, varname, value) return vars=_vars({'_varA': 0, '_varB': 0}) Then you can access:

Re: Newbie look at Python and OO

2007-05-10 Thread Larry Bates
object that has all the methods any other string object will have. Objects don't have to be named (via variables) to have methods. You could write: underline="_" underline.join(a) > And still other times, is seems that "this" is an object, acted upon > by "that" : > >>>> a = list("1234") >>>> b = "_".join(a) >>>> b.split("_") > ['1', '2', '3', '4', '5'] > Not really, you can write: underline="_" b=underline.join(a) c=b.split(underline) seems perfectly clear to me (but I have to admit it took me a while to see the beauty of python's syntax). > BTW: it seems a bit odd to that the positions of the string, and the > delimitor, are reversed between the complementory functions join(), > and split(). I suppose if it weren't for OO, we have something > terribly complicated, like: > > split(str, "_") > join(str, "_") > > Again, those who think in Python, will understand right away that: > > math.count(x) > > is counting the substring "x" in the "math" string. But can you see > where that might be confused to be a function called count() in the > math module? Actually it could be either. If you write your own class called math that has a count method this would work. If the math module had a count method (which it doesn't) and you import it, you might call that method of the math module this way. One thing you will come to appreciate is that you can replace virtually any module, function, etc. in Python with your own code. A mistake many new python programmers make is to shadow str, list, dict, etc. by using them as variable names. Then later they can't figure out why they can't do str(n). Hope the feedback helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: File record separators.

2007-05-15 Thread Larry Bates
7;) lists=[] for n, line in enumerate(fp): try: l=eval(line) except SyntaxError: print "SyntaxError on line=%i" % (n+1) lists.append(l) If you want something different, I might use a tab between lists and commas between values. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: remove all elements in a list with a particular value

2007-05-16 Thread Larry Bates
'', > '3.0', '', '', ''] > > It doesn't remove all of the empty elements. Is there a better way to > split the original string? Or a way to catch all of the empty > elements? > > Thanks > When you split on a space (' ') multiple spaces will return empty list elements between them. Change to: line = ' SRCPARAM 1 6.35e-07 15.00 340.00 1.10 3.0 ' li = line.split() And you will get what you want: ['SRCPARAM', '1', '6.35e-07', '15.00', '340.00', '1.10', '3.0'] -Larry -- http://mail.python.org/mailman/listinfo/python-list

calldll for Python 2.5

2007-05-16 Thread Larry Bates
code that are dependent on calldll. Anyone out there have a version that works with Python 2.5 so I don't have to a massive rewrite? Thanks in advance, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: zipfile stupidly broken

2007-05-16 Thread Larry Bates
beast. As with any open source product it is much better to roll up your sleeves and pitch in to fix a problem than to rail about "how it is stupidly broken". You are welcome to submit a patch or at the very least a good description of the problem and possible solutions. If you have

Re: progress indicator in a mod_python script

2007-05-18 Thread Larry Bates
s to achieve this would be very appreciated. > > Thanks, > If you want "real" progress than you must do it with some asynchronous communications via XMLRPC or sockets. You can "simulate" progress by doing a little client-side javascript and include a progressive GIF. Ther

Re: Python compared to other language

2007-05-18 Thread Larry Bates
n Python, I find I write almost 100% of my code in Python. This means that I am getting better at Python not learning lots of other languages which I will never know well. I hope you find the information at least helpful. Regards, Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Larry Bates
t would help me understand > python syntax a little better. > > Thanks > > Richard > I find something like the following easy to read and easy to extend the contents of searchkeys in the future. searchkeys=range(60, 69) + [3] goodlist=[(k, v) for k, v in mydict.items() if

Re: [Fwd: Re: managed lists?]

2007-05-22 Thread Larry Bates
self.__list.append(obj) if self.__add_cb: self.__add_cb(self, obj) else: raise ObjListException("append.obj must implement 'methodname'" \ method") I would also write append_many as: def extend(self, lst): map(self.append, lst) return I would find it easier to remember extend (since that is very pythonic). If your collection of objects is large, I would also consider putting them in a dictionary instead of a list and indexing them on ID. Hope this helps in some way. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing dots in sequence ('...')

2007-05-22 Thread Larry Bates
Thanks. > Björn > I wrote this a donated to Python Cookbook some time ago, enjoy. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207 -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: pipe tutorial

2007-05-22 Thread Larry Bates
Gigs_ wrote: > does anyone know some good tutorial on pipes in python? > > thx Pipes is specific only to Windows (you can use sockets on Windows/Linux/mac). The only specific treatment of pipes I've seen is in Python Programming for Win32 by Mark Hammond/Andy Robinson. -

Re: Printing dots in sequence ('...')

2007-05-22 Thread Larry Bates
t; Thanks. > Björn > See example here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207 -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: drag and drop with wxPython ?

2007-05-22 Thread Larry Bates
o drag & drop components with wxPython ? > > thanks, > Stef Mientki The demo that comes with wxWindows has good examples of this. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: pipe tutorial

2007-05-22 Thread Larry Bates
Gabriel Genellina wrote: > En Tue, 22 May 2007 11:11:45 -0300, Larry Bates > <[EMAIL PROTECTED]> escribió: > >> Gigs_ wrote: >>> does anyone know some good tutorial on pipes in python? >> >> Pipes is specific only to Windows (you can use sockets &g

Re: using google search api for python

2007-05-22 Thread Larry Bates
> > Thanks! > Gerardo The server (Google) on the other end doesn't know what type of app you are. It just responds to XMLRPC requests. I haven't used the interface but I'm guessing that I would use Twisted to make XMLRPC request to Google and process the response XML payloa

Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations

2007-05-23 Thread Larry Clapp
["Followup-To:" header set to comp.lang.lisp.] On 2007-05-23, Xah Lee <[EMAIL PROTECTED]> wrote: > The Concepts and Confusions of Prefix, Infix, Postfix and Fully > Functional Notations > > Xah Lee, 2006-03-15 Xah, why do you post year-old essays to newsgroups that couldn't care less about them?

Re: read file to a dictionary

2007-05-23 Thread Larry Bates
nary when read from a file. More info will be required to help more. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Amount of Data

2007-05-25 Thread Larry Bates
p memory or will it fail? >> What about putting the data into a database? If the keys are strings the >> `shelve` module might be a solution. >> >> Ciao, >> Marc 'BlackJack' Rintsch > > Purchase more memory. It is REALLY cheap these days. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: csv.reader length?

2007-05-25 Thread Larry Bates
t;e"]]) >>>> len(open("tmp.csv").readlines()) > 3 # number of lines >>>> len(list(csv.reader(open("tmp.csv" > 2 # number of records > > Peter > Did you try: import crystal_ball num_lines=crystal_ball(reader) Sorry I couldn't resist. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: SMTPAuthenticationError

2007-05-29 Thread Larry Bates
e that your SMTP server uses this type of authentication? Some SMTP servers use POP3 followed by SMTP to authenticate instead. use telnet to verify, this link might help. http://www.computerperformance.co.uk/exchange2003/exchange2003_SMTP_Auth_Login.htm#3)%20Auth%20Login -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: replace the base class

2007-05-30 Thread Larry Bates
of new base class : 3DGraph, .. > > Thanks > > Alain > I believe what you are looking for is the 'as' clause on import from module import Graph as Graph class Circle(Graph): pass Circle will have Graph as its baseclass from module import ColorGraph as Graph class Circle(Graph): pass Circle will have ColorGraph as its baseclass -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Examples of high-quality python code?

2007-05-31 Thread Larry Bates
ook by Mark Hammond/Andy Robinson) Reading source code to standard library Reading ReportLab source (www.reportlab.org) Reading PIL source (www.effbot.org) Reading wxPython source (www.wxpython.org) Monitoring this list on a daily basis -Larry -- http://mail.python.org/mailman/listinfo/python-list

Using PIL to find separator pages

2007-05-31 Thread Larry Bates
where 100% would be a perfect match and any number lower would indicate that it was less likely that it was a coverpage. Thanks in advance for any thoughts or advice. Regards, Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: link between python and the windows command prompt

2007-07-23 Thread Larry Bates
subprocess module. import os import sys os.chdir('D:\\folder') os.system('D:\\nec2++ -i inputfile.new -o outputfile.out') -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused with csv.reader copies

2007-07-23 Thread Larry Bates
27;t get it to work properly if the variable outside > of the function call ends up having its state (e.g., its "next" > pointer) modified by passing it into other functions. > > Any tips on getting this to work? I'm a native C++ programmer still > learning Python, so I apologize for any confusion. Thanks. > By reference means that mutable objects can be modified (in place) by the functions that they are passed into. This is a common mistake people make when they first get started. Normally lists seem to throw people first. I don't know how long the file is, but you probably should just read the entire file into memory and process it from there. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a single executable of a Python program

2007-07-25 Thread Larry Bates
metimes hundreds) of files. So what is the problem. If you want a single file to distribute, look at Inno Installer. Use it to make a single, setup.exe out of all the files that come out of py2exe along with documentation, shortcuts, etc. that a good modern application needs. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows error 126 loading a dll on windows 2000

2007-07-25 Thread Larry Bates
2000, the some code raise the windows error 126, it > can't load the module statistics.dll > > thanks in advance > Using Google on "windows error 126" turned this up, hope it helps. http://flashexperiments.insh-allah.com/ApacheError126.html -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Directory

2007-08-02 Thread Larry Bates
istofdirs=[d for d in os.listdir(mydir) if os.pathisdir(d)] -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Determining if file is valid image file

2007-08-02 Thread Larry Bates
added: I'm interesting in validating the file *content* > - not the filename :-) > And what's wrong with bundling PIL in your application? -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: File access

2007-08-02 Thread Larry Bates
nd expecting them to by synchronized most likely won't work. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: amra and py2exe

2007-08-06 Thread Larry Bates
or i am getting while creating the exe > The following modules appear to be missing > ['amara', 'ext.IsDOMString', 'ext.SplitQName'] > > can anybody please help me with this? > > Thanks, > Vinod > You should post this on gmane.comp.python.

Re: RTF 2 Tiff

2007-08-06 Thread Larry Bates
us what operating system you are running on. Most likely you will want to automate one of the off-the shelf solutions rather than trying to roll your own. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get output.

2007-08-09 Thread Larry Bates
;>> python. How can I do this? >>> Using the subprocess-module. >>> However, I'm not sure what DIR /AD /B does - but there are many >>> functions in module os that might deliver what you want without invoking >>> an external command. >>> Diez- Hide quoted text - >> - Show quoted text - > > That is better done in python with: import os dirs=[d for d in os.listdir(os.curdir) if os.path.isdir(d)] or dirs=filter(os.path.isdir, os.listdir(os.curdir)) -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Drawing a graph

2007-08-13 Thread Larry Bates
IL? > > Thanks. > ReportLab graphics works for me. www.reportlab.org -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Drawing a graph

2007-08-14 Thread Larry Bates
IL? > > Thanks. > ReportLab graphics works for me. www.reportlab.org -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: encrypting files + filestreams?

2007-08-15 Thread Larry Bates
so','r') > ofile = file('/tmp/ubuntu-7.04-desktop-i386.iso.out','w') > > encrypt2(crptz, ifile, ofile) > ifile.close() > ofile.close() > > # crypto_hardcoded.py ends here > Padding and keeping information in a header is how I solved the problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: "Variable variable name" or "variable lvalue"

2007-08-15 Thread Larry Bates
], 2:[Material2, 25.0], 3:[Material3, 12.5] } x=3 slab_arg=0 for i in range(1,x): func, farg=mdict[i] slab_arg+=func(farg) Period=Slab(slab_arg) Obviously not tested! I sense that the Material functions should be consolidated into something more general here. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Who told str() to round my int()'s!!!

2007-08-15 Thread Larry Bates
>> See e.g. http://docs.python.org/tut/node16.html >> >> > I should also point out that the subject line for this thread is > inaccurate, as it wasn't rounding ints at all. > > regards > Steve What are they teaching in schools these days? I see questions like

Re: How would I go about making a file open. Not the way you might think.

2007-08-23 Thread Larry Bates
xt files on that machine. That could be different from notepad if the user has chosen to override the defaults. os.system('notepad.exe c:\\junk.txt') will force notepad.exe to load and it will load the file specified. All depends on what you want to do. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket - gaierror

2007-08-27 Thread Larry Bates
ecific error shown is a DNS resolution problem. Based on the URL "theHost" smtplib can't resolve to an IP address (which is what socket.gethostbyname does). You don't say what happened when you changed to ip, but I suspect it is a different error or some other problem. Maybe a firewall issue (port 25 not open?), but I'm just guessing. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting subprocesses to be hidden on Windows

2007-08-28 Thread Larry Bates
ant, I think you can accomplish it by using win32CreateProcess instead of subprocess. You can run the application minimized or perhaps in a REALLY small window. If you have modal dialog boxes, I don't think you can do anything as they don't run in the parent windows frame but rather outside (I could be wrong about this). -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way of reading a textfile line by line without throwing an exception

2007-08-28 Thread Larry Bates
you you can just loop on them. fp=open(filename, 'r') for line in fp: # do something with line fp.close() -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonwin Install COM exceptions on Windows Vista Ultimate

2007-08-29 Thread Larry Bates
Sandipan News wrote: > What do I do? Can't do without Python! > Any experience, advice, hope is welcome. > Thanks. > Sandipan > > If you are asking if you can run COM objects created in Python on Windows Vista Ultimate, the answer is yes. I have several. -Larry --

Re: Python Unicode to String conversion

2007-08-31 Thread Larry Bates
thijs > Question is, what should it be converted to when there is no corresponding ascii character to map the offending character to? Do you want to throw it away? Your expectation "works always" is very ill-defined. Write a small function to process the strings yourself and set up a substitution dictionary to do the conversion yourself. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: parsing response from SOAPpy request

2007-08-31 Thread Larry Bates
available for download for prior versions) to parse it for what you want to extract. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Subclassing zipfile (new style class)

2007-09-06 Thread Larry Bates
ck (most recent call last): File "", line 192, in run_nodebug File "", line 2, in TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) >>> Thanks in advance. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the complete command line as-is

2007-09-12 Thread Larry Bates
raw input or from some configuration file? something like: python program (pgm.py): cmdline=raw_input("enter your parameters") external file (cmd.txt): "abc def" xyz python pgm.py < cmd.txt -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: xml question

2007-09-12 Thread Larry Bates
ch 'color' xml > element inside and > pull any that have > values (which would be Black, Light Blue and Green). I'd like to know how to > pull 'attributes' > too. > > Thanks very much for your help. > > Jay Python 2.5 has elementtree built

Re: I want py2exe not to create library.zip

2007-09-12 Thread Larry Bates
.EXE file. Don't try to update the program via patching "pieces". Wrap everything in a proper installer (I use and highly recommend Inno Setup). It can handle version control, there is a plug-in for over-the-wire updates, etc. Best way I know of to automate everything. -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question

2007-03-05 Thread Larry Bates
ng a list comprehension you would write this as: for line in lines: xin, yin, zin=[float(x) for x in line.split()] This if course expects your data to be perfect. If you want error handling (e.g. less or more than 3 values, values that cause exception when passed to float, etc.) you will have

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