Re: Vectors

2011-04-22 Thread sturlamolden
On Apr 23, 2:32 am, Algis Kabaila wrote: > Thanks for that.  Last time I looked at numpy (for Python3) it > was available in source only.  I know, real men do compile, but > I am an old man...  I will compile if it is unavoidable, but in > case of numpy it does not seem  a simple matter. Am I bad

Re: Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Dan Stromberg
You could open a pivot_root subprocess using the subprocess module, or you could run pivot_root() directly using ctypes. I doubt any preexisting Python module wraps pivot_root(), but I'd love to be surprised. You may find that your Python module path does amusing things right after the pivot, so

Re: Closing generators

2011-04-22 Thread Terry Reedy
On 4/22/2011 4:01 AM, Thomas Rachel wrote: Am 22.04.2011 09:01, schrieb Wolfgang Rohdewald: On Freitag 22 April 2011, Terry Reedy wrote: When returning from the function, g, if local, should disappear. yes - it disappears in the sense that it no longer accessible, but AFAIK python makes n

Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Frederick Grose
Forwarded conversation Subject: Run a few Python commands from a temporary filesystem when the rootfs is halted From: *Frederick Grose* Date: Fri, Apr 22, 2011 at 7:54 PM To: tu...@python.org With Bash, when one needs to halt the current root filesystem, to pivot to a n

Re: Vectors

2011-04-22 Thread Algis Kabaila
On Saturday 23 April 2011 06:57:23 sturlamolden wrote: > On Apr 20, 9:47 am, Algis Kabaila wrote: > > Are there any modules for vector algebra (three dimensional > > vectors, vector addition, subtraction, multiplication > > [scalar and vector]. Could you give me a reference to such > > module? >

Re: .Well, ok, I will try some of that. But I am running window 7, not Linux.

2011-04-22 Thread P S
I did a little writeup for setting PyVISA up in Windows. It's not exactly polished, but it can get you through the difficult bits. If you need any additional help, leave comments/questions on my blog. http://psonghi.wordpress.com/2011/03/29/pyvisa-setup-in-windows/ > On Friday, April 01, 2011 1

Re: Input() in Python3

2011-04-22 Thread Chris Angelico
On Sat, Apr 23, 2011 at 9:55 AM, Steven D'Aprano wrote: > On Sat, 23 Apr 2011 06:25:51 +1000, Chris Angelico wrote: > >> On Sat, Apr 23, 2011 at 12:08 AM, Mel wrote: >>> But sys.exit() doesn't return a string.  My fave is >> >> It doesn't return _at all_. Boom, process terminated. > > > Technical

Re: Input() in Python3

2011-04-22 Thread Steven D'Aprano
On Sat, 23 Apr 2011 06:25:51 +1000, Chris Angelico wrote: > On Sat, Apr 23, 2011 at 12:08 AM, Mel wrote: >> But sys.exit() doesn't return a string.  My fave is > > It doesn't return _at all_. Boom, process terminated. Technically it raises an exception, which can then be caught by the usual e

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Steven D'Aprano
On Fri, 22 Apr 2011 07:38:38 -0700, Chris Rebert wrote: > Also, the following occurs to me as another idiomatic, perhaps more > /conceptually/ elegant possibility, but it's /practically/ speaking > quite inefficient (unless perhaps some dict view tricks can be > exploited): > > def is_subdict(sub

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 11:38 PM, harrismh777 wrote: > > Yes. And you have managed to point out a serious flaw in the overall logic > and consistency of Python, IMHO. > > Strings should auto-type-promote to numbers if appropriate. Please no. It's a little more convenient sometimes when you're c

Re: Vectors

2011-04-22 Thread sturlamolden
On Apr 20, 9:47 am, Algis Kabaila wrote: > Are there any modules for vector algebra (three dimensional > vectors, vector addition, subtraction, multiplication [scalar > and vector]. Could you give me a reference to such module? NumPy Or one of these libraries (ctypes or Cython): BLAS (Intel MK

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread MRAB
On 22/04/2011 21:31, Vlastimil Brom wrote: Thanks everyone for your opinions and suggestions! I especially like the all(...) approaches of MRAB and Peter Otten, however, the set conversion like set(test_dct.items())<= set(base_dct.items()) True looks elegant too. That works only if the values

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Vlastimil Brom
Thanks everyone for your opinions and suggestions! I especially like the all(...) approaches of MRAB and Peter Otten, however, the set conversion like >>> set(test_dct.items()) <= set(base_dct.items()) True looks elegant too. In both approaches I can get rid of the negated comparison and the additi

Re: Input() in Python3

2011-04-22 Thread Chris Angelico
On Sat, Apr 23, 2011 at 12:08 AM, Mel wrote: > But sys.exit() doesn't return a string.  My fave is It doesn't return _at all_. Boom, process terminated. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about Python Classes

2011-04-22 Thread Carl Banks
On Thursday, April 21, 2011 11:00:08 AM UTC-7, MRAB wrote: > On 21/04/2011 18:12, Pascal J. Bourguignon wrote: > > chad writes: > > > >> Let's say I have the following > >> > >> class BaseHandler: > >> def foo(self): > >> print "Hello" > >> > >> class HomeHandler(BaseHandler): >

Re: A question about Python Classes

2011-04-22 Thread Ian Kelly
On Fri, Apr 22, 2011 at 7:49 AM, Kyle T. Jones wrote: >> You don't need to create an instance of BaseHandler.  You have the >> class, Python knows you have the class -- Python will look there if the >> subclasses lack an attribute. >> >> ~Ethan~ >> > > Really?  That's not at all how I thought it w

Re: dict comparison [was: suggestions, comments on an "is_subdict" test]

2011-04-22 Thread Peter Otten
Zero Piraeus wrote: > : > > On 22 April 2011 13:30, Peter Otten <__pete...@web.de> wrote: > def is_subdict(test_dct, base_dct): >> ... return test_dct <= base_dct and all(test_dct[k] == base_dct[k] >> for ... k in test_dct) >> ... > is_subdict({1:0}, {2:0}) >> Traceback (most recent c

Re: A question about Python Classes

2011-04-22 Thread Ethan Furman
Kyle T. Jones wrote: Ethan Furman wrote: chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I nev

Re: About threads in python

2011-04-22 Thread sturlamolden
On Apr 21, 3:19 pm, dutche wrote: > My question is about the efficiency of threads in python, does anybody > has something to share? Never mind all the FUD about the GIL. Most of it is ill-informed and plain wrong. The GIL prevents you from doing one thing, which is parallel compute-bound code

dict comparison [was: suggestions, comments on an "is_subdict" test]

2011-04-22 Thread Zero Piraeus
: On 22 April 2011 13:30, Peter Otten <__pete...@web.de> wrote: def is_subdict(test_dct, base_dct): > ...     return test_dct <= base_dct and all(test_dct[k] == base_dct[k] for > ... k in test_dct) > ... is_subdict({1:0}, {2:0}) > Traceback (most recent call last): >  File "", line 1, in

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Peter Otten
Zero Piraeus wrote: >>> Anything wrong with this? >>> >>> def is_subdict(test_dct, base_dct): >>> return test_dct <= base_dct and all(test_dct[k] == base_dct[k] for >>> k in test_dct) >> >> It may raise a KeyError. > > Really? That was what ``test_dct <= base_dct and`` ... is supposed to > preven

Re: Input() in Python3

2011-04-22 Thread Benjamin Kaplan
On Apr 22, 2011 10:12 AM, "Mel" wrote: > > Westley Martínez wrote: > > On Fri, Apr 22, 2011 at 04:49:19PM +1000, Chris Angelico wrote: > > >> U NO. NO NO NO. What if someone enters "os.exit()" as their > >> number? You shouldn't eval() unchecked user input! > >> > >> Chris Angelico > > > >

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Zero Piraeus
: >> Anything wrong with this? >> >> def is_subdict(test_dct, base_dct): >>     return test_dct <= base_dct and all(test_dct[k] == base_dct[k] for >> k in test_dct) > > It may raise a KeyError. Really? That was what ``test_dct <= base_dct and`` ... is supposed to prevent. Have I missed something?

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread MRAB
On 22/04/2011 15:57, Irmen de Jong wrote: On 22-4-2011 15:55, Vlastimil Brom wrote: Hi all, I'd like to ask for comments or advice on a simple code for testing a "subdict", i.e. check whether all items of a given dictionary are present in a reference dictionary. Sofar I have: def is_subdict(tes

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Peter Otten
Zero Piraeus wrote: > : > >>> I'd like to ask for comments or advice on a simple code for testing a >>> "subdict", i.e. check whether all items of a given dictionary are >>> present in a reference dictionary. > > Anything wrong with this? > > def is_subdict(test_dct, base_dct): > return tes

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Irmen de Jong
On 22-4-2011 15:55, Vlastimil Brom wrote: > Hi all, > I'd like to ask for comments or advice on a simple code for testing a > "subdict", i.e. check whether all items of a given dictionary are > present in a reference dictionary. > Sofar I have: > > def is_subdict(test_dct, base_dct): > """Test

Re: Finding empty columns. Is there a faster way?

2011-04-22 Thread nn
On Apr 21, 4:32 pm, Jon Clements wrote: > On Apr 21, 5:40 pm, nn wrote: > > > > > > > > > > > time head -100 myfile  >/dev/null > > > real    0m4.57s > > user    0m3.81s > > sys     0m0.74s > > > time ./repnullsalt.py '|' myfile > > 0 1 Null columns: > > 11, 20, 21, 22, 23, 24, 25, 26, 27, 30

Re: Pairwise frequency count from an incidence matrix of group membership

2011-04-22 Thread scattered
On Apr 22, 6:57 am, Jean-Michel Pichavant wrote: > Shafique, M. (UNU-MERIT) wrote: > > Hi, > > I have a number of different groups g1, g2, … g100 in my data. Each > > group is comprised of a known but different set of members (m1, m2, > > …m1000) from the population. The data has been organized in

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Wolfgang Rohdewald
On Freitag 22 April 2011, Vlastimil Brom wrote: > check whether all items of a given dictionary are > present in a reference dictionary I would not call this is_subdict. That name does not clearly express that all keys need to have the same value. set(subdict.items()) <= set(reference.items()) s

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Zero Piraeus
: >> I'd like to ask for comments or advice on a simple code for testing a >> "subdict", i.e. check whether all items of a given dictionary are >> present in a reference dictionary. Anything wrong with this? def is_subdict(test_dct, base_dct): return test_dct <= base_dct and all(test_dct[k]

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Chris Rebert
On Fri, Apr 22, 2011 at 6:55 AM, Vlastimil Brom wrote: > Hi all, > I'd like to ask for comments or advice on a simple code for testing a > "subdict", i.e. check whether all items of a given dictionary are > present in a reference dictionary. > Sofar I have: > > def is_subdict(test_dct, base_dct):

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Peter Otten
Vlastimil Brom wrote: > Hi all, > I'd like to ask for comments or advice on a simple code for testing a > "subdict", i.e. check whether all items of a given dictionary are > present in a reference dictionary. > Sofar I have: > > def is_subdict(test_dct, base_dct): > """Test whether all the it

Re: ctypes for AIX

2011-04-22 Thread Anssi Saari
"Waddle, Jim" writes: > I do not have sufficient knowledge to know how to fix this. I would think > that this error somehow is related to compiling on aix. If you have any > suggestions on how to correct this problem , I would appreciate it I'd have to guess your main problem is not using gcc

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread MRAB
On 22/04/2011 14:55, Vlastimil Brom wrote: Hi all, I'd like to ask for comments or advice on a simple code for testing a "subdict", i.e. check whether all items of a given dictionary are present in a reference dictionary. Sofar I have: def is_subdict(test_dct, base_dct): """Test whether all

Re: Input() in Python3

2011-04-22 Thread Mel
Westley Martínez wrote: > On Fri, Apr 22, 2011 at 04:49:19PM +1000, Chris Angelico wrote: >> U NO. NO NO NO. What if someone enters "os.exit()" as their >> number? You shouldn't eval() unchecked user input! >> >> Chris Angelico > > Right, there's no way to check you're getting a number,

suggestions, comments on an "is_subdict" test

2011-04-22 Thread Vlastimil Brom
Hi all, I'd like to ask for comments or advice on a simple code for testing a "subdict", i.e. check whether all items of a given dictionary are present in a reference dictionary. Sofar I have: def is_subdict(test_dct, base_dct): """Test whether all the items of test_dct are present in base_dct

Re: Input() in Python3

2011-04-22 Thread Westley Martínez
On Fri, Apr 22, 2011 at 04:49:19PM +1000, Chris Angelico wrote: > On Fri, Apr 22, 2011 at 4:22 PM, harrismh777 wrote: > > now we get this for input(): > > > >   raw_input("prompt>") --> string > > I would have to say that the 2.x behaviour of input() is a mistake > that's being corrected in 3.x.

Re: A question about Python Classes

2011-04-22 Thread Kyle T. Jones
Ethan Furman wrote: chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance

Re: Teaching Python

2011-04-22 Thread Westley Martínez
On Fri, Apr 22, 2011 at 01:04:55AM -0500, harrismh777 wrote: > Westley Martínez wrote: > >But really, hack > >> >has always been a negative term. It's original definition is chopping, > >> >breaking down, kind of like chopping down the security on someone elses > >> >computer. Now I don't know wh

Re: ctypes for AIX

2011-04-22 Thread Stefan Behnel
sjw, 22.04.2011 15:26: I need to!But ctypes can't work on AIX... Need help.. What are you trying to do, and why do you need ctypes for it? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes for AIX

2011-04-22 Thread sjw
I need to!But ctypes can't work on AIX... Need help.. -- http://mail.python.org/mailman/listinfo/python-list

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Roy Smith
In article , Mel wrote: > > Strings should auto-type-promote to numbers if appropriate. > > "Appropriate" is the problem. This is why Perl needs two completely > different kinds of comparison -- one that works as though its operands are > numbers, and one that works as though they're strings

Re: dictionary size changed during iteration

2011-04-22 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > You now have to create the list explicitly to avoid the error: > > >>> d = dict(a=1) > >>> keys = list(d.keys()) > >>> for k in keys: > ... d["b"] = 42 > ... That works, but if d is large, it won't be very efficient because it has to gen

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Mel
harrismh777 wrote: > Heiko Wundram wrote: >> The difference between strong typing and weak typing is best described >> by: >> >> Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01) >> [GCC 4.3.4 20090804 (release) 1] on cygwin >> Type "help", "copyright", "credits" or "license" for more information.

Re: dictionary size changed during iteration

2011-04-22 Thread Mark Niemczyk
As of Python 3.x (which I suspect you are running): "The objects returned by dict.keys(), dict.values() and dict.items() are view objects. They provide a dynamic view on the dictionary’s entries, which means that when the dictionary changes, the view reflects these changes.", and "Iterating vi

Re: Vectors

2011-04-22 Thread Algis Kabaila
On Friday 22 April 2011 11:43:26 Gregory Ewing wrote: > Algis Kabaila wrote: > > the Vector3 class > > is available without any prefix euclid: > > > > import euclid > > v = Vector3(111.., 222.2, 333.3) > > Doesn't work that way for me: > > Python 2.7 (r27:82500, Oct 15 2010, 21:14:33) > [GCC 4.2

Re: Pairwise frequency count from an incidence matrix of group membership

2011-04-22 Thread Jean-Michel Pichavant
Shafique, M. (UNU-MERIT) wrote: Hi, I have a number of different groups g1, g2, … g100 in my data. Each group is comprised of a known but different set of members (m1, m2, …m1000) from the population. The data has been organized in an incidence matrix: g1 g2 g3 g4 g5 m1 1 1 1 0 1 m2 1 0 0 1 0

Pairwise frequency count from an incidence matrix of group membership

2011-04-22 Thread Shafique, M. (UNU-MERIT)
Hi, I have a number of different groups g1, g2, … g100 in my data. Each group is comprised of a known but different set of members (m1, m2, …m1000) from the population. The data has been organized in an incidence matrix: g1g2g3g4g5 m01 m210010 m301100 m411011 m500110 I need to count how many

Re: Argument count mismatch

2011-04-22 Thread Daniel Kluev
On Fri, Apr 22, 2011 at 12:43 PM, Steven D'Aprano wrote: > It looks to me like this function relies on no fewer than three global > variables, two that you read from and one which you write to: > > c > Session > MSPResponse > > This is almost certainly poor design. Using global state is almost alw

Re: PyLZMA lastwritetime file to python datetime

2011-04-22 Thread rabusta
On Apr 22, 5:12 pm, Chris Rebert wrote: > [Mildly educated guess after > scanninghttps://github.com/fancycode/pylzma/blob/master/py7zlib.py]: > > It's likely a Unix timestamp. Perhaps try > datetime.datetime.utcfromtimestamp() or > datetime.datetime.fromtimestamp() > ?http://docs.python.org/libr

Re: A question about Python Classes

2011-04-22 Thread Jean-Michel Pichavant
MRAB wrote: On 21/04/2011 18:12, Pascal J. Bourguignon wrote: chad writes: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHa

Re: PyLZMA lastwritetime file to python datetime

2011-04-22 Thread Chris Rebert
On Fri, Apr 22, 2011 at 1:49 AM, rabusta wrote: > How convert lastwritetime file to python datetime? [Mildly educated guess after scanning https://github.com/fancycode/pylzma/blob/master/py7zlib.py ]: It's likely a Unix timestamp. Perhaps try datetime.datetime.utcfromtimestamp() or datetime.date

PyLZMA lastwritetime file to python datetime

2011-04-22 Thread rabusta
How convert lastwritetime file to python datetime? -- http://mail.python.org/mailman/listinfo/python-list

Re: Closing generators

2011-04-22 Thread Thomas Rachel
Am 22.04.2011 09:01, schrieb Wolfgang Rohdewald: On Freitag 22 April 2011, Terry Reedy wrote: When returning from the function, g, if local, should disappear. yes - it disappears in the sense that it no longer accessible, but AFAIK python makes no guarantees as for when an object is destro

Re: Snowball to Python compiler

2011-04-22 Thread Stefan Behnel
Terry Reedy, 22.04.2011 05:48: On 4/21/2011 8:25 PM, Paul Rubin wrote: Matt Chaput writes: I'm looking for some code that will take a Snowball program and compile it into a Python script. Or, less ideally, a Snowball interpreter written in Python. (http://snowball.tartarus.org/) Anyone heard

Re: Input() in Python3

2011-04-22 Thread Chris Rebert
On Thu, Apr 21, 2011 at 11:22 PM, harrismh777 wrote: > My interactive scripts are giving errors on the input(). I discovered > another fairly significant change in Python3, as discussed in PEP 3111. > > I was a little flabbergasted to discover that input() was proposed to be > removed 'totally' fr

Re: shared dictionary of dictionaries with Manager

2011-04-22 Thread Dan Stromberg
2011/4/21 Darío Suárez Gracia > Hi all, > I was trying to share a dictionary of dictionaries of arrays with Manager > from multiprocessing. Without multiprocessing the code works perfectly, but > with the current example the last print does not show the correct result. > It appears that if you p

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Chris Angelico
On Fri, Apr 22, 2011 at 4:38 PM, harrismh777 wrote: > My feelings about this are strongly influenced by my experiences with the > REXX language on IBM's SAA systems--- OS/2 and VM/CMS. In REXX everything is > a string... everything. If a string just happens to be a REXX number, then > it can be ma

Re: Closing generators

2011-04-22 Thread Wolfgang Rohdewald
On Freitag 22 April 2011, Terry Reedy wrote: > > for i in g: > > if i is not None: > > g.close() > > return i > > When returning from the function, g, if local, should > disappear. yes - it disappears in the sense that it no longer accessible, but AFAIK python makes no guarantees as for when an