Re: how to separate a list into two lists?

2011-08-06 Thread Vito 'ZeD' De Tullio
David Robinow wrote: > On Sat, Aug 6, 2011 at 1:23 PM, Kabie wrote: >> No. >> L1, L2 = zip(*L) > > Not quite. That makes L1 & L2 tuples. > > L1, L2 = zip(*L) > L1 = list(L1) > L2 = list(L2) > ??? L1, L2 = map(list, zip(*L)) -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list

Re: how to separate a list into two lists?

2011-08-06 Thread Paul Rubin
smith jack writes: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop, any meth

Re: how to dynamically generate __name__ for an object?

2011-08-06 Thread Steven D'Aprano
Eric Snow wrote: > Thought I knew how to provide a dynamic __name__ on instances of a > class. My first try was to use a non-data descriptor: Perhaps you should explain what you are trying to do. If you want to give instances their own name, why not just give them an instance attribute "name"? D

how to dynamically generate __name__ for an object?

2011-08-06 Thread Eric Snow
Thought I knew how to provide a dynamic __name__ on instances of a class. My first try was to use a non-data descriptor: # module base.py class _NameProxy(object): def __init__(self, oldname): self.oldname = oldname def __get__(self, obj, cls): if obj is None:

Re: how to separate a list into two lists?

2011-08-06 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Aug 7, 2011 at 1:58 AM, Tim Roberts wrote: >> I did momentarily consider the following slimy solution: >> L1 = dict(L).keys() >> L2 = dict(L).values() >> but that reorders the tuples.  They still correspond, but in a different >> order. >> > > Which can be overcom

help with DLL or path issue trying to use cx_Freeze

2011-08-06 Thread Bart Manchester
Im trying to use the most basic of cx_Freeze in a dos window and I receive the following error (see below). I suspect I have some kind of path issue, but am at a loss as to how to proceed. I am trying to execute this in the Scripts directory and have both the cxfreeze bat and also the .py file

Re: how to separate a list into two lists?

2011-08-06 Thread Chris Angelico
On Sun, Aug 7, 2011 at 1:58 AM, Tim Roberts wrote: > I did momentarily consider the following slimy solution: >  L1 = dict(L).keys() >  L2 = dict(L).values() > but that reorders the tuples.  They still correspond, but in a different > order. > Which can be overcome with collections.OrderedDict. B

Re: how to separate a list into two lists?

2011-08-06 Thread Tim Roberts
smith jack wrote: > >if a list L is composed with tuple consists of two elements, that is >L = [(a1, b1), (a2, b2) ... (an, bn)] > >is there any simple way to divide this list into two separate lists , such that >L1 = [a1, a2... an] >L2=[b1,b2 ... bn] > >i do not want to use loop, any methods to m

Re: how to separate a list into two lists?

2011-08-06 Thread Steven D'Aprano
Chris Angelico wrote: > On Sat, Aug 6, 2011 at 6:07 PM, smith jack wrote: >> if a list L is composed with tuple consists of two elements, that is >> L = [(a1, b1), (a2, b2) ... (an, bn)] >> >> is there any simple way to divide this list into two separate lists , >> such that L1 = [a1, a2... an] >

Re: how to separate a list into two lists?

2011-08-06 Thread Steven D'Aprano
bud wrote: > I'll have to check up on the *L - is that a reference? No, as Chris already answered, unary * is used for packing and unpacking positional arguments to functions; unary ** is similarly used for collecting keyword arguments. > I know in Perl, you can assign the lhs to a list, > belo

Re: how to separate a list into two lists?

2011-08-06 Thread Steven D'Aprano
Gelonida N wrote: > Asuming you [Bud] are not an alias of Jack Smith and assuming you did > not see Jack's thread asking the same question: That's a strange thing to say when Bud *answered* Jack's question. > x,y = unzip(*L) What's unzip? It doesn't exist in any version of Python between 1.5

Re: DDE vs. COM for Python Windows apps

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 10:33 PM, Kevin Walzer wrote: > The main complaint I've seen about DDE is that it is very old. I can't speak about COM, as I have not used it to any great extent, but DDE has a number of things going for it. Firstly though, "old" does not need to be a criticism. How many ne

Re: help

2011-08-06 Thread Dan Stromberg
I'll be a lot easier for you to get help, if you take a shot at it yourself first, then post a link to what you have here, along with any error messages you may be getting. On Sat, Aug 6, 2011 at 1:38 PM, aahan noor wrote: > > Hi all: > i am new to python. i am working with lm-sensors to monito

Re: Problem installing 3.2.1 on a Linux server

2011-08-06 Thread Ned Deily
In article , John S James wrote: > My ISP (Bluehost) does not yet support Python version 3, but gave me shell > access (no sudo) so that I can install Python 3 myself on my server account > (running Apache). So I uploaded the standard Python.org installation package > (Python 3.2.1 for Linux) an

DDE vs. COM for Python Windows apps

2011-08-06 Thread Kevin Walzer
I'm developing a Windows version of a Mac/Python app and I'd like to add a scripting interface to it. On the Mac I do this via Apple Events--this is an Apple technology that allows applications to drive other applications and query them for data using a message-passing interface. Each applicati

Re: how to separate a list into two lists?

2011-08-06 Thread David Robinow
On Sat, Aug 6, 2011 at 1:23 PM, Kabie wrote: > No. > L1, L2 = zip(*L) Not quite. That makes L1 & L2 tuples. L1, L2 = zip(*L) L1 = list(L1) L2 = list(L2) ??? -- http://mail.python.org/mailman/listinfo/python-list

help

2011-08-06 Thread aahan noor
Hi all: i am new to python. i am working with lm-sensors to monitor the cpu fan speed, temperature and voltages. i have to use python code to get integer value of cpu temperature from lm sensors. please help me how i do that i shall be gratefullAahan -- h

Re: how to separate a list into two lists?

2011-08-06 Thread John Posner
On 2:59 PM, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop

Re: how to separate a list into two lists?

2011-08-06 Thread John Posner
On 2:59 PM, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop

Re: how to separate a list into two lists?

2011-08-06 Thread Gelonida N
On 08/06/2011 08:13 PM, bud wrote: > On Sun, 07 Aug 2011 01:07:00 +0800, smith jack wrote: > >> if a list L is composed with tuple consists of two elements, that is L = >> [(a1, b1), (a2, b2) ... (an, bn)] >> >> is there any simple way to divide this list into two separate lists , >> such that L1

Re: can virtualenv run without the main installation?

2011-08-06 Thread Gelonida N
On 08/06/2011 09:51 AM, smith jack wrote: > env create by virtualenv will refer to the main env, how did it find > the main env, is there any configuration files, if yes, where is it? > > 2011/8/6 smith jack : >> At first i have a python environment, after using virtualenv test >> command, a new e

Re: can virtualenv run without the main installation?

2011-08-06 Thread Gelonida N
On 08/06/2011 09:51 AM, smith jack wrote: > env create by virtualenv will refer to the main env, how did it find > the main env, is there any configuration files, if yes, where is it? > > 2011/8/6 smith jack : >> At first i have a python environment, after using virtualenv test >> command, a new e

Re: can virtualenv run without the main installation?

2011-08-06 Thread Gelonida N
On 08/06/2011 09:38 AM, smith jack wrote: > At first i have a python environment, after using virtualenv test > command, a new environment named test is created, in that directory > have some of the executable commands > such as python.exe, so can i program without the main installation of python?

Re: how to separate a list into two lists?

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 7:21 PM, bud wrote: > Nice. :)  I forgot about zip, still learning Python myself. > > I'll have to check up on the *L - is that a reference? > I It expands the list into the arguments. It's the parallel to: def func(*args): which collapses the args into a list. ChrisA --

Re: how to separate a list into two lists?

2011-08-06 Thread bud
On Sat, 06 Aug 2011 10:24:10 -0700, Emile van Sebille wrote: > On 8/6/2011 10:07 AM smith jack said... >> if a list L is composed with tuple consists of two elements, that is L >> = [(a1, b1), (a2, b2) ... (an, bn)] >> >> is there any simple way to divide this list into two separate lists , >> suc

Re: Complex sort on big files

2011-08-06 Thread sturlamolden
On Aug 1, 5:33 pm, aliman wrote: > I've read the recipe at [1] and understand that the way to sort a > large file is to break it into chunks, sort each chunk and write > sorted chunks to disk, then use heapq.merge to combine the chunks as > you read them. Or just memory map the file (mmap.mmap)

Re: how to separate a list into two lists?

2011-08-06 Thread bud
On Sun, 07 Aug 2011 01:07:00 +0800, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is L = > [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , > such that L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i

Problem installing 3.2.1 on a Linux server

2011-08-06 Thread John S James
My ISP (Bluehost) does not yet support Python version 3, but gave me shell access (no sudo) so that I can install Python 3 myself on my server account (running Apache). So I uploaded the standard Python.org installation package (Python 3.2.1 for Linux) and followed instructions, starting with ./con

Fwd: how to separate a list into two lists?

2011-08-06 Thread Zero Piraeus
: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] How about this? >>> L = [("a1", "b1"), ("a2", "b2"), (

Re: how to separate a list into two lists?

2011-08-06 Thread Kabie
No. L1, L2 = zip(*L) 2011/8/7 Chris Angelico > On Sat, Aug 6, 2011 at 6:07 PM, smith jack wrote: > > if a list L is composed with tuple consists of two elements, that is > > L = [(a1, b1), (a2, b2) ... (an, bn)] > > > > is there any simple way to divide this list into two separate lists , > su

Re: how to separate a list into two lists?

2011-08-06 Thread Emile van Sebille
On 8/6/2011 10:07 AM smith jack said... if a list L is composed with tuple consists of two elements, that is L = [(a1, b1), (a2, b2) ... (an, bn)] is there any simple way to divide this list into two separate lists , such that L1 = [a1, a2... an] L2=[b1,b2 ... bn] >>> L = [('a1', 'b1'), ('a2'

Re: how to separate a list into two lists?

2011-08-06 Thread Gary Herron
On 08/06/2011 10:07 AM, smith jack wrote: if a list L is composed with tuple consists of two elements, that is L = [(a1, b1), (a2, b2) ... (an, bn)] is there any simple way to divide this list into two separate lists , such that L1 = [a1, a2... an] L2=[b1,b2 ... bn] i do not want to use loop, a

Re: how to separate a list into two lists?

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 6:07 PM, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do

how to separate a list into two lists?

2011-08-06 Thread smith jack
if a list L is composed with tuple consists of two elements, that is L = [(a1, b1), (a2, b2) ... (an, bn)] is there any simple way to divide this list into two separate lists , such that L1 = [a1, a2... an] L2=[b1,b2 ... bn] i do not want to use loop, any methods to make this done? -- http://mai

Re: Segmentation Fault on exit

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 2:34 PM, Vipul Raheja wrote: > Here's the link: www.geofemengineering.it/data/master_wrap.cxx > Thanks and Regards, > Vipul Raheja Ugh. Unfortunately that file is somewhat lengthy... I hate to say "tl;dr" to people, but... is there any way to simplify that down? Perhaps th

Re: Segmentation Fault on exit

2011-08-06 Thread Dan Stromberg
I have little reason to doubt that it's related to referencing counting, but: http://stromberg.dnsalias.org/~dstromberg/checking-early.html On Sat, Aug 6, 2011 at 3:35 AM, Vipul Raheja wrote: > Hi, > > I have wrapped a library from C++ to Python using SWIG. But when I > import it in Python, I a

Re: Segmentation Fault on exit

2011-08-06 Thread Vipul Raheja
Hi, I did look out for the problem's solution but have been struggling with it ever since. I also asked around on IRC too but haven't quite progressed towards the solution. Here is the link to the swig-generated .cxx file which we need to look into for the answers. Could you please have a look at

Re: How to make the program support communication behind NAT device?

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 11:20 AM, smith jack wrote: > The subnet behind my router is 192.168.1.0/24, my pc ip is 192.168.1.9, > the server written with python is hosted on 192.168.1.3 on port 1033, > i can connect to this server from my pc > > But cannot connect to this server when outside of this

Re: How do I implement two decorators in Python both of which would eventually want to call the calling function

2011-08-06 Thread Tim Chase
On 08/06/2011 02:49 AM, Chris Rebert wrote: On Fri, Aug 5, 2011 at 10:49 PM, Devraj wrote: My question, how do I chain decorators that end up executing the calling method, but ensure that it's only called once. That's how it works normally; decorators stack (and order is therefore important).

How to make the program support communication behind NAT device?

2011-08-06 Thread smith jack
The subnet behind my router is 192.168.1.0/24, my pc ip is 192.168.1.9, the server written with python is hosted on 192.168.1.3 on port 1033, i can connect to this server from my pc But cannot connect to this server when outside of this subnet? why? I have made port translate on router, that is 1

Hi

2011-08-06 Thread Naresh Agrawal
Looking for a Python Developer with · Database (Oracle or SQL server ) – MUST have Capital Market Experience  - Fixed Income Market / Trading Systems    · Java/.Net as the base development expertise Please let me know if any one is interested

Re: Segmentation Fault on exit

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 12:16 PM, Vipul Raheja wrote: > Hi Chris, > Thanks for the reply. > However, the error occurs even if I don't do anything, that is, even if I > simply import the library and exit() after that. > I created a file a.py whose contents were the following: > import pyossim > exit

Re: Segmentation Fault on exit

2011-08-06 Thread Vipul Raheja
Hi Chris, Thanks for the reply. However, the error occurs even if I don't do anything, that is, even if I simply import the library and exit() after that. I created a file a.py whose contents were the following: import pyossim exit() Upon execution, the log was as follows: vipul@vipul-laptop:

Re: Segmentation Fault on exit

2011-08-06 Thread Chris Angelico
On Sat, Aug 6, 2011 at 11:35 AM, Vipul Raheja wrote: > Hi, > > I have wrapped a library from C++ to Python using SWIG. But when I > import it in Python, I am able to work fine with it, but it gives a > segmentation fault while exiting. Following is the log: The most likely cause of this is that y

Segmentation Fault on exit

2011-08-06 Thread Vipul Raheja
Hi, I have wrapped a library from C++ to Python using SWIG. But when I import it in Python, I am able to work fine with it, but it gives a segmentation fault while exiting. Following is the log: vipul@vipul-laptop:~/ossim-svn/src/pyossim/swig$ python Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:3

Re: install editra

2011-08-06 Thread Steven D'Aprano
守株待兔 wrote: > sudo python /opt/Editra-0.6.58/setup.py install > Traceback (most recent call last): > File "/opt/Editra-0.6.58/setup.py", line 639, in > DoSourcePackage() > File "/opt/Editra-0.6.58/setup.py", line 498, in DoSourcePackage > DATA = GenerateSrcPackageFiles() > File "/op

install editra

2011-08-06 Thread 守株待兔
sudo python /opt/Editra-0.6.58/setup.py install Traceback (most recent call last): File "/opt/Editra-0.6.58/setup.py", line 639, in DoSourcePackage() File "/opt/Editra-0.6.58/setup.py", line 498, in DoSourcePackage DATA = GenerateSrcPackageFiles() File "/opt/Editra-0.6.58/setup.py",

Re: Calling super() in __init__ of a metaclass

2011-08-06 Thread Eli Bendersky
On Sat, Aug 6, 2011 at 11:04, Chris Rebert wrote: > On Sat, Aug 6, 2011 at 12:34 AM, Eli Bendersky wrote: >> Consider this standard metaclass definition: >> >> class MyMetaclass(type): >>    def __init__(cls, name, bases, dct): >>        super(MyMetaclass, cls).__init__(name, bases, dct) >>      

Re: Calling super() in __init__ of a metaclass

2011-08-06 Thread Peter Otten
Eli Bendersky wrote: > Consider this standard metaclass definition: > > class MyMetaclass(type): > def __init__(cls, name, bases, dct): > super(MyMetaclass, cls).__init__(name, bases, dct) > # do meta-stuff > > class Foo(object): > __metaclass__ = MyMetaclass > > The cal

Re: Calling super() in __init__ of a metaclass

2011-08-06 Thread Chris Rebert
On Sat, Aug 6, 2011 at 12:34 AM, Eli Bendersky wrote: > Consider this standard metaclass definition: > > class MyMetaclass(type): >    def __init__(cls, name, bases, dct): >        super(MyMetaclass, cls).__init__(name, bases, dct) >        # do meta-stuff > > class Foo(object): >    __metaclass__

Re: How do I implement two decorators in Python both of which would eventually want to call the calling function

2011-08-06 Thread Peter Otten
Devraj wrote: > Hi all, > > I am trying to simply my Web application handlers, by using Python > decorators. > > Essentially I want to use decorators to abstract code that checks for > authenticated sessions and the other that checks to see if the cache > provider (Memcache in this instance) has

Re: can virtualenv run without the main installation?

2011-08-06 Thread smith jack
env create by virtualenv will refer to the main env, how did it find the main env, is there any configuration files, if yes, where is it? 2011/8/6 smith jack : > At first i have a python environment, after using virtualenv test > command, a new environment named test is created, in that directory

Re: How do I implement two decorators in Python both of which would eventually want to call the calling function

2011-08-06 Thread Chris Rebert
On Fri, Aug 5, 2011 at 10:49 PM, Devraj wrote: > Hi all, > > I am trying to simply my Web application handlers, by using Python > decorators. > > Essentially I want to use decorators to abstract code that checks for > authenticated sessions and the other that checks to see if the cache > provider

Re: How do I implement two decorators in Python both of which would eventually want to call the calling function

2011-08-06 Thread Rafael Durán Castañeda
You don't need doing something special, each decorator returns a new function that and only the result function formed by all decorators will be run. Consider this: def clear_cache(func): def decorator(*args, **kwargs): print "cache cleared" return func(*args, **kwargs)

can virtualenv run without the main installation?

2011-08-06 Thread smith jack
At first i have a python environment, after using virtualenv test command, a new environment named test is created, in that directory have some of the executable commands such as python.exe, so can i program without the main installation of python? -- http://mail.python.org/mailman/listinfo/python

Calling super() in __init__ of a metaclass

2011-08-06 Thread Eli Bendersky
Consider this standard metaclass definition: class MyMetaclass(type): def __init__(cls, name, bases, dct): super(MyMetaclass, cls).__init__(name, bases, dct) # do meta-stuff class Foo(object): __metaclass__ = MyMetaclass The call "super(MyMetaclass, cls)" should returns t