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: 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: 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: '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: 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: 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: 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,

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 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

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: 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: 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, 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: 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: 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: 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: 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

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

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

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

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: 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 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

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 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

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: 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

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: 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 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

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 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

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 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 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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

<    1   2