Re: Need help calling a proprietary C DLL from Python

2008-03-21 Thread Craig
On Mar 21, 4:04 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 20 Mar 2008 16:50:18 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > I received a direct email from someone, and I came up with the > > following after implementing his advice:

Re: How can I make a function equal to 0?

2008-03-21 Thread John Machin
On Mar 22, 3:32 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 21 mar, 19:25, John Machin <[EMAIL PROTECTED]> wrote: > > > > > On Mar 22, 8:51 am, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > > > If you drop this condition then you could fill the array with zeroes > > > as before, replac

Re: How can I make a function equal to 0?

2008-03-21 Thread Gabriel Genellina
On 21 mar, 19:25, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 22, 8:51 am, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > > If you drop this condition then you could fill the array with zeroes > > as before, replace only the interesting ones with actual functions, > > and write: > > > for ite

Re: Improving datetime

2008-03-21 Thread John Machin
On Mar 22, 4:36 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > Colin J. Williams schrieb: > > > You might consider adding the Julian date > > (http://en.wikipedia.org/wiki/Julian_date). > > > I had a crack at this a while ago but didn't seem to get quire the right > > result, using the ACM algor

Re: Improving datetime

2008-03-21 Thread Nicholas F. Fabry
On Mar 21, 2008, at 13:36, Christian Heimes wrote: > Colin J. Williams schrieb: >> You might consider adding the Julian date >> (http://en.wikipedia.org/wiki/Julian_date). >> >> I had a crack at this a while ago but didn't seem to get quire the >> right >> result, using the ACM algorithm. I se

Re: zope and python 2.5.1

2008-03-21 Thread hberig
On Mar 20, 11:45 pm, Nikita the Spider <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > > hberig <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm sorry if this is an off-topic message, but I didn't found other > > group. > > I've read some articles about Zope, and since I like very much

Re: forkpty not working?

2008-03-21 Thread est
On Mar 21, 2:58 am, Dan Stromberg <[EMAIL PROTECTED]> wrote: > If you google a bit, I believe you'll find one or more python modules for > working with ssh. > > Also, if you want to roll your own, the easiest way to get around the > password requirement is to use ssh passwordless authentication usi

Re: How can I make a function equal to 0?

2008-03-21 Thread Martin Manns
On Fri, 21 Mar 2008 14:51:49 -0700 (PDT) Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > If I fill the array with 0 instead of the functions that > > return "" this works really fast. > > > > However, I would like to be able call the content of each > > cell in the array as a function. > > If yo

Re: Subprocess and /usr/bin/dialog

2008-03-21 Thread Grant Edwards
On 2008-03-21, harrelson <[EMAIL PROTECTED]> wrote: > I am trying to get the below code to work and can't quite make things > happen. This is with Python 2.5.1. Dialog is doing something odd... > I have tinkered with different combinations and I can't get the dialog > to show properly-- it does s

Re: List question

2008-03-21 Thread bearophileHUGS
Ricky Zhou: > Look at the this line: > if 'one' and 'two' in f: Very cute, it's the first time I see a bug like this. I think it's not a common enough pattern to justify a language change, but a bit smarter computer language may be able to do that too ;-) (it's not easy to tell the two meaning

Re: Prototype OO

2008-03-21 Thread John Machin
On Mar 21, 11:48 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [1] Just one example:http://docs.mootools.net/Class/Class.js Mootools being something a coworker might use? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make a function equal to 0?

2008-03-21 Thread John Machin
On Mar 22, 8:51 am, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > If you drop this condition then you could fill the array with zeroes > as before, replace only the interesting ones with actual functions, > and write: > > for item in myarray[nonzero(myarray)]: > print item() if callable(item)

Subprocess and /usr/bin/dialog

2008-03-21 Thread harrelson
I am trying to get the below code to work and can't quite make things happen. This is with Python 2.5.1. Dialog is doing something odd... I have tinkered with different combinations and I can't get the dialog to show properly-- it does show properly directly in the shell. Any hints? import subp

Re: List question

2008-03-21 Thread Paul Rubin
[EMAIL PROTECTED] writes: > if 'one' and 'two' in f: > alist.append(f) Use: if 'one' in f and 'two' in f: ... -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make a function equal to 0?

2008-03-21 Thread Gabriel Genellina
On 21 mar, 17:43, Martin Manns <[EMAIL PROTECTED]> wrote: > Basically I have a lot of functions inside a numpy array, > of which most return "" and actually are derived as follows: > > from numpy import * > > grid_size = 100 > > class F(object): > def __cmp__(self, other): return 0 > d

Re: List question

2008-03-21 Thread Ricky Zhou
On 2008-03-21 05:16:41 PM, [EMAIL PROTECTED] wrote: > alist = [] > blist = [ 'one','two','one and two','one and four','five','one two'] > for f in blist: > if 'one' and 'two' in f: > alist.append(f) > > for i in alist: > print i > > two > one and two > one two > > >

Re: How can I make a function equal to 0?

2008-03-21 Thread Ben Finney
Martin Manns <[EMAIL PROTECTED]> writes: > I do not want the function to return 0 but to equal 0. Then it seems you don't want a function, but something else. Functions are functions, not integers. What problem are you trying to solve, and why do you think this behaviour will help? -- \

List question

2008-03-21 Thread From
Hello, I am learning python and dont quuite understand why is this happening could someone explain? alist = [] blist = [ 'one','two','one and two','one and four','five','one two'] for f in blist: if 'one' and 'two' in f: alist.append(f) for i in alist: print i tw

Re: os.path.getsize() on Windows

2008-03-21 Thread Martin v. Löwis
>> Why do you say that? It most definitely returns what the size currently >> is, not what it will be in the future (how could it know, anyway). > > I've seen this before, when copying a file in Windows. Windows reports > the size the file will be after the copy is complete (it knows, after > al

Re: os.path.getsize() on Windows

2008-03-21 Thread Paul M¢Nett
Martin v. Löwis wrote: >> def isGrowing(f, timeout): >> ssize = os.path.getsize(f) >> time.sleep(timeout) >> esize =os.path.getsize(f) >> return esize != ssize >> >> On windows, this returns the size of the file as it _will be_, not the >> size that it currently is.

Re: eval and unicode

2008-03-21 Thread Martin v. Löwis
> eval() somehow decoded the passed expression. No question. It did not > use 'ascii', nor 'latin2' but something else. Why is that? Why there is > a particular encoding hard coded into eval? Which is that encoding? (I > could not decide which one, since '\xdb' will be the same in latin1, > lat

Re: eval and unicode

2008-03-21 Thread Martin v. Löwis
> Well at least this is what I think. If I'm not right then please explain > why. I think your confusion comes from the use of the interactive mode. PEP 263 doesn't really apply to the interactive mode, hence the behavior in interactive mode is undefined, and may and will change across Python ve

Re: Removal of tkinter from python 3.0? [was: Fate of the repr module in Py3.0]

2008-03-21 Thread Martin v. Löwis
> I've been thinking of volunteering to "port" Tkinter to Python 3.0, I > hadn't noticed that there was any discussion of removing it. It would > be a shame IMHO. I don't think Tkinter will be removed. It works just fine in 3k. Of course, if you would port IDLE to Tk 8.5: that would be a useful

Re: os.path.getsize() on Windows

2008-03-21 Thread Martin v. Löwis
> def isGrowing(f, timeout): > ssize = os.path.getsize(f) > time.sleep(timeout) > esize =os.path.getsize(f) > return esize != ssize > > On windows, this returns the size of the file as it _will be_, not the > size that it currently is. Why do you say that? It most

Re: How can I make a function equal to 0?

2008-03-21 Thread Martin Manns
On Fri, 21 Mar 2008 13:12:56 -0700 (PDT) Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Mar 21, 7:48 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > Why do you want to do that? First thank you for your help, the callable object works. Basically I have a lot of functions inside a numpy array, of

Re: finding items that occur more than once in a list

2008-03-21 Thread John Machin
On Mar 22, 1:11 am, [EMAIL PROTECTED] wrote: > On Mar 21, 4:17 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > > > > > Arnaud Delobelle wrote: > > > Bryan Olson wrote: > > [...] > > >> Arnaud Delobelle offered a good Wikipedia link, and for more background > > >> look up "amortized analysis. > > > > H

Re: beginners question about return value of re.split

2008-03-21 Thread John Machin
On Mar 22, 2:53 am, klaus <[EMAIL PROTECTED]> wrote: > On Fri, 21 Mar 2008 10:31:20 -0500, Tim Chase wrote: > > <..> > > Ok thank you ! > > I think I got a bit lost in all the possibilities python has to offer. IMHO you got more than a bit lost. You seem to have stumbled on a possibly unin

Re: How can I make a function equal to 0?

2008-03-21 Thread Arnaud Delobelle
On Mar 21, 7:48 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to create a function that is equal to 0? > I try to redefine __cmp__ but I am pretty stuck. > > Something like: > > >>> def f(): return "" > ... > >>> # Some magic > >>> f == 0 > > True Why do you want to do that?

Re: How can I make a function equal to 0?

2008-03-21 Thread [EMAIL PROTECTED]
On Mar 21, 12:48 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to create a function that is equal to 0? > I try to redefine __cmp__ but I am pretty stuck. > > Something like: > > >>> def f(): return "" > ... > >>> # Some magic > >>> f == 0 > > True > You would have to bind

Re: How can I make a function equal to 0?

2008-03-21 Thread Peter Otten
Martin Manns wrote: > Is there a way to create a function that is equal to 0? > I try to redefine __cmp__ but I am pretty stuck. > > Something like: > def f(): return "" > ... # Some magic f == 0 > True > > Thanks in advance > > Martin Use a callable object: >>> class F(object

Re: How can I make a function equal to 0?

2008-03-21 Thread Grant Edwards
On 2008-03-21, Paul Rubin wrote: > Martin Manns <[EMAIL PROTECTED]> writes: >> Is there a way to create a function that is equal to 0? > > def f(): return 0 I assumed he meant he wanted this to evaluate to True instead of False: >>> def f(): return 0 ... >>> >>> f == 0 False -- Gra

Re: How can I make a function equal to 0?

2008-03-21 Thread Martin Manns
On 21 Mar 2008 12:52:12 -0700 Paul Rubin wrote: > def f(): return 0 Let us try it: Python 2.5.1 (r251:54863, Jan 26 2008, 01:34:00) [GCC 4.1.2 (Gentoo 4.1.2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): return 0 ... >

Re: How can I make a function equal to 0?

2008-03-21 Thread Michael Wieher
Well, you could have a variable f that points at a memory address, such that >>> def x(): ... return ... >>> x >>> x=0 >>> x 0 >>> but I don't really understand why/what you're trying to do 2008/3/21, Martin Manns <[EMAIL PROTECTED]>: > > Hi, > > Is there a way to create a function that is equ

Re: How can I make a function equal to 0?

2008-03-21 Thread Paul Rubin
Martin Manns <[EMAIL PROTECTED]> writes: > Is there a way to create a function that is equal to 0? def f(): return 0 -- http://mail.python.org/mailman/listinfo/python-list

How can I make a function equal to 0?

2008-03-21 Thread Martin Manns
Hi, Is there a way to create a function that is equal to 0? I try to redefine __cmp__ but I am pretty stuck. Something like: >>> def f(): return "" ... >>> # Some magic >>> f == 0 True Thanks in advance Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this doable

2008-03-21 Thread Jonathan Gardner
On Mar 21, 4:48 am, fkallgren <[EMAIL PROTECTED]> wrote: > Hi. > > I have a little problem. I have a script that is in the scheduler > (win32). But every now and then I update this script and I dont want > to go to every computer and update it. So now I want the program to 1) > check for new versio

Re: Is this doable

2008-03-21 Thread Gabriel Genellina
On 21 mar, 15:11, MRAB <[EMAIL PROTECTED]> wrote: > On Mar 21, 11:48 am, fkallgren <[EMAIL PROTECTED]> wrote:> Hi. > > > I have a little problem. I have a script that is in the scheduler > > (win32). But every now and then I update this script and I dont want > > to go to every computer and update

Re: Is this doable

2008-03-21 Thread MRAB
On Mar 21, 11:48 am, fkallgren <[EMAIL PROTECTED]> wrote: > Hi. > > I have a little problem. I have a script that is in the scheduler > (win32). But every now and then I update this script and I dont want > to go to every computer and update it. So now I want the program to 1) > check for new versi

Re: dividing tuple elements with an int or float

2008-03-21 Thread Gabriel Genellina
On 21 mar, 10:14, [EMAIL PROTECTED] wrote: > On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > A more general > > solution might use a generator expression, like this: > > newsz = tuple(x/scale for x in origsz) > > You want to perform a uniform call on the elements of a collection. >

Re: Improving datetime

2008-03-21 Thread Christian Heimes
Colin J. Williams schrieb: > You might consider adding the Julian date > (http://en.wikipedia.org/wiki/Julian_date). > > I had a crack at this a while ago but didn't seem to get quire the right > result, using the ACM algorithm. I seemed to be a day out at the BC/AD > divide. Yes, the Julian dat

Re: Improving datetime

2008-03-21 Thread Aahz
In article <[EMAIL PROTECTED]>, Nicholas F. Fabry <[EMAIL PROTECTED]> wrote: > >Please clarify how long a novel is? The problem with the modules are >not bugs, they are problems with real world use scenarios that result >in inescabably ugly code without improvements to the module - so the >e

Python 2.x future (was Re: Improving datetime)

2008-03-21 Thread Aahz
In article <[EMAIL PROTECTED]>, Tim Roberts <[EMAIL PROTECTED]> wrote: > >I thought there wasn't going to be a 2.7... Whatever gave you that idea? There's no *guarantee* that 2.7 will exist, but certainly it's being planned. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncra

Re: beginners question about return value of re.split

2008-03-21 Thread klaus
On Fri, 21 Mar 2008 10:31:20 -0500, Tim Chase wrote: <..> Ok thank you ! I think I got a bit lost in all the possibilities python has to offer. But your answers did the trick. Thank you all again for responding and elaborating. Cheers, KL. -- http://mail.python.org/mailman/listinfo

Re: beginners question about return value of re.split

2008-03-21 Thread Diez B. Roggisch
klaus schrieb: > Hello, > > I have a question regarding the return value of re.split() since I have > been unable to find any answers in the regular sources of documentation. > > Please consider the following: > > #!/usr/bin/env python > > import re > > if __name__ == "__main__": > datum

Re: beginners question about return value of re.split

2008-03-21 Thread Tim Chase
> datum = "2008-03-14" > the_date = re.split('^([0-9]{4})-([0-9]{2})-([0-9]{2})$', datum, 3) > print the_date > > Now the result that is printed is: > ['', '2008', '03', '14', ''] > > My question: what are the empty strings doing there in the beginning and > in the end ? Is this due

Re: Distributing Python Apps on Linux\BSD

2008-03-21 Thread Miki
Hello, Disclaimer: I'm not an expert on the subject. > Setuptools and friends seem to be focused on distributing modules, I'm > at the other end of the scale where I want to distribute an entire > application so that an Administrator can run a single install and have > a fully operational product

Re: script won't run using cron.d or crontab

2008-03-21 Thread Bjorn Meyer
Thank you for your reply. This is pretty much what I found from my digging around. I asume this can still be done. Is there an easy way to determine what needs to be added to the environment? Bjorn On Fri, Mar 21, 2008 at 2:01 AM, Robert Bossy <[EMAIL PROTECTED]> wrote: > Bjorn Meyer wrote: > >

beginners question about return value of re.split

2008-03-21 Thread klaus
Hello, I have a question regarding the return value of re.split() since I have been unable to find any answers in the regular sources of documentation. Please consider the following: #!/usr/bin/env python import re if __name__ == "__main__": datum = "2008-03-14" the_date = re.split('^

Re: How do I change the font size for the default coordinates in matplotlib?

2008-03-21 Thread Carl
On Mar 20, 10:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Mar 20, 8:20 pm, Carl <[EMAIL PROTECTED]> wrote: > > > I've searched the user manual (and this forum) but I don't see > > anything that helps. > > Did you mean the font size for the ticks or for > the labels? Here's an exampl

Re: Is this doable

2008-03-21 Thread Mike Driscoll
On Mar 21, 6:48 am, fkallgren <[EMAIL PROTECTED]> wrote: > Hi. > > I have a little problem. I have a script that is in the scheduler > (win32). But every now and then I update this script and I dont want > to go to every computer and update it. So now I want the program to 1) > check for new versio

Re: An Application Program to Play a CD

2008-03-21 Thread W. Watson
Thanks for the link. I briefly looked at it, and it sure would be hard to tell if it has application here. The material looks developer oriented. Your short descriptions gives more insight than their home page. They aren't exactly marketing driven; however, I'll give it a closer look. Maybe join

Re: Is this valid ?

2008-03-21 Thread Colin J. Williams
Lie wrote: > On Mar 20, 4:18 am, Stef Mientki <[EMAIL PROTECTED]> wrote: >> hello, >> >> by accident I typed a double value test, >> and to my surprise it seems to work. >> Is this valid ? >> >> a = 2 >> b = 2 >> >> a == b == 2 >> >> thanks, >> Stef Mientki > > a == b == 2 > is equivalent to > a =

Re: Fate of the repr module in Py3.0

2008-03-21 Thread Colin J. Williams
Raymond Hettinger wrote: > Was looking at PEP 3108, http://www.python.org/dev/peps/pep-3108/ , > and saw that the repr module was slated for vaporization. I've only > used the module a few times ever. I'm curious if the community wants > it kept around or whether it is considered clutter. > > Th

Re: Code folder with Emacs

2008-03-21 Thread Grant Edwards
On 2008-03-21, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> Has anybody figured out how to do code folding of Python source >> files in emacs? >> >> I tried "hide-show" minor mode, but it doesn't really work for >> Python code: the only think it knows how to hide/show are >> function bodies.

Re: eval and unicode

2008-03-21 Thread Jonathan Gardner
On Mar 21, 1:54 am, Laszlo Nagy <[EMAIL PROTECTED]> wrote: >  >>> eval( "# -*- coding: latin2 -*-\n" + expr) > u'\u0170' # You can specify the encoding for eval, that is cool. > I didn't think of that. That's pretty cool. > I hope it is clear now.  Inside eval, an unicode object was created from

Re: finding items that occur more than once in a list

2008-03-21 Thread castironpi
On Mar 21, 4:17 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > Bryan Olson wrote: > [...] > >> Arnaud Delobelle offered a good Wikipedia link, and for more background > >> look up "amortized analysis. > > > Hrvoje Niksic provided the link :). > > Oops, careless thread-foll

Re: Improving datetime

2008-03-21 Thread Colin J. Williams
Nicholas F. Fabry wrote: > On Mar 19, 2008, at 16:30, Christian Heimes wrote: > >> Nicholas F. Fabry schrieb: >>> This is a query for information as to how to proceed. I am not a >>> professional programmer, but I use Python a great deal to help me in >>> my main job, which involves designing

Re: What c.l.py's opinions about Soft Exception?

2008-03-21 Thread castironpi
On Mar 11, 2:30 pm, Lie <[EMAIL PROTECTED]> wrote: > On Mar 12, 12:00 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > Actually, the latter is even less cluttered, misses a raise - if pure number > > of literals is your metric, that is. > > You don't just compare by the calling code, you've

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 21, 8:14 am, [EMAIL PROTECTED] wrote: > On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > > >  > suppose > > >  > origsz=(400,300) > > >  >

Funny video :)

2008-03-21 Thread shrek33333
http://rozrywka.yeba.pl/show.php?id=1029 :) Funny Sports Bloopers :) -- http://mail.python.org/mailman/listinfo/python-list

Re: lists v. tuples

2008-03-21 Thread castironpi
On Mar 19, 4:56 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I am puzzled by the failure on 'a in a' for a=[a].  >>> a== [a] also > > fails.  Can we assume/surmise/deduce/infer it's intentional? > > It may be less confusing if instead of an assignment following by a te

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > >  > suppose > >  > origsz=(400,300) > >  > i want to divide the origsize by 2.5 so i can resize to (

Re: removing all instances of a certain value from a list

2008-03-21 Thread bearophileHUGS
[EMAIL PROTECTED]: > >>> a=filter ( lambda b: b != None, a) With None it's better to use is/not is instead of ==/!= Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Prototype OO

2008-03-21 Thread Diez B. Roggisch
> I can see that Python and Javascript inheritance model is almost the > same. Both languages are dynamically typed. And it seems that using > "classes" in Python makes some things more complicated then it is > necessary (eg functions, methods and lambdas are differen beeing in > Python concept

Re: What Programming Languages Should You Learn Next?

2008-03-21 Thread Bryan Olson
wesley chun wrote: > http://it.slashdot.org/it/08/03/18/1633229.shtml > > it was surprising and disappointing that Python was not mentioned > *anywhere* in that article but when someone replied, it sparked a long > thread of post-discussion. What I found disappointing was how many people thought

Re: Beautiful Code in Python?

2008-03-21 Thread castironpi
On Mar 9, 6:44 pm, [EMAIL PROTECTED] wrote: > On Mar 2, 1:18 pm, [EMAIL PROTECTED] wrote: > > > On Mar 2, 12:01 pm, John DeRosa <[EMAIL PROTECTED]> wrote: > > > > On Mon, 3 Mar 2008 01:23:32 +0900, js <[EMAIL PROTECTED]> wrote: > > > >Hi, > > > > >Have you ever seen Beautiful Python code? > > > >Zo

Is this doable

2008-03-21 Thread fkallgren
Hi. I have a little problem. I have a script that is in the scheduler (win32). But every now and then I update this script and I dont want to go to every computer and update it. So now I want the program to 1) check for new version of the script, 2) if there is a new version, copy that verision fr

Re: eval and unicode

2008-03-21 Thread Laszlo Nagy
> > Your problem is, I think, that you think the magic of decoding source > code from the byte sequence into unicode happens in exec or eval. It > doesn't. It happens in between reading the file and passing the > contents of the file to exec or eval. > I think you are wrong here. Decoding sourc

Re: os.path.getsize() on Windows

2008-03-21 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I think you're confused. Or possibly I'm confused. Or both. I think it is you, but then I could be wrong. > It seems to me that you're assuming that the OP has opened the file > for reading first, and *then* another process comes along and wants to >

Re: Prototype OO

2008-03-21 Thread Steven D'Aprano
On Fri, 21 Mar 2008 11:43:33 +0100, sam wrote: > I can see that Python and Javascript inheritance model is almost the > same. Both languages are dynamically typed. And it seems that using > "classes" in Python makes some things more complicated then it is > necessary (eg functions, methods and lam

Re: Prototype OO

2008-03-21 Thread sam
Bruno Desthuilliers napisał(a): >> In dynamically typed language when you create object A that is >> inherited from another object B, than object A knows that B is his >> predecessor. So >> when you reference A.prop, then prop is looked in A first, then in B, >> then in predecessors of B, and

Re: Prototype OO

2008-03-21 Thread Bruno Desthuilliers
sam a écrit : > Bruno Desthuilliers napisał(a): > >> Most of the arguments in favor of prototypes seems to come to, mainly: >> 1/ it lets you customize behaviour on a per-object base >> 2/ it removes the mental overhead of inheritance, classes etc >> >> Point 1. is a non-problem in Python, since y

Re: Anomaly in time.clock()

2008-03-21 Thread Gabriel Genellina
On 21 mar, 03:13, Godzilla <[EMAIL PROTECTED]> wrote: > Just found out that win32api.GetTickCount() returns a tick count in > milli-second since XP started. Not sure whether that is reliable. > Anyone uses that for calculating elapsed time? I use GetTickCount on other languages because it's easy

Re: Code folder with Emacs

2008-03-21 Thread Diez B. Roggisch
Grant Edwards schrieb: > Has anybody figured out how to do code folding of Python source > files in emacs? > > I tried "hide-show" minor mode, but it doesn't really work for > Python code: the only think it knows how to hide/show are > function bodies. It can't do normal things like hide/show a

Re: finding items that occur more than once in a list

2008-03-21 Thread Bryan Olson
Arnaud Delobelle wrote: > Bryan Olson wrote: [...] >> Arnaud Delobelle offered a good Wikipedia link, and for more background >> look up "amortized analysis. > > Hrvoje Niksic provided the link :). Oops, careless thread-following. Hrvoje Niksic it was. > I still think two unrelated > things are

Re: How to send a var to stdin of an external software

2008-03-21 Thread Bryan Olson
Benjamin Watine wrote: > [EMAIL PROTECTED] a écrit : >> I wrote: >>> And here's a thread example, based on Benjamin's code: >> [...] >> >> Doh! Race condition. Make that: >> >> import subprocess >> import thread >> import Queue >> >> def readtoq(pipe, q): >> q.put(pipe.read(

Re: removing all instances of a certain value from a list

2008-03-21 Thread r . grimm
On Mar 19, 11:28 pm, Lee Sander <[EMAIL PROTECTED]> wrote: > Hi, > I have a float array ( eg [-1.3, 1.22, 9.2, None, 2.3] ) but there are > many missing vlaues which are represented as None. I would like to > remove all such instances in one go. > There is a remove function but it removes only the

Re: eval and unicode

2008-03-21 Thread Laszlo Nagy
Hi Jonathan, I think I made it too complicated and I did not concentrate on the question. I could write answers to your post, but I'm going to explain it formally: >>> s = '\xdb' # This is a byte, without encoding specified. >>> s.decode('latin1') u'\xdb' # The above byte decoded in lat

Re: Anomaly in time.clock()

2008-03-21 Thread Gabriel Genellina
On 20 mar, 08:47, Godzilla <[EMAIL PROTECTED]> wrote: > Thanks Ross and John for your help. I apologise for the code I posted > earlier not being the full picture of what I was trying to achieve. I > had instantiated multiple instances of elapseTime class and each of > them gets called approximate

Re: script won't run using cron.d or crontab

2008-03-21 Thread Robert Bossy
Bjorn Meyer wrote: > I appologize if this been discussed previously. If so, just point me > to that information. > > I have done a fair bit of digging, but I haven't found a description > of what to actually do. > > I have a fairly lengthy script that I am able to run without any > problems from

decoupling a certain method

2008-03-21 Thread castironpi
class Proxy: def __init__( self, proxer ): object.__setattr__( self, '_proxer', proxer ) ComplexObject= object viewA= type( 'ComplexView', ( Proxy, ComplexObject ), { '__eq__': lambda self, other: abs( self._proxer- other )<= 1 } ) j= range( 10 ) g= 5 for a in j: p= viewA( a ) pr