Re: ANN: psyco V2

2009-07-17 Thread Christian Tismer
It is just being transferred Von meinem iTouch gesendet On Jul 18, 2009, at 7:03, est wrote: On Jul 17, 10:48 am, Christian Tismer wrote: Announcing Psyco V2 source release -- This is the long awaited announcement of Psyco V2. Psyco V2 is a continuation of

Re: turtle dump

2009-07-17 Thread Peter Otten
Terry Reedy wrote: > alex23 wrote: > >> The help in iPython says the same, but also mentions that it's a >> dynamically generated function, so it may not be picking up the >> docstring that way. turtle.ScrolledCanvas.postscript is similarly >> terse, but you can find more info in turtle.Canvas.po

Re: turtle dump

2009-07-17 Thread Terry Reedy
David Robinow wrote: If you want to generate high-quality graphics easily you need different primitives. http://cairographics.org has Python bindings, but I don't know if it's available on Windows. Effectively not, as far as I can tell. PyCairo appears to be *nix and require later binaries tha

Re: ANN: psyco V2

2009-07-17 Thread est
On Jul 17, 10:48 am, Christian Tismer wrote: > Announcing Psyco V2 source release > -- > > This is the long awaited announcement of Psyco V2. > > Psyco V2 is a continuation of the well-known psyco project, > which was called finished and was dis-continued by its aut

Re: Question regarding style/design..

2009-07-17 Thread Michael Torrie
Wells Oliver wrote: > Sometimes I see relatively small application, generally task scripts, > written as essentially a list of statements. Other times, I see them neatly > divided into functions and then the "if __name__ == '__main__':" convention. > Is there a preference? Is there an... applicatio

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread Michael Torrie
LoD MoD wrote: > In this instance the trackback was somewhat unhelpful.There problem was > here: > >file = open(filename, 'r') > > should be > >file = open(a, 'r') > > args should be passed within the getopt riff Well given the code you posted, this little "problem" you

Re: Retrieving a partial pickle

2009-07-17 Thread Paul Rubin
Zac Burns writes: > I have a large pickle file, which happens to be a list with lots of > objects in it. > What sort of things can I do without unpickling the whole object? If it's for some kind of data recovery of a busted file, you could code some awful hack to pull stuff out of the middle of t

Re: Einstein summation notation

2009-07-17 Thread Paul Rubin
Ethan Furman writes: > Or if any(p for p in [header, body, footer, whatever, ...]) No need for the genexp: if any([header, body, footer, whatever, ...]) But, you are using the built-in bool cast either way. -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving a partial pickle

2009-07-17 Thread Gabriel Genellina
En Fri, 17 Jul 2009 21:43:21 -0300, Zac Burns escribió: I have a large pickle file, which happens to be a list with lots of objects in it. What sort of things can I do without unpickling the whole object? I would particularly like to retrieve one of the elements in the list without unpicking

Re: turtle dump

2009-07-17 Thread David Robinow
>> If you want to generate high-quality graphics easily you need different >> primitives. >> >> http://cairographics.org >> >> has Python bindings, but I don't know if it's available on Windows. > > Effectively not, as far as I can tell. PyCairo appears to be *nix and > require later binaries than

Re: PDF version of Python Tutorial?

2009-07-17 Thread Gabriel Genellina
En Fri, 17 Jul 2009 22:12:31 -0300, Dr. Phillip M. Feldman escribió: Does anyone know if there is a PDF version of the Python Tutorial (URL= http://www.python.org/doc/current/tutorial/)? From that page, click on the top left corner to go up one level, and you'll see a download link. Or, star

Re: Beginners question

2009-07-17 Thread Gabriel Genellina
En Fri, 17 Jul 2009 22:42:43 -0300, Ronn Ross escribió: How do you define a global variable in a class. I tried this with do success: class ClassName: global_var = 1 def some_method(self): print global_var This doesn't work. What am I doing wrong? [some typos fixed] In Pyth

Re: PDF version of Python Tutorial?

2009-07-17 Thread David Robinow
On Fri, Jul 17, 2009 at 9:12 PM, Dr. Phillip M. Feldman wrote: > > Does anyone know if there is a PDF version of the Python Tutorial (URL= > http://www.python.org/doc/current/tutorial/)? http://docs.python.org/download.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginners question

2009-07-17 Thread gabrielmonnerat
nohics nohics wrote: When defining your class methods, you /must/ explicitly list self as the first argument for each method, including __init__. When you call a method of an ancestor class from within your class, you /must/ include the self argument. But when you call your class method from o

Try... except....Try again?

2009-07-17 Thread Xavier Ho
Darn it. On Sat, Jul 18, 2009 at 8:55 AM, Dave Angel wrote: > > You don't need a counter. len() will tell you the size of the list of > primes. Does len() go through and count by itself, or does it actually keep track of the size and just return the memory? I always thought it would go throug

Re: Beginners question

2009-07-17 Thread nohics nohics
When defining your class methods, you *must* explicitly list self as the first argument for each method, including __init__. When you call a method of an ancestor class from within your class, you *must* include the selfargument. But when you call your class method from outside, you do not specify

Re: Beginners question

2009-07-17 Thread Albert Hopkins
On Fri, 2009-07-17 at 21:42 -0400, Ronn Ross wrote: > How do you define a global variable in a class. I bit of a mix-up with words here. A variable can be a class variable or a global variable (wrt the module).. not both. > I tried this with do success: > class ClassName: > global_var = 1 >

Re: Beginners question

2009-07-17 Thread gabrielmonnerat
Ronn Ross wrote: How do you define a global variable in a class. I tried this with do success: class ClassName: global_var = 1 def some_methos(): print global_var This doesn't work. What am I doing wrong? You need pass "self" to the function and "global_var" needs be called

Re: Find first matching substring

2009-07-17 Thread John Machin
On Jul 18, 2:11 am, Eloff wrote: > Almost every time I've had to do parsing of text over the last 5 years > I've needed this function: [snip] > It finds the first matching substring in the target string, if there > is more than one match, it returns the position of the match that > occurs at the l

Beginners question

2009-07-17 Thread Ronn Ross
How do you define a global variable in a class. I tried this with do success: class ClassName: global_var = 1 def some_methos(): print global_var This doesn't work. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list

Re: Self optimizing iterable

2009-07-17 Thread Carl Banks
On Jul 17, 5:40 pm, Paul Rubin wrote: > Zac Burns writes: > > An example use case for this would be for something like a large table > > of regular expressions that would be iterated over trying to match in > > some string. If some regular expressions are more statis

PDF version of Python Tutorial?

2009-07-17 Thread Dr. Phillip M. Feldman
Does anyone know if there is a PDF version of the Python Tutorial (URL= http://www.python.org/doc/current/tutorial/)? -- View this message in context: http://www.nabble.com/PDF-version-of-Python-Tutorial--tp24543817p24543817.html Sent from the Python - python-list mailing list archive at Nabble.

Re: Self optimizing iterable

2009-07-17 Thread Gabriel Genellina
En Fri, 17 Jul 2009 21:31:44 -0300, Zac Burns escribió: I would like a set like object that when iterated maintains a count of where iteration stopped and then re-orders itself based on that count so that the iteration stopped on the most bubble to the top. An example use case for this would b

Re: missing 'xor' Boolean operator

2009-07-17 Thread Dr. Phillip M. Feldman
Suppose that 'xor' returns the value that is true when only one value is true, and False otherwise. This definition of xor doesn't have the standard associative property, that is, (a xor b) xor c will not necessarily equal a xor (b xor c) To see that this is the case, let a= 1, b= 2, and c= 3

Re: Self optimizing iterable

2009-07-17 Thread MRAB
Zac Burns wrote: Greetings, I would like a set like object that when iterated maintains a count of where iteration stopped and then re-orders itself based on that count so that the iteration stopped on the most bubble to the top. An example use case for this would be for something like a large

Re: Self optimizing iterable

2009-07-17 Thread Paul Rubin
Zac Burns writes: > An example use case for this would be for something like a large table > of regular expressions that would be iterated over trying to match in > some string. If some regular expressions are more statistically more > successful then the iteration will generally be short. Genera

Retrieving a partial pickle

2009-07-17 Thread Zac Burns
I have a large pickle file, which happens to be a list with lots of objects in it. What sort of things can I do without unpickling the whole object? I would particularly like to retrieve one of the elements in the list without unpicking the whole object. If the answer is not specific to lists th

Self optimizing iterable

2009-07-17 Thread Zac Burns
Greetings, I would like a set like object that when iterated maintains a count of where iteration stopped and then re-orders itself based on that count so that the iteration stopped on the most bubble to the top. An example use case for this would be for something like a large table of regular ex

Re: Generator Expressions and CSV

2009-07-17 Thread Jon Clements
On 17 July, 23:57, Zaki wrote: > On Jul 17, 6:40 pm, Jon Clements wrote: > > > > > On 17 July, 21:08, Zaki wrote: > > > > On Jul 17, 2:49 pm, MRAB wrote: > > > > > Zaki wrote: > > > > > Hey all, > > > > > > I'm really new to Python and this may seem like a really dumb > > > > > question, but ba

Re: Propagate import for all modules in a package.

2009-07-17 Thread Ben Finney
Phil writes: > I was thinking that I could just, for example, 'from datetime import > datetime' in __init__.py and have the ability to use 'datetime' > anywhere in any of the modules in 'package'. That would break one of the very nice features of Python's namespace system: that, because nothing[

Re: Unable to get Tkinter menubar to appear under OS X

2009-07-17 Thread Matt
same problem on OS 10.4, menu doesn't show up on either from tkinter or wxpython, continuing search.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not enforce four space indentations in version 3.x?

2009-07-17 Thread David Bolen
Nobody writes: > On Thu, 16 Jul 2009 09:18:47 -0500, Tim Chase wrote: > >> Yes, the dictatorial "a tab always equals 8 spaces" > > Saying "always" is incorrect; it is more accurate to say that tab stops > are every 8 columns unless proven otherwise, with the burden of proof > falling on whoever w

Re: Generator Expressions and CSV

2009-07-17 Thread Zaki
On Jul 17, 6:40 pm, Jon Clements wrote: > On 17 July, 21:08, Zaki wrote: > > > > > On Jul 17, 2:49 pm, MRAB wrote: > > > > Zaki wrote: > > > > Hey all, > > > > > I'm really new to Python and this may seem like a really dumb > > > > question, but basically, I wrote a script to do the following, h

Re: Generator Expressions and CSV

2009-07-17 Thread Jon Clements
On 17 July, 21:08, Zaki wrote: > On Jul 17, 2:49 pm, MRAB wrote: > > > > > Zaki wrote: > > > Hey all, > > > > I'm really new to Python and this may seem like a really dumb > > > question, but basically, I wrote a script to do the following, however > > > the processing time/memory usage is not wh

Re: Generator Expressions and CSV

2009-07-17 Thread Zaki
On Jul 17, 5:31 pm, MRAB wrote: > Zaki wrote: > > On Jul 17, 2:49 pm, MRAB wrote: > >> Zaki wrote: > >>> Hey all, > >>> I'm really new to Python and this may seem like a really dumb > >>> question, but basically, I wrote a script to do the following, however > >>> the processing time/memory usage

Re: creating my own logwatch in python

2009-07-17 Thread Mahmoud Abdelkader
A few code critiques: - Your code is not very help friendly because it can not be run, so I have to deadlist debug it. - There are various syntax errors in the code: - for example: file is not defined when you invoke tail(file) - You are overshadowing a built-in type 'file' by that name,

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
On Sat, Jul 18, 2009 at 5:58 AM, Lie Ryan wrote: > > > If you're looking for speed, you should be aware that a failed > try-clause is quite expensive in python and often (as in this case) > codes using exception can be less readable than the one without since a > program's flow in the case of exc

creating my own logwatch in python

2009-07-17 Thread LoD MoD
I am trying to fabricate a logwatch-type script in Python and I'm having some trouble.What happens with the following code is that it prints to the screen but the if condition on line 22 never gets executed. http://pastie.org/549975 Any suggestions are appreciated. -- http://mail.python.org/mail

Re: Try... except....Try again?

2009-07-17 Thread Lie Ryan
Xavier Ho wrote: > oops, wrong address. > > When will reply-to tag appear on the Python mailing list? =/ > > Good idea, Steven and MRAB. > > I changed my code to the following: > > > def nPrime(self, n): > "Returns nth prime number, the first one being 2, where n = 0. > When n = 1,

Re: Generator Expressions and CSV

2009-07-17 Thread Emile van Sebille
On 7/17/2009 1:08 PM Zaki said... Here is the final code that I have running. It's very much 'hack' type code and not at all efficient or optimized and any help in optimizing it would be greatly appreciated. There are some things I'd approach differently , eg I might prefer glob to build iNuQ

Re: Generator Expressions and CSV

2009-07-17 Thread MRAB
Zaki wrote: On Jul 17, 2:49 pm, MRAB wrote: Zaki wrote: Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any suggestions? Outline: 1. Rea

Re: 'del' function for Dictionary

2009-07-17 Thread Terry Reedy
mayank gupta wrote: Hi all, I wanted to know whether there is a more efficient way to delete an entry from a dictionary (instead of using the 'del' function), because after analyzing the time taken by the code, it seems to me that the 'del' function takes most of the time. That is hard to i

Re: Passing python list from C to python

2009-07-17 Thread Aahz
In article <94c1adf3-a25d-4ae5-9f38-7ca8680d0...@b14g2000yqd.googlegroups.com>, hartley wrote: >On Jul 16, 9:26=A0pm, a...@pythoncraft.com (Aahz) wrote: >> In article <0afc5c4d-1af5-4d0e-9442-26b51b12e...@m11g2000yqh.googlegroups= >.com>, >> hartley =A0 wrote: >>> >>>If you had loosened up on the

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Piet van Oostrum
I should add that *if the wait times out* it still could be the case that your answer has arrived but that the notify occured a microsecond after the timeout. So knowing if the timeout occurred really doesn't tell you much. It's just a way to prevent infinite waiting. -- Piet van Oostrum URL: htt

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-17 Thread Terry Reedy
Sion Arrowsmith wrote: Jack Diederich wrote: It isn't an OrderedDict thing, it is a comparison thing. Two regular dicts also raise an error if you try to LT them. Since when? Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "lice

Re: proposal: add setresuid() system call to python

2009-07-17 Thread Jean-Paul Calderone
On Fri, 17 Jul 2009 15:01:41 -0500, travis+ml-pyt...@subspacefield.org wrote: Hello, [snip] I am suggesting that the setresuid function be added to python, perhaps in the OS module, because it has the clearest semantics for manipulating user ids. The reason why is best described in the followi

Re: A Bug By Any Other Name ...

2009-07-17 Thread MRAB
J. Cliff Dyer wrote: On Fri, 2009-07-17 at 20:53 +, Albert van der Horst wrote: Because unlike in algol 68 in python whitespace is relevant, we could get by with requiring whitespace: x= -q # okay a This is actually quite thoroughly untrue. In python,

Re: Writing a single list of numbers to a .m (matlab) file

2009-07-17 Thread Chris Rebert
On Fri, Jul 17, 2009 at 11:06 AM, Hanna Michelsen wrote: > Hi, > > I was wondering if I could get some suggestions on how to write a single > list of numbers to a .m file (for matlab) so that I can create a matlab > vector out of the list of numbers from my python program. I have been using > a csv

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Piet van Oostrum
> Gabriel Rossetti (GR) wrote: >GR> Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: >>> >>> >GR> I have a 1-1 relation, I have a thread reading msgs from a network socket >GR> and a method waiting for an answer to arrive (see my thread >GR> "Threading.Condition prob

Re: turtle dump

2009-07-17 Thread Terry Reedy
alex23 wrote: The help in iPython says the same, but also mentions that it's a dynamically generated function, so it may not be picking up the docstring that way. turtle.ScrolledCanvas.postscript is similarly terse, but you can find more info in turtle.Canvas.postscript: Print the contents of

Re: turtle dump

2009-07-17 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: I tried it. Unfortunately, OOo does not open it correctly. It just displays the first three lines of metadate - Title, Creator, Date -- as image text. Photoshop does read the image, and does an ok job of conversion once anti-aliasing is turned off. I snat

Re: proposal: add setresuid() system call to python

2009-07-17 Thread Robert Kern
On 2009-07-17 15:01, travis+ml-pyt...@subspacefield.org wrote: Hello, Historically, I have used scripting languages like python for typical uses, but they tend to not fare very well at system programming; for close interfacing with the operating system, I'm often forced to use a language like C.

Re: proposal: add setresuid() system call to python

2009-07-17 Thread Mahmoud Abdelkader
Why don't you write a python extension module? This is a perfect opportunity for that. -- mahmoud mack abdelkader http://blog.mahmoudimus.com/ On Fri, Jul 17, 2009 at 4:01 PM, > wrote: > Hello, > > Historically, I have used scripting languages like python for typical > uses, but they tend to

Re: Generator Expressions and CSV

2009-07-17 Thread Zaki
On Jul 17, 2:49 pm, MRAB wrote: > Zaki wrote: > > Hey all, > > > I'm really new to Python and this may seem like a really dumb > > question, but basically, I wrote a script to do the following, however > > the processing time/memory usage is not what I'd like it to be. Any > > suggestions? > > > O

Re: A Bug By Any Other Name ...

2009-07-17 Thread J. Cliff Dyer
On Fri, 2009-07-17 at 20:53 +, Albert van der Horst wrote: > Because unlike in algol 68 in python whitespace is relevant, > we could get by with requiring whitespace: > x= -q # okay > a 8 ** -2 # okay This is actually quite thor

proposal: add setresuid() system call to python

2009-07-17 Thread travis+ml-python
Hello, Historically, I have used scripting languages like python for typical uses, but they tend to not fare very well at system programming; for close interfacing with the operating system, I'm often forced to use a language like C. This is undesirable to me. I do not think this has to be the c

Re: A Bug By Any Other Name ...

2009-07-17 Thread Albert van der Horst
In article , Gabriel Genellina wrote: >En Mon, 06 Jul 2009 00:28:43 -0300, Steven D'Aprano > escribi?: >> On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote: >> >>> I wonder how many people have been tripped up by the fact that >>> >>> ++n >>> >>> and >>> >>> --n >>> >>> fail si

Re: ctype performance benchmark

2009-07-17 Thread Duncan Booth
Wai Yip wrote: > I started with ctypes because it is the battery included with the > Python standard library. My code is very fluid and I'm looking for > easy opportunity to optimize it. One example is to find the longest > common prefix among two strings. Right now I am comparing it character >

Mechanize not recognized by py2exe

2009-07-17 Thread Stephen M. Olds
I have a Python script getData.py that uses Mechanize, and runs fine under the interpreter. It was installed using easy_install - and the install seemed to indicate it was completed. The problem is, when I try to compile it using py2exe while in the folder of the script, and using the run line

Re: Generator Expressions and CSV

2009-07-17 Thread MRAB
Zaki wrote: Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any suggestions? Outline: 1. Read tab delim files from a directory, files ar

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just treat the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: ctype performance benchmark

2009-07-17 Thread Nick Craig-Wood
Wai Yip wrote: > I started with ctypes because it is the battery included with the > Python standard library. My code is very fluid and I'm looking for > easy opportunity to optimize it. One example is to find the longest > common prefix among two strings. Right now I am comparing it character

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
In this instance the trackback was somewhat unhelpful.There problem was here: file = open(filename, 'r') should be file = open(a, 'r') args should be passed within the getopt riff On Fri, Jul 17, 2009 at 11:08 AM, MRAB wrote: > LoD MoD wrote: > >> I am having trouble ex

Re: Generator Expressions and CSV

2009-07-17 Thread Emile van Sebille
On 7/17/2009 10:58 AM Zaki said... Now, I've tried running this and it takes much longer than I'd like. I was wondering if there might be a better way to do things Suppose, for the sake of argument, that you've written highly efficient code. Then the processing time would already be entirel

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread MRAB
LoD MoD wrote: I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where)

Writing a single list of numbers to a .m (matlab) file

2009-07-17 Thread Hanna Michelsen
Hi, I was wondering if I could get some suggestions on how to write a single list of numbers to a .m file (for matlab) so that I can create a matlab vector out of the list of numbers from my python program. I have been using a csv writer to create .m files from lists of lists, but I'm not sure how

Re: Question regarding style/design..

2009-07-17 Thread Tim Chase
Robert Kern wrote: [sage advice snipped] Don't waste half a day trying to figure out why your script mysteriously doesn't work. Learn from my mistakes. :-) I find that's the best type of mistake to learn from: other people's ;-) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Propagate import for all modules in a package.

2009-07-17 Thread Albert Hopkins
On Fri, 2009-07-17 at 10:28 -0700, Phil wrote: > I'm really new to Python and I am absolutely stumped trying to figure > this out. I have searched plenty, but I am either searching for the > wrong keywords or this isn't possible. > > What I want to do is have one import be global for the entire pa

Generator Expressions and CSV

2009-07-17 Thread Zaki
Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any suggestions? Outline: 1. Read tab delim files from a directory, files are of 3 types:

Re: Find first matching substring

2009-07-17 Thread MRAB
Eloff wrote: > Almost every time I've had to do parsing of text over the last 5 years > I've needed this function: > > def find_first(s, subs, start=None, end=None): > results = [s.find(sub, start, end) for sub in subs] > results = [r for r in results if r != -1] > if results: >

Re: Propagate import for all modules in a package.

2009-07-17 Thread Diez B. Roggisch
Phil schrieb: I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire package. Here is an example... __init__

Re: Question regarding style/design..

2009-07-17 Thread Robert Kern
On 2009-07-17 12:11, Tim Chase wrote: Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the "if __name__ == '__main__':" convention. Is there a preference? Is there an..

Re: Einstein summation notation

2009-07-17 Thread Matthew Barnett
Steven D'Aprano wrote: On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote: Python did always have True and False. Oops! I meant "didn't", of course. $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematis

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-17 Thread Scott David Daniels
akhil1988 wrote: > Nobody-38 wrote: On Thu, 16 Jul 2009 15:43:37 -0700, akhil1988 wrote: ... In Python 3 you can't decode strings because they are Unicode strings and it doesn't make sense to decode a Unicode string. You can only decode encoded things which are byte strings. So you are mixing

Propagate import for all modules in a package.

2009-07-17 Thread Phil
I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire package. Here is an example... __init__.py module1.py

getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where) el

Installing python-gnutls on Windows

2009-07-17 Thread IronyOfLife
Hi, I'm new to python and would like to request your help installing python-gnutls on windows. Are there binaries available which can be installed ? Looks like the setup.py file which came with the package is for Debian. I tried modifying it for windows but am still getting errors. get_options()

Re: ctype performance benchmark

2009-07-17 Thread Wai Yip
I started with ctypes because it is the battery included with the Python standard library. My code is very fluid and I'm looking for easy opportunity to optimize it. One example is to find the longest common prefix among two strings. Right now I am comparing it character by character with pure Pyth

Re: Question regarding style/design..

2009-07-17 Thread Tim Chase
Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the "if __name__ == '__main__':" convention. Is there a preference? Is there an... application scope such that the prefe

Regular exprssion for IRC messages

2009-07-17 Thread nohics nohics
Hello, When an IRC client receive a messages, this message in in a special format defined here: Message format in pseudo BNF( http://www.irchelp.org/irchelp/rfc/chapter2.html#c2_3_1 ). For example we can have: :mynickname!n=myusern...@41.2

Re: missing 'xor' Boolean operator

2009-07-17 Thread Emile van Sebille
On 7/17/2009 7:34 AM Jean-Michel Pichavant said... Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means "no error" and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1

A multi-threaded file searcher for processing large text files

2009-07-17 Thread Mahmoud Abdelkader
I'm building a threaded file searcher that uses some of Fredrik Lundh's ( http://effbot.org/zone/wide-finder.htm) suggestions for parsing text very quickly in pure python, as I have about a 10GB log file to parse every day. A naiive approach would be to just parse the 1MB chunks, add the results in

Question regarding style/design..

2009-07-17 Thread Wells Oliver
Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the "if __name__ == '__main__':" convention. Is there a preference? Is there an... application scope such that the prefer

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Paul Rubin
Steven D'Aprano writes: > Since I haven't specified an implementation for assemble_page, it could > be doing *anything*. Perhaps it has to talk to a remote database over a > slow link, perhaps it generates 300 lines of really inefficient HTML code > with no content, perhaps it sends a print job

Re: Einstein summation notation

2009-07-17 Thread Ethan Furman
Paul Rubin wrote: Steven D'Aprano writes: def assemble_page(header, body, footer): if header or body or footer: do_lots_of_expensive_processing() else: do_nothing_gracefully() Why should the processing be expensive if all three fields are empty? if header or body o

Find first matching substring

2009-07-17 Thread Eloff
Almost every time I've had to do parsing of text over the last 5 years I've needed this function: def find_first(s, subs, start=None, end=None): results = [s.find(sub, start, end) for sub in subs] results = [r for r in results if r != -1] if results: return min(results) re

Re: 'del' function for Dictionary

2009-07-17 Thread Michiel Overtoom
mayank gupta wrote: after analyzing the time taken by the code, What code? -- http://mail.python.org/mailman/listinfo/python-list

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
On Fri, Jul 17, 2009 at 11:02 PM, Jack Diederich wrote: > > If you use an off-the-shelf prime number generator fucntion[1] that > returns consecutive primes the method collapses into a simple > function. > > def nPrime(n, primes=[], next_prime=eratosthenes().next): >while len(primes) < n: >

'del' function for Dictionary

2009-07-17 Thread mayank gupta
Hi all, I wanted to know whether there is a more efficient way to delete an entry from a dictionary (instead of using the 'del' function), because after analyzing the time taken by the code, it seems to me that the 'del' function takes most of the time. I might be incorrect as well. Kindly help me

Re: Einstein summation notation

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote: > Python did always have True and False. $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> True, False Traceback (innermost last

Re: missing 'xor' Boolean operator

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 16:34:57 +0200, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: >> >> >> Given three result codes, where 0 means "no error" and an arbitrary >> non- zero integer means some error, it is simple and easy to

Re: Einstein summation notation

2009-07-17 Thread Jerry Hill
On Fri, Jul 17, 2009 at 11:09 AM, MRAB wrote: > Python did always have True and False. Only if "always" means "since python 2.2.1". See: http://www.python.org/doc/2.3/whatsnew/section-bool.html and http://www.python.org/dev/peps/pep-0285/ for details. -- Jerry -- http://mail.python.org/mailma

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: GR> I have a 1-1 relation, I have a thread reading msgs from a network socket GR> and a method waiting for an answer to arrive (see my thread GR> "Threading.Condition problem"). I would like to be able to have a timeout GR>

Re: Einstein summation notation

2009-07-17 Thread MRAB
koranthala wrote: That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing. This is an extremely common type of error. Actually, I felt that 0 not being considered False would be a better option

Re: Try... except....Try again?

2009-07-17 Thread Jack Diederich
On Fri, Jul 17, 2009 at 10:35 AM, Xavier Ho wrote: > I changed my code to the following: > >     def nPrime(self, n): >     "Returns nth prime number, the first one being 2, where n = 0. When > n = 1, it returns 3." >     for x in range(n+2): >     try: >     return sel

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 07:12:51 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> def assemble_page(header, body, footer): >> if header or body or footer: >> do_lots_of_expensive_processing() >> else: >> do_nothing_gracefully() > > Why should the processing be expensive

Re: missing 'xor' Boolean operator

2009-07-17 Thread Ethan Furman
Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means "no error" and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1 or result_2 or result

Try... except....Try again?

2009-07-17 Thread Xavier Ho
oops, wrong address. When will reply-to tag appear on the Python mailing list? =/ Good idea, Steven and MRAB. I changed my code to the following: def nPrime(self, n): "Returns nth prime number, the first one being 2, where n = 0. When n = 1, it returns 3." for x in range(n+2

  1   2   >