Re: "for" cycle with assigning index

2009-08-15 Thread dmitrey
Thanks all, especially Dennis for your detailed answer. left_arr_indexes is list of nonnegative integers, eg [0,0,0,1,1,4] IndDict is a dict like {0: [1,2], 3: [0,1], 10:[0,2,3]}, so that's why I don't use python list instead. The code is taken from OpenOpt framework that I develop. Currently I hav

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread Emmanuel Surleau
> Dr. Phillip M. Feldman wrote: [snip] > > def is_prime(n): > >for j in range(2,n): > > if (n % j) == 0: return False > >return True > > > > It seems as though Python is actually expanding range(2,n) into a list of > > numbers, even though this is incredibly wasteful of memory. Ther

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread John Nagle
Hendrik van Rooyen wrote: On Saturday 15 August 2009 14:40:35 Michael Ströder wrote: Hendrik van Rooyen wrote: In the past, on this group, I have made statements that said that on Linux, the serial port handling somehow does not allow transmitting and receiving at the same time, and nobody con

Re: Pygresql, and query meta informations

2009-08-15 Thread Tim Roberts
durumdara wrote: > >Pygresql, DB-API. > >I search for a solution to get meta information about last query, >because I must export these infos to Delphi. > >Delphi have TDataSet, and it have meta structure that must be defined >before I create it. >For char/varchar fields I must define their sizes!

Xah's Edu Corner: The importance of syntax & notations.

2009-08-15 Thread Xah Lee
Xah's Edu Corner: The importance of syntax & notations. http://www.stephenwolfram.com/publications/recent/mathml/mathml_abstract.html this article should teach the coding sophomorons and computer “science” idiotic authors who harbor the notion that syntax is not important, picked up by all the el

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 16, 1:05 am, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: > > So, as far as I can tell, Python has no real authority to throw stones > > at C++ on this little tiny particular issue. > I think you're being a tad over-defensive. Defensive? Personally, I p

Re: Python or ActionScript 3.0

2009-08-15 Thread Michel Claveau - MVP
Hi! > Python doesn't run in your typical web browser Yes, Python can do it... on Windows. Two (examples) ways: - ActiveScripting (PythonScript), include in PyWin32 - Gestalt (who mix Python, Ruby & Javascript, via Silverlight) And alse, these two solutions run OK in HTA (HTml Application) fo

Re: redoing libgmail interface to "smtplib" blah?

2009-08-15 Thread John Haggerty
I did detect one problem thus far File "test.py", line 152 if len(args) == 1 and args[0] = "-c": On Sat, Aug 15, 2009 at 7:23 PM, Dennis Lee Bieber wrote: > On Sat, 15 Aug 2009 14:23:26 -0600, John Haggerty > declaimed the following in gmane.comp.python.general: > > > The following progra

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: > So, as far as I can tell, Python has no real authority to throw stones > at C++ on this little tiny particular issue. I think you're being a tad over-defensive. I asked a genuine question about a quote in somebody's signature. That's a qu

Re: Komodo(!)

2009-08-15 Thread Kee Nethery
On Aug 14, 2009, at 1:55 PM, William wrote: Personally, I rather like Wing I tried Wing and basically as a newbie, there were too many setup parameters that I did not know how to set correctly and I could never get it to work for me. It runs under X11 and I guess that was just a bit too

Re: Python or ActionScript 3.0

2009-08-15 Thread Sebastian Bassi
On Sat, Aug 15, 2009 at 10:29 PM, Douglas Alan wrote: > Python doesn't run in your typical web browser, but it is common to > use Python for doing the server-side programming, along with a Python- > based web development framework, such as Django. > You could use Jython to make a JVM applet that wo

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread John Haggerty
Erlang I assume is a computer programming language? On Sat, Aug 15, 2009 at 10:18 PM, Paul Rubin wrote: > Dennis Lee Bieber writes: > > No language can guard against independent access of a shared/global > > object by multiple threads... > > Erlang? > -- > htt

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread Paul Rubin
Dennis Lee Bieber writes: > No language can guard against independent access of a shared/global > object by multiple threads... Erlang? -- http://mail.python.org/mailman/listinfo/python-list

Re: ignored test cases in unittest

2009-08-15 Thread Terry Yin
Yes, should be more than 200. But now 187+ are running (some are 'ignored').It's a personal project, I just don't feel safe without all the testing as it grows bigger and bigger. On Sun, Aug 16, 2009 at 11:40 AM, John Haggerty wrote: > So you are saying you have several hundred tests you have t

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread John Haggerty
On Sat, Aug 15, 2009 at 7:23 PM, Dennis Lee Bieber wrote: > On Sat, 15 Aug 2009 14:34:36 -0600, John Haggerty > declaimed the following in gmane.comp.python.general: > > > What does the term "thread safe" mean exactly. I never had to program > with > > "threads" before > > That, part way

Re: Python or ActionScript 3.0

2009-08-15 Thread John Haggerty
If it were me I'd go with python at least based on the fact that it's more supported and more popular, enough so that it has o'reiley soruces on it. On Sat, Aug 15, 2009 at 3:32 PM, Jaseem wrote: > Hi, > > Is python similar to actionscript 3.0 > Which is better to create a rich gui internet appl

Re: ignored test cases in unittest

2009-08-15 Thread John Haggerty
So you are saying you have several hundred tests you have to do on your program? On Sat, Aug 15, 2009 at 7:04 PM, Terry wrote: > Hi, > > I have some 100s unittest cases with my python program. And sometimes, > I did quick-and-dirty work by ignoring some test cases by adding an > 'x' (or somethin

Re: unittest

2009-08-15 Thread John Haggerty
This is an interesting question. I am just wondering: do you really have that many features that it would be impossible to just have a shell script run specific types of input or tests? When I did programming in the past for education they just had lists of input data and we ran the program agains

Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-15 Thread John Haggerty
I would have to agree with that since I've had to work with Word 2007 issues with formatting from some...demanding people in the past. Took at least 1hour plus. On Sat, Aug 15, 2009 at 8:22 PM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > On Sat, 15 Aug 2009 12:24:26 -0700, Jo

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 15, 10:19 pm, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 13:01:43 -0700, Douglas Alan wrote: > > P.S. I find it strange, however, that anyone who is not okay with > > "abusing" operator overloading in this manner, wouldn't also take > > umbrage at Python's overloading of "+" to work with

Re: redoing libgmail interface to "smtplib" blah?

2009-08-15 Thread John Haggerty
On Sat, Aug 15, 2009 at 7:23 PM, Dennis Lee Bieber wrote: > On Sat, 15 Aug 2009 14:23:26 -0600, John Haggerty > declaimed the following in gmane.comp.python.general: > > > The following program is theoretically supposed to use a supported > library. > > Issues have come up where the library is no

Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 12:24:26 -0700, John Nagle wrote: > fortunatus wrote: >> On Aug 14, 1:01 pm, vippstar wrote: >>> Why would you fill your website with junk? >> >> The OP made it clear: >> >>> Just wanted to express some frustration with whitespace-mode. > > Well, it took until Python 3.

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 13:01:43 -0700, Douglas Alan wrote: > P.S. I find it strange, however, that anyone who is not okay with > "abusing" operator overloading in this manner, wouldn't also take > umbrage at Python's overloading of "+" to work with strings and lists, > etc. Numerical addition and seq

Re: ignored test cases in unittest

2009-08-15 Thread Ben Finney
Terry writes: > It seemed the to me that python unittest module does not support the > counting of ignored test cases directly. Is there any ready solution > for this? One solution I've seen involves: * a custom exception class, ‘TestSkipped’ * raising that exception at the top of test cases y

Re: Python- javascript

2009-08-15 Thread Douglas Alan
On Aug 15, 8:02 pm, Mike Paul wrote: > I'm trying to scrap a dynamic page with lot of javascript in it. > Inorder to get all the data from the page i need to access the > javascript. But i've no idea how to do it. I'm not sure exactly what you are trying to do, but scraping websites that use a l

Re: OptionParser How to: prog [options] [arguments]

2009-08-15 Thread Steven Woody
Thanks for all you suggestions! -- http://mail.python.org/mailman/listinfo/python-list

Re: Python or ActionScript 3.0

2009-08-15 Thread Douglas Alan
On Aug 15, 5:32 pm, Jaseem wrote: > Is python similar to actionscript 3.0 For some very rough sense of "similar" it might be, but not really. > Which is better to create a rich gui internet application? > Is it AS 3.0 with flex or python with its GUI libs? Python doesn't run in your typical we

Re: ignored test cases in unittest

2009-08-15 Thread Roy Smith
In article , Terry wrote: > Hi, > > I have some 100s unittest cases with my python program. And sometimes, > I did quick-and-dirty work by ignoring some test cases by adding an > 'x' (or something else) to the beginning of the case name. > As time pass by, it's very hard for me to find which t

ignored test cases in unittest

2009-08-15 Thread Terry
Hi, I have some 100s unittest cases with my python program. And sometimes, I did quick-and-dirty work by ignoring some test cases by adding an 'x' (or something else) to the beginning of the case name. As time pass by, it's very hard for me to find which test cases are ignored. It seemed the to m

Re: Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread John Machin
On Aug 16, 2:41 am, Mark Dickinson wrote: > and got the expected memory usage for my Python process, as > displayed by top:  memory usage went up to nearly 1Gb after > each assignment to b, then dropped down to 19 Mb or so after > each 'del b'.  I get similar results under Python 2.5. > > So maybe

Re: Unrecognized escape sequences in string literals

2009-08-15 Thread Douglas Alan
On Aug 14, 1:55 pm, Steven D'Aprano wrote: > Douglas, you and I clearly have a difference of opinion on > this. Neither of us have provided even the tiniest amount > of objective, replicable, reliable data on the > error-proneness of the C++ approach versus that of > Python. The supposed superior

Python - scraping - javascript

2009-08-15 Thread Mike Paul
I'm trying to scrap a dynamic page with lot of javascript in it. Inorder to get all the data from the page i need to access the javascript. But i've no idea how to do it. Say I'm scraping some site htttp://www.xyz.com/xyz request=urllib2.Request("htttp://www.xyz.com/xyz") response=urllib2.urlopen

Python- javascript

2009-08-15 Thread Mike Paul
I'm trying to scrap a dynamic page with lot of javascript in it. Inorder to get all the data from the page i need to access the javascript. But i've no idea how to do it. Say I'm scraping some site htttp://www.xyz.com/xyz request=urllib2.Request("htttp://www.xyz.com/xyz") response=urllib2.urlopen

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 15, 6:28 pm, MRAB wrote: > >      >>> for z in ["75096042068045", "509", "12024", "7", "2009"]: > >            print re.sub(r"(?<=.)(?=(?:...)+$)", ",", z) > > >     75,096,042,068,045 > >     509 > >     12,024 > >     7 > >     2,009 > > The call replaces a zero-width match with a comma,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread MRAB
Brian wrote: On Sat, Aug 15, 2009 at 4:06 PM, MRAB > wrote: ryles wrote: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substr

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Brian
On Sat, Aug 15, 2009 at 4:06 PM, MRAB wrote: > ryles wrote: > >> On Aug 14, 8:22 pm, candide wrote: >> >>> Suppose you need to split a string into substrings of a given size >>> (except >>> possibly the last substring). I make the hypothesis the first slice is at >>> the >>> end of the string. >

Re: Splitting a string into substrings of equal size

2009-08-15 Thread MRAB
ryles wrote: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with thousands

Re: PyQt4.__file__ gives PyQt4/__init__.py as value

2009-08-15 Thread wgw
On Aug 15, 2:19 pm, Christian Heimes wrote: > wgw wrote: > > I don't understand why the __file__ value in my installation of PyQt > > would not give a proper, full path. > > > I'm guessing that I did not install pyqt properly (I'm on Ubuntu > > Hardy, trying to install QT4.5), but before redoing t

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 14, 8:22 pm, candide wrote: > Suppose you need to split a string into substrings of a given size (except > possibly the last substring). I make the hypothesis the first slice is at the > end of the string. > A typical example is provided by formatting a decimal string with thousands > separ

Python or ActionScript 3.0

2009-08-15 Thread Jaseem
Hi, Is python similar to actionscript 3.0 Which is better to create a rich gui internet application? Is it AS 3.0 with flex or python with its GUI libs? Is python in demand? Heard that python is similar to lisp. But both python and AS 3.0 is almost identical. Which is more similar to lisp are pow

Re: PyQt4.__file__ gives PyQt4/__init__.py as value

2009-08-15 Thread Christian Heimes
wgw wrote: I don't understand why the __file__ value in my installation of PyQt would not give a proper, full path. I'm guessing that I did not install pyqt properly (I'm on Ubuntu Hardy, trying to install QT4.5), but before redoing the install, I want to see if there is a quicker fix. Some ve

Re: Why is "unpacking" of tuples only allowed when there's 1 tupple ?

2009-08-15 Thread Stef Mientki
thanks Jan, for the clear explanation. cheers, Stef Jan Kaliszewski wrote: Dnia 15-08-2009 o 22:50:39 Stef Mientki napisał(a): hello, I'm not sure if "unpacking" is the right term but if I have a tuple of 2 arrays, I can either call a function with: Space_State = tf2ss ( filt[0]

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread MRAB
John Nagle wrote: Hendrik van Rooyen wrote: On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote: And while you are about it, you may as well teach them that it is much better to do a multiplication than a division. Actually, division speed hasn't been much of an issue in yea

Re: Why is "unpacking" of tuples only allowed when there's 1 tupple ?

2009-08-15 Thread Jan Kaliszewski
Dnia 15-08-2009 o 22:50:39 Stef Mientki napisał(a): hello, I'm not sure if "unpacking" is the right term but if I have a tuple of 2 arrays, I can either call a function with: Space_State = tf2ss ( filt[0], filt[1] ) or with Space_State = tf2ss ( *filt ) Now if I've to

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread Alan G Isaac
> On Aug 15, 12:49 pm, Alan G Isaac wrote: >> Quotinghttp://docs.python.org/3.1/library/random.html#random.gauss: >> Gaussian distribution. mu is the mean, and sigma is the >> standard deviation. This is slightly faster than the >> normalvariate() function defined below. >> >> So since

Why is "unpacking" of tuples only allowed when there's 1 tupple ?

2009-08-15 Thread Stef Mientki
hello, I'm not sure if "unpacking" is the right term but if I have a tuple of 2 arrays, I can either call a function with: Space_State = tf2ss ( filt[0], filt[1] ) or with Space_State = tf2ss ( *filt ) Now if I've to call a function with more parameters, why can't I use (Pol

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread John Haggerty
What does the term "thread safe" mean exactly. I never had to program with "threads" before On Sat, Aug 15, 2009 at 2:26 PM, Carl Banks wrote: > On Aug 15, 12:49 pm, Alan G Isaac wrote: > > Quotinghttp://docs.python.org/3.1/library/random.html#random.gauss: > > Gaussian distribution. mu is t

redoing libgmail interface to "smtplib" blah?

2009-08-15 Thread John Haggerty
The following program is theoretically supposed to use a supported library. Issues have come up where the library is not working and now another interface is being requierd to be used. At this point I'm looking at just changing the send commands but don't feel confident in doing so. Wondering spec

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread Carl Banks
On Aug 15, 12:49 pm, Alan G Isaac wrote: > Quotinghttp://docs.python.org/3.1/library/random.html#random.gauss: >     Gaussian distribution. mu is the mean, and sigma is the >     standard deviation. This is slightly faster than the >     normalvariate() function defined below. > > So since both ar

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Mark Tolonen
"Gregor Lingl" wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for i

PyQt4.__file__ gives PyQt4/__init__.py as value

2009-08-15 Thread wgw
I don't understand why the __file__ value in my installation of PyQt would not give a proper, full path. I'm guessing that I did not install pyqt properly (I'm on Ubuntu Hardy, trying to install QT4.5), but before redoing the install, I want to see if there is a quicker fix. Also, though PyQt4/ i

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread John Haggerty
I guess the problem is---does it actually matter? On Fri, Aug 14, 2009 at 10:11 AM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > > > "I saw `cout' being shifted "Hello world" times to the left and stopped > > right there." --S

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 14, 10:25 pm, Dave Angel wrote: > Benjamin Kaplan wrote: > > On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan wrote: > >> P.S. Overloading "left shift" to mean "output" does indeed seem a bit > >> sketchy, but in 15 years of C++ programming, I've never seen it cause > >> any confusion or b

Re: getting the fractional part of a real?

2009-08-15 Thread Roy Smith
In article <4a8704ca$0$2292$91cee...@newsreader02.highway.telekom.at>, Gregor Lingl wrote: > Christian Heimes schrieb: > > Roy Smith schrieb: > >> What's the best way to get the fractional part of a real? The two > >> ways I can see are r % 1 and r = int(r), but both seem a bit hokey. > >> I

random.gauss vs. random.normalvariate

2009-08-15 Thread Alan G Isaac
Quoting http://docs.python.org/3.1/library/random.html#random.gauss: Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate() function defined below. So since both are offered and gauss is faster, I assume it must have

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread John Nagle
Hendrik van Rooyen wrote: On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote: And while you are about it, you may as well teach them that it is much better to do a multiplication than a division. Actually, division speed hasn't been much of an issue in years. Arithmetic has

Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-15 Thread John Nagle
fortunatus wrote: On Aug 14, 1:01 pm, vippstar wrote: Why would you fill your website with junk? The OP made it clear: Just wanted to express some frustration with whitespace-mode. Well, it took until Python 3.0 until Python enforced rules that ensured that the indentation the user see

Re: getting the fractional part of a real?

2009-08-15 Thread Gregor Lingl
Christian Heimes schrieb: Roy Smith schrieb: What's the best way to get the fractional part of a real? The two ways I can see are r % 1 and r = int(r), but both seem a bit hokey. Is there something more straight-forward that I'm missing, like fraction(r)? import math math.modf(1.5) (0.5,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for ii in range(0,len(jj),3)]) '123,456,789,012,345,678,9' >>> Emile Less beautiful but more correct:

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: getting the fractional part of a real?

2009-08-15 Thread Mark Dickinson
On Aug 15, 7:40 pm, Christian Heimes wrote: > Roy Smith schrieb: > > > What's the best way to get the fractional part of a real?  The two ways I > > can see are r % 1 and r = int(r), but both seem a bit hokey.  Is there > > something more straight-forward that I'm missing, like fraction(r)? > >>>

Re: getting the fractional part of a real?

2009-08-15 Thread Christian Heimes
Roy Smith schrieb: What's the best way to get the fractional part of a real? The two ways I can see are r % 1 and r = int(r), but both seem a bit hokey. Is there something more straight-forward that I'm missing, like fraction(r)? import math math.modf(1.5) (0.5, 1.0) Christian -- http://m

getting the fractional part of a real?

2009-08-15 Thread Roy Smith
What's the best way to get the fractional part of a real? The two ways I can see are r % 1 and r = int(r), but both seem a bit hokey. Is there something more straight-forward that I'm missing, like fraction(r)? -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Aug 15)

2009-08-15 Thread Gabriel Genellina
QOTW: "They questioned my competence and that made her very sad." - Roger Wallis,expert witness for Pirate Bay, on his wife http://torrentfreak.com/pirate-bay-witness-wife-overwhelmed-with-flowers-090227/ unicode(s) is, surprisingly, MUCH faster (for certain encodings) than s.decode

Re: Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread Christian Heimes
Mark Dickinson wrote: and got the expected memory usage for my Python process, as displayed by top: memory usage went up to nearly 1Gb after each assignment to b, then dropped down to 19 Mb or so after each 'del b'. I get similar results under Python 2.5. I get the same results on Linux: Pyt

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Hendrik van Rooyen
On Saturday 15 August 2009 16:25:03 Grant Edwards wrote: > > Are you using python file operations open/read/write or OS > file-descriptor operations os.open/os.read/os.write? The former - that seems to be the source of my trouble. I have now written a little test that uses serial.Serial and it w

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Emile van Sebille
On 8/14/2009 5:22 PM candide said... Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with thousands separator.

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Hendrik van Rooyen
On Saturday 15 August 2009 14:40:35 Michael Ströder wrote: > Hendrik van Rooyen wrote: > > In the past, on this group, I have made statements that said that on > > Linux, the serial port handling somehow does not allow transmitting and > > receiving at the same time, and nobody contradicted me. >

Re: What's a good solution to implement rich comparison for user-defined classes? (was: What happened to __cmp__() in Python 3.x?)

2009-08-15 Thread Mark Lawrence
Xavier Ho wrote: Never mind my last email. Google actually found me something at last. I also found this page: http://mail.python.org/pipermail/python-list/2008-November/688591.html That still uses a sloppy way of defining the special methods, and a little chunky. Is there a better way for the

Re: What happened to __cmp__() in Python 3.x?

2009-08-15 Thread Mark Lawrence
Xavier Ho wrote: Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six rich comparison methods to work it out? If this question has already been asked som

Re: unittest

2009-08-15 Thread Scott David Daniels
Mag Gam wrote: I am writing an application which has many command line arguments. For example: foo.py -args "bar bee" I would like to create a test suit using unittest so when I add features to "foo.py" I don't want to break other things. I just heard about unittest and would love to use it for

Error: No SSL support included in this Python ?

2009-08-15 Thread kramed
Hi there, I am running Windows on my dev machine and am running into the following error while running Django and my email routines. Exception Type: RuntimeError Exception Value:No SSL support included in this Python Exception Location: C:\Python26\lib\smtplib.py in starttls, l

Re: Python docs disappointing - group effort to hire writers?

2009-08-15 Thread Mark Lawrence
Bill Jones wrote: On Aug 8, 3:27 pm, Mark Lawrence wrote: Kee Nethery wrote: As someone trying to learn the language I want to say that the tone on this list towards people who are trying to learn Python feels like it has become anti-newbies. [snip] Kee Nethery My gut feeling (which could

Re: Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread Mark Dickinson
On Aug 15, 12:55 pm, Chris Withers wrote: > Hi All, > > I thought this was fixed back in Python 2.5, but I guess not? > > So, I'm playing in an interactive session: > >  >>> from xlrd import open_workbook >  >>> b = open_workbook('some.xls',pickleable=0,formatting_info=1) > > At this point, top sh

Re: callable virtual method

2009-08-15 Thread Scott David Daniels
Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote: Sorry guys (means guys *and* gals :op ), I realized I've not been able to describe precisely what I want to do. I'd like the base class to be virtual (aka abstract). However i

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Grant Edwards
On 2009-08-15, Hendrik van Rooyen wrote: > 8< > -PosixSerial.py > > Thanks that looks, on first inspection, similar to the > serialposix.py module in the stdlib, but less cluttered. pyserial is a bit more complex because it is cross-p

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Grant Edwards
On 2009-08-15, Hendrik van Rooyen wrote: > On Friday 14 August 2009 16:03:22 Diez B. Roggisch wrote: > >> You should *really* just use pyserial. No hassle, instant satisfaction. > >:-) I have downloaded and had a quick look, and I see it is > based on the standard library's serial.Serial class - a

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Grant Edwards
On 2009-08-15, Hendrik van Rooyen wrote: > On Friday 14 August 2009 16:19:04 Grant Edwards wrote: > >> What platform are you using? I suppose it's possible that >> there's something broken in the serial driver for that >> particular hardware. > > Your experience seems to be exactly the opposite t

Re: Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread Dave Angel
Chris Withers wrote: Hi All, I thought this was fixed back in Python 2.5, but I guess not? So, I'm playing in an interactive session: >>> from xlrd import open_workbook >>> b = open_workbook('some.xls',pickleable=0,formatting_info=1) At this point, top shows the process usage for python to be

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Jan Kaliszewski
Dnia 15-08-2009 o 08:08:14 Rascal wrote: I'm bored for posting this, but here it is: def add_commas(str): str_list = list(str) str_len = len(str) for i in range(3, str_len, 3): str_list.insert(str_len - i, ',') return ''.join(str_list) For short strings (for sure most

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Michael Ströder
Hendrik van Rooyen wrote: > In the past, on this group, I have made statements that said that on Linux, > the serial port handling somehow does not allow transmitting and receiving at > the same time, and nobody contradicted me. Despite all the good comments here by other skilled people I'd rec

Re: unittest

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 07:32:15 -0400, Mag Gam wrote: > So, in this example: > > "import random" > > In my case I would do "import foo" ? is there anything I need to do for > that? Suppose you have a file mymodule.py containing your code, and you want some unit tests. If you only have a few, y

Re: Splitting a string into substrings of equal size

2009-08-15 Thread candide
Thanks to all for your response. I particularly appreciate Rascal's solution. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread Steven D'Aprano
On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote: > It seems as though Python is actually expanding range(2,n) into a list > of numbers, even though this is incredibly wasteful of memory. There > should be a looping mechanism that generates the index variable values > incrementally

What's a good solution to implement rich comparison for user-defined classes? (was: What happened to __cmp__() in Python 3.x?)

2009-08-15 Thread Xavier Ho
Never mind my last email. Google actually found me something at last. I also found this page: http://mail.python.org/pipermail/python-list/2008-November/688591.html That still uses a sloppy way of defining the special methods, and a little chunky. Is there a better way for the lazy me? Ching-Yu

What happened to __cmp__() in Python 3.x?

2009-08-15 Thread Xavier Ho
Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six rich comparison methods to work it out? If this question has already been asked somewhere, I apologise

Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread Chris Withers
Hi All, I thought this was fixed back in Python 2.5, but I guess not? So, I'm playing in an interactive session: >>> from xlrd import open_workbook >>> b = open_workbook('some.xls',pickleable=0,formatting_info=1) At this point, top shows the process usage for python to be about 500Mb. That's o

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread greg
Terry Reedy wrote: I believe the C standard specifies that the behavior of mixed reads and writes is undefined without intervening seek and/or flush, even if the seek is ignored (as it is on some Unix systems). With two threads, the timing is undetermined. It's also possible that the stdio o

Re: unittest

2009-08-15 Thread Mag Gam
So, in this example: "import random" In my case I would do "import foo" ? is there anything I need to do for that? On Sat, Aug 15, 2009 at 2:24 AM, Richard Thomas wrote: > On Aug 15, 4:28 am, Mag Gam wrote: >> I am writing an application which has many command line arguments. >> For example:

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Hendrik van Rooyen
On Saturday 15 August 2009 04:03:42 Terry Reedy wrote: > greg wrote: > > You can't read and write with the same stdio file object > > at the same time. Odd things tend to happen if you try. > > I believe the C standard specifies that the behavior of mixed reads and > writes is undefined without int

Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-15 Thread Byung-Hee HWANG
Xah Lee writes: > • A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode > http://xahlee.org/UnixResource_dir/writ/emacs_whitespace-mode_problems.html > [... snip 38 lines ...] OK, Xah, thanks for good writing, i'll read it 27 hours later. And i respect for your passion on Elisp, P

Re: get the pause status from amarok 2.1

2009-08-15 Thread Sleepy Cabbage
On Fri, 14 Aug 2009 12:55:07 +0200, Diez B. Roggisch wrote: > Sleepy Cabbage schrieb: >> As the title says, I'm trying to find a way to get the pause status >> from amarok 2.1. >> >> I'm running kubuntu 9.04 with kde 4.2.2, python 2.6.2. >> >> Thanks in advance. > > Not at my linux-system right

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread John Machin
On Aug 15, 11:38 am, Mark Lawrence wrote: > Dr. Phillip M. Feldman wrote:> I wrote the following correct but inefficient > test of primality for purposes > > of demonstrating that the simplest algorithm is often not the most > > efficient.  But, when I try to run the following code with a value o

Re: Python 'for' loop is memory inefficient

2009-08-15 Thread Hendrik van Rooyen
On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote: > It seems as though Python is actually expanding range(2,n) into a list of > numbers, even though this is incredibly wasteful of memory. There should be > a looping mechanism that generates the index variable values incrementally >

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Chris Rebert
On Sat, Aug 15, 2009 at 4:47 AM, Hendrik van Rooyen wrote: > On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: >> On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: >> > "I saw `cout' being shifted "Hello world" times to the left and stopped >> > right there."  --Steve Gonedes >> >> Assuming th

Re: Why does my ftp script quit after couple of hours?

2009-08-15 Thread Hendrik van Rooyen
On Friday 14 August 2009 18:25:50 kk wrote: > As far as robustness, I agree with your assestment. I guess my main > confusion with my result is that the console window just disappears. I > wonder if I can make the window stay even if it crashesor if there are > connection issues? I will createa s

Re: Python docs disappointing - group effort to hire writers?

2009-08-15 Thread Carl Banks
On Aug 14, 10:15 pm, Bill Jones wrote: > On Aug 8, 3:27 pm, Mark Lawrence wrote: > > My gut feeling (which could of course be wrong) is that many hard core > > Pythonistas are cheesed off with newbies who refuse to help themselves. > > The funny thing is that their response is to shutdown changes

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Hendrik van Rooyen
On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > > "I saw `cout' being shifted "Hello world" times to the left and stopped > > right there." --Steve Gonedes > > Assuming that's something real, and not invented for humour, I presume > that

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-15 Thread Hendrik van Rooyen
On Friday 14 August 2009 16:28:26 Grant Edwards wrote: > On 2009-08-14, greg wrote: > > Hendrik van Rooyen wrote: 8<--- > Doh! It didn't even occur to me that somebody would use python > "file" objects for serial ports, and I completely

  1   2   >