Re: Presentation software for Python code

2009-04-24 Thread alex23
On Apr 24, 4:23 pm, Michael Hoffman <4g4trz...@sneakemail.com> wrote: > That looks like it would be perfect. Unfortunately it doesn't seem to > work on my Windows laptop: > > I don't understand this. OpenGL Extensions Viewer says I have OpenGL 1.5 > and the glGenBuffers function. That's a shame, i

Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-24 Thread CM
On Apr 22, 9:11 am, srinivasan srinivas wrote: > Hi, > Could you suggest me some modules in Python which can be used to develop GUI > based applications? and tell me which could be the best(in terms of > efficiency) one for a small GUI based application development? > > Thanks, > Srini > >      

Re: Large data arrays?

2009-04-24 Thread Ole Streicher
Hi John, John Machin writes: > The Morton layout wastes space if the matrix is not square. Your 100K > x 4K is very non-square. Looks like you might want to use e.g. 25 > Morton arrays, each 4K x 4K. What I found was that Morton layout shall be usable, if the shape is rectangular and both dimens

Re: sorting two corresponding lists?

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 2:32 am, "Hans DushanthaKumar" wrote: > Just being pedantic here :) > > [items[x] for x in [i for i in map(values.index, new_values)]] > > Is the same as > > [items[x] for x in map(values.index, new_values)] It's also the same as [items[x] for x in [values.index(i) for i in new_va

Re: Large data arrays?

2009-04-24 Thread Ole Streicher
Hi Nick, Nick Craig-Wood writes: > I'd start by writing a function which took (x, y) in array > co-ordinates and transformed that into (z) remapped in the Morton > layout. This removes the possibility to use the sum() and similar methods of numpy. Implementing them myself is probably much worse

Re: Regular expression to capture model numbers

2009-04-24 Thread Piet van Oostrum
> John Machin (JM) wrote: >JM> On Apr 24, 1:29 am, Piet van Oostrum wrote: >>> obj = re.compile(r'(?:[a-z]+[-0-9]|[0-9]+[-a-z]|-+[0-9a-z])[-0-9a-z]*', >>> re.I) >JM> Understandable and maintainable, I don't think. Suppose that instead >JM> the first character is limited to being alphabeti

Re: What IDE support python 3.0.1 ?

2009-04-24 Thread Peter Anderson
Sam (I presume), Like you I am also in the process of learning to program in Python. I have been using Python 2.5.2 for quite some time but recently made the switch to 3.0.1. Why? Because I read an article where Guido van Rossum himself recommended that anyone starting out learning Python now

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Piet van Oostrum
> John Yeung (JY) wrote: >JY> It takes care of the duplicates, but so does your initial solution, >JY> which I like best: >>> sorted(a)==sorted(b) >JY> This is concise, clear, and in my opinion, the most Pythonic. It may >JY> well even be the fastest. (If you didn't have to match up the n

Re: getter and setter and list appends

2009-04-24 Thread Piet van Oostrum
> dasacc22 (d) wrote: >d> Ah thank you for clarifying, I did confuse instance and class >d> attributes from creating the list in the class def. I actually just >d> spiffed up that class to represent a portion of a much larger class >d> that needs getter and setter for children. Doing as you s

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-24 Thread Marco Mariani
Scott David Daniels wrote: I am afraid it will make it too easy to define functions in other modules remotely, a tempting sharp stick to poke your eye out with. It's not very hard at the moment, and I don't see lots of eyes flying by. I don't know about Ruby where monkeypatching seems to be c

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 06:50:01 +, Lie Ryan wrote: > Gerhard Häring wrote: >> len() make it clear that the argument is a sequence. > > Not necessarily. len() works on dicts and sets, and they're not sequences. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Steven D'Aprano
On Thu, 23 Apr 2009 21:51:42 -0400, Esmail wrote: >> set(a) == set(b)# test if a and b have the same elements >> >> # check that each list has the same number of each element # i.e. >> [1,2,1,2] == [1,1,2,2], but [1,2,2,2] != [1,1,1,2] for elem in set(a): >> a.count(elem) == b.count(elem

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-24 Thread Steven D'Aprano
On Thu, 23 Apr 2009 10:48:57 -0700, Scott David Daniels wrote: > I am afraid it will make it too easy to define functions in other > modules remotely, a tempting sharp stick to poke your eye out with. It's not terribly difficult to do so already: >>> def spam(): ... return "spam spam spam"

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Steven D'Aprano
On Thu, 23 Apr 2009 17:18:25 +0800, Leo wrote: >> There's also the performance issue. I might have a sequence-like >> structure where calling len() takes O(N**2) time, (say, a graph) but >> calling __nozero__ might be O(1). Why defeat the class designer's >> optimizations? > > Is that true? > Cal

wxpython notebook oddness

2009-04-24 Thread Lawson English
Can anyone tell me why these two behave differfently? http://pastebin.com/m57bee079 vs http://pastebin.com/m3c044b29 Lawson -- http://mail.python.org/mailman/listinfo/python-list

Raw command line arguments

2009-04-24 Thread Enchanter
How to pass the raw command line arguments to the python? Such as: mypython.py txt -c "Test Only" {Help} The arguments I hope to get is: txt -c "Test Only" {Help} -- Keep the quotation marks in the arguments. -- http://mail.python.org/mailman/listinfo/python-

Re: unicode(lString, "utf8") vs. lString.encode("utf8") vs. ur"jakiś tekst"

2009-04-24 Thread Jax
Sorry, my mistake. My interntion was post this message on pl.comp.lang.python. Jax -- http://mail.python.org/mailman/listinfo/python-list

Re: Raw command line arguments

2009-04-24 Thread Chris Rebert
On Fri, Apr 24, 2009 at 2:40 AM, Enchanter wrote: > How to pass the raw command line arguments to the python? > > Such as: > >     mypython.py  txt -c "Test Only" {Help} > > > The arguments I hope to get is: > >              txt -c "Test Only" {Help}               -- Keep the > quotation marks in

Convert numpy.ndarray into "normal" array

2009-04-24 Thread Johannes Bauer
Hi group, I'm confused, kind of. The application I'm writing currently reads data from a FITS file and should display it on a gtk window. So far I have: [...] pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) pb_pixels = pb.get_pixels_array() print(type(fits_pixels)) print(typ

if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching something like this: if (t = Test()) == 'Vla': print t # Vla or if (t = Test()): print t # Vla ---

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. I want to use > that variable inside that if loop , without defining it. > > def Test(): > return 'Vla' > > I searching something like this: > > if (t = Test()) ==

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Chris Rebert
On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. > I want to use that variable inside that if loop , without defining it. > > def Test(): >    return 'Vla' > > I searching something like this: > > if (t = Test()) == 'Vla': >

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
On 24 apr, 12:11, Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > > Hello, > > > I'm trying to do a if statement with a function inside it. I want to use > > that variable inside that if loop , without defining it. > > > def Test(): > >     return 'Vla' > > > I sea

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Paul Rubin
Steven D'Aprano writes: > len() works on dicts and sets, and they're not sequences. Of course dicts and sets are sequences. But there are also sequences on which len doesn't work. You could use: sum(1 for x in seq) Of course iterating through seq may have undesired side effects. -- http://mail

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Paul Rubin
Chris Rebert writes: > Python forces you to do it the "long way" (the Right Way(tm) if you > ask most Python partisans). > > If you could explain your situation and the context of your question > in greater detail, someone might be able to suggest an alternate > structure for your code which obvi

Re: Raw command line arguments

2009-04-24 Thread Dave Angel
Enchanter wrote: How to pass the raw command line arguments to the python? Such as: mypython.py txt -c "Test Only" {Help} The arguments I hope to get is: txt -c "Test Only" {Help} -- Keep the quotation marks in the arguments. As Chris has said, the shel

PDB break

2009-04-24 Thread Ricardo Aráoz
Hi, I need to track where a certain condition is met in a program. Checking on pdb docs I find the break statement : b(reak) [[/filename/:]/lineno/ | /function/[, /condition/]] But it requires me to name a line/function where my condition is tested. Now there are far too many places in a project

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Esmail
John Yeung wrote: so does your initial solution, which I like best: sorted(a)==sorted(b) This is concise, clear, and in my opinion, the most Pythonic. It may well even be the fastest. Great .. I can live with that :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Peter Otten
Paul Rubin wrote: > Steven D'Aprano writes: >> len() works on dicts and sets, and they're not sequences. > > Of course dicts and sets are sequences. But there are also sequences > on which len doesn't work. That was my intuition, too. But Python takes a different stance: >>> from collections

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 03:22:50 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> len() works on dicts and sets, and they're not sequences. > > Of course dicts and sets are sequences. Dicts and sets are explicitly described as "other containers": http://docs.python.org/library/stdtypes.html#s

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Esmail
MRAB wrote: You could use Raymond Hettinger's Counter class: http://code.activestate.com/recipes/576611/ on both lists and compare them for equality. thanks for the pointer, I'll study the code provided. Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to compare contents of 2 lists?

2009-04-24 Thread bearophileHUGS
Arnaud Delobelle: > Thanks to the power of negative numbers, you only need one dict: > > d = defaultdict(int) > for x in a: >     d[x] += 1 > for x in b: >     d[x] -= 1 > # a and b are equal if d[x]==0 for all x in d: > not any(d.itervalues()) Very nice, I'll keep this for future use. Someday I'l

HTTP Authentication using urllib2

2009-04-24 Thread Lakshman
I am trying to authenticate using urllib2. The basic authentication works if I hard code authheaders. def is_follows(follower, following): theurl = 'http://twitter.com/friendships/exists.json? user_a='+follower+'&user_b='+following username = 'uname1' password = 'pwd1' handle = ur

Re: Convert numpy.ndarray into "normal" array

2009-04-24 Thread MRAB
Johannes Bauer wrote: Hi group, I'm confused, kind of. The application I'm writing currently reads data from a FITS file and should display it on a gtk window. So far I have: [...] pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) pb_pixels = pb.get_pixels_array() print(type

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: >> t = Test() >> if (t == 'Vla': >> print t # must contain Vla > > > What's wrong with that? It unnecessarily injects the name 't' into the scope. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amts

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread MRAB
GC-Martijn wrote: On 24 apr, 12:15, Chris Rebert wrote: On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching something

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 7:12 am, bearophileh...@lycos.com wrote: [...] > Another solution is to use frequency dicts, O(n): > > from itertools import defaultdict > d1 = defaultdict(int) > for el in a: >     d1[el] += 1 > d2 = defaultdict(int) > for el in b: >     d2[el] += 1 > d1 == d2 Thanks to the power of ne

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
On 24 apr, 12:15, Chris Rebert wrote: > On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: > > Hello, > > > I'm trying to do a if statement with a function inside it. > > I want to use that variable inside that if loop , without defining it. > > > def Test(): > >    return 'Vla' > > > I searching

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Esmail
Thanks all, after reading all the posting and suggestions for alternatives, I think I'll be going with sorted(a)==sorted(b) it seems fast, intuitive and clean and can deal with duplicates too. Best, Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Esmail
Piet van Oostrum wrote: John Yeung (JY) wrote: JY> It takes care of the duplicates, but so does your initial solution, JY> which I like best: sorted(a)==sorted(b) JY> This is concise, clear, and in my opinion, the most Pythonic. It may JY> well even be the fastest. (If you didn't have

unicode(lString, "utf8") vs. lString.encode("utf8") vs. ur"jakiś tekst"

2009-04-24 Thread Jax
Witam Zakładam, że kod Pythona w drugiej lini ma: # -*- coding: utf-8 -*- oraz gdzieś na początku: reload(sys) sys.setdefaultencoding('utf8') No i mam takie pytania odnośnie unicode w utf8: Czy obie poniższe linie dają ten sam efekt, czyli obiekt unicode zakodowany w utf8? lString = unicode(lSt

Re: Presentation software for Python code

2009-04-24 Thread Sebastian Wiesner
> I'm willing to consider TeX- and HTML-based approaches. I can recommend latex with the beamer package. It doesn't directly support formatting of code snippets, but the pygments syntax highlighter comes with a Latex formatter. -- Freedom is always the freedom of dissenters.

Re: JSON and Firefox sessionstore.js

2009-04-24 Thread Дамјан Георгиевски
> Unless I'm badly mistaken, the Firefox sessionstore.js file is > supposed to be JSON. ... > If it matters, I'm using Firefox 2.0.0.5 under Linux. maybe it can be parsed with PyYAML? -- дамјан ( http://softver.org.mk/damjan/ ) Well when _I_ was in school, I had to run Netscape on HP/UX, displ

Re: Numpy Performance

2009-04-24 Thread timlash
Thanks for your replies. @Peter - My arrays are not sparse at all, but I'll take a quick look as scipy. I also should have mentioned that my numpy arrays are of Object type as each data point (row) has one or more text labels for categorization. @Robert - Thanks for the comments about how numpy

Python-URL! - weekly Python news and links (Apr 24)

2009-04-24 Thread Gabriel Genellina
QOTW: "... [C]alling Python Object-Orientated is a bit of an insult :-). I would say that Python is Ego-Orientated, it allows me to do what I want." - Martin P. Hellwig April 25: Python Bug Day A perfect opportunity to get involved in Python development, bring your own issues to att

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Marco Mariani
Ulrich Eckhardt wrote: t = Test() if (t == 'Vla': print t # must contain Vla What's wrong with that? It unnecessarily injects the name 't' into the scope. Since there is no concept in Python of a scope local to block statements, I don't understant what you would like to happen instead

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Paul McGuire
On Apr 24, 5:00 am, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. > I want to use that variable inside that if loop , without defining it. > > def Test(): >     return 'Vla' > > I searching something like this: > > if (t = Test()) == 'Vla': >     print t

Failed to build these modules:_ctypes

2009-04-24 Thread PS
Hello all I can't install neither python 2.6.1 nor 2.6.2 because an error during compilation of _ctypes module, I don't need the module but I don't know how to instruct to skip it. The plattform is Suse 11.0 The steps I performed are the following: ./configure --prefix $HOME/app/Python-2.6.2 m

Re: getter and setter and list appends

2009-04-24 Thread dasacc22
On Apr 24, 4:04 am, Piet van Oostrum wrote: > > dasacc22 (d) wrote: > >d> Ah thank you for clarifying, I did confuse instance and class > >d> attributes from creating the list in the class def. I actually just > >d> spiffed up that class to represent a portion of a much larger class > >d> tha

Re: Convert numpy.ndarray into "normal" array

2009-04-24 Thread Johannes Bauer
MRAB schrieb: >> >> >> >> So now I want to copy the fits_pixels -> pb_pixels. Doing >> >> pb_pixels = fits_pixels >> > This simply makes pb_pixels refer to the same object as fits_pixels. It > doesn't copy the values into the existing pb_pixels object. Oh okay, I was thinking of C++ std::vector

Superclass initialization

2009-04-24 Thread Ole Streicher
Hi again, I am trying to initialize a class inherited from numpy.ndarray: from numpy import ndarray class da(ndarray): def __init__(self, mydata): ndarray.__init__(self, 0) self.mydata = mydata When I now call the constructor of da: da(range(100)) I get the message: ValueE

Re: Superclass initialization

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 16:04:00 +0200, Ole Streicher wrote: > I get the message: > > ValueError: sequence too large; must be smaller than 32 > > which I do not understand. This message is generated by the constructor > of ndarray, but the ndarray constructor (ndarray.__init__()) has only > "0" as a

Re: Superclass initialization

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 3:04 pm, Ole Streicher wrote: > Hi again, > > I am trying to initialize a class inherited from numpy.ndarray: > > from numpy import ndarray > > class da(ndarray): >     def __init__(self, mydata): >         ndarray.__init__(self, 0) >         self.mydata = mydata > > When I now call the

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread Grant Edwards
On 2009-04-23, MRAB wrote: > tinn...@isbd.co.uk wrote: >> It seems to me that mailbox.mbox.add() sets the access time of a mbox >> file as well as the modification time. This is not good for MUAs that >> detect new mail by looking to see if the access time is before the >> modification time. >>

Re: Superclass initialization

2009-04-24 Thread Ole Streicher
Steven D'Aprano writes: > Perhaps you should post the full trace back instead of just the final > line. No Problem, although I dont see the information increase there: In [318]: class da(ndarray): .: def __init__(self, mydata): .: ndarray.__init__(self, 0) .

Re: Superclass initialization

2009-04-24 Thread Ole Streicher
Arnaud Delobelle writes: > numpy.ndarray has a __new__ method (and no __init__). I guess this is > the one you should override. Try: What is the difference? best regards Ole -- http://mail.python.org/mailman/listinfo/python-list

Re: Superclass initialization

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 3:46 pm, Ole Streicher wrote: > Arnaud Delobelle writes: > > numpy.ndarray has a __new__ method (and no __init__).  I guess this is > > the one you should override.  Try: > > What is the difference? > > best regards > > Ole Here's an explanation. http://www.python.org/download/re

repost: http web page fetch question

2009-04-24 Thread grocery_stocker
Given the following... [cdal...@localhost oakland]$ more basic.py #!/usr/bin/python import sched import time scheduler = sched.scheduler(time.time, time.sleep) def print_event(name): print 'EVENT:', time.time(), name print 'START:', time.time() scheduler.enter(2, 1, print_event, ('firs

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread MRAB
Grant Edwards wrote: On 2009-04-23, MRAB wrote: tinn...@isbd.co.uk wrote: It seems to me that mailbox.mbox.add() sets the access time of a mbox file as well as the modification time. This is not good for MUAs that detect new mail by looking to see if the access time is before the modification

Re: Failed to build these modules:_ctypes

2009-04-24 Thread Thomas Heller
PS schrieb: > Hello all > > I can't install neither python 2.6.1 nor 2.6.2 because an error during > compilation of _ctypes module, I don't need the module but I don't > know how to instruct to skip it. You only get a warning, right? So a subsequent 'make install' should work. -- http://mail.pyt

Re: Large data arrays?

2009-04-24 Thread John Machin
On Apr 24, 5:17 pm, Ole Streicher wrote: > Hi John, > > John Machin writes: > > The Morton layout wastes space if the matrix is not square. Your 100K > > x 4K is very non-square. Looks like you might want to use e.g. 25 > > Morton arrays, each 4K x 4K. > > What I found was that Morton layout shal

Re: Help with code! Gamepad?

2009-04-24 Thread DC16
On Apr 23, 4:03 pm, Mike Driscoll wrote: > On Apr 23, 6:46 am, DC16 wrote: > > > > > > > I am using pygame and OpenGL. > > How do I make a gamepad able to move the camera to a side of a cube on > > screen. > > > Here is the code for keyboard use: > > > import pygame > > from pygame.locals import

Re: Large data arrays?

2009-04-24 Thread Ole Streicher
Hi John, John Machin writes: >> From my access pattern, it would be probably better to combine 25 rows >> into one slice and have one matrix where every cell contains 25 rows. >> Are there any objections about that? > Can't object, because I'm not sure what you mean ... how many elements > in a "

python list handling and Lisp list handling

2009-04-24 Thread Mark Tarver
This page says that Python lists are often flexible arrays http://www.brpreiss.com/books/opus7/html/page82.html but also says that their representation is implementation dependent. As far as I see this should mean that element access in Python should run in constant time. Now if so this is a boo

Re: Large data arrays?

2009-04-24 Thread John Machin
On Apr 25, 1:14 am, Ole Streicher wrote: > Hi John, > > John Machin writes: > >> From my access pattern, it would be probably better to combine 25 rows > >> into one slice and have one matrix where every cell contains 25 rows. > >> Are there any objections about that? > > Can't object, because I'

Re: gethostbyname blocking

2009-04-24 Thread marc wyburn
On Apr 23, 2:16 pm, Piet van Oostrum wrote: > > marc wyburn (MW) wrote: > >MW> Hi, I am writing anasynchronousping app to check if 1000s of hosts > >MW> are alive very quickly.  Everything works extremely quickly unless the > >MW> host name doesn't have a DNS record. > >MW> when calling socke

Re: python list handling and Lisp list handling

2009-04-24 Thread MRAB
Mark Tarver wrote: This page says that Python lists are often flexible arrays http://www.brpreiss.com/books/opus7/html/page82.html but also says that their representation is implementation dependent. As far as I see this should mean that element access in Python should run in constant time. No

Re: Large data arrays?

2009-04-24 Thread Ole Streicher
Hi John John Machin writes: > On Apr 25, 1:14 am, Ole Streicher wrote: >> John Machin writes: >> >> From my access pattern, it would be probably better to combine 25 rows >> >> into one slice and have one matrix where every cell contains 25 rows. >> >> Are there any objections about that? >> >

Re: python list handling and Lisp list handling

2009-04-24 Thread Paul Rubin
Mark Tarver writes: > But are Python lists also indistinguishable from conventional > Lisplists for list processing. Forgot to add: you might look at http://norvig.com/python-lisp.html Mark Tarver writes: > But are Python lists also indistinguishable from conventional > Lisplists for list pr

Re: python list handling and Lisp list handling

2009-04-24 Thread Paul Rubin
Mark Tarver writes: > But are Python lists also indistinguishable from conventional > Lisplists for list processing. For example, can I modify a Python > list non-destructively? Are they equivalent to Lisp lists. Can CAR > and CDR in Lisp be thought of as Python lists are vectors that automatic

mod_python form upload: permission denied sometimes...

2009-04-24 Thread psaff...@googlemail.com
I have a mod_python application that takes a POST file upload from a form. It works fine from my machine, other machines in my office and my home machine. It does not work from my bosses machine in a different city - he gets "You don't have permission to access this on this server". In the logs, i

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Terry Reedy
Steven D'Aprano wrote: On Thu, 23 Apr 2009 21:51:42 -0400, Esmail wrote: set(a) == set(b)# test if a and b have the same elements # check that each list has the same number of each element # i.e. [1,2,1,2] == [1,1,2,2], but [1,2,2,2] != [1,1,1,2] for elem in set(a): a.count(elem) ==

Re: Help with code! Gamepad?

2009-04-24 Thread Mike Driscoll
On Apr 24, 10:11 am, DC16 wrote: > On Apr 23, 4:03 pm, Mike Driscoll wrote: > > > > > On Apr 23, 6:46 am, DC16 wrote: > > > > I am using pygame and OpenGL. > > > How do I make a gamepad able to move the camera to a side of a cube on > > > screen. > > > > Here is the code for keyboard use: > > >

Re: Raw command line arguments

2009-04-24 Thread Gabriel Genellina
En Fri, 24 Apr 2009 06:40:23 -0300, Enchanter escribió: How to pass the raw command line arguments to the python? That depends on the OS or the shell you're using. Such as: mypython.py txt -c "Test Only" {Help} The arguments I hope to get is: txt -c "Test Only" {He

Re: sorting two corresponding lists?

2009-04-24 Thread tiefeng wu
> > > Just being pedantic here :) > > > > [items[x] for x in [i for i in map(values.index, new_values)]] > > > > Is the same as > > > > [items[x] for x in map(values.index, new_values)] > > It's also the same as > >[items[x] for x in [values.index(i) for i in new_values]] > > Which reduces to >

Re: first, second, etc line of text file

2009-04-24 Thread Gabriel Genellina
En Thu, 23 Apr 2009 18:50:06 -0300, Scott David Daniels escribió: Gabriel Genellina wrote: En Wed, 25 Jul 2007 19:14:28 -0300, James Stroud escribió: [nice recipe to retrieve only certain lines of a file] I think your time machine needs an adjustment, it spits things almost two years la

Python servlet for Java applet ?

2009-04-24 Thread Linuxguy123
Hi guys. Is there a way to use a python application as the back end (ie rpc) for a Java based applet ? How does it work compared to a Java servlet with a Java applet ? Thanks -- http://mail.python.org/mailman/listinfo/python-list

confused with so many python package locations for imports

2009-04-24 Thread Krishnakant
hello all, I was doing my first complete python packaging for my software and I am totally confused. I see, /usr/local/lib/python-2.6/site-packages and also dist-packages. Then I also see a directory called pyshare, then again site-packages in usr/lib/python (I am not even remembering correct path

Re: best way to compare contents of 2 lists?

2009-04-24 Thread norseman
Esmail wrote: What is the best way to compare the *contents* of two different lists regardless of their respective order? The lists will have the same number of items, and be of the same type. E.g. a trivial example (my lists will be larger), a=[1, 2, 3] b=[2, 3, 1] should yield true if a==b

PyQt4 - widget signal trouble

2009-04-24 Thread Joacim Thomassen
Hello, I'm trying to get my first PyQt4 application to work as intended, but it seems I'm stuck and out of ideas for now. The program is a simple GUI showing an image. If the image on disk change my intension is that the displayed image in my application also change accordingly. What works: T

Re: Convert numpy.ndarray into "normal" array

2009-04-24 Thread Aahz
In article <75dgm1f16hqn...@mid.dfncis.de>, Johannes Bauer wrote: > >So now I want to copy the fits_pixels -> pb_pixels. Doing > >pb_pixels = fits_pixels > >works and is insanely fast, however the picture looks all screwed-up >(looks like a RGB picture of unititialized memory, huge chunks of 0s >

Help AIX 5.3 build on Python-3.1a2

2009-04-24 Thread pruebauno
OPT=-O2 LDFLAGS=-s ./configure --prefix=/ptst --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" --disable-ipv6 AR="ar -X64" --without-locale -- without-ctypes checking for --with-universal-archs... 32-bit checking MACHDEP... aix5 checking machine type as reported by uname -m... 00023AAA4C00 checking

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote: > AFAIK, atime contains new mail for at least 20 years. Doesn't apply to maildir though, does it? Updating atime adds a lot of filesystem overhead; that's why the relatime option was invented . But better still is not to bothe

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 10:39:39 -0700, norseman wrote: > Technically, == is reserved for identical, as in byte for byte same Really? Then how do you explain these? >>> u'abc' == 'abc' True >>> 1 == 1.0 True >>> 2L == 2 True >>> >>> import decimal >>> decimal.Decimal('42') == 42 True Here's one t

Re: python list handling and Lisp list handling

2009-04-24 Thread Mark Tarver
On 24 Apr, 17:19, Paul Rubin wrote: > Mark Tarver writes: > > But are Python lists also indistinguishable from conventional > > Lisplists for list processing.   > > Forgot to add: you might look athttp://norvig.com/python-lisp.html > > Mark Tarver writes: > > But ar

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread Grant Edwards
On 2009-04-24, MRAB wrote: >>> [snip] >>> The access time is the time it was last accessed, ie read or modified. >> >> Usually. >> >>> The modification time is the time it was last modified. >> >> Usually. >> >>> The access time can never be before the modification time because it >>> must be

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread Grant Edwards
On 2009-04-24, Lawrence D'Oliveiro wrote: > In message , Grant Edwards > wrote: > >> AFAIK, atime> when an mbox contains new mail for at least 20 years. > > Doesn't apply to maildir though, does it? Nope. With maildir, there's a completely separate directory where one puts new messages. > Upda

Re: repost: http web page fetch question

2009-04-24 Thread Emile van Sebille
grocery_stocker wrote: Given the following... [cdal...@localhost oakland]$ more basic.py How do I modify it so that it runs every hour on the hour. I'd probably use cron, but here's one way. Emile - import sched import time scheduler = sched.scheduler(time.time, time.sleep) def pri

Re: and [True,True] --> [True, True]?????

2009-04-24 Thread Martin v. Löwis
>> Of course dicts and sets are sequences. But there are also sequences >> on which len doesn't work. > > That was my intuition, too. But Python takes a different stance: It's a sequence if it can be indexed by numbers in range(len(seq)). Neither dicts nor sets can be indexed that way. Regards

Re: mailbox.mbox.add() sets access time as well as modification time

2009-04-24 Thread Grant Edwards
On 2009-04-24, Grant Edwards wrote: > Anybody writing to an mbox mailbox has to follow the rules if > they expect to interoperate with other mail applications. If > mailbox.mbox.add() doesn't preserve the atime when writing to > an mbox, then mailbox.mbox.add is broken. I should qualify that: s

Re: Large data arrays?

2009-04-24 Thread Scott David Daniels
Ole Streicher wrote: Hi John John Machin writes: On Apr 25, 1:14 am, Ole Streicher wrote: John Machin writes: From my access pattern, it would be probably better to combine 25 rows into one slice and have one matrix where every cell contains 25 rows. Are there any objections about that? C

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-24 Thread Scott David Daniels
Marco Mariani wrote: Scott David Daniels wrote: I am afraid it will make it too easy to define functions in other modules remotely, a tempting sharp stick to poke your eye out with. Imagine debugging a pile of code that includes a module with: import random def random.random():

Re: python list handling and Lisp list handling

2009-04-24 Thread Arnaud Delobelle
Mark Tarver writes: > Ah; so this > > def cons (x,y): > return [x] + y > > is not accurate? Depends what you mean by accurate! in lisp, if you do: (setq a '(1 2)) (setq b (cons 0 a)) (rplaca a 3) Then a is now (3 2) b is now (0 3 2) In Python, if you do: a = [1

pythoncom -- ImportError: DLL load failed

2009-04-24 Thread Richard Whidden
I've sniffed around for a solution to this problem but I can't find anything. The simple COM example in the "Programming on Win32" O'Reilly book works fine. However, as soon as I add 'import pgdb' to the object, chaos ensues promply. Here's what I did. Step 1, write this: foo.py -- # pri

Re: best way to compare contents of 2 lists?

2009-04-24 Thread norseman
Steven D'Aprano wrote: On Fri, 24 Apr 2009 10:39:39 -0700, norseman wrote: Technically, == is reserved for identical, as in byte for byte same Really? Then how do you explain these? u'abc' == 'abc' True 1 == 1.0 True 2L == 2 True import decimal decimal.Decimal('42') == 42 True Her

Re: [Python-Dev] PEP 383: Non-decodable Bytes in System Character Interfaces

2009-04-24 Thread Lino Mastrodomenico
2009/4/22 "Martin v. Löwis" : > To convert non-decodable bytes, a new error handler "python-escape" is > introduced, which decodes non-decodable bytes using into a private-use > character U+F01xx, which is believed to not conflict with private-use > characters that currently exist in Python codecs.

Python not importing mysqldb

2009-04-24 Thread 83nini
hi guys, i've been sweating the whole day trying to make python work with mysql but in vain! i'm doing the following: 1. visiting http://sourceforge.net/projects/mysql-python 2. dowloading mysql-python-test-1.2.3c1 3. extracting the files to C:\Python26\Lib\site-packages 4. writing "import MySQLdb

Re: Numpy Performance

2009-04-24 Thread Robert Kern
On 2009-04-24 08:05, timlash wrote: Essentially, I'm testing tens of thousands of scenarios on a relatively small number of test cases. Each scenario requires all elements of each test case to be scored, then summarized, then sorted and grouped with some top scores captured for reporting. It se

Re: Python not importing mysqldb

2009-04-24 Thread Emile van Sebille
83nini wrote: hi guys, i've been sweating the whole day trying to make python work with mysql but in vain! i'm doing the following: 1. visiting http://sourceforge.net/projects/mysql-python 2. dowloading mysql-python-test-1.2.3c1 3. extracting the files to C:\Python26\Lib\site-packages From tha

Re: pythoncom -- ImportError: DLL load failed - Update

2009-04-24 Thread Richard Whidden
By including the following DLLs on a Windows 2000 image I have running Python 2.5, my little sample app works... comerr32.dll krb5_32.dll libintl-8.dllpython26.dll gssapi32.dll libeay32.dll libpq.dllssleay32.dll k5sprt32.dll libiconv-2.dll python25.dll msvcm90.dl

  1   2   >