Re: Preventing execution of a method

2008-12-12 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : On Dec 11, 7:48 pm, Bruno Desthuilliers wrote: or to provide read-only access. I.e. right now I'm working on the graphical client which potentially could be rewritten entirely by the users. It is necessary and perfectly reasonable for the client module to access some

Re: [Python.NET] Where does the clr in IronPython look the dll

2008-12-12 Thread Craig Farrow
The dll needs to be on the Python path (sys.path). You can either add to the path with sys.path.append("c:\") or put your dll in a folder in the Python site-packages directory and add a .pth file (for Python.NET, but not IronPython -- it doesn't recognise the .pth files). Regards, Craig.

Removing None objects from a sequence

2008-12-12 Thread Filip Gruszczyński
Hi! I would like to iterate over a sequence nad ignore all None objects. The most obvious way is explicitly checking if element is not None, but it takes too much space. And I would like to get something faster. I can use [ sth for sth in self.__sth if not sth is None ], but I don't know if that's

Re: Removing None objects from a sequence

2008-12-12 Thread Erik Max Francis
Filip Gruszczyński wrote: I would like to iterate over a sequence nad ignore all None objects. The most obvious way is explicitly checking if element is not None, but it takes too much space. That doesn't make much sense; why would iterating over the sequence take more _space_? -- Erik Max

Re: Python is slow

2008-12-12 Thread Marco Mariani
Giampaolo Rodola' wrote: The real (and still unsolved) problem with PyPy is the installation which requires something like a dozen of third-party packages to be installed. Unfortunately it seems there are no plans yet for releasing any Windows/Linux/Mac installer in the near future. I'm not us

Re: Moving to subprocess from os.popen--pipe closes prematurely

2008-12-12 Thread Martin P. Hellwig
Kevin Walzer wrote: Hello, I'm trying to move from os.popen to using subprocess, and I'm having trouble with the pipe suddenly closing. My old code looked something like this: Hi Kevin, You could try something more like: >>> import subprocess >>> cmd = subprocess.Popen([executable_path,

Re: Removing None objects from a sequence

2008-12-12 Thread alex23
On Dec 12, 7:18 pm, "Filip Gruszczyński" wrote: > Hi! > > I would like to iterate over a sequence nad ignore all None objects. > The most obvious way is explicitly checking if element is not None, > but it takes too much space. And I would like to get something faster. > I can use > [ sth for sth

File names, character sets and Unicode

2008-12-12 Thread Michal Ludvig
Hi all, is there any way to determine what's the charset of filenames returned by os.walk()? The trouble is, if I pass argument to os.walk() I get the filenames as byte-strings. Possibly UTF-8 encoded Unicode, who knows. OTOH If I pass to os.walk() all the filenames I get in the loop are alrea

Re: File names, character sets and Unicode

2008-12-12 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Dec 2008 23:32:27 +1300, Michal Ludvig wrote: > is there any way to determine what's the charset of filenames returned > by os.walk()? No. Especially under *nix file systems file names are just a string of bytes, not characters. It is possible to have file names in different encond

Re: Removing None objects from a sequence

2008-12-12 Thread Filip Gruszczyński
I don't mean memory, but space in code ;-) I'll try this generator :) -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list

Building extensions for python 2.6 adm64 with the SDK compiler

2008-12-12 Thread David Cournapeau
Hi, I have some trouble building python 2.6 extensions with the SDK compiler on windows 64 bits. The problem is that after link step, mt.exe is called to embed the MANIFEST into the executable, but the manifest is not created, so the build fails with a "general error c1010070:Failed to load and pa

Re: Removing None objects from a sequence

2008-12-12 Thread Tim Rowe
2008/12/12 Filip Gruszczyński : > I don't mean memory, but space in code ;-) Trying to save printer paper for your listings, then? -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

(Very Newbie) Problems defining a variable

2008-12-12 Thread febaen
#!/usr/bin/python #Py3k, UTF-8 bank = int(input("How much money is in your account?\n>>")) target = int(input("How much money would you like to earn each year? \n>>")) interest = 0 i = 0 while interest < target: #determine the interest rate to use if bank >= : rate =

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread feba
On Dec 12, 5:56 am, Bruno Desthuilliers wrote: > feb...@gmail.com a écrit : > > > > > #!/usr/bin/python > > #Py3k, UTF-8 > > > bank = int(input("How much money is in your account?\n>>")) > > target = int(input("How much money would you like to earn each year? > > \n>>")) > > > interest = 0 > > i =

How to write binary data to file and socket

2008-12-12 Thread Lee Soin
Hello, all! I'm new to python. In Linux C programming, writing data to file and socket share the same system call "write". But it seems that only data of string type can be used for "write" and "send". So how to write binary data to file and socket? -- Sun Li Department of Physics Nanjing Univers

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Steven D'Aprano
On Fri, 12 Dec 2008 04:05:21 -0800, feba wrote: > that's it, thanks! was confused with it being basically in a column of > all >= *. > > I replaced it with > > if bank <= 0: > print("You're in the red!") > quit() > elif bank >= 1 and bank <= : >

Re: Removing None objects from a sequence

2008-12-12 Thread Steven D'Aprano
On Fri, 12 Dec 2008 10:18:35 +0100, Filip Gruszczyński wrote: > Hi! > > I would like to iterate over a sequence nad ignore all None objects. The > most obvious way is explicitly checking if element is not None, but it > takes too much space. Too much space??? seq = [x for x in seq if x is not N

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Chris Rebert
On Fri, Dec 12, 2008 at 3:42 AM, wrote: > #!/usr/bin/python > #Py3k, UTF-8 > > > #determine the interest rate to use >if bank >= : >rate = 0.006 >elif bank >= 1 and bank <= 24999: >rate = 0.0085 >elif bank >= 25000 and bank <= 4

IF YOU WANT TO LIVE LONGER, YOU SHOULD CHECK THIS!!

2008-12-12 Thread andrew
http://www.associatedcontent.com/article/995306/parameningeal_infection_brain_abscess.html?cat=70 -- http://mail.python.org/mailman/listinfo/python-list

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread bearophileHUGS
feba: >         if bank <= 0: >                 print("You're in the red!") >                 quit() >         elif bank >= 1 and bank <= : >                 rate = 0.0060 >         elif bank >= 1 and bank <= 24999: >                 rate = 0.0085 >         elif bank >= 25000 and bank <= 49

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Bruno Desthuilliers
feb...@gmail.com a écrit : #!/usr/bin/python #Py3k, UTF-8 bank = int(input("How much money is in your account?\n>>")) target = int(input("How much money would you like to earn each year? \n>>")) interest = 0 i = 0 while interest < target: #determine the interest rate to use if bank >=

Re: var or inout parm?

2008-12-12 Thread Chris Rebert
On Fri, Dec 12, 2008 at 4:34 AM, sturlamolden wrote: > You cannot modify parameters by rebinding. x = x + 1 is a rebinding. x > += 1 is not. Python begs to differ, as those two statements are both semantically identical in this case: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (App

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-12 Thread David Cournapeau
On Thu, Dec 11, 2008 at 10:30 PM, Nick Craig-Wood wrote: > David Cournapeau wrote: >> On Wed, Dec 10, 2008 at 12:04 PM, Chris Rebert wrote: >> > On Tue, Dec 9, 2008 at 6:49 PM, wrote: >> >> On Ubuntu, I accidentally manually installed setuptools >> >> http://pypi.python.org/pypi/setuptools/0.

Imaging library in jython

2008-12-12 Thread whiter4bbit
Hi, Is there any ways to use python Imaging library in jython? -- http://mail.python.org/mailman/listinfo/python-list

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 7, 9:54 am, m...@pixar.com wrote: > How can I make a "var" parm, where the called function can modify > the value of the parameter in the caller? > > def f(x): > x = x + 1 Short ansver: You can modify function parameters if they are mutable. If they are immutable any attempt to modify

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Bruno Desthuilliers
feba a écrit : On Dec 12, 5:56 am, Bruno Desthuilliers wrote: (snip) I guess you wanted your first test to be: if bank <= : ... (snip) that's it, thanks! was confused with it being basically in a column of all >= *. I replaced it with if bank <= 0: p

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 1:44 pm, "Chris Rebert" wrote: > Python begs to differ, as those two statements are both semantically > identical in this case: That is because integers are immutable. When x += 1 is done on an int, there will be a rebinding. But try the same on say, a numpy array, and the result will

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread feba
Actually, I have gedit set to four spaces per tab. I have no reason why it's showing up that large on copy/paste, but the file itself is fine. Thanks for the advice Chris, Stephen, I can definitely see how those are both far better ways of doing it. I have it as: #!/usr/bin/python #Py3k, UTF-8 b

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 1:56 pm, sturlamolden wrote: > That is because integers are immutable. When x += 1 is done on an int, > there will be a rebinding. But try the same on say, a numpy array, and > the result will be different: And a consequence of this is, if you have a function like def foobar(x):

Re: Removing None objects from a sequence

2008-12-12 Thread Filip Gruszczyński
I am not doing it, because I need it. I can as well use "if not elem is None", but I just wanted to know, if there is some better way of doing this. I like to know :-) And I can't understand why you are becoming so aggressive because of this. Just because I asked for that, doesn't mean, that I wil

Re: File names, character sets and Unicode

2008-12-12 Thread Steve Holden
Michal Ludvig wrote: > Hi all, > > is there any way to determine what's the charset of filenames returned > by os.walk()? > > The trouble is, if I pass argument to os.walk() I get the > filenames as byte-strings. Possibly UTF-8 encoded Unicode, who knows. > > OTOH If I pass to os.walk() all th

Re: How to write binary data to file and socket

2008-12-12 Thread Steve Holden
Lee Soin wrote: > Hello, all! > I'm new to python. In Linux C programming, writing data to file and > socket share the same system call "write". But it seems that only data > of string type can be used for "write" and "send". So how to write > binary data to file and socket? > Assuming you are usi

Re: Python is slow

2008-12-12 Thread sturlamolden
On Dec 11, 4:25 am, Carl Banks wrote: > cm_gui is TROLL. And I am not compring it with bots like Aaron > Castironpi Brody. cm_gui is even troller than Xah Lee! Sure he is a troll, but he also have a point. Python is slower than it needs to be. Creating a fast implementation of a dynamic langu

Re: Removing None objects from a sequence

2008-12-12 Thread Steve Holden
Filip Gruszczyński wrote: > Hi! > > I would like to iterate over a sequence nad ignore all None objects. > The most obvious way is explicitly checking if element is not None, > but it takes too much space. And I would like to get something faster. > I can use > [ sth for sth in self.__sth if not s

Re: var or inout parm?

2008-12-12 Thread Hrvoje Niksic
sturlamolden writes: > On Dec 12, 1:44 pm, "Chris Rebert" wrote: > >> Python begs to differ, as those two statements are both semantically >> identical in this case: > > That is because integers are immutable. When x += 1 is done on an int, > there will be a rebinding. But try the same on say, a

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 2:34 pm, Hrvoje Niksic wrote: > >>> import numpy > >>> t = (numpy.zeros(10),) > >>> t > > (array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),)>>> t[0] += 1 > > Traceback (most recent call last): > File "", line 1, in > TypeError: 'tuple' object does not support item assignme

Re: Python is slow

2008-12-12 Thread sturlamolden
On Dec 12, 2:29 pm, sturlamolden wrote: > Creating a fast implementation of a dynamic language is almost rocket > science. But it has been done. There is Stronghold, I meant of course Strongtalk... -- http://mail.python.org/mailman/listinfo/python-list

Interface & Implementation

2008-12-12 Thread J Ramesh Kumar
Hi, I am new to python. I require some help on implementing interface and its implementation. I could not find any sample code in the web. Can you please send me some sample code which is similar to the below java code ? Thanks in advance for your help. public interface MyIfc {

Re: var or inout parm?

2008-12-12 Thread Steve Holden
sturlamolden wrote: > On Dec 12, 1:56 pm, sturlamolden wrote: > >> That is because integers are immutable. When x += 1 is done on an int, >> there will be a rebinding. But try the same on say, a numpy array, and >> the result will be different: > > > And a consequence of this is, if you have a

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Dec 2008 04:58:36 -0800, feba wrote: > Actually, I have gedit set to four spaces per tab. I have no reason why > it's showing up that large on copy/paste, but the file itself is fine. The file contains one tab character per indentation level and it depends on the software you use to l

Re: Python is slow

2008-12-12 Thread Luis M . González
On Dec 12, 10:43 am, sturlamolden wrote: > On Dec 12, 2:29 pm, sturlamolden wrote: > > > Creating a fast implementation of a dynamic language is almost rocket > > science. But it has been done. There is Stronghold, > > I meant of course Strongtalk... Blah, blah, blah... Why don't you guys google

Re: var or inout parm?

2008-12-12 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Dec 2008 05:39:35 -0800, sturlamolden wrote: > On Dec 12, 2:34 pm, Hrvoje Niksic wrote: > >> >>> import numpy >> >>> t = (numpy.zeros(10),) >> >>> t >> >> (array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),)>>> t[0] += >> 1 >> >> Traceback (most recent call last): >> File ""

Re: var or inout parm?

2008-12-12 Thread Hrvoje Niksic
sturlamolden writes: > Actually I would consider this to be a bug. The tuple is immutable, > but no mutation of the tuple is ever attempted. That's a common misconception about how += works in Python. It simply *always* rebinds. Once you grok that, everything else follows. -- http://mail.pytho

Re: Python is slow

2008-12-12 Thread sturlamolden
On Dec 12, 3:04 pm, Luis M. González wrote: > Why don't you guys google a little bit to know what's being done to > address python's "slowness"?? Nothing is being done, and woth Py3k it got even worse. > It has been mentioned in this thread the pypy project (isn't it enough > for you??) > Othe

Re: Python is slow

2008-12-12 Thread David Cournapeau
On Fri, Dec 12, 2008 at 11:04 PM, Luis M. González wrote: > It has been mentioned in this thread the pypy project (isn't it enough > for you??) Since pypy can't be used today for most production use (most python packages can't work on it), I don't see how it could be enough for anyone interested

Reading online zip files - zipfile and zlib, wbits

2008-12-12 Thread Brendan
I am fooling around with accessing contents of zip files online. I download the tail end of the zip and use zipfile to get the zip central directory structure. I download the section of the zip file I need, directly read the zip file headers and use that information with zlib to uncompress the data

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 3:08 pm, Marc 'BlackJack' Rintsch wrote: > No bug because a mutation *is* attempted. ``a += x`` calls `a.__iadd__` > which *always* returns the result which is *always* rebound to the name > `a`. Even with mutable objects where `__iadd__()` simply returns > `self`! No, a mutation is

Re: Python is slow

2008-12-12 Thread sturlamolden
On Dec 12, 3:27 pm, "David Cournapeau" wrote: > I want faster function > calls to use with numpy: do you know of any solution ? Pypy certainly > isn't, at least today. An interesting thing for numpy would be to use CUDA. If we can move floating point ops to the GPU, a common desktop computer cou

Re: Python is slow

2008-12-12 Thread Stefan Behnel
David Cournapeau wrote: > I want faster function > calls to use with numpy: do you know of any solution ? http://cython.org/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading online zip files - zipfile and zlib, wbits

2008-12-12 Thread Brendan
On Dec 12, 10:25 am, Brendan wrote: > I am fooling around with accessing contents of zip files online. I > download the tail end of the zip and use zipfile to get the zip > central directory structure. I download the section of the zip file I > need, directly read the zip file headers and use that

Re: var or inout parm?

2008-12-12 Thread Steve Holden
sturlamolden wrote: > On Dec 12, 3:08 pm, Marc 'BlackJack' Rintsch wrote: > >> No bug because a mutation *is* attempted. ``a += x`` calls `a.__iadd__` >> which *always* returns the result which is *always* rebound to the name >> `a`. Even with mutable objects where `__iadd__()` simply returns >

Re: Python is slow

2008-12-12 Thread sturlamolden
On Dec 12, 3:43 pm, Stefan Behnel wrote: > http://cython.org/ How is the numpy support in Cython going? It was supposed to know about ndarrays natively. I.e. not treat them as Python objects, but rather as known C structs. That way an operation like arr[n] would not result in a callback to Pytho

Re: var or inout parm?

2008-12-12 Thread Hrvoje Niksic
sturlamolden writes: > On Dec 12, 3:08 pm, Marc 'BlackJack' Rintsch wrote: > >> No bug because a mutation *is* attempted. ``a += x`` calls `a.__iadd__` >> which *always* returns the result which is *always* rebound to the name >> `a`. Even with mutable objects where `__iadd__()` simply returns

Re: Python is slow

2008-12-12 Thread bearophileHUGS
sturlamolden: > On a recent benchmark Java 6 -server beats C compiled by GCC 4.2.3 And > most of that magic comes from an implementation of a dynamically typed > language (Smalltalk). [...] > http://shootout.alioth.debian.org/u32q/benchmark.php?test=all〈=all That is indeed a nice result, JavaVM ha

Re: Python is slow

2008-12-12 Thread MRAB
sturlamolden wrote: On Dec 12, 3:04 pm, Luis M. González wrote: Why don't you guys google a little bit to know what's being done to address python's "slowness"?? Nothing is being done, and woth Py3k it got even worse. It has been mentioned in this thread the pypy project (isn't it enough f

Re: Removing None objects from a sequence

2008-12-12 Thread pruebauno
On Dec 12, 8:08 am, "Filip Gruszczyński" wrote: > I am not doing it, because I need it. I can as well use "if not elem > is None", but I just wanted to know, if there is some better way of > doing this. I like to know :-) > > And I can't understand why you are becoming so aggressive because of > t

Re: Python is slow

2008-12-12 Thread Stefan Behnel
sturlamolden wrote: > How is the numpy support in Cython going? It was supposed to know > about ndarrays natively. It does. > I.e. not treat them as Python objects, but > rather as known C structs. That way an operation like arr[n] would not > result in a callback to Python, but translate direct

Re: Interface & Implementation

2008-12-12 Thread rdmurray
On Fri, 12 Dec 2008 at 16:07, J Ramesh Kumar wrote: I am new to python. I require some help on implementing interface and its implementation. I could not find any sample code in the web. Can you please send me some sample code which is similar to the below java code ? Thanks in advance for your h

Re: Removing None objects from a sequence

2008-12-12 Thread Vito De Tullio
Filip Gruszczyński wrote: > I checked itertools, but the only thing that > seemed ok, was ifilter - this requires seperate function though, so > doesn't seem too short. is this too much long? >>> from itertools import ifilter >>> for element in ifilter(lambda x: x is not None, [0,1,2,None,3,Non

Re: newbie question: if var1 == var2:

2008-12-12 Thread J. Cliff Dyer
On Thu, 2008-12-11 at 13:44 -0600, Kirk Strauser wrote: > At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: > > > >>> ' ab c \r\n'.rstrip('\r\n') > > ' ab c ' > > >>> ' ab c \n'.rstrip('\r\n') > > ' ab c ' > > >>> ' ab c '.rstrip('\r\n') > > ' ab c ' > >

Re: concept of creating structures in python

2008-12-12 Thread Joe Strout
On Dec 11, 2008, at 10:52 PM, navneet khanna wrote: I want to create a structure within a structure i.e. nested structures in python. I tried with everything but its not working. my code is like this: class L(Structure): def __init__(self,Name='ND',Addr=0,ds_obj = D()): Change the defa

Re: Reading online zip files - zipfile and zlib, wbits

2008-12-12 Thread Brendan
On Dec 12, 10:46 am, Brendan wrote: > On Dec 12, 10:25 am, Brendan wrote: > > > I am fooling around with accessing contents of zip files online. I > > download the tail end of the zip and use zipfile to get the zip > > central directory structure. I download the section of the zip file I > > need

Re: Mathematica 7 compares to other languages

2008-12-12 Thread Tom McGlynn
On Dec 11, 6:46 am, "William James" wrote: > John W Kennedy wrote: > > Xah Lee wrote: > > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > > Java, you'll have 50 or hundreds lines. > > > Java: > > > static float[] normal(final float[] x) { > >float sum = 0.0f; > >for (

Re: Removing None objects from a sequence

2008-12-12 Thread Marco Mariani
Filip Gruszczyński wrote: I am not doing it, because I need it. I can as well use "if not elem is None", I suggest "if elem is not None", which is not quite the same. If you slip such an error in a post, I suggest to practice some time writing correct code before having one-liner contests w

Re: Python is slow

2008-12-12 Thread Christian Heimes
sturlamolden schrieb: > On Dec 12, 3:04 pm, Luis M. González wrote: > >> Why don't you guys google a little bit to know what's being done to >> address python's "slowness"?? > > Nothing is being done, and woth Py3k it got even worse. Indeed, it *is* slower for now. As I already said in another

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 3:54 pm, Steve Holden wrote: > sturlamolden wrote: > > On Dec 12, 3:08 pm, Marc 'BlackJack' Rintsch wrote: > > >> No bug because a mutation *is* attempted. ``a += x`` calls `a.__iadd__` > >> which *always* returns the result which is *always* rebound to the name > >> `a`. Even with m

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 4:55 pm, sturlamolden wrote: > def __setitem__(self, index, value): >if _buf[index] is not value: # given that _buf is the tuple's > internal buffer > raise TypeError, 'tuple' object does not support item > assignment blæh, that should be self._buf[index] -- http://mail.

Re: concept of creating structures in python

2008-12-12 Thread Steve Holden
Joe Strout wrote: > On Dec 11, 2008, at 10:52 PM, navneet khanna wrote: > >> I want to create a structure within a structure i.e. nested structures >> in python. >> I tried with everything but its not working. >> my code is like this: >> >> class L(Structure): >> >> def __init__(self,Name='ND'

Re: newbie question: if var1 == var2:

2008-12-12 Thread Kirk Strauser
At 2008-12-12T15:35:11Z, "J. Cliff Dyer" writes: > Python has a version equally good: > > def chomp(s): > return s.rstrip('\r\n') > > You'll hardly miss Perl at all. ;) I haven't missed Perl in years! I just wish there was a basestring.stripeol method because I seem to end up writing the in

Re: concept of creating structures in python

2008-12-12 Thread Joe Strout
On Dec 12, 2008, at 9:00 AM, Steve Holden wrote: Change the default value of ds_obj here to None. Otherwise, you will certainly confuse yourself (there would be just one default object shared among all instances). Joe missed a piece out here. If you change the signature of your D.__init__() t

Re: var or inout parm?

2008-12-12 Thread Steve Holden
sturlamolden wrote: > On Dec 12, 3:54 pm, Steve Holden wrote: [...] >> The interpreter "should not" have a GIL. > >> The tuple "should" check that >> it is actually being mutated. How? > > In Python it would be something similar to: > > def __setitem__(self, index, value): >if _buf[index] i

Re: Removing None objects from a sequence

2008-12-12 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Dec 2008 16:51:15 +0100, Marco Mariani wrote: > Filip Gruszczyński wrote: > > >> I am not doing it, because I need it. I can as well use "if not elem is >> None", > > I suggest "if elem is not None", which is not quite the same. In which way is it not the same? Has the same behavio

Re: Removing None objects from a sequence

2008-12-12 Thread Kirk Strauser
At 2008-12-12T15:51:15Z, Marco Mariani writes: > Filip Gruszczyński wrote: > >> I am not doing it, because I need it. I can as well use "if not elem >> is None", > I suggest "if elem is not None", which is not quite the same. So what's the difference exactly? "foo is not None" is actually surp

Re: Reading online zip files - zipfile and zlib, wbits

2008-12-12 Thread Brendan
On Dec 12, 11:36 am, Brendan wrote: > On Dec 12, 10:46 am, Brendan wrote: > > > > > > > On Dec 12, 10:25 am, Brendan wrote: > > > > I am fooling around with accessing contents of zip files online. I > > > download the tail end of the zip and use zipfile to get the zip > > > central directory str

Re: Removing None objects from a sequence

2008-12-12 Thread Marco Mariani
Kirk Strauser wrote: So what's the difference exactly? "foo is not None" is actually surprising to me, since "not None" is True. "0 is True" is False, but "0 is not None" is True. Why is that? Cause I was tired of course, and got the not precedente not right!! Argh -- http://mail.python.org

Re: var or inout parm?

2008-12-12 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Dec 2008 07:56:58 -0800, sturlamolden wrote: > On Dec 12, 4:55 pm, sturlamolden wrote: > >> def __setitem__(self, index, value): >>if _buf[index] is not value: # given that _buf is the tuple's >> internal buffer >> raise TypeError, 'tuple' object does not support item >> ass

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-12 Thread Nick Craig-Wood
David Cournapeau wrote: > On Thu, Dec 11, 2008 at 10:30 PM, Nick Craig-Wood > wrote: > > David Cournapeau wrote: > >> On Wed, Dec 10, 2008 at 12:04 PM, Chris Rebert wrote: > >> > On Tue, Dec 9, 2008 at 6:49 PM, wrote: > >> >> On Ubuntu, I accidentally manually installed setuptools > >> >>

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 5:13 pm, Steve Holden wrote: > > It should be the tuple's __setitem__ that was invoked here, not > > __iadd__, or the parser is faulty. > > OK, so now you are proposing to alter the parser, and possibly the > implementation of the INPLACE_ADD opcode in eval.c, so can you give us > the

Re: Removing None objects from a sequence

2008-12-12 Thread MRAB
Kirk Strauser wrote: At 2008-12-12T15:51:15Z, Marco Mariani writes: Filip Gruszczyński wrote: I am not doing it, because I need it. I can as well use "if not elem is None", I suggest "if elem is not None", which is not quite the same. So what's the difference exactly? "foo is not None"

Re: newbie question: if var1 == var2:

2008-12-12 Thread MRAB
Kirk Strauser wrote: At 2008-12-12T15:35:11Z, "J. Cliff Dyer" writes: Python has a version equally good: def chomp(s): return s.rstrip('\r\n') You'll hardly miss Perl at all. ;) I haven't missed Perl in years! I just wish there was a basestring.stripeol method because I seem to end up

Re: Removing None objects from a sequence

2008-12-12 Thread Steve Holden
Kirk Strauser wrote: > At 2008-12-12T15:51:15Z, Marco Mariani writes: > >> Filip Gruszczyński wrote: >> >>> I am not doing it, because I need it. I can as well use "if not elem >>> is None", > >> I suggest "if elem is not None", which is not quite the same. > > So what's the difference exactly?

Re: var or inout parm?

2008-12-12 Thread Steve Holden
sturlamolden wrote: > On Dec 12, 5:13 pm, Steve Holden wrote: > >>> It should be the tuple's __setitem__ that was invoked here, not >>> __iadd__, or the parser is faulty. >> OK, so now you are proposing to alter the parser, and possibly the >> implementation of the INPLACE_ADD opcode in eval.c, s

Re: var or inout parm?

2008-12-12 Thread sturlamolden
On Dec 12, 5:13 pm, Steve Holden wrote: > OK, so now you are proposing to alter the parser, and possibly the > implementation of the INPLACE_ADD opcode in eval.c, so can you give us > the patch for those, please? That is not where the problem resides. -- http://mail.python.org/mailman/listinfo/

Re: concept of creating structures in python

2008-12-12 Thread Steve Holden
Joe Strout wrote: > On Dec 12, 2008, at 9:00 AM, Steve Holden wrote: > >>> Change the default value of ds_obj here to None. Otherwise, you will >>> certainly confuse yourself (there would be just one default object >>> shared among all instances). >>> >> Joe missed a piece out here. If you change

Python extension: callbacks blocked when holding button down

2008-12-12 Thread alan . chambers
I'm developing a Python extension. It's a wrapper for some firmware, and simulates the target hardware environment. I'm using wxPython. I pass a function to the extension so it can let Python know about certain events. The code is currently single threaded. My problem is that the callback seems to

Re: Mathematica 7 compares to other languages

2008-12-12 Thread George Neuner
On Wed, 10 Dec 2008 21:37:34 + (UTC), Kaz Kylheku wrote: >Now try writing a device driver for your wireless LAN adapter in Mathematica. Notice how Xah chose not to respond to this. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Bidirectional Networking

2008-12-12 Thread Emanuele D'Arrigo
Thank you both for the suggestions! Eventually I tried with threading as illustrated in the code below. And it works pretty well! The only problem I'm having with it is that as the server is a daemon the program should end when the client thread cease to be alive. But it doesn't seem to work that w

Re: Python is slow

2008-12-12 Thread Luis M . González
On Dec 12, 11:17 am, sturlamolden wrote: > On Dec 12, 3:04 pm, Luis M. González wrote: > > > Why don't you guys google a little bit to know what's being done to > > address python's "slowness"?? > > Nothing is being done, and woth Py3k it got even worse. > > > It has been mentioned in this thread

Re: Mathematica 7 compares to other languages

2008-12-12 Thread George Neuner
On Thu, 11 Dec 2008 10:41:59 -0800 (PST), Xah Lee wrote: >On Dec 10, 2:47 pm, John W Kennedy wrote: >> Xah Lee wrote: >> > In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java, >> > you'll have 50 or hundreds lines. >> >> C: >> >> #include >> #include >> >> void normal(int dim,

Re: Python is slow

2008-12-12 Thread Andreas Kostyrka
On Fri, Dec 12, 2008 at 06:17:43AM -0800, sturlamolden wrote: > None of those projects addresses inefficacies in the CPython > interpreter, except for psyco - which died of an overdose PyPy. Bullshit. All that discussion about performance forgets that performance is a function of the whole system

newbie question...

2008-12-12 Thread trfilmographer
Hi! Im new at python and I just want to know if (and how) it is possible to send parameters to a program. what I mean is that when we start python I can call a file that should be run like this: python myfile.py can I send additional parameters along with it? like::: python myfile.py myVar1 myVa

Re: newbie question...

2008-12-12 Thread Tim Chase
Im new at python and I just want to know if (and how) it is possible to send parameters to a program. what I mean is that when we start python I can call a file that should be run like this: python myfile.py can I send additional parameters along with it? like::: python myfile.py myVar1 myVar2

Re: newbie question...

2008-12-12 Thread r
yes, but your script will need to know hoe to handle this.the following will open a file who's name was passed to the script if len(sys.argv) > 1: try: open_file(fname=sys.argv[1]) except: pass -- http://mail.python.org/mailman/listinfo/python-list

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Benjamin Kaplan
On Fri, Dec 12, 2008 at 12:50 PM, Dennis Lee Bieber wrote: > On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the > following in comp.lang.python: > > > #!/usr/bin/python > > #Py3k, UTF-8 > > > > bank = int(input("How much money is in your account?\n>>")) > > target = int(input

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Tim Rowe
Since we all seem to be having a go, here's my take. By pulling the rates and thresholds into a dictionary I feel I'm getting a step closer to the real world, where these would presumably be pulled in from a database and the number of interest bands might vary. But is there a tidier way to get 'thr

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread MRAB
Tim Rowe wrote: Since we all seem to be having a go, here's my take. By pulling the rates and thresholds into a dictionary I feel I'm getting a step closer to the real world, where these would presumably be pulled in from a database and the number of interest bands might vary. But is there a tidi

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Kirk Strauser
At 2008-12-12T18:12:39Z, "Tim Rowe" writes: > Is there a tidy way of making rates and thresholds local to get_rate, > without recalculating each time? I suppose going object oriented is > the proper way. > > #Py3k,UTF-8 > > rates = {0: 0.006, 1: 0.0085, 25000: 0.0124, 5: 0.0149, 10:

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread John Machin
On Dec 13, 4:50 am, Dennis Lee Bieber wrote: > On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the > following in comp.lang.python: > > > #!/usr/bin/python > > #Py3k, UTF-8 > > > bank = int(input("How much money is in your account?\n>>")) > > target = int(input("How much money

Re: newbie question...

2008-12-12 Thread trfilmographer
On Dec 12, 12:59 pm, r wrote: > yes, but your script will need to know hoe to handle this.the > following will open a file who's name was passed to the script > > if len(sys.argv) > 1: >     try: >         open_file(fname=sys.argv[1]) >     except: >         pass ah, ok. now what if I want the

Re: Python extension: callbacks blocked when holding button down

2008-12-12 Thread skip
alan> I'm developing a Python extension. It's a wrapper for some alan> firmware, and simulates the target hardware environment. I'm using alan> wxPython. I pass a function to the extension so it can let Python alan> know about certain events. The code is currently single threaded.

  1   2   >