Re: Storing of folder structure in SQL DB

2012-09-20 Thread santhosh . sweetmemory
On Friday, September 21, 2012 11:57:05 AM UTC+5:30, santhosh.s...@gmail.com wrote: > folderid name parentid > > > > 1 cricket 0 > > 2 india 1 > > 3 sachin 2 > > 4 tennis 0 > > 5 saniamirza 4 > > > > i need coding for

Re: python idioms : some are confusing

2012-09-20 Thread Steven D'Aprano
On Thu, 20 Sep 2012 22:52:45 -0700, alex23 wrote: > On Sep 21, 3:34 pm, Vineet wrote: >> Amongst the python idioms, how the below-mentioned make sense? ## There >> should be one-- and preferably only one --obvious way to do it. --- In >> programming, there can be a number of ways, equally efficie

Re: Is there a public API equvalent for urllib2.parse_http_list?

2012-09-20 Thread Cosmia Luna
On Friday, September 21, 2012 2:22:08 PM UTC+8, Cosmia Luna wrote: > I'm porting my code to python3, and found there is no parse_http_list in any > module of urllib of python3. > > > > So, is there a public API equvalent for urllib2.parse_http_list? > > > > Thanks. > > > > > > C

Re: Storing of folder structure in SQL DB

2012-09-20 Thread santhosh . sweetmemory
folderid name parentid 1 cricket 0 2 india 1 3 sachin 2 4 tennis 0 5 saniamirza 4 i need coding for this table..folder id 'll automatically populate.. -- http://mail.python.org/mailman/listinfo/python-list

Is there a public API equvalent for urllib2.parse_http_list?

2012-09-20 Thread Cosmia Luna
I'm porting my code to python3, and found there is no parse_http_list in any module of urllib of python3. So, is there a public API equvalent for urllib2.parse_http_list? Thanks. Cosmia Luna -- http://mail.python.org/mailman/listinfo/python-list

Re: python idioms : some are confusing

2012-09-20 Thread Steven D'Aprano
On Thu, 20 Sep 2012 22:34:48 -0700, Vineet wrote: > Amongst the python idioms, how the below-mentioned make sense? They're not Python idioms. Idioms are common pieces of code, like looping: for item in sequence: do_something What you have quoted are parts of the Zen of Python, which is del

Re: python idioms : some are confusing

2012-09-20 Thread Vineet
Oh I see ! On these lines mentioned by you, I can now sense the sense. Thanks. On Friday, 21 September 2012 11:22:45 UTC+5:30, alex23 wrote: > On Sep 21, 3:34 pm, Vineet wrote: > > > Amongst the python idioms, how the below-mentioned make sense? > > > ## There should be one-- and preferably on

Re: python idioms : some are confusing

2012-09-20 Thread Chris Angelico
I'm responding to the OP here, not to Alex, but I'm quoting his text to expand on it. :) On Fri, Sep 21, 2012 at 3:52 PM, alex23 wrote: > On Sep 21, 3:34 pm, Vineet wrote: >> Amongst the python idioms, how the below-mentioned make sense? >> ## There should be one-- and preferably only one --obvi

Re: python idioms : some are confusing

2012-09-20 Thread Chris Rebert
On Thu, Sep 20, 2012 at 10:34 PM, Vineet wrote: > Amongst the python idioms, how the below-mentioned make sense? These aren't idioms (that term has a specific technical meaning in programming); they're *way* too abstract to be idioms. "Design principles" or "design guidelines" would be a better d

Re: python idioms : some are confusing

2012-09-20 Thread alex23
On Sep 21, 3:34 pm, Vineet wrote: > Amongst the python idioms, how the below-mentioned make sense? > ## There should be one-- and preferably only one --obvious way to do it. > --- In programming, there can be a number of ways, equally efficient, to do > certain  thing. This isn't talking about y

python idioms : some are confusing

2012-09-20 Thread Vineet
Amongst the python idioms, how the below-mentioned make sense? ## There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. --- In programming, there can be a number of ways, equally efficient, to do certain thing.

Re: Obnoxious postings from Google Groups

2012-09-20 Thread Robert Miles
On 9/16/2012 8:18 AM, Ben Finney wrote: Νικόλαος Κούρας writes: Iam sorry i didnt do that on purpose and i dont know how this is done. Iam positng via google groups using chrome, thats all i know. It is becoming quite clear that some change has happened recently to Google Groups that makes

Re: portable way of locating an executable (like which)

2012-09-20 Thread Andrew Berg
On 2012.09.20 21:31, Dave Angel wrote: > I don't have a Windows machine set up right now, but I believe there are > two more directories to search, besides the ones described in the PATH > variable. > > One is the current directory, and the other is the Windows directory > (maybe also the xxx/syst

Re: portable way of locating an executable (like which)

2012-09-20 Thread Dave Angel
On 09/20/2012 06:04 PM, Jason Swails wrote: > On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: > >> I'd like to implement the equivalent functionality of the unix command >> /usr/bin/which >> >> The function should work under Linux and under windows. >> >> Did anybody already implement such a fu

Re: portable way of locating an executable (like which)

2012-09-20 Thread Nobody
On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: > I'd like to implement the equivalent functionality of the unix command > /usr/bin/which > > The function should work under Linux and under windows. Note that "which" attempts to emulate the behaviour of execvp() etc. The exec(3) manpage wil

Re: looping in array vs looping in a dic

2012-09-20 Thread MRAB
On 2012-09-21 00:35, giuseppe.amatu...@gmail.com wrote: Hi Ian and MRAB thanks to you input i have improve the speed of my code. Definitely reading in dic() is faster. I have one more question. In the dic() I calculate the sum of the values, but i want count also the number of observation, in

Re: portable way of locating an executable (like which)

2012-09-20 Thread Mark Lawrence
On 21/09/2012 00:15, Gelonida N wrote: On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split

Re: looping in array vs looping in a dic

2012-09-20 Thread giuseppe . amatulli
Hi Ian and MRAB thanks to you input i have improve the speed of my code. Definitely reading in dic() is faster. I have one more question. In the dic() I calculate the sum of the values, but i want count also the number of observation, in order to calculate the average in the end. Should i creat

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:21 AM, Chris Angelico wrote: On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence wrote: On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybod

Re: portable way of locating an executable (like which)

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 8:32 AM, Ian Kelly wrote: > On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico wrote: >> os.sep is the directory separator, but os.pathsep may be what you >> want. Between that and os.getenv('path') you can at least get the >> directories. Then on Windows, you also need to ch

Re: portable way of locating an executable (like which)

2012-09-20 Thread Ian Kelly
On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico wrote: > os.sep is the directory separator, but os.pathsep may be what you > want. Between that and os.getenv('path') you can at least get the > directories. Then on Windows, you also need to check out > os.getenv('pathext') and split _that_ on the s

Re: portable way of locating an executable (like which)

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence wrote: > On 20/09/2012 22:06, Gelonida N wrote: >> >> I'd like to implement the equivalent functionality of the unix command >> /usr/bin/which >> >> The function should work under Linux and under windows. >> >> Did anybody already implement such a fun

Re: portable way of locating an executable (like which)

2012-09-20 Thread Jason Swails
On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: > I'd like to implement the equivalent functionality of the unix command > /usr/bin/which > > The function should work under Linux and under windows. > > Did anybody already implement such a function. > If not, is there a portable way of splittin

Re: portable way of locating an executable (like which)

2012-09-20 Thread Mark Lawrence
On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. Searching found nothing obvious to me :( If not, is there a por

portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? Thanks for any sugestions --

Re: Installing Pip onto a mac os x system

2012-09-20 Thread John Mordecai Dildy
On Thursday, September 20, 2012 4:37:36 PM UTC-4, John Gordon wrote: > In John Mordecai > Dildy writes: > > > > > Now it shows the error of: > > > > > sudo: easy_instal: command not found > > > > Try 'easy_install' instead of 'easy_instal'. > > > > -- > > John Gordon

Re: Installing Pip onto a mac os x system

2012-09-20 Thread John Gordon
In John Mordecai Dildy writes: > Now it shows the error of: > sudo: easy_instal: command not found Try 'easy_install' instead of 'easy_instal'. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Installing Pip onto a mac os x system

2012-09-20 Thread John Mordecai Dildy
Thank you Hans M. for some input. Now it shows the error of: sudo: easy_instal: command not found -- http://mail.python.org/mailman/listinfo/python-list

Re: When should I use "development mode"?

2012-09-20 Thread Ian Kelly
On Thu, Sep 20, 2012 at 1:38 PM, py_lrnr wrote: > Can anyone (very briefly) explain to me, in a sentence or two: > > what 'development mode' is? > how 'development mode' differs from other 'modes'? > why/when I would use 'development mode'? > what 'development mode' does or does not allow me to do

When should I use "development mode"?

2012-09-20 Thread py_lrnr
I am new to python and I have come across the following command and its description: >Now to be able to run the project you will need to install it and its >>dependencies. >python setup.py develop I looked up what the 'develop' argument does and found: >Extra commands: > develop in

Re: looping in array vs looping in a dic

2012-09-20 Thread Ian Kelly
On Thu, Sep 20, 2012 at 1:28 PM, Ian Kelly wrote: > Expanding on what MRAB wrote, since you probably have far fewer > categories than pixels, you may be able to take better advantage of > numpy's vectorized operations (which are pretty much the whole point > of using numpy in the first place) by l

Re: looping in array vs looping in a dic

2012-09-20 Thread Ian Kelly
On Thu, Sep 20, 2012 at 1:09 PM, MRAB wrote: > for col in range(cols): > for row in range(rows): > cat = valuesCategory[row, col] > ras = valuesRaster[row, col] > totals[cat] += ras Expanding on what MRAB wrote, since you probably have far fewer categories than pixels,

Re: How to limit CPU usage in Python

2012-09-20 Thread Christian Heimes
Am 20.09.2012 17:12, schrieb Rolando Cañer Roblejo: > Hi all, > > Is it possible for me to put a limit in the amount of processor usage (% > CPU) that my current python script is using? Is there any module useful > for this task? I saw Resource module but I think it is not the module I > am lookin

Re: Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Steven D'Aprano
On Thu, 20 Sep 2012 06:52:07 -0700, Jure Erznožnik wrote: > I'm trying to create a class that would lie to the user that a member is > in some cases a simple variable and in other cases a class. The nature > of the member would depend on call syntax like so: > 1. x = obj.member #x becomes the "si

Re: looping in array vs looping in a dic

2012-09-20 Thread MRAB
On 2012-09-20 19:31, giuseppe.amatu...@gmail.com wrote: Hi, I have this script in python that i need to apply for very large arrays (arrays coming from satellite images). The script works grate but i would like to speed up the process. The larger computational time is in the for loop process. Is

"Development mode"

2012-09-20 Thread py_lrnr
I am new to python and I have come across the following command and its description: >Now to be able to run the project you will need to install it and its >>dependencies. >python setup.py develop I looked up what the 'develop' argument does and found: >Extra commands: > develop

looping in array vs looping in a dic

2012-09-20 Thread giuseppe . amatulli
Hi, I have this script in python that i need to apply for very large arrays (arrays coming from satellite images). The script works grate but i would like to speed up the process. The larger computational time is in the for loop process. Is there is a way to improve that part? Should be better

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Piet van Oostrum
Chris Rebert writes: > Use the `subprocess` module instead (with shell=False). You then won't > need to worry about escaping. > http://docs.python.org/library/subprocess.html You will still need to worry about escaping because on the remote end you invoke ssh which is a shell. The obvious call:

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Piet van Oostrum
Ismael Farfán writes: > How about something like this: > os.system ( 'ssh remoteuser@remote python remote.py "arg 1" "arg 2" "arg 3"' ) That won't work. You need an additional level of quoting because ssh is also a shell so it adds another level of interpretation. The following works: os.syste

Re: How to limit CPU usage in Python

2012-09-20 Thread Jerry Hill
On Thu, Sep 20, 2012 at 11:12 AM, Rolando Cañer Roblejo wrote: > Hi all, > > Is it possible for me to put a limit in the amount of processor usage (% > CPU) that my current python script is using? Is there any module useful for > this task? I saw Resource module but I think it is not the module I

Re: Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Terry Reedy
On 9/20/2012 9:52 AM, Jure Erznožnik wrote: I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the "simple" value containe

Re: How to limit CPU usage in Python

2012-09-20 Thread Terry Reedy
On 9/20/2012 12:46 PM, Terry Reedy wrote: On 9/20/2012 11:12 AM, Rolando Cañer Roblejo wrote: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think

Re: How to limit CPU usage in Python

2012-09-20 Thread Terry Reedy
On 9/20/2012 11:12 AM, Rolando Cañer Roblejo wrote: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Som

Re: A little morning puzzle

2012-09-20 Thread Tobiah
Here is my solution: ** Incredibly convoluted and maximally less concise solution than other offerings. ** Might be better ones though. Unlikely. Zing! -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Chris Rebert
On Wed, Sep 19, 2012 at 12:50 PM, ashish wrote: > 2. I have a python script, local.py, running on 'local' which needs to pass > arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) > to a python script, remote.py running on 'remote' (the remote machine). > 3. Has anybody

Re: [Q] How to exec code object with local variables specified?

2012-09-20 Thread Terry Reedy
On 9/20/2012 7:27 AM, Makoto Kuwata wrote: Is it possible to run code object with local variables specified? In the way you mean that, no. I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(), loca

Re: [Q] How to exec code object with local variables specified?

2012-09-20 Thread Makoto Kuwata
On Thu, Sep 20, 2012 at 10:15 PM, Peter Otten <__pete...@web.de> wrote: > loc = {} exec("x = 1; y = 2", globals(), loc) loc > {'y': 2, 'x': 1} > > However, this won't work with the code object taken from a function which > uses a different a bytecode (STORE_FAST instead of STORE_NAME

How to limit CPU usage in Python

2012-09-20 Thread Rolando Cañer Roblejo
Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Emile van Sebille
On 9/19/2012 12:50 PM ashish said... Hi c.l.p folks Here is my situation 1. I have two machines. Lets call them 'local' & 'remote'. Both run ubuntu & both have python installed 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string arguments, contai

Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Jure Erznožnik
I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the "simple" value contained in member 2. x = obj.member.another_member #

Re: 'indent'ing Python in windows bat

2012-09-20 Thread Duncan Booth
Jason Friedman wrote: >> I'm converting windows bat files little by little to Python 3 as I >> find time and learn Python. >> The most efficient method for some lines is to call Python like: >> python -c "import sys; sys.exit(3)" >> >> How do I "indent" if I have something like: >> if (sR=='Cope'

Re: [Q] How to exec code object with local variables specified?

2012-09-20 Thread Peter Otten
Makoto Kuwata wrote: > Is it possible to run code object with local variables specified? > I'm trying the following code but not work: > > def fn(): >x = 1 >y = 2 > localvars = {'x': 0} > exec(fn.func_code, globals(), localvars) > print(localvars) > ## what I e

Re: Programming Issues

2012-09-20 Thread Dave Angel
On 09/19/2012 07:01 PM, Nathan Spicer wrote: > Dave, > You sent this response privately, which isn't the way the mailing list works. Private responses are good for thank-yous and for personal remarks of no interest to others. But you're short-circuiting the helping process if you don't let ever

[Q] How to exec code object with local variables specified?

2012-09-20 Thread Makoto Kuwata
Hi, Is it possible to run code object with local variables specified? I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(), localvars) print(localvars) ## what I expected is: {'x': 1, 'y': 2} ## b

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-20 Thread Hans Mulder
On 20/09/12 05:11:11, Chris Angelico wrote: > On Thu, Sep 20, 2012 at 7:09 AM, Ian Kelly wrote: >> You could do: >> >> os.listdir("/proc/%d/fd" % os.getpid()) >> >> This should work on Linux, AIX, and Solaris, but obviously not on Windows. On MacOS X, you can use os.listdir("/dev/fd") This

Re: Installing Pip onto a mac os x system

2012-09-20 Thread Hans Mulder
On 20/09/12 03:32:40, John Mordecai Dildy wrote: > Does anyone know how to install Pip onto a mac os x ver 10.7.4? > > Ive tried easy_instal pip but it brings up this message (but it doesn't help > with my problem): > > error: can't create or remove files in install directory > > The following

Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked

2012-09-20 Thread Mark Lawrence
On 19/09/2012 20:12, ashish wrote: Folks, I asked the same query on the python tutor mailing list. The responses i received are here : http://thread.gmane.org/gmane.comp.python.tutor/77601 Mark, There is nothing wrong in asking a query on multiple forums. Poeple on the tutor list, may not be

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine

2012-09-20 Thread ashish
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote: > On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano > > wrote: > > > On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote: > > > > > >> 2. I have a python script, local.py, running on local which needs to > > >> pass argum