ANN: python-aspects 1.2 released

2008-10-09 Thread Antti Kervinen
Hello! aspects.py is a lightweight and low-level library for intercepting function calls. Functions and methods (also in Python standard library and third party code) can be wrapped so that when they are called, the wrap is invoked first. Depending on the wrap, the execution of the original

Announce : Python Bootcamp at Big Nerd Ranch, 11/10-11/14

2008-10-09 Thread David Beazley
Announce: Python Bootcamp at Big Nerd Ranch. November 10-14, 2008 Atlanta, Georgia http://www.bignerdranch.com/classes/python.shtml Economic news got you down? It's not too register for a total escape at Big Nerd Ranch where the upcoming Python Bootcamp will put you on the fast path to becoming

Re: split a list based on a predicate

2008-10-09 Thread beginner
Hi, On Oct 8, 6:36 pm, Rajanikanth Jammalamadaka [EMAIL PROTECTED] wrote: Hi! Is there a functional way to do this? I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of non-decreasing values from this array (eg: In this case I want [0,1,2,3]) Thanks, Rajanikanth Here is

Re: first of not None

2008-10-09 Thread Serge Matveenko
On 10/9/08, Serge Matveenko [EMAIL PROTECTED] wrote: I need to put in the var property of the first object from the list that is not None. Somth like: foo = first_of([any, beny, riki,]).name Dont want to ugly if-cascade: foo = any.name if name is not None else beny.name if beny is not None

Re: first of not None

2008-10-09 Thread Diez B. Roggisch
Serge Matveenko schrieb: On 10/9/08, Serge Matveenko [EMAIL PROTECTED] wrote: I need to put in the var property of the first object from the list that is not None. Somth like: foo = first_of([any, beny, riki,]).name Dont want to ugly if-cascade: foo = any.name if name is not None else

Re: Inefficient summing

2008-10-09 Thread Matt Nordhoff
Chris Rebert wrote: I personally would probably do: from collections import defaultdict label2sum = defaultdict(lambda: 0) FWIW, you can just use: label2sum = defaultdict(int) You don't need a lambda. for r in rec: for key, value in r.iteritems(): label2sum[key] += value

Clever way of sorting strings containing integers?

2008-10-09 Thread Holger
I tried to do this elegantly, but did not come up with a good solution Sort strings like foo1bar2 foo10bar10 foo2bar3 foo10bar2 So that they come out: foo1bar2 foo2bar3 foo10bar2 foo10bar10 I.e. isolate integer parts and sort them according to integer value. Thx Holger --

default value in __init__

2008-10-09 Thread kenneth
Dear all, I have encountered this weird problem. I have a class definition with an __init__ argument 'd' which defaults to {}. This argument is put in the 'self.d' attribute at initialization I create two independent instances of this class; the code is as follows. class C: def

replace numbers in a string

2008-10-09 Thread Beema Shafreen
hi All, i have few lines in file ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg i need to replace the number and get only the alphabet in such a case what should i do. Can any body suggest me -- Beema Shafreen -- http://mail.python.org/mailman/listinfo/python-list

Re: default value in __init__

2008-10-09 Thread Chris Rebert
See Pitfall #5 on http://zephyrfalcon.org/labs/python_pitfalls.html It also applies to dictionaries (and sets, any mutable object really). On Thu, Oct 9, 2008 at 1:03 AM, kenneth [EMAIL PROTECTED] wrote: Dear all, I have encountered this weird problem. I have a class definition with an

Re: default value in __init__

2008-10-09 Thread Christian Heimes
kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this is a problem ? No, it always contains the default argument because default values are created just ONE TIME.

Re: Clever way of sorting strings containing integers?

2008-10-09 Thread Holger
On 9 Okt., 09:41, Holger [EMAIL PROTECTED] wrote: I tried to do this elegantly, but did not come up with a good solution Sort strings like foo1bar2 foo10bar10 foo2bar3 foo10bar2 So that they come out: foo1bar2 foo2bar3 foo10bar2 foo10bar10 I.e. isolate integer parts and sort them

Traceback not going all the way to the exception?

2008-10-09 Thread sert
I just got an exception and the traceback wouldn't go all the way to the statement that threw the exception. I found that out by using the debugger. Contrast the traceback: http://tinyurl.com/5xglde with the debugger output (notice the arrow pointing to the last statement the traceback

Re: replace numbers in a string

2008-10-09 Thread Gary Herron
Beema Shafreen wrote: hi All, i have few lines in file ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg i need to replace the number and get only the alphabet in such a case what should i do. Can any body suggest me From the regular expression module, use re.sub like this:

Re: Inefficient summing

2008-10-09 Thread bieffe62
On 8 Ott, 22:23, beginner [EMAIL PROTECTED] wrote: Hi All, I have a list of records like below: rec=[{F1:1, F2:2}, {F1:3, F2:4} ] Now I want to write code to find out the ratio of the sums of the two fields. One thing I can do is: sum(r[F1] for r in rec)/sum(r[F2] for r in rec) But

Re: default value in __init__

2008-10-09 Thread Chris Rebert
On Thu, Oct 9, 2008 at 1:39 AM, kenneth [EMAIL PROTECTED] wrote: On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this

Re: ssh problem using paramiko?

2008-10-09 Thread Diez B. Roggisch
Steve Holden wrote: Diez B. Roggisch wrote: sa6113 wrote: I couldn't find any good source for download Openssh on the net? Would you please introduce a URL for download that? http://www.vapor.com/amtelnet/ it supports only SSHv1, but I guess that's ok. No, you really don't want to

Re: Reading from stdin

2008-10-09 Thread Hendrik van Rooyen
Luis Zarrabeitia wrote: But it doesn't say how to put the file object in non-blocking mode. (I was trying to put the file object in non-blocking mode to test next()'s behavior). ??Ideas? # Some magic to make a file non blocking - from the internet def unblock(f): Given file 'f', sets its

SimpleXmlRpcServer and character encoding

2008-10-09 Thread shymon
I'm using SimpleXmlRpcServer class. Although I set encoding parameter in the constructor, I have to return all strings in default platform encoding (windows-1250/win32 or iso-8859-2/linux in my case). When I send values in, for example, UTF-8, string received by client is messed up. The client

Re: Inefficient summing

2008-10-09 Thread bearophileHUGS
FB: def add_r( sums, r ): return sums[0]+r['F1'], sums[1]+r['F2'] sum_f1, sum_f2 = reduce( add_r, rec, (0,0) ) result = sum_f1/sum_f2 Until this feature vanishes I think it's better to use it (untested): add_r = lambda (a, b), r: (a + r['F1'], b + r['F2']) Bye, bearophile --

Re: How to calculate two time?

2008-10-09 Thread skip
lookon Thank you for your help.It works. However, I am using Google lookon App Engine and cannot import dateutil and epsilon. I don't know how Google App Engine works, but are you not able to install pure Python modules? lookon Are there any other ways? Take a look at the

Re: ABCs - infix syntax for isinstance() ?

2008-10-09 Thread Boris Borcic
Terry Reedy wrote: Boris Borcic wrote: ... - allowing containment tests, ie x in Number to invoke isinstance() in the background when the container is of type type. My brain is too muddled by flu at the moment, to see whether Guido's fabled time machine allowed him to already provide all

Efficient Bit addressing in Python.

2008-10-09 Thread Hendrik van Rooyen
Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or whatever? It seems to me that there is a dilemma here : if you can

Re: SimpleXmlRpcServer and character encoding

2008-10-09 Thread shymon
Diez B. Roggisch-2 wrote: shymon wrote: I'm using SimpleXmlRpcServer class. Although I set encoding parameter in the constructor, I have to return all strings in default platform encoding (windows-1250/win32 or iso-8859-2/linux in my case). When I send values in, for example, UTF-8,

Re: template strings for matching?

2008-10-09 Thread Tino Wildenhain
Joe Strout wrote: Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! However, just as a template string has some advantages over % substitution for building a string, it seems like it would have

Re: template strings for matching?

2008-10-09 Thread skip
Joe templ = Template(The $object in $location falls mainly in the $subloc.) Joe d = templ.match(s) Joe and then d would either by None (if s doesn't match), or a Joe dictionary with values for 'object', 'location', and 'subloc'. Joe But I couldn't find anything like

Re: How to calculate two time?

2008-10-09 Thread lookon
I have solved the problem. thank you On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote:     lookon Thank you for your help.It works.  However, I am using Google     lookon App Engine and cannot import dateutil and epsilon. I don't know how Google App Engine works, but are you not able to install

Re: Access to Google Calendar

2008-10-09 Thread eliben
On Oct 8, 4:04 pm, pepitovadecurt [EMAIL PROTECTED] wrote: Hi I need to access to the Google Calendar under python. Is posible? Yes: http://code.google.com/p/gdata-python-client/ Eli -- http://mail.python.org/mailman/listinfo/python-list

Re: How to calculate two time?

2008-10-09 Thread skip
lookon but can you tell me what format is it? Read the strftime man page on your computer or Google for strftime or read the Python docs about the time.strftime function. (strftime and strptime strive to have the same set of format characters.) Skip --

Re: inspect feature

2008-10-09 Thread Bruno Desthuilliers
Aaron Castironpi Brady a écrit : Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, including the locals as defined in the frame, as shown. def f( a, b, d= None, *c, **e ): ... import inspect ...

Re: Clever way of sorting strings containing integers?

2008-10-09 Thread Holger
On 9 Okt., 10:57, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 09 Oct 2008 00:41:27 -0700, Holger wrote: I tried to do this elegantly, but did not come up with a good solution Sort strings like foo1bar2 foo10bar10 foo2bar3 foo10bar2 So that they come out: foo1bar2

Twisted Matrix and multicast broadcast

2008-10-09 Thread Stodge
I'm trying to get a simple multicast application working using Twisted; so far I have: from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor from twisted.application.internet import MulticastServer class MulticastServerUDP(DatagramProtocol): def

Re: template strings for matching?

2008-10-09 Thread skip
Tino Yeah, its a bit hard to spot: Tino http://docs.python.org/library/stdtypes.html#string-formatting-operations That shows how to use the template formatting as it currently exists. To my knowledge there is no support for the inverse operation, which is what Joe asked about. Given

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Tino Wildenhain
Hi, Hendrik van Rooyen wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or whatever? It seems to me that there is

Re: default value in __init__

2008-10-09 Thread kenneth
On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this is a problem ? No, it always contains the default argument

Re: no unbound methods in py3k

2008-10-09 Thread Thomas Heller
Christian Heimes schrieb: Thomas Heller wrote: but this is very ugly, imo. Is there another way? The raw_func instances that I have are not descriptors (they do not implement a __get__() method...) I've written PyInstanceMethod_Type for this use case. It's not (yet) available for Python

Re: Python/Django hosting on normal hosting plans

2008-10-09 Thread Steve Holden
Tim Chase wrote: [In response t David Lyon] My questions are: - can most everyday vanilla linux web hosts run a django site ? - can most everyday vanilla linux web hosts run python web scripts? Depends on your definition of most everyday vanilla linux web hosts. :) The

Re: ssh problem using paramiko?

2008-10-09 Thread Steve Holden
Diez B. Roggisch wrote: Steve Holden wrote: Diez B. Roggisch wrote: sa6113 wrote: I couldn't find any good source for download Openssh on the net? Would you please introduce a URL for download that? http://www.vapor.com/amtelnet/ it supports only SSHv1, but I guess that's ok. No, you

Re: re : do something in time interval

2008-10-09 Thread Hendrik van Rooyen
Lawrence D'Oliveiro wrote: Hendrik van Rooyen wrote: import time while True: end_time = time.time() + 5 while time.time() end_time: do_the_in_between_stuff() do_the_every_five_second_stuff() Maybe I'm dense, but ... where do you stop the

Re: Clever way of sorting strings containing integers?

2008-10-09 Thread Marc 'BlackJack' Rintsch
On Thu, 09 Oct 2008 00:41:27 -0700, Holger wrote: I tried to do this elegantly, but did not come up with a good solution Sort strings like foo1bar2 foo10bar10 foo2bar3 foo10bar2 So that they come out: foo1bar2 foo2bar3 foo10bar2 foo10bar10 I.e. isolate integer parts and sort

Can anyone Pythonize this lexical algorithm?

2008-10-09 Thread ShashiGowda
I am writing a package manager and stuck unable to write the version sorting function the algorithm is here http://www.linux.gr/cgi-bin/man/man2html?deb-version+5 and all other info is also in it please tell me how to do lexical comparision in python it'll be cool if you just write the code! --

Re: ANN: python-aspects 1.2 released

2008-10-09 Thread Stef Mientki
Antti Kervinen wrote: Hello! aspects.py is a lightweight and low-level library for intercepting function calls. Functions and methods (also in Python standard library and third party code) can be wrapped so that when they are called, the wrap is invoked first. Depending on the wrap, the

Re: template strings for matching?

2008-10-09 Thread Robin Becker
Joe Strout wrote: Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! However, just as a template string has some advantages over % substitution for building a string, it seems like it would have

Re: Twisted Matrix and multicast broadcast

2008-10-09 Thread Jean-Paul Calderone
On Thu, 9 Oct 2008 06:03:44 -0700 (PDT), Stodge [EMAIL PROTECTED] wrote: [snip] class MulticastServerUDP(DatagramProtocol): def startProtocol(self): print 'Started Listening' # Join a specific multicast group, which is the IP we will respond to

About print exception message

2008-10-09 Thread WaterWalk
Until Python 2.5, the exception object still uses ansi string. Thus, in the following example: f = open(u\u6d4b.log) Suppose the file to open does not exist, the output message of the exception maybe like: [Errno 2] No such file or directory: u'\u6d4b.log' This is not a clear message. I

Re: SimpleXmlRpcServer and character encoding

2008-10-09 Thread Diez B. Roggisch
shymon wrote: Diez B. Roggisch-2 wrote: shymon wrote: I'm using SimpleXmlRpcServer class. Although I set encoding parameter in the constructor, I have to return all strings in default platform encoding (windows-1250/win32 or iso-8859-2/linux in my case). When I send values in,

Re: template strings for matching?

2008-10-09 Thread Paul McGuire
Pyparsing makes building expressions with named fields pretty easy. from pyparsing import Word, alphas wrd = Word(alphas) templ = The + wrd(object) + in + wrd(location) + \ stays mainly in the + wrd(subloc) + . tests = \ The rain in Spain stays mainly in the plain. The snake in

On the indexing order in (numpy) arrays

2008-10-09 Thread Almar Klein
Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? This is reversed in Matlab too, because Matlab is a matrix package and matrix are often used this way.

Re: Twisted Matrix and multicast broadcast

2008-10-09 Thread Stodge
On Oct 9, 9:33 am, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Thu, 9 Oct 2008 06:03:44 -0700 (PDT), Stodge [EMAIL PROTECTED] wrote: [snip] class MulticastServerUDP(DatagramProtocol):    def startProtocol(self):        print 'Started Listening'        # Join a specific multicast

Re: template strings for matching?

2008-10-09 Thread Tino Wildenhain
[EMAIL PROTECTED] wrote: Tino Yeah, its a bit hard to spot: Tino http://docs.python.org/library/stdtypes.html#string-formatting-operations That shows how to use the template formatting as it currently exists. To my knowledge there is no support for the inverse operation, which is

How to do regular BASH work in Python?

2008-10-09 Thread Frantisek Malina
What is the best way to do the regular bash commands in native python? - create directory - create file - make a symlink - copy a file to another directory - move a file - set permissions I need to write a program that creates real application/FTP accounts and make regular backups to external

Re: How to do regular BASH work in Python?

2008-10-09 Thread Frantisek Malina
Hey, I found it. Python rocks: http://www.python.org/doc/2.5.2/lib/os-file-dir.html If you have any further links that provide some lively code examples and recipes, please pass them on. Thank you Frank Malina http://vizualbod.com -- http://mail.python.org/mailman/listinfo/python-list

Re: template strings for matching?

2008-10-09 Thread Joe Strout
On Oct 9, 2008, at 7:05 AM, [EMAIL PROTECTED] wrote: Tino http://docs.python.org/library/stdtypes.html#string-formatting-operations That shows how to use the template formatting as it currently exists. To my knowledge there is no support for the inverse operation, which is what Joe

Re: How to do regular BASH work in Python?

2008-10-09 Thread jdd
On Oct 9, 10:13 am, Frantisek Malina [EMAIL PROTECTED] wrote: Hey, I found it. Python rocks:http://www.python.org/doc/2.5.2/lib/os-file-dir.html If you have any further links that provide some lively code examples and recipes, please pass them on. Thank you Frank

Re: template strings for matching?

2008-10-09 Thread Peter Otten
Joe Strout wrote: Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! I don't think they've gained much traction and expect them to be superseded by PEP 3101 (see

Re: template strings for matching?

2008-10-09 Thread skip
Tino ??? can you elaborate? I don't see the problem. Tino %(foo)s % mapping Joe wants to go in the other direction. Using your example, he wants a function which takes a string and a template string and returns a dict. Here's a concrete example: s = My dog has fleas fmt = My

authenticated problem for paramiko

2008-10-09 Thread sa6113
I am using this code to connect to a windows machine using paramiko, I have installed sshd on the machine and it works properly: sock.connect((hostname, port)) t = paramiko.Transport(sock) event = threading.Event() t.start_client(event) event.wait() if not t.is_active(): print

hi can someone help me i would like to run this program 3 times and would like to append the cPickle file as a high score table

2008-10-09 Thread garywood
hi, Can someone help me i would like to run this program 3 times or more and would like to append the cPickle file as a high score table keeping my top scores. Right now it only records the last score thanks. # Trivia Challenge # Trivia game that reads a plain text file def

Re: replace numbers in a string

2008-10-09 Thread Peter Otten
Gary Herron wrote: Beema Shafreen wrote: hi All, i have few lines in file ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg i need to replace the number and get only the alphabet in such a case what should i do. Can any body suggest me From the regular expression module,

Re: inspect bug

2008-10-09 Thread Gabriel Genellina
En Thu, 09 Oct 2008 00:24:20 -0300, Aaron Castironpi Brady [EMAIL PROTECTED] escribió: Found this bug. It's in 2.6, too bad. Posting here is not going to help much, it just will be lost. Would be better to file a bug report at http://bugs.python.org/ -- Gabriel Genellina --

Re: Access to Google Calendar

2008-10-09 Thread Grant Edwards
On 2008-10-08, pepitovadecurt [EMAIL PROTECTED] wrote: Hi I need to access to the Google Calendar under python. Odd. You'd think somebody who uses Google Calendar would know how to use Google. Is posible? http://www.google.com/search?q=google+calendar+python First hit. -- Grant Edwards

Re: How to calculate two time?

2008-10-09 Thread lookon
but can you tell me what format is it? in the str there is a float and I can not deal with it On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote:     lookon Thank you for your help.It works.  However, I am using Google     lookon App Engine and cannot import dateutil and epsilon. I don't know how

first of not None

2008-10-09 Thread Serge Matveenko
Hello, everybody! Could someone help me with coding this thing? I need to put in the var property of the first object from the list that is not None. Somth like: foo = first_of([any, beny, riki,]).name Dont want to ugly if-cascade: foo = any.name if name is not None else beny.name if beny is

Re: Compiler, ast and forwards/backwards compatibility

2008-10-09 Thread Orestis Markou
On Wed, Oct 8, 2008 at 9:14 PM, Martin v. Löwis [EMAIL PROTECTED] wrote: The documentation for the ast module states that it helps to find out programmatically what the current grammar looks like. I can't find any reference (even when reading the code) on how you should go about this, other

Re: first of not None

2008-10-09 Thread Bruno Desthuilliers
Serge Matveenko a écrit : Hello, everybody! Could someone help me with coding this thing? I need to put in the var property of the first object from the list that is not None. Somth like: foo = first_of([any, beny, riki,]).name Dont want to ugly if-cascade: foo = any.name if name is not

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Orestis Markou
The ast module in 2.6 has something... On Thu, Oct 9, 2008 at 1:34 AM, Warren DeLano [EMAIL PROTECTED] wrote: I would like to parse arbitrary insecure text string containing nested Python data structures in eval-compatible form: # For example, given a config.txt such as: { 'my_atom' :

Access to Google Calendar

2008-10-09 Thread pepitovadecurt
Hi I need to access to the Google Calendar under python. Is posible? -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXmlRpcServer and character encoding

2008-10-09 Thread Diez B. Roggisch
shymon wrote: I'm using SimpleXmlRpcServer class. Although I set encoding parameter in the constructor, I have to return all strings in default platform encoding (windows-1250/win32 or iso-8859-2/linux in my case). When I send values in, for example, UTF-8, string received by client is

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread franck
I would like to parse arbitrary insecure text string containing nested Python data structures in eval-compatible form:   Python 2.6 has ast.literal_eval to do exactly this. It handle lists, tuples, dict, numbers, strings, bool and None, with arbitrary nesting. Cheers, Franck --

Re: About print exception message

2008-10-09 Thread Jean-Paul Calderone
On Thu, 9 Oct 2008 06:37:04 -0700 (PDT), WaterWalk [EMAIL PROTECTED] wrote: Until Python 2.5, the exception object still uses ansi string. Thus, in the following example: f = open(u\u6d4b.log) Suppose the file to open does not exist, the output message of the exception maybe like: [Errno 2]

template strings for matching?

2008-10-09 Thread Joe Strout
Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! However, just as a template string has some advantages over % substitution for building a string, it seems like it would have advantages over

Re: first of not None

2008-10-09 Thread Tim Chase
I need to put in the var property of the first object from the list that is not None. Somth like: foo = first_of([any, beny, riki,]).name Dont want to ugly if-cascade: foo = any.name if name is not None else beny.name if beny is not None \ else riki.name if riki is not None assuming you

Re: How to calculate two time?

2008-10-09 Thread lookon
Thank you for your help.It works. However, I am using Google App Engine and cannot import dateutil and epsilon. Are there any other ways? On Oct 8, 10:06 pm, [EMAIL PROTECTED] wrote:     lookon I have two string like 2007-03-27T08:54:43+08:00 how do I get     lookon the hours between these

Re: Clever way of sorting strings containing integers?

2008-10-09 Thread bieffe62
On 9 Ott, 09:41, Holger [EMAIL PROTECTED] wrote: I tried to do this elegantly, but did not come up with a good solution Sort strings like foo1bar2 foo10bar10 foo2bar3 foo10bar2 So that they come out: foo1bar2 foo2bar3 foo10bar2 foo10bar10 I.e. isolate integer parts and sort them

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Lie Ryan
On Fri, 10 Oct 2008 00:30:18 +0200, Hendrik van Rooyen wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Lie Ryan
On Thu, 09 Oct 2008 13:26:17 +0100, Orestis Markou wrote: The ast module in 2.6 has something... in python 2.6, ast.literal_eval may be used to replace eval() for literals. It does not accepts statements and function calls, i.e.: a = set([1, 2, 3]) repr(a) set([1, 2, 3])

NameError question - def(self,master) - master not in namespace within class?

2008-10-09 Thread harijay
Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and child. I am getting an error within child where in one line it understands variable master.name and in

Re: Efficient Bit addressing in Python.

2008-10-09 Thread George Sakkis
On Oct 9, 6:30 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? I don't know of a canonical way (bit hacking is not really common in Python) but pehaps BitPacket [1] comes close to what you're after.

Re: NameError question - def(self, master) - master not in namespace within class?

2008-10-09 Thread bieffe62
On 9 Ott, 17:43, harijay [EMAIL PROTECTED] wrote: Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and child. I am getting an error within child where

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Paul Rubin
Lie Ryan [EMAIL PROTECTED] writes: in python 2.6, ast.literal_eval may be used to replace eval() for literals. What happens on literal_eval('[1]*9') ? -- http://mail.python.org/mailman/listinfo/python-list

Re: NameError question - def(self, master) - master not in namespace within class?

2008-10-09 Thread Jerry Hill
On Thu, Oct 9, 2008 at 11:43 AM, harijay [EMAIL PROTECTED] wrote: Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and child. I am getting an error

Re: NameError question - def(self, master) - master not in namespace within class?

2008-10-09 Thread harijay
Thanks beiff for your prompt reply - But I shouldnt need to import master in child. Actually and very strangely. The problem fixed itself without any change to my code. I dont understand how. It may have been a problem with a bad *.pyc lingering around . But now I cannot get the old NameError to

Re: NameError question - def(self, master) - master not in namespace within class?

2008-10-09 Thread harijay
Thanks Jerry and beiff , Jerry was right, it was an indent problem . Between using my text editor and running from commandline something went out of sync and I didnt catch it probably. I can now reproduce the error with a bad ident . These are my first posts to comp.lang.python..and I am very

Re: template strings for matching?

2008-10-09 Thread Joe Strout
Wow, this was harder than I thought (at least for a rusty Pythoneer like myself). Here's my stab at an implementation. Remember, the goal is to add a match method to Template which works like Template.substitute, but in reverse: given a string, if that string matches the template, then

Re: How to do regular BASH work in Python?

2008-10-09 Thread Frank Malina @ vizualbod.com
On Oct 9, 3:22 pm, jdd [EMAIL PROTECTED] wrote: On Oct 9, 10:13 am, Frantisek Malina [EMAIL PROTECTED] wrote: Hey, I found it. Python rocks:http://www.python.org/doc/2.5.2/lib/os-file-dir.html If you have any further links that provide some lively code examples and recipes, please

Re: split a list based on a predicate

2008-10-09 Thread Rajanikanth Jammalamadaka
Thanks for all of your replies. Rajanikanth On Wed, Oct 8, 2008 at 11:59 PM, beginner [EMAIL PROTECTED] wrote: Hi, On Oct 8, 6:36 pm, Rajanikanth Jammalamadaka [EMAIL PROTECTED] wrote: Hi! Is there a functional way to do this? I have an array [0,1,2,3,0,1,2,2,3] and I want the first

How to delete readonly and hidden files directories on windows xp?

2008-10-09 Thread dudeja . rajat
Hi, I'm using Windows XP and I'm looking for way out to remove .svn folders from my directory. But I'm unable to do that. Does any one one has written any script for removing the hidden / readonly files or directories? Regards, Rajat -- http://mail.python.org/mailman/listinfo/python-list

Re: Access to Google Calendar

2008-10-09 Thread Joshua Kugler
pepitovadecurt wrote: Hi I need to access to the Google Calendar under python. Is posible? You mean this? http://code.google.com/apis/calendar/developers_guide_python.html j -- http://mail.python.org/mailman/listinfo/python-list

Re: utf-8 read/write file

2008-10-09 Thread gigs
Kent Johnson wrote: On Oct 8, 5:55 pm, gigs [EMAIL PROTECTED] wrote: Benjamin wrote: On Oct 8, 12:49 pm, Bruno [EMAIL PROTECTED] wrote: Hi! I have big .txt file which i want to read, process and write to another .txt file. I have done script for that, but im having problem with croatian

Re: Pr. Euler 18, recursion problem

2008-10-09 Thread Lie Ryan
On Mon, 06 Oct 2008 00:14:37 -0700, process wrote: On Oct 6, 8:13 am, Aidan [EMAIL PROTECTED] wrote: process wrote: I am trying to solve project euler problem 18 with brute force(I will move on to a better solution after I have done that for problem 67).

Re: Python 2.6, GUI not working on vista?

2008-10-09 Thread Thorsten Kampe
* Lawrence D'Oliveiro (Wed, 08 Oct 2008 10:47:54 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote: * Lawrence D'Oliveiro (Mon, 06 Oct 2008 23:18:10 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote: * Lawrence D'Oliveiro (Sun, 05 Oct 2008 22:13:46 +1300) In message

Re: Python 2.6, GUI not working on vista?

2008-10-09 Thread Thorsten Kampe
* Mensanator (Tue, 7 Oct 2008 10:58:24 -0700 (PDT)) On Oct 7, 12:40 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Lawrence D'Oliveiro (Mon, 06 Oct 2008 23:18:10 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote: * Lawrence D'Oliveiro (Sun, 05 Oct 2008 22:13:46 +1300) In

Get High on Rave Pills

2008-10-09 Thread easta01
Many pills in the market today like Ecstasy are popular at rave parties. These pills though effective in giving you a kick can also be risky to consume possess. Reactions to these drugs include teeth gritting, nausea, hazy vision, chills, spasms sweating. Increased heart rate high BP levels

Re: Python 2.6, GUI not working on vista?

2008-10-09 Thread Mensanator
On Oct 9, 12:36 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Mensanator (Tue, 7 Oct 2008 10:58:24 -0700 (PDT)) On Oct 7, 12:40 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Lawrence D'Oliveiro (Mon, 06 Oct 2008 23:18:10 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote:

paramiko and stackless

2008-10-09 Thread Linnorm
I've written a port forwarding wrapper with paramiko for an app we use and it works fine except that it consumes way too much processor. (i.e. 25% +) I'm trying to write a stackless-based server class to replace the threading one but I can't get the tunnel the wrapper creates to work for more

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Mensanator
On Oct 9, 5:30 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or

Re: A question about funcation parameter and self defined object

2008-10-09 Thread Wei Guo
Hi Terry, Thanks for your reply. But the reason I want to have that is for not changing the functions which already based on translation functions. If there is any idea how to bring parameter in static method, that will be great. Wei On Wed, Oct 8, 2008 at 8:24 PM, Terry Reedy [EMAIL PROTECTED]

Re: How to do regular BASH work in Python?

2008-10-09 Thread Chris Rebert
You might also be interested in the 'shutil' module: http://docs.python.org/library/shutil.html#module-shutil Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com On Thu, Oct 9, 2008 at 7:13 AM, Frantisek Malina [EMAIL PROTECTED] wrote: Hey, I found it. Python rocks:

Re: default value in __init__

2008-10-09 Thread Bruno Desthuilliers
kenneth a écrit : On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this is a problem ? No, it always contains the default

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Jason Scheirer
On Oct 9, 9:01 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Lie Ryan [EMAIL PROTECTED] writes: in python 2.6, ast.literal_eval may be used to replace eval() for literals. What happens on literal_eval('[1]*9') ? The documentation clearly states that it will fail to evaluate and

  1   2   3   >