Re: Is there any module/utility like 'rsync' in python

2010-04-08 Thread Steven D'Aprano
On Thu, 08 Apr 2010 23:22:46 -0700, hiral wrote: > Hi, > > Is there any module/utility like 'rsync' in python. http://code.activestate.com/recipes/577022-rsync-algorithm-in-python/ but you probably aren't going to beat the performance and reliability of your platform's rsync utility. Chances

Re: Preserving logging streams through a daemon.DaemonContext switch

2010-04-08 Thread Rebelo
Ben Finney wrote: Vinay Sajip writes: On Apr 8, 1:58 pm, Rebelo wrote: Vinay Sajip wrote: My guess is - files_preserve needs to be passed a file handle and not alogginghandler. This is correct. As the ‘DaemonContext.__init__’ docstring says:: | `files_preserve` | :Default: ``None

Re: Is there any module/utility like 'rsync' in python

2010-04-08 Thread garabik-news-2005-05
hiral wrote: > Hi, > > Is there any module/utility like 'rsync' in python. > http://freshmeat.net/projects/pysync/ http://vdesmedt.com/~vds2212/rsync.html -- --- | Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ | | __..--^^^-

Is there any module/utility like 'rsync' in python

2010-04-08 Thread hiral
Hi, Is there any module/utility like 'rsync' in python. Thank you in advance. -Hiral -- http://mail.python.org/mailman/listinfo/python-list

Re: Cleanup guarantees?

2010-04-08 Thread Martin P. Hellwig
On 04/09/10 05:13, Alf P. Steinbach wrote: Second, I'm unable to find documentation of when they're called and what they do. It seems that (A) when the connection object's stream is exhausted by reading, its close() method is called automatically, and (B) that when the text_reader object's clos

Re: SIP

2010-04-08 Thread omnia neo
On Apr 9, 10:42 am, omnia neo wrote: > On Apr 9, 10:30 am, Stefan Behnel wrote: > > > omnia neo, 09.04.2010 07:01: > > > > import siptest > > > > I get following error : > > > import error : no module named siptest > > > Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)?

Re: SIP

2010-04-08 Thread omnia neo
On Apr 9, 10:30 am, Stefan Behnel wrote: > omnia neo, 09.04.2010 07:01: > > > import siptest > > > I get following error : > > import error : no module named siptest > > Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)? > > Otherwise, Python can't find it. > > Stefan tha

Re: SIP

2010-04-08 Thread Stefan Behnel
omnia neo, 09.04.2010 07:01: import siptest I get following error : import error : no module named siptest Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)? Otherwise, Python can't find it. Stefan -- http://mail.python.org/mailman/listinfo/python-list

SIP

2010-04-08 Thread omnia neo
Hi All, I was looking at the SIP tool to create a C extensions for python to call. Here is what I tried: 1. I created a simple c file and .h file 2. Then I created a corresponding testfunc.sip file ### %CModule siptest 0 %UnitCode #include"testfunc.h" %End void pyfunc()

Re: lambda with floats

2010-04-08 Thread Steven D'Aprano
On Thu, 08 Apr 2010 21:32:10 -0400, monkeys paw wrote: > I was going from example and looking for something useful from the > lambda feature. I come from C -> Perl -> Python (recent). I don't find > lambda very useful yet. Perhaps you feel that lambda is a special kind of object. It isn't. It's

Re: The Regex Story

2010-04-08 Thread Patrick Maupin
On Apr 8, 9:32 pm, Dotan Cohen wrote: > > Regexes do have their uses. It's a case of knowing when they are the > > best approach and when they aren't. > > Agreed. The problems begin when the "when they aren't" is not recognised. Arguing against this is like arguing against motherhood and apple pi

Cleanup guarantees?

2010-04-08 Thread Alf P. Steinbach
Consider ... import urllib.request # urlopen import codecs # getreader import sys # stderr def text_stream_from( url, encoding ): text_reader = codecs.getreader( encoding ) connection = urllib.request.urlopen( url ) return text_reader( connection ) def lis

Re: The Regex Story

2010-04-08 Thread Lie Ryan
On 04/09/10 12:32, Dotan Cohen wrote: >> Regexes do have their uses. It's a case of knowing when they are the >> best approach and when they aren't. > > Agreed. The problems begin when the "when they aren't" is not recognised. But problems also arises when people are suggesting overly complex ser

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/7/2010 12:15 AM, Patrick Maupin wrote: On Apr 6, 11:10 pm, Patrick Maupin wrote: On Apr 6, 11:04 pm, Patrick Maupin wrote: On Apr 6, 10:16 pm, monkeys paw wrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return float ((208

Re: The Regex Story

2010-04-08 Thread Dotan Cohen
> Regexes do have their uses. It's a case of knowing when they are the > best approach and when they aren't. > Agreed. The problems begin when the "when they aren't" is not recognised. -- Dotan Cohen http://bido.com http://what-is-what.com -- http://mail.python.org/mailman/listinfo/python-list

Re: The Regex Story

2010-04-08 Thread MRAB
Dotan Cohen wrote: I would have agreed with you if someone were to make the statement until a few weeks ago; somehow in the last week or so, the mood about regex seems to has shifted to "regex is not suitable for anything" type of mood. As soon as someone (OP or not) proposed a regex solution, so

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/8/2010 7:19 PM, Patrick Maupin wrote: On Apr 8, 6:06 pm, monkeys paw wrote: On 4/7/2010 1:08 PM, Peter Pearson wrote: On Tue, 06 Apr 2010 23:16:18 -0400, monkeys pawwrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return f

Re: order that destructors get called?

2010-04-08 Thread Alf P. Steinbach
* Brendan Miller: Thanks Steven and Gabriel. Those are very informative responses. In my case my resource isn't bound to a lexical scope, but the: def __del__(self, delete_my_resource=delete_my_resource): pattern works quite well. I've made sure to prevent my class from being

Re: The Regex Story

2010-04-08 Thread Dotan Cohen
> I would have agreed with you if someone were to make the statement > until a few weeks ago; somehow in the last week or so, the mood about > regex seems to has shifted to "regex is not suitable for anything" > type of mood. As soon as someone (OP or not) proposed a regex > solution, someone else

Re: order that destructors get called?

2010-04-08 Thread Brendan Miller
Thanks Steven and Gabriel. Those are very informative responses. In my case my resource isn't bound to a lexical scope, but the: def __del__(self, delete_my_resource=delete_my_resource): pattern works quite well. I've made sure to prevent my class from being part of a circular

Re: How to open and read an unknown extension file

2010-04-08 Thread Tim Chase
On 04/08/2010 12:22 PM, varnikat t wrote: it gives me this error TypeError: coercing to Unicode: need string or buffer, list found Thanks for the help.it detects now using glob.glob("*.*.txt") Can u suggest how to open and read file this way? *if glob.glob("*.*.txt"): file=open(gl

Re: Dynamically growing an array to implement a stack

2010-04-08 Thread Patrick Maupin
On Apr 8, 3:54 pm, "M. Hamed" wrote: > Thanks Patrick, that is what I was exactly looking for. You're welcome! But I have to say, you should consider what Paul and Lie are saying. In general, when I use a stack, I just use append() and pop(), as they mention, and let the list automagically keep

Re: pass object or use self.object?

2010-04-08 Thread Lie Ryan
On 04/08/10 18:20, Bruno Desthuilliers wrote: > Lie Ryan a écrit : >> On 04/07/10 18:34, Bruno Desthuilliers wrote: >>> Lie Ryan a écrit : >>> (snip) >>> Since in function in python is a first-class object, you can instead do something like: def process(document): # not

Re: Performance of list vs. set equality operations

2010-04-08 Thread Patrick Maupin
On Apr 8, 6:35 pm, "Gabriel Genellina" wrote: > The CPython source contains lots of shortcuts like that. Perhaps the   > checks should be stricter in some cases, but I imagine it's not so easy to   > fix: lots of code was written in the pre-2.2 era, assuming that internal   > types were not subcl

Re: Pythonic list reordering

2010-04-08 Thread Chris Rebert
On Thu, Apr 8, 2010 at 4:01 PM, Joaquin Abian wrote: > On Apr 9, 12:52 am, Ben Racine wrote: >> I have a list... >> >> ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', >> 'dir_330_error.dat'] >> >> I want to sort it based upon the numerical value only. >> >> Does someone have an eleg

Re: daemon.DaemonContext

2010-04-08 Thread Ben Finney
Rebelo writes: > i found a crude workaround: > i wrote a function in which i start logging after deamon starts That seems rather sub-optimal; you'll be unable to use the logger for anything before the daemon context opens. This kind of problem is exactly what ‘DaemonContext.files_preserve’ is in

Preserving logging streams through a daemon.DaemonContext switch (was: daemon.DaemonContext)

2010-04-08 Thread Ben Finney
Vinay Sajip writes: > On Apr 8, 1:58 pm, Rebelo wrote: > > Vinay Sajip wrote: > > > My guess is - files_preserve needs to be passed a file handle and > > > not alogginghandler. This is correct. As the ‘DaemonContext.__init__’ docstring says:: | `files_preserve` | :Default: ``None`` |

Re: Pythonic list reordering

2010-04-08 Thread Lie Ryan
On 04/09/10 08:52, Ben Racine wrote: > I have a list... > > ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', > 'dir_330_error.dat'] > > I want to sort it based upon the numerical value only. > > Does someone have an elegant solution to this? > > Thanks, > Ben R. list.sort() and s

Re: Why these don't work??

2010-04-08 Thread Lie Ryan
On 04/09/10 06:36, Robert Kern wrote: > On 2010-04-08 15:08 PM, M. Hamed wrote: > >> On the other hand (other than installing NumPy) is there a built-in >> way to do an array full of zeros or one just like the numpy.zeros()? I >> know I can do it with list comprehension (like [0 for i in >> range(

Re: Dynamically growing an array to implement a stack

2010-04-08 Thread Lie Ryan
On 04/09/10 06:54, M. Hamed wrote: > Thanks Patrick, that is what I was exactly looking for. > > Paul, thanks for your example. wasn't familiar with the stack class. The stack class is nothing but a wrapper that renames append() to push(); everything you need can be fulfilled by the regular list

Re: Performance of list vs. set equality operations

2010-04-08 Thread Gabriel Genellina
En Thu, 08 Apr 2010 04:07:53 -0300, Steven D'Aprano escribió: On Wed, 07 Apr 2010 20:14:23 -0700, Raymond Hettinger wrote: [Raymond Hettinger] > If the two collections have unequal sizes, then both ways immediately > return unequal. [Steven D'Aprano] Perhaps I'm misinterpreting what you

Re: lambda with floats

2010-04-08 Thread Patrick Maupin
On Apr 8, 6:06 pm, monkeys paw wrote: > On 4/7/2010 1:08 PM, Peter Pearson wrote: > > > > > On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw  wrote: > >> I have the following acre meter which works for integers, > >> how do i convert this to float? I tried > > >> return float ((208.0 * 208.0) * n)

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/7/2010 1:08 PM, Peter Pearson wrote: On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw wrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return float ((208.0 * 208.0) * n) def s(n): ... return lambda x: (208 * 208) * n ... f = s

Re: Pythonic list reordering

2010-04-08 Thread Joaquin Abian
On Apr 9, 12:52 am, Ben Racine wrote: > I have a list... > > ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', > 'dir_330_error.dat'] > > I want to sort it based upon the numerical value only. > > Does someone have an elegant solution to this? > > Thanks, > Ben R. not sure about elega

Re: Pythonic list reordering

2010-04-08 Thread Gary Herron
Ben Racine wrote: I have a list... ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', 'dir_330_error.dat'] I want to sort it based upon the numerical value only. Does someone have an elegant solution to this? Thanks, Ben R. How about a one liner? L.sort(key=lambda s: int

Re: Pythonic list reordering

2010-04-08 Thread Chris Rebert
On Thu, Apr 8, 2010 at 3:52 PM, Ben Racine wrote: > I have a list... > > ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', > 'dir_330_error.dat'] > > I want to sort it based upon the numerical value only. a = ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', 'dir_330_error.

Pythonic list reordering

2010-04-08 Thread Ben Racine
I have a list... ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', 'dir_330_error.dat'] I want to sort it based upon the numerical value only. Does someone have an elegant solution to this? Thanks, Ben R. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating a rainbow?

2010-04-08 Thread Chris Colbert
On Thu, Apr 8, 2010 at 2:34 PM, Tobiah wrote: >> How does that answer your original question? > > I was able to do this: > > import colorsys > > sat = 1 > value = 1 > length = 1000 > for x in range(0, length + 1): >        hue = x / float(length) >        color = list(colorsys.hsv_to_rgb(hue, sat,

Re: Generating a rainbow?

2010-04-08 Thread Neil Hodgson
Me: >You should use different variables for the two loops. Actually it is closing the divs that makes it work in FireFox: import colorsys sat = 1 value = 1 length = 1000 for h in range(0, length + 1): hue = h / float(length) color = list(colorsys.hsv_to_rgb(hue, sat, value

Re: Generating a rainbow?

2010-04-08 Thread Neil Hodgson
Tobiah: > for x in range(0, length + 1): > ... > for x in range(3): You should use different variables for the two loops. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: The Regex Story

2010-04-08 Thread Lie Ryan
On 4/9/10, Tim Chase wrote: > Lie Ryan wrote: >> Why am I seeing a lot of this pattern lately: >> >> OP: Got problem with string >> +- A: Suggested a regex-based solution >>+- B: Quoted "Some people ... regex ... two problems." >> >> or >> >> OP: Writes some regex, found problem >> +- A: Quote

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Patrick Maupin
On Apr 8, 3:40 pm, gry wrote: > >    >>> s='555tHe-rain.in#=1234' > >    >>> import re > >    >>> r=re.compile(r'([a-zA-Z]+|\d+|.)') > >    >>> r.findall(s) > >    ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234'] > > This is nice and simple and has the invertible property that Patrick > me

Re: Why these don't work??

2010-04-08 Thread M. Hamed
OMG! That's beautiful! I loved the [0]*n how simple and how it never occurred to me! Robert I agree with your comment. I feel though that since I'm not very experienced yet with Python, it's useful to learn about all those simple yet powerful methods so I can use them when I really need them. Plus

Re: Dynamically growing an array to implement a stack

2010-04-08 Thread M. Hamed
Thanks Patrick, that is what I was exactly looking for. Paul, thanks for your example. wasn't familiar with the stack class. I feel Patrick's method is a lot simpler for my purpose. Regards. On Apr 8, 1:29 pm, Patrick Maupin wrote: > On Apr 8, 3:21 pm, "M. Hamed" wrote: > > > > > I have troubl

Re: python as pen and paper substitute

2010-04-08 Thread Manuel Graune
Giacomo Boffi writes: > Manuel Graune writes: > >> Hello everyone, >> >> I am looking for ways to use a python file as a substitute for simple >> pen and paper calculations. > > search("embedded calc mode") if manuel in emacs_fellows_set or sys.exit(1) Well, the subject does say python and not

Re: regex help: splitting string gets weird groups

2010-04-08 Thread gry
>    >>> s='555tHe-rain.in#=1234' >    >>> import re >    >>> r=re.compile(r'([a-zA-Z]+|\d+|.)') >    >>> r.findall(s) >    ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234'] This is nice and simple and has the invertible property that Patrick mentioned above. Thanks much! -- http://mail.py

Re: Generating a rainbow?

2010-04-08 Thread Peter Parker
Tobiah wrote: How does that answer your original question? I was able to do this: import colorsys sat = 1 value = 1 length = 1000 for x in range(0, length + 1): hue = x / float(length) color = list(colorsys.hsv_to_rgb(hue, sat, value)) for x in range(3):

Re: python as pen and paper substitute

2010-04-08 Thread Giacomo Boffi
Manuel Graune writes: > Hello everyone, > > I am looking for ways to use a python file as a substitute for simple > pen and paper calculations. search("embedded calc mode") if manuel in emacs_fellows_set or sys.exit(1) -- http://mail.python.org/mailman/listinfo/python-list

Re: Why these don't work??

2010-04-08 Thread Joaquin Abian
On Apr 8, 10:08 pm, "M. Hamed" wrote: > Thanks All. That clears alot of confusion. It seems I assumed that > everything that works for lists works for strings (the immutable vs > mutable hasn't sunken in yet). > > On the other hand (other than installing NumPy) is there a built-in > way to do an a

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: regex help: splitting string gets weird groups

2010-04-08 Thread gry
On Apr 8, 3:40 pm, MRAB wrote: ... > Group 1 and group 4 match '='. > Group 1 and group 3 match '1234'. > > If a group matches then any earlier match of that group is discarded, Wow, that makes this much clearer! I wonder if this behaviour shouldn't be mentioned in some form in the python docs?

Re: Why these don't work??

2010-04-08 Thread Robert Kern
On 2010-04-08 15:08 PM, M. Hamed wrote: On the other hand (other than installing NumPy) is there a built-in way to do an array full of zeros or one just like the numpy.zeros()? I know I can do it with list comprehension (like [0 for i in range(0,20)] but these are too many keystrokes for python

Re: Recommend Commercial graphing library

2010-04-08 Thread Giacomo Boffi
Grant Edwards writes: > If it's 2D data, you don't need to use a 3D graph. if it's tabular data, you don't need an uber-histogram -- giampippetto, coso, come si chiama? ah si` "MMAX" ha scritto: > Tra il trascendente e l'interpretazione prevalente del dato come > assioma ne passa... -- http://

Re: Dynamically growing an array to implement a stack

2010-04-08 Thread Patrick Maupin
On Apr 8, 3:21 pm, "M. Hamed" wrote: > I have trouble with some Python concept. The fact that you can not > assign to a non-existent index in an array. For example: > > a = [0,1] > a[2] => Generates an error > > I can use a.append(2) but that always appends to the end. Sometimes I > want t

Re: Dynamically growing an array to implement a stack

2010-04-08 Thread Paul McGuire
On Apr 8, 3:21 pm, "M. Hamed" wrote: > I have trouble with some Python concept. The fact that you can not > assign to a non-existent index in an array. For example: > > a = [0,1] > a[2] => Generates an error > > I can use a.append(2) but that always appends to the end. Sometimes I > want t

Re: Why these don't work??

2010-04-08 Thread Emile van Sebille
On 4/8/2010 1:08 PM M. Hamed said... On the other hand (other than installing NumPy) is there a built-in way to do an array full of zeros or one just like the numpy.zeros()? I know I can do it with list comprehension (like [0 for i in range(0,20)] but these are too many keystrokes for python :) I

Dynamically growing an array to implement a stack

2010-04-08 Thread M. Hamed
I have trouble with some Python concept. The fact that you can not assign to a non-existent index in an array. For example: a = [0,1] a[2] => Generates an error I can use a.append(2) but that always appends to the end. Sometimes I want to use this array as a stack and hence my indexing lo

Re: Why these don't work??

2010-04-08 Thread M. Hamed
Thanks All. That clears alot of confusion. It seems I assumed that everything that works for lists works for strings (the immutable vs mutable hasn't sunken in yet). On the other hand (other than installing NumPy) is there a built-in way to do an array full of zeros or one just like the numpy.zero

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Tim Chase
gry wrote: [ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.',

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Patrick Maupin
On Apr 8, 1:49 pm, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: regex help: splitting string gets weird groups

2010-04-08 Thread MRAB
gry wrote: [ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.',

regex help: splitting string gets weird groups

2010-04-08 Thread gry
[ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.', 'in', '#', '=

Re: ftp and python

2010-04-08 Thread John Nagle
Anssi Saari wrote: John Nagle writes: In theory, the FTP spec supports "three-way transfers", where the source, destination, and control can all be on different machines. But no modern implementation supports that. I remember even using that way back when, Unix machines in the 1990s.

Re: Why these don't work??

2010-04-08 Thread MRAB
M. Hamed wrote: I'm trying the following statements that I found here and there on Google, but none of them works on my Python 2.5, are they too old? or newer? "abc".reverse() Lists have a .reverse() method which reverses the list elements in-place, but strings don't because they're immutable.

Re: Generating a rainbow?

2010-04-08 Thread Tobiah
> How does that answer your original question? I was able to do this: import colorsys sat = 1 value = 1 length = 1000 for x in range(0, length + 1): hue = x / float(length) color = list(colorsys.hsv_to_rgb(hue, sat, value)) for x in range(3): color[x] = in

Re: Why these don't work??

2010-04-08 Thread Mark Dickinson
On Apr 8, 7:10 pm, "M. Hamed" wrote: > I'm trying the following statements that I found here and there on > Google, but none of them works on my Python 2.5, are they too old? or > newer? > > "abc".reverse() This isn't valid Python in any version that I'm aware of. Where did you see it? It would

Re: Why these don't work??

2010-04-08 Thread nn
M. Hamed wrote: > I'm trying the following statements that I found here and there on > Google, but none of them works on my Python 2.5, are they too old? or > newer? > > "abc".reverse() > import numpy reverse does not work on strings but does work on lists: >>> x=list("abc") >>> x.reverse() >>>

Re: How to open and read an unknown extension file

2010-04-08 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 10:39 PM, varnikat t wrote: > Hey, > Thanks for the help.it detects now using glob.glob("*.*.txt") > Can u suggest how to open and read file this way? > > if glob.glob("*.*.txt"): >             file=open(glob.glob("*.*.txt")) >             self.text_view.get_buffer().set_tex

Re: pass object or use self.object?

2010-04-08 Thread Tim Arnold
On Apr 8, 4:20 am, Bruno Desthuilliers wrote: > Lie Ryan a écrit : > > > > > > > On 04/07/10 18:34, Bruno Desthuilliers wrote: > >> Lie Ryan a écrit : > >> (snip) > > >>> Since in function in python is a first-class object, you can instead do > >>> something like: > > >>> def process(document): >

Why these don't work??

2010-04-08 Thread M. Hamed
I'm trying the following statements that I found here and there on Google, but none of them works on my Python 2.5, are they too old? or newer? "abc".reverse() import numpy -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing Periods with Backspaces

2010-04-08 Thread Gabriel Genellina
En Thu, 08 Apr 2010 12:26:56 -0300, Booter escribió: I am trying to replace a series of periods in a sting with backspaces that way I can easily parse information from a Windows command. the current statement I have for this is ***Statement*

Re: Py3: Read file with Unicode characters

2010-04-08 Thread Gnarlodious
On Apr 8, 11:04 am, "Martin v. Loewis" wrote: > That's because you need to re-learn some things. Apparently so, every little item is a lesson. Thank you. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating a rainbow?

2010-04-08 Thread Chris Colbert
On Thu, Apr 8, 2010 at 1:14 PM, Tobiah wrote: >> Look at the colorsys module. >> >> http://docs.python.org/library/colorsys.html?highlight=colorsys#module- > colorsys > > That so rocks.  Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > How does that answer your original questi

Re: Generating a rainbow?

2010-04-08 Thread Gary Herron
Tobiah wrote: I'm having a difficult time with this. I want to display a continuous range of hues using HTML hex representation (#RRGGBB). How would I go about scanning through the hues in order to make a rainbow? Thanks, Toby Use the hue-saturation-value color space, and call hsv_to_r

Re: How to open and read an unknown extension file

2010-04-08 Thread varnikat t
it gives me this error TypeError: coercing to Unicode: need string or buffer, list found On Thu, Apr 8, 2010 at 10:48 PM, varnikat t wrote: > > > > > Hey, > Thanks for the help.it detects now using glob.glob("*.*.txt") > Can u suggest how to open and read file this way? > > *if glob.glob("*.*.

How to open and read an unknown extension file

2010-04-08 Thread varnikat t
Hey, Thanks for the help.it detects now using glob.glob("*.*.txt") Can u suggest how to open and read file this way? *if glob.glob("*.*.txt"): file=open(glob.glob("*.*.txt")) self.text_view.get_buffer().set_text(file.read()) else: file=open(glob.glob("*

Re: Generating a rainbow?

2010-04-08 Thread Tobiah
> Look at the colorsys module. > > http://docs.python.org/library/colorsys.html?highlight=colorsys#module- colorsys That so rocks. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating a rainbow?

2010-04-08 Thread Richard Thomas
On Apr 8, 5:46 pm, Tobiah wrote: > I'm having a difficult time with this.  I want > to display a continuous range of hues using HTML > hex representation (#RRGGBB).  How would I go > about scanning through the hues in order to > make a rainbow? > > Thanks, > > Toby Look at the colorsys module. h

Re: Generating a rainbow?

2010-04-08 Thread Chris Colbert
On Thu, Apr 8, 2010 at 12:46 PM, Tobiah wrote: > I'm having a difficult time with this.  I want > to display a continuous range of hues using HTML > hex representation (#RRGGBB).  How would I go > about scanning through the hues in order to > make a rainbow? > > Thanks, > > Toby > -- > http://mail

Re: Py3: Read file with Unicode characters

2010-04-08 Thread Martin v. Loewis
Gnarlodious wrote: > On Apr 8, 9:14 am, "Martin v. Loewis" wrote: > >> When opening the file, you need to specify the file encoding. > > OK, I had tried this: > > open(path, 'r').read().encode('utf-8') No, when *opening* the file, you need to specify the encoding: open(path, 'r', encoding='utf

Generating a rainbow?

2010-04-08 Thread Tobiah
I'm having a difficult time with this. I want to display a continuous range of hues using HTML hex representation (#RRGGBB). How would I go about scanning through the hues in order to make a rainbow? Thanks, Toby -- http://mail.python.org/mailman/listinfo/python-list

Re: How to open and read an unknown extension file

2010-04-08 Thread Steven Howe
On 04/08/2010 08:57 AM, Chris Colbert wrote: On Thu, Apr 8, 2010 at 11:42 AM, Kushal Kumaran wrote: On Thu, Apr 8, 2010 at 9:00 PM, varnikat t wrote: I am trying to do this if os.path.exists("*.*.txt"): file=open("*.*.txt") self.text_view.get_buffer().set_

Re: fcntl, serial ports and serial signals on RS232.

2010-04-08 Thread Grant Edwards
On 2010-04-08, Anssi Saari wrote: > It seems to me also that RTS is always on after the port has been > opened. I didn't dig out my voltmeter or anything to check this, > though. IIRC, that's generally true: RTS and DTR are both set to "on" by the tty layer's open() handler _if_ the device's use

Re: fcntl, serial ports and serial signals on RS232.

2010-04-08 Thread Grant Edwards
On 2010-04-07, Max Kotasek wrote: > I'm trying to figure out how to parse the responses from fcntl.ioctl() > calls that modify the serial lines in a way that asserts that the line > is now changed. Two comments: 1) None of the Linux serial drivers I've worked on return line states except

Re: ftp and python

2010-04-08 Thread Anssi Saari
John Nagle writes: > In theory, the FTP spec supports "three-way transfers", where the > source, destination, and control can all be on different machines. > But no modern implementation supports that. I remember even using that way back when, Unix machines in the 1990s. But, server to ser

catch clipboard status in gnome

2010-04-08 Thread Tracubik
Hi all, i'ld like to create an gnome applet in python that, if left-clicked, perform a particular operation using the text of the clipboard. i've found this example: import pygtk pygtk.require('2.0') import gtk # get the clipboard clipboard = gtk.clipboard_get() # read the clipboard text data.

Re: How to open and read an unknown extension file

2010-04-08 Thread Chris Colbert
On Thu, Apr 8, 2010 at 11:42 AM, Kushal Kumaran wrote: > On Thu, Apr 8, 2010 at 9:00 PM, varnikat t wrote: >> I am trying to do this >> if os.path.exists("*.*.txt"): >>             file=open("*.*.txt") >>             self.text_view.get_buffer().set_text(file.read()) >> else: >>             file=o

Re: fcntl, serial ports and serial signals on RS232.

2010-04-08 Thread Anssi Saari
Max Kotasek writes: > Hello to all out there, > > I'm trying to figure out how to parse the responses from fcntl.ioctl() > calls that modify the serial lines in a way that asserts that the line > is now changed. For example I may want to drop RTS explicitly, and > assert that the line has been d

Re: Py3: Read file with Unicode characters

2010-04-08 Thread Gnarlodious
On Apr 8, 9:14 am, "Martin v. Loewis" wrote: > When opening the file, you need to specify the file encoding. OK, I had tried this: open(path, 'r').read().encode('utf-8') however I get error TypeError: Can't convert 'bytes' object to str implicitly I had assumed a Unicode string was a Unicode

Re: How to open and read an unknown extension file

2010-04-08 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 9:00 PM, varnikat t wrote: > I am trying to do this > if os.path.exists("*.*.txt"): >             file=open("*.*.txt") >             self.text_view.get_buffer().set_text(file.read()) > else: >             file=open("*.*.html") >             self.text_view.get_buffer().set_te

Re: python grep

2010-04-08 Thread Stefan Behnel
Mag Gam, 08.04.2010 14:21: On Thu, Apr 8, 2010 at 7:31 AM, Stefan Behnel wrote: Mag Gam, 08.04.2010 13:21: I am in the process of reading a zipped file which is about 6gb. I would like to know if there is a command similar to grep in python because I would like to emulate, -A -B option of GNU

How to open and read an unknown extension file

2010-04-08 Thread varnikat t
I am trying to do this if os.path.exists("*.*.txt"): file=open("*.*.txt") self.text_view.get_buffer().set_text(file.read()) else: file=open("*.*.html") self.text_view.get_buffer().set_text(file.read()) It gives error *.*.txt not existingThere are

Replacing Periods with Backspaces

2010-04-08 Thread Booter
All, I am trying to replace a series of periods in a sting with backspaces that way I can easily parse information from a Windows command. the current statement I have for this is ***Statement capture = re.sub('\.*', '\b', capture) ===

Re: Performance of list vs. set equality operations

2010-04-08 Thread Raymond Hettinger
[Steven D'Aprano] > So what happens in my example with a subclass that (falsely) reports a > different length even when the lists are the same? > > I can guess that perhaps Py_SIZE does not call the subclass __len__ > method, and therefore is not fooled by it lying. Is that the case? Yes. Py_SIZE

Re: Py3: Read file with Unicode characters

2010-04-08 Thread Martin v. Loewis
Gnarlodious wrote: > Attempting to read a file containing Unicode characters such as ±: > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position > 5007: ordinal not in range(128) > > I did succeed by converting all the characters to HTML entities such > as "±", but I want the charact

Re: get objects from image

2010-04-08 Thread Chris Colbert
lookup "connected component labeling" in a machine vision book. On Thu, Apr 8, 2010 at 9:57 AM, Chris Hulan wrote: > On Apr 8, 9:17 am, Jannis Syntychakis wrote: >> Hallo Everybody, >> >> Maybe you can help me with this: >> >> i have a picture. The picture is black, with some white objects. >> >

Py3: Read file with Unicode characters

2010-04-08 Thread Gnarlodious
Attempting to read a file containing Unicode characters such as ±: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 5007: ordinal not in range(128) I did succeed by converting all the characters to HTML entities such as "±", but I want the characters to be the actual font in th

Re: How to call application in the background with subprocess.call

2010-04-08 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 7:39 PM, jorma kala wrote: > Hi, > > I'd like to call an external application (firefox) from a python program (a > PyQT GUI), but I want the external application to run in the background, I > mean I do not want my python calling program to wait till the external > subprocess

Re: The Regex Story

2010-04-08 Thread Tim Chase
Lie Ryan wrote: Why am I seeing a lot of this pattern lately: OP: Got problem with string +- A: Suggested a regex-based solution +- B: Quoted "Some people ... regex ... two problems." or OP: Writes some regex, found problem +- A: Quoted "Some people ... regex ... two problems." +- B: Sup

  1   2   >