how to normalize indentation sources
Hi, I have a lot of sources with mixed indentation typically 2 or 4 or 8 spaces. Is there any way to automatically convert them in let's say 4 spaces? Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
deploying big python applications
Hi, let me describe how I do that today. There is standard python taken from python.org installed in a c:\python23 with at least dozen different additional python packages (e.g. SOAPpy, Twisted, wx, many smaller ones etc) included. Also python23.dll moved from c:\windows to c:\python23. This is zipped and available as over 100MB file to anyone to manually unzip on his/her PC. This is a one time step. On top of that there is 30K lines of code with over 100 .py files application laid out within a directory tree. Very specific for the domain, typical application. This again is zipped and available to anyone as much smaller file to unzip and use. This step is per software releases. There is one obvious drawback - I can not separate python from standard libraries easily. So when upgrade to 2.4 comes, I need to reinstall all the packages. In order to address that as well as the Linux port I project following structure: -default python.org installation or one time step on Windows -set of platform dependent libraries in directory A -set of platform independent libraries in directory B -application in directory C This way I can easily port (or just use) entire software under Linux/Unix yet do not have to worry about collecting all the packages evry time I change the platform or the version of Python. I hope I described it well enough. How to achieve it, is there any better solution, or ready one. Please advice. Thx in advance, A. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to normalize indentation sources
John Machin wrote: On 25/05/2006 12:00 PM, AndyL wrote: Hi, I have a lot of sources with mixed indentation typically 2 or 4 or 8 spaces. Is there any way to automatically convert them in let's say 4 spaces? Yup. Right under your nose: C:\junk\python24\tools\scripts\reindent.py --help reindent [-d][-r][-v] [ path ... ] -d (--dryrun) Dry run. Analyze, but don't make any changes to, files. -r (--recurse) Recurse. Search for all .py files in subdirectories too. -v (--verbose) Verbose. Print informative msgs; else no output. -h (--help)Help. Print this usage information and exit. Change Python (.py) files to use 4-space indents and no hard tab characters. Also trim excess spaces and tabs from ends of lines, and remove empty lines at the end of files. Also ensure the last line ends with a newline. [snip] thx a lot, A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web framework comparison video
Iain King wrote: http://compoundthinking.com/blog/index.php/2006/03/10/framework-comparison-video/ Thought this might be interesting to y'all. (I can't watch it 'cos I'm at work, so any comments about it would be appreciated :) Indeed it was. The headache factor is 1, for some reason my Mandrake 2006 media players mute the sound. Had to boot to M$ :-(. A. -- http://mail.python.org/mailman/listinfo/python-list
redirecting print to a a file
Hi, Can I redirect print output, so it is send to a file, not stdout. I have a large program and would like to avoid touching hundreds of print's. Thx, Andy -- http://mail.python.org/mailman/listinfo/python-list
python equivalent of the following program
Hi, What would by a python equivalent of following shell program: #!/bin/sh prog1 file1 prog2 file2 As you see, I need to spawn a few processes and redirect stdout to some files. Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
Re: redirecting print to a a file
Harold Fellermann wrote: import sys sys.stdout = file(output,w) print here you go And what if I want to still send the output to stdout and just a log it in the file as well? A. -- http://mail.python.org/mailman/listinfo/python-list
Re: redirecting print to a a file
Sybren Stuvel wrote: I have a large program and would like to avoid touching hundreds of print's. I can suggest using the logging module instead of print. It's much more flexible than prints, and well suited for large programs. Thx for the hint. I will look into that. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: redirecting print to a a file
Sybren Stuvel wrote: AndyL enlightened us with: And what if I want to still send the output to stdout and just a log it in the file as well? $ python some_program.py | tee output.log Or write a class that has a write() function and outputs to a file and to the original value of sys.stdout (IIRC that's in sys.__stdout__) Sybren Thx again. Python is cool, do that in C++ or Java :-) A. -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of the following program
Edward Elliott wrote: Steven Bethard wrote: import subprocess file1 = open('file1', 'w') prog1 = subprocess.Popen(['prog1'], stdout=file1) And if the script runs somewhere that stderr is likely to disappear: prog1 = subprocess.Popen(['prog1'], stdout=file1, stderr=subprocess.STDOUT) Forgot to mention before that the main motivation is to have the same code on bot Linux and M$ platforms. Does subprocess work well on both? Also how to find out that the 'prog1' e.g. has exited and it is done? Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Chicago Python Users Group Thurs May 11 at 7pm
Brian Ray wrote: This will be our best meeting yet! ChiPy's Monthly meeting this Thurs. May 11, 2006. 7pm. I will miss it. When the next is planed? -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of the following program
Edward Elliott wrote: AndyL wrote: Edward Elliott wrote: And if the script runs somewhere that stderr is likely to disappear: prog1 = subprocess.Popen(['prog1'], stdout=file1, stderr=subprocess.STDOUT) Forgot to mention before that the main motivation is to have the same code on bot Linux and M$ platforms. Does subprocess work well on both? yes Also how to find out that the 'prog1' e.g. has exited and it is done? prog1.wait() or prog1.poll(). look at the subprocess docs. thx a lot. -- http://mail.python.org/mailman/listinfo/python-list
__all__ does not work?
This a mm.py module: _all__=('getsize1',) size=85 def getsize1(): return size def getsize2(): return 2*size I do not know why but getsize2 is not kept priviate? $ python Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import mm mm.getsize2() 170 Any ideas? A. -- http://mail.python.org/mailman/listinfo/python-list
Re: __all__ does not work?
[EMAIL PROTECTED] wrote: Andy This a mm.py module: Andy _all__=('getsize1',) Andy size=85 Andy def getsize1(): Andy return size Andy def getsize2(): Andy return 2*size Andy I do not know why but getsize2 is not kept priviate? That's not what __all__ is used for. Try this: from mm import * The only name added to your namespace will be getsize1. Skip Okay, got it. Thx. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range was not reimplemented? -- http://mail.python.org/mailman/listinfo/python-list
what is the the best way to express following:
if type(key).__name__ == int or type(key).__name__ == long: abc() elif type(key).__name__ == str: efg() elif type(key).__name__ == tuple or type(key).__name__ == list: ijk() In other words I need to determinie intiger type or string or []/() in elegant way, possibly without or ... Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
Re: what is the the best way to express following:
James Stroud wrote: Here is a suggestion todo = {(int, long):abc, (str,):afg, (tuple, list):ijk} todo[type(key)]() Is not that a shortcut? I have got KeyError exception ... -- http://mail.python.org/mailman/listinfo/python-list
Re: what is the the best way to express following:
Paul McGuire wrote: AndyL [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if type(key).__name__ == int or type(key).__name__ == long: abc() elif type(key).__name__ == str: efg() elif type(key).__name__ == tuple or type(key).__name__ == list: ijk() In other words I need to determinie intiger type or string or []/() in elegant way, possibly without or ... Thx, A. Your literal Pythonic approach is to use the isinstance() builtin: if isinstance(key,(int,long)): abc() elif isinstance(key,str): efg(): elif isinstance(key,(tuple,list)): ijk() thx a lot . In fact I do not do dispatch, just wanted ilustrate if: elif: sequence. Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: path to modules per import statement
[EMAIL PROTECTED] wrote: For instance: import my.path.module would load module from ./my/path/module.py? Yeah, just do that. I don't understand the question, it works just like this today. I work on rather big set of Python applications: something like 100 .py files divided into libs and separate sub-applications. For now I keep almost everything in one directory but I wish following structure to be in place: app1/ app2/ lib1/ lib2/ lib3/ and be able to import from each app[12] all the libs. I do not want to touch existing code to prefix all the import places with lib[123] nether I want to play with sys.path.append too much. A. -- http://mail.python.org/mailman/listinfo/python-list
path to modules per import statement
Hi, is there any way to specify the path to modules within import statement (like in Java)? For instance: import my.path.module would load module from ./my/path/module.py? Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
multi/double dispatch, multifunctions once again
Hi, Where I can find a module supporting that? A. -- http://mail.python.org/mailman/listinfo/python-list