Python on BlackBerry PlayBook

2011-10-21 Thread Peter Hansen
I'm slightly surprised to search and not see any recent mention of Python running on the BlackBerry PlayBook. Since the PlayBook simulators (for developers) were first available late last year, they've contained Python 2.7. Some time before release, the permissions were changed so the binaries wer

Re: Inconsistency producing constant for float "infinity"

2006-08-11 Thread Peter Hansen
Sybren Stuvel wrote: > Peter Hansen enlightened us with: > >>I'm investigating a puzzling problem involving an attempt to >>generate a constant containing an (IEEE 754) "infinity" value. (I >>understand that special float values are a "platform-depen

Inconsistency producing constant for float "infinity"

2006-08-11 Thread Peter Hansen
I'm investigating a puzzling problem involving an attempt to generate a constant containing an (IEEE 754) "infinity" value. (I understand that special float values are a "platform-dependent accident" etc...) The issue appears possibly to point to a bug in the Python compiler, with it producing

Re: list.clear() missing?!?

2006-04-13 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: >>One of very first things newcomers learn (I believe, though I don't know >>how soon the tutorial teaches it) > > let's see. lists are introduced on page 19, a more extensive discussion of > lists is > found on

Re: list.clear() missing?!?

2006-04-13 Thread Peter Hansen
Duncan Booth wrote: > Peter Hansen wrote: > Looking in the 'obvious' place in the Tutorial, section 5.1 'More on > Lists' I found in the immediately following section 5.2 'The del > statement': > >>There is a way to remove an item from a l

Re: list.clear() missing?!?

2006-04-13 Thread Peter Hansen
Alan Morgan wrote: > Ah, but if you know your basic python then you wouldn't be looking for > s.clear() in the first place; you'd just use s[:]=[] (or s=[], whichever > is appropriate). One of very first things newcomers learn (I believe, though I don't know how soon the tutorial teaches it) is

Re: Iterating command switches from a data file - have a working solution but it seems inefficient

2006-04-12 Thread Peter Hansen
News wrote: > Hi everyone, > > My goal is to pull command switches/options from a file and then assign > the values to select variables which would eventually be included in a > class object. > > The data file looks something like this but the switches could be in any > order and not all may be u

Re: list.clear() missing?!?

2006-04-12 Thread Peter Hansen
Steven D'Aprano wrote: > Convenience and obviousness are important for APIs -- that's why lists > have pop, extend and remove methods. The only difference I can see between > a hypothetical clear and these is that clear can be replaced with a > one-liner, while the others need at least two, e.g. fo

Re: list.clear() missing?!?

2006-04-12 Thread Peter Hansen
Alan Morgan wrote: > Right. I was wondering what would happen in this case: > > s=[1,2,3] > t=s > s.clear() > t # [] or [1,2,3]?? > > If you know your basic python it is "obvious" what would happen > if you do s=[] or s[:]=[] instead of s.clear() and I guess it is > equally "obvious" which on

Re: list.clear() missing?!?

2006-04-12 Thread Peter Hansen
Raymond Hettinger wrote: > Cons: > - > * learning slices is basic to the language (this lesson shouldn't be > skipped) And yet it doesn't appear to be in the tutorial. I could have missed it, but I've looked in a number of the obvious places, without actually going through it (again) from s

Re: Regular Expressions

2006-04-12 Thread Peter Hansen
david brochu jr wrote: > I am trying to grab the following string out of a text file using > regular expression (re module): Why do you have to use a regular expression? > "DcaVer"=dword:0640 Is all your other input pretty much identical in form? Specifically, the number of interest is th

Re: list.clear() missing?!?

2006-04-12 Thread Peter Hansen
John Salerno wrote: > Steven Bethard wrote: >>I think these are all good reasons for adding a clear method, but being >>that it has been so hotly contended in the past, I don't think it will >>get added without a PEP. Anyone out there willing to take out the best >>examples from this thread and

Re: list.clear() missing?!?

2006-04-12 Thread Peter Hansen
Georg Brandl wrote: > John Salerno wrote: >>Steven Bethard wrote: >>>I think these are all good reasons for adding a clear method, but being >>>that it has been so hotly contended in the past, I don't think it will >>>get added without a PEP. Anyone out there willing to take out the best >>>exa

Re: converting lists to strings to lists

2006-04-12 Thread Peter Hansen
robin wrote: > i'm doing some udp stuff and receive strings of the form '0.87 > 0.25 0.79;\n' > what i'd need though is a list of the form [0.87 0.25 0.79] > i got to the [0:-3] part to obtain a string '0.87 0.25 Actually, that's already a bug. You want [0:-2] if y

Re: example of logging w/ user-defined keywords?

2006-04-12 Thread Peter Hansen
Chris Curvey wrote: > Several things that I've read lead me to think this is possible, but I > can't figure out how to do it. I have some information (a "job > number") that I would like logged on every log message, just like the > time or the severity. > > I saw some mail threads that suggested

Re: Decorators, Identity functions and execution...

2006-04-12 Thread Peter Hansen
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > "Ben Sizer" <[EMAIL PROTECTED]> wrote: >>Every day I come across people or programs that use tab stops every 2 >>or 8 columns. I am another fan of tabs every 4 columns, but >>unfortunately this isn't standard, so spaces in Python it is

Re: How to initiate HotSync of Palm device?

2006-04-11 Thread Peter Hansen
dylpkls91 wrote: > I posted a similar question on comp.sys.palmtops.pilot and am waiting > for a response. Thank you for your reply; the acknowledgement is > appreciated. I believe that a possible solution would be to use a > command line option of HotSync Manager, but I am not sure what the > corr

Re: Help...TT Python 2.4 decompiler

2006-04-11 Thread Peter Hansen
Robert Boyd wrote: > Can anyone on the list shed light on this? I'm accustomed to having > readable .py files with my .pyc files and I am unfamiliar with any > scenario where one would need to turn the byte-compiled version back > to the text version. One scenario is that you've lost your source c

Re: XPath/Screen Scraping Gurus..

2006-04-11 Thread Peter Hansen
bruce wrote: > I'm not that familiar with Pythin, but I wasn wondering if there are any > XPath/Python Gurus that I might be able to talk to regarding screen scraping > applications... Since you mention XPath, it seems likely you are really interested in *web-scraping*. Screen-scraping refers, I

Re: Override on terminal

2006-04-11 Thread Peter Hansen
fivestars wrote: > Do you know how to write, from python code, on a unix(linux) terminal > on specified coordinates? Search for the "curses" module. > And also: is it possible to override, from python code, something on a > unix(linux) terminal? The word "override" is ambiguous here (actually it

Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread Peter Hansen
looping wrote: > But I think that if we make "class C():" a synonym of "class > C(object):", it will save lot of keystrokes ;-) Saving keystrokes has only rarely influenced Python's design, thankfully. If you read "import this", you'll see "explicit is better than implicit", and interpreting in

Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread Peter Hansen
Georg Brandl wrote: > class C(): > > is meant to be synonymous with > > class C: > > and therefore cannot create a new-style class. I think "looping" understands that, but is basically asking why anyone is bothering with a change that involves a part of the language that is effectively deprec

Re: wxStyledTextCtrl - Dead?

2006-04-11 Thread Peter Hansen
David Rasmussen wrote: > I am trying to make a programmer's editor (and later a full IDE), and I > want things like syntax highlighting etc. I could of course roll my own > fancy editing control, but if STC could solve my problem and is flexible > enough, then I'll use that for now :) There are

Re: How to initiate HotSync of Palm device?

2006-04-11 Thread Peter Hansen
dylpkls91 wrote: > I know how to get the program to wait for a process to finish, but I'm > having trouble initiating a HotSync through Python. While poking around > the Palm Desktop and HotSync system files, I found a DLL called "HSAPI" > with the title "HotSync API", but I'm not sure if this is w

Re: updated pre-PEP: The create statement

2006-04-11 Thread Peter Hansen
Michele Simionato wrote: > Honestly, I don't want the 'create' statement to be used to write XML > in Python. > I think this would be a misuse of the functionality. OTOH I believe > that the main selling point for the 'create' statements is that it make > it easy to implement declarative minilangua

Re: can't pass command-line arguments

2006-04-10 Thread Peter Hansen
BartlebyScrivener wrote: > It has something to do with importing the cbfindfiles.py file as a > module, right? Because I just did that, and now the .py and .pyc files > are synchronized, and I'm getting the same result when I run > cbfindfiles or cbfindfiles.py, whereas before I was not. Yes! Tha

Re: can't pass command-line arguments

2006-04-10 Thread Peter Hansen
BartlebyScrivener wrote: >>>You missed the other option: if PATHEXT has .pyc in front of .py then you >>>get exactly the described behaviour. > > That's it!! > > Trust me, I didn't do it. It was either ActiveState, Wing, or Komodo > Dragon, or some combination thereof. > > So remove .pyc from pa

Re: can't pass command-line arguments

2006-04-10 Thread Peter Hansen
BartlebyScrivener wrote: > Well, I tried to let this die because I just KNEW I was going to look > like an idiot before it was over. It's the .pyc versus the .py file. > Obviously I don't understand how that works yet. The .pyc file lags > behind the .py file? So when I run cbfindfiles.py I'm runn

Re: Query : sys.excepthook exception in Python

2006-04-10 Thread Peter Hansen
Pramod, TK wrote: > Sometimes during execution of python scripts below mentioned error > string is displayed on the console. > > *"Unhandled exception in thread started by Error in sys.excepthook: * > *Original exception was:"* > > The scripts are not terminated, they continue to execute norma

Re: Is this code snippet pythonic

2006-04-10 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > My Tead Lead my object counter code seen below is not pythonic I'm guessing this was supposed to say "My team lead says my " (?) > class E(object): > _count = 0 > def __init__(self): > E._count += 1 > count = property(lambda self: E._count )

Re: can't pass command-line arguments

2006-04-10 Thread Peter Hansen
BartlebyScrivener wrote: > No conflicting bat file. What about a conflicting non-BAT file? Anything in PATHEXT ahead of the .PY extension is a candidate... > if __name__ == "__main__": > print sys.argv > for path in all_files(sys.argv[1], sys.argv[2]): > print path > > If I ru

Re: Problems with current value of wx.SpinCtrl and EVT_SPIN

2006-04-09 Thread Peter Hansen
blackno666 wrote: > I am new to Python/wxPython and am experiencing first problems. I have > a dialog which includes a SpinCtrl and a Slider. I want the Slider to > affect the SpinCtrl and vice versa > (http://wiki.wxpython.org/index.cgi/ChallengeDemos#Part1). > > The code I wrote does, however, n

Re: Creating an event loop

2006-04-09 Thread Peter Hansen
Fabian Steiner wrote: > I am currently wondering how to write something like an "event loop". > For example, if I want to write a function that checks whether a file > was added or removed in a directory I would think of a "while 1: ..." > construct that checks the mtime of the directory. Is this t

Re: fnmatch on filename (without specific extension)

2006-04-09 Thread Peter Hansen
kepioo wrote: > I have some files in a directory : > Results Log, 11;21AM, Apr 09 2006.txt > Results Log, 11;21AM, Apr 08 2006.txt > Results Log, 03;59AM, Apr 07 2006.txt > otherfile1.txt > otherfile2.txt > > I'd like to copy all the Results Log file, whatever the hour but with a > specific day. F

Re: Insertion (sql) bug in Py2.4 pySQLite 2.2

2006-04-08 Thread Peter Hansen
DurumDara wrote: > So: I create a table in the first, and later I want to push some > elements to it. Before this example code I use special method to create > insert sql with tuple of values. But everytime it have been failed with > this message: SQL error or inaccessible database. Then I simpl

Re: Working with decimal points

2006-04-08 Thread Peter Hansen
Byte wrote: > That dosnt work either: > > sum = 0.1+1/4 > print sum > > Just returns 0.1 That's because the 1/4 is executed first, and the problem mentioned still applies (i.e. you get a 0, then add it to 0.1). The best fix for you might be simply to place this line at the start (before all o

Re: calculating system clock resolution

2006-04-08 Thread Peter Hansen
Steven D'Aprano wrote: > This brings me to an even simpler method of getting the resolution of > time.time(), without the overhead of a while loop: > abs(time.time() - time.time()) > > 1.0013580322265625e-05 > which is approximately 0.01ms, just as you expected. This doesn't necessarily work

Re: minidom + wxPython woes

2006-04-07 Thread Peter Hansen
Lonnie Princehouse wrote: > Oops, I missed a bracket... that should read: > > testxml = '' > > But it still crashes ;-) Maybe missing a question mark still too? (It's like a processing instruction, not an element.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: GUI Treeview

2006-04-07 Thread Peter Hansen
Arne wrote: > Hello ! > > I am looking for a widget with the following properties: > - showing the tree file structure/ directory structure > - next to each file should be a checkbox > - the tree should only show certain files (i. e. only for the looked in > user) For which GUI framework? (e.g.

Re: How to catch python's STDOUT

2006-04-06 Thread Peter Hansen
Steven D'Aprano wrote: > >>> import sys, StringIO > >>> SAVEOUT = sys.stdout > >>> capture = StringIO.StringIO() > >>> sys.stdout = capture > >>> print "hello" > >>> > > But be warned, I've had difficulty restoring stdout > afterwards, and needed to exit the interactive > interpreter to ge

Re: ``pickling'' and ``unpickling''

2006-04-06 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Hi, > I am new in Python World.I want to know what is mean by ``pickling'' > and ``unpickling'' ? > And how can we used it?Please Give Me some links of Picking Examples. > Thanks You can generally answer such questions yourself by heading to docs.python.org and typi

Re: "The World's Most Maintainable Programming Language"

2006-04-06 Thread Peter Hansen
Mirco Wahab wrote: > Hi Ralf >>So we should rename Python into Cottonmouth >>to get more attention. > > No, always take some word that relates to > something more or less 'feminine', its about > 96% of young males who sit hours on programming > over their beloved 'languages' ;-) > > Pythia? (htt

Re: output formatting for user-defined types

2006-04-06 Thread Peter Hansen
Russ wrote: > Thanks, but that is not acceptable for my application. Any other ideas? Yeah, how about we read your mind or make wild guesses about why it's not acceptable, and about what your requirements really are. Really, your response seems a little bizarre to me, given that __float__ is th

Re: output formatting for user-defined types

2006-04-05 Thread Peter Hansen
Russ wrote: > I'd like to get output formatting for my own classes that mimics the > built-in output formatting. For example, > > x = 4.54 print "%4.2f" % x > > > 4.54 > > In other words, if I substitute a class instance for "x" above, I'd > like to make the format string apply to an e

Re: how to convert string

2006-04-05 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I want to print number 0 to 9 in one line like this > 0 1 2 3 4 5 6 7 8 9 > > if I do like this, it prints in different lines > > for i in xrange(10): > print i > > so i tried like this > > str = "" > for i in xrange(10): > str = i + " " > print str > > but i

Re: Python Decompilers?

2006-04-04 Thread Peter Hansen
flamesrock wrote: > Hi, > > Are there any good decompilers for python? Decompyle can manage any version from 1.5 up to 2.3.3. Is that "good"? What is "good" to you? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: question about nasty regex

2006-04-04 Thread Peter Hansen
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > Paul Rubin wrote: >>"Some people, when confronted with a problem, think ``I know, I'll use >>regular expressions.'' Now they have two problems." --JWZ > > Regexes are good if you need a solution quickly, an

Re: [ANN] markup.py - 1.2 - an HTML/XML generator

2006-04-03 Thread Peter Hansen
Felipe Almeida Lessa wrote: > $ pwd > /usr/lib/python2.4/site-packages > $ grep -re klass . | wc -l > 274 > $ grep -re class_ . | wc -l > 897 How many of those "class_" instances are really just substrings of "__class__" and "class_name" and such? On my machine, I see a handful in the standard

Re: MOO meets Python

2006-04-03 Thread Peter Hansen
Istvan Albert wrote: > Quote from the webpage: "It's a buggy bundle of Python code that, by > default, opens interfaces to your computer and makes it insecure." So it's a way of using Python to emulate the Windows operating system, for people stuck using Linux? > ... just what I was looking for

Re: Can't detect EOF from stdin on windows console

2006-04-03 Thread Peter Hansen
Serge Orlov wrote: > Dmitry Anikin wrote: >>I want to read stdin in chunks of fixed size until EOF >>I want to be able (also) to supply data interactively in console >>window and then to hit Ctrl+Z when finished > > [snip fighting with windows] > >>Read at most size bytes from the file (less if t

Re: Oserror: [Errno 20]

2006-04-03 Thread Peter Hansen
k r fry wrote: > Sorry for not copying the whole traceback before, I hop I have done it > right this time. > > I am now getting: > > Traceback (most recent call last): >File "katiescint.py", line 153, in ? > for subdir in os.path.istdir(DATADIR): #loop through > list of st

Re: Oserror: [Errno 20]

2006-04-03 Thread Peter Hansen
k r fry wrote: > Hi, I am new to this list and also programming with python. > > I have an error: oserror [errno 20] not a directory "katiescint.py" Please always post complete tracebacks, and without manually reentering the data. In most cases you'll save us and you lots of time and guessing.

Re: Scatter/gather on sockets?

2006-04-01 Thread Peter Hansen
Roy Smith wrote: > I've got a bunch of strings in a list: > > vector = [] > vector.append ("foo") > vector.append ("bar") > vector.append ("baz") > > I want to send all of them out a socket in a single send() call, so > they end up in a single packet (assuming the MTU is large enough). I > can d

Re: Exception handling....dumb question?

2006-04-01 Thread Peter Hansen
kbperry wrote: > I have a Python book, but it didn't mention this at all. I also tried > looking through the online docs to no avail. This is covered by the tutorial though, and if you're a Python rookie it would be a good idea to step your way through most of it soon: See http://docs.python.or

Re: Very stupid question.

2006-03-30 Thread Peter Hansen
On 3/30/06, *Sullivan Zheng* <[EMAIL PROTECTED] > wrote: > > Wow, seems I am not that supid. Why python does not include this > function in the file object. It is almost a tradition in other > languages... > > import os > > os.stat(path).st

Re: How to determine an object is "scriptable"

2006-03-30 Thread Peter Hansen
abcd wrote: > Daniel Evers wrote: > >>Right. You can check this e.g. with >> >>hasattr(x, "__getitem__") >> >>because the __getitem__ method is used for indexing. > > Thanks...that is what I was looking for! Maybe, but it's not a particularly Pythonic way of doing it. Better is probabl

Re: SEEK_SET defined?

2006-03-29 Thread Peter Hansen
Roger Miller wrote: > I see that the posixfile module is deprecated. Have the SEEK_SET, etc. > constants moved somewhere else, or do I need to define them myself? In Python 2.5 they have been added to the os module, but for now I think you are probably expected to just continue using posixfile o

Re: pySerial: write in a blocking mode

2006-03-29 Thread Peter Hansen
Alejandro wrote: > Peter Hansen wrote: > >>Alejandro wrote: >> >>>I'm using pySerial to talk to a RS232 to RS485 converter. In order to >>>control the converter, I need to control the DTR line to enable/disable >>>de RS485 driver. >> &g

Re: pySerial: write in a blocking mode

2006-03-28 Thread Peter Hansen
Alejandro wrote: > I'm using pySerial to talk to a RS232 to RS485 converter. In order to > control the converter, I need to control the DTR line to enable/disable > de RS485 driver. This seems a little odd to me. We've used several RS232-RS485 converters without needing to do that. Maybe a mor

Re: Obtaining the remote ip address

2006-03-28 Thread Peter Hansen
EP wrote: > While on the subject of network identity, does anyone have a scheme to > get the MAC address of the end device? I've never come up with a way to > do it, but I haven't had it proven to me that it is impossible (yet). Which end? I'll assume you mean _not_ the server end. :-) The MA

Re: How to inplement Session in CGI

2006-03-28 Thread Peter Hansen
Sullivan WxPyQtKinter wrote: > Python disappointly failed to provide a convinient cgi session > management module. Not willing to use external modules, I would like to > implement a simplest Session object on my own. > > The basic problem is: how could a python CGI program understand several > req

Re: Difference between 'is' and '=='

2006-03-28 Thread Peter Hansen
Joel Hedlund wrote: >>This does *not* also mean constants and such: > > > >>>>> a = 123456789 >>>>> a == 123456789 >>True >>>>> a is 123456789 >>False > > I didn't mean that kind of constant. I meant named constants with defined > meaning, as in the example that I cooked up

Re: "For" loop and list comprehension similarity

2006-03-27 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Do you think this discussion is a proof that the following principle > got violated, or do you think that "loop with condition" is not such an > atomic thing to be subject to this: "There should be one -- and > preferably only one -- obvious way to do it." Mitja's sugges

Re: Difference between 'is' and '=='

2006-03-27 Thread Peter Hansen
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Joel Hedlund <[EMAIL PROTECTED]> wrote: >>Which means that "is" comparisons in general will be faster than == >>comparisons. > > I thought that == automatically compared identify before trying to compare > the values. Or am I thinking of som

Re: path to modules per import statement

2006-03-24 Thread Peter Hansen
AndyL wrote: > [EMAIL PROTECTED] wrote: > I work on rather big set of Python applications: something like 100 .py > files divided into libs and separate sub-applications. > > For now I keep almost everything in one directory but I wish following > structure to be in place: > > app1/ app2

Re: Remove integer from float number

2006-03-24 Thread Peter Hansen
kpp9c wrote: > okay... out of curiousity... how would you then seperate the interger > value from the fractional part do something to one side and then put it > back together... like if you had 8.01 and you want to add to the '8' > part in one way (ordinary decimal) and add to the .01 part modulo >

Re: raw_input

2006-03-24 Thread Peter Hansen
Tim Williams (gmail) wrote: > The following will accept any subset of "carmel" in upper, lower or > mixed case > > EG Carmel, carmel, Carm, mel etc > > >>> if raw_input ("hello what's your name? ").lower() in 'carmel': > print "Ahh the boss's wife" It's so powerful, it accepts ev

Re: Python 2.5 Schedule

2006-03-21 Thread Peter Hansen
Terry Reedy wrote: > "Ant" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Looks like some good new stuff coming along. Does anyone know what's >>happened to the path PEP (http://www.python.org/doc/peps/pep-0355/) - I >>thought I'd seen somewhere that that was originally planned

Re: Module import information

2006-03-21 Thread Peter Hansen
Eric White wrote: > Is it possible to determine the name of the module that invoked import > from within the imported module? Almost anything is possible in Python. On the other hand, some things are probably impractical, and others ill-advised. Perhaps you can describe your requirements, *wh

Re: Do anyone already have code to copy nested files to a flat directory?

2006-03-20 Thread Peter Hansen
Podi wrote: > OK, please don't bother. Here is my wheel :-) > > import os > import shutil > > def CopyFlat(source, target): > count = 0 > for root, dirs, files in os.walk(source): > for file in files: > count += 1 > name = root + '\\' + file A small improv

Re: remove a directory with special chars

2006-03-19 Thread Peter Hansen
andy wrote: > Is there a special reason you want to use Python to do this? The Linux > command shell would probably do exactly the same job (you can specify > backslash-escaped characters at the command-line)... > > anyway to do it in python: > > import os > os.remove("/path/to/the/file/.\17

Re: Why won't the sprites in my group show up? (PyGame)

2006-03-18 Thread Peter Hansen
Isis wrote: > Hi all, > I am writing a snake game, but all is not going well... Chances are good that you'll get access to many more potential respondents by posting the question to the Pygame mailing list. -- http://mail.python.org/mailman/listinfo/python-list

Re: Have you ever considered of mousing ambidextrously?

2006-03-18 Thread Peter Hansen
Roy Smith wrote: > "WangQiang" <[EMAIL PROTECTED]> wrote: >>I'm also a programmer, as working in front of computer day and day, my >>right hand is so tired and ached. So I tried to mouse in both hands. I >>find that it is really an efficient way to release pains. At first I >>switched the mouse but

Re: Is there no end to Python?

2006-03-18 Thread Peter Hansen
Scott David Daniels wrote: > Kind of like the core developers saying, rather than getting more > users of this language, I'd prefer they submit careful bug reports > with money attached to fix the bugs -- ain't gonna happen. Actually, it does happen: http://www.python.org/psf/donations/ (The actu

Re: filter list fast

2006-03-18 Thread Peter Hansen
Diez B. Roggisch wrote: >>Both of these techniques are O(n^2). You can reduce it to O(n log n) >>by using sets: >> >set2 = set(list2) >[x for x in list1 if x not in set2] >> >>Checking to see if an item is in a set is much more efficient than a >>list. > > Is the set-lookup reliably O(log

Re: FIR filtering

2006-03-15 Thread Peter Hansen
LabWINC wrote: > It's for research work. I'm implementing an algorithm from a matlab > one. > It could be very difficult to find the fir coefficients because i have > lot of fileters to implement. Oh, you mean you need to find the coefficients, not just implement the FIR filter itself. (Perhaps

Re: FIR filtering

2006-03-15 Thread Peter Hansen
LabWINC wrote: > i'm looking for a module to implement a digital FIR filter! > Can anyone help me? Is this for homework, for academic interest, for a control system problem, or what? Some context would be useful in helping us answer. (The first thing that occurs to me, for example, is "why don'

Re: Threads: does Thread.start() atomically set Thread.__started ?

2006-03-15 Thread Peter Hansen
Enigma Curry wrote: > Can some kind person please further my education on Threads? > > When I create a thread called "t" and I do a "t.start()" am I > guaranteed that "t.isAlive()" will return True as long as the thread > hasn't already completed? Put another way, does "t.start()" ever return > be

Re: anonymous memory mapping

2006-03-13 Thread Peter Hansen
Fabiano Sidler wrote: > 2006/3/12, Fabiano Sidler <[EMAIL PROTECTED]>: > >>Is there any way to use anonymous memory mapping in python, versions >>earlier than 2.5? > > No idea or no way to do it? Often when there's no reply for a while, it's because the question is unclear. Rather than just ap

Re: reading float from binary data file

2006-03-08 Thread Peter Hansen
cesco wrote: > I have a binary file containing 1000 floating point numbers. I want to > load that file into an array. A way to do it could be the following: > import array data = array.array('f') f = open('FileName.bin', 'rb') data.fromfile(f, 1000) > > Now I have the following pr

Re: Send email notification

2006-03-08 Thread Peter Hansen
Dennis Lee Bieber wrote: > On Wed, 08 Mar 2006 06:20:42 +, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >>Hang around here long and you'll see a bunch of people waiting on >>replies to questions Google could have given them far quicker. If we >>weren't pa

Re: Opening files without closing them

2006-03-07 Thread Peter Hansen
3c273 wrote: > "Robert Kern" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Paul Rubin wrote: >> >>>Say that the open is inside the try block. If the file can't be >>>opened, then 'open' raises an exception, 'f' doesn't get set, and then >>>the 'finally' clause tries to close f

Re: SAX/Python : read an xml from the end to the top

2006-03-07 Thread Peter Hansen
kepioo wrote: > Peter, > > I cannot really process as your advice : it is not that stereotypical > entrieswe built a data structure for the xml and we report various > types of events, always under the same format but with different > contents types. > > The script i am writing aims at pickin

Re: Pyserial again

2006-03-07 Thread Peter Hansen
Richie Hindle wrote: > A piece of that code has been chopped off by someone's newsreader - it's the > body of a method, and ser.readline() is the last line of that method. I'm pretty sure that's true. Technically, however, it's still a guess, though at this point one I'm sure we're all comfortab

Re: SAX/Python : read an xml from the end to the top

2006-03-07 Thread Peter Hansen
kepioo wrote: > The input xml I am parsing is always well formed. It is coming out from > another application that append to this xml. I didn't see the source > code of the application, but i know that it is not re-writing the whole > xml. I thinnk it is just removing the last root element, adding

Re: Pyserial again

2006-03-07 Thread Peter Hansen
luca72 wrote: > Here is my code ; why after the readline the port close? > What is the line of code before the first one shown here? > ser = serial.Serial(0) > ser.baudrate = 9600 > ser.parity = serial.PARITY_ODD > ser.stopbits = serial.STOPBITS_TWO > ser.

Re: Is this not infinite?

2006-03-07 Thread Peter Hansen
John Salerno wrote: > Kent Johnson wrote: > > >>This should be >> def __init__(self, etc): >> Base.__init__(self, etc...) > > >>It's a typo in the book. > > Thank goodness! At least I know my mind is heading in the right > direction then... :) Which book? Many of the author

Re: spliting on ":"

2006-03-06 Thread Peter Hansen
Cyril Bazin wrote: > I agree. None is an object! If you want to compare an object to another > object why not using "=="? The term "compare" is ambiguous. If you want to compare for *identity*, you use "is". If you want to compare for equality, you use "==". In most cases with None you are i

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > a = 'something' > b = ('%r'%a) > eval(b) == a > > that in general should return True. I hope. But I'm sure there are > counterexamples to that, too. Provided 'something' is a string, that should be true, as should the simpler statement a == eval(repr(a)) (since '%r' is jus

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > I'm trying to get a complete grip on %r. Is it true that the two programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts* can

Re: Pyserial again

2006-03-06 Thread Peter Hansen
luca72 wrote: > I have solve the problem of configuration with pyserial but i have > another question. > The serial port close every time i make the read and re-open when i do > i new write. Please describe what you are observing that makes you say that the port is closing. > In my script there

Re: Inline assignments

2006-03-05 Thread Peter Hansen
Fredrik Tolf wrote: > I'm relatively new to Python, and one thing I can't seem to get over is > the lack of in-expression assignments, as present in many other > languages. I'd really like to know how Python regulars solve the > problems posed by that. > > For example, I recently wanted to do this

Re: Argument Precedence (possible bug?)

2006-03-05 Thread Peter Hansen
vbgunz wrote: > I am just learning Python and have come across something I feel might > be a bug. Please enlightenment me... The following code presents a > challenge. How in the world do you provide an argument for *arg4? Maybe by putting that in the list of arguments? ... You don't even *have*

Re: spliting on ":"

2006-03-04 Thread Peter Hansen
Petr Jakes wrote: >>I think you're getting caught by the classic and/or trap in Python, >>trying to avoid using a simple if statement. > > What do you mean by "the classic and/or trap"? Can you give an example > please? Sure, see my subsequent reply to Cyril, elsewhere in this thread. (In summar

Re: spliting on ":"

2006-03-04 Thread Peter Hansen
Cyril Bazin wrote: > Ok, ok, there was a mistake in the code. > (Of course, it was done on prupose in order to verify if everybody is > aware ;-) > I don't know why it is preferable to compare an object to the object > "None" using "is not". > "==" is, IMHO, more simple. Simple is better than com

Re: spliting on ":"

2006-03-04 Thread Peter Hansen
Cyril Bazin wrote: > Your file looks like a list of IP adresses. > You can use the urllib and urllib2 modules to parse IP adresses. > > import urllib2 > for line in open("fileName.txt"): > addr, port = urllib2.splitport(line) > print (port != None) and '' or port Is this what you want to

Re: How to except the unexpected?

2006-03-03 Thread Peter Hansen
Rene Pijlman wrote: > One of the things I dislike about Java is the need to declare exceptions > as part of an interface or class definition. But perhaps Java got this > right... > > I've writen an application that uses urllib2, urlparse, robotparser and > some other modules in the battery pack. O

Re: Use empty string for self

2006-02-28 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > It seems that lots of people don't like having to prefix self. in front ... > But what if we keep the '.' and leave out the self. ... > Any comments? Has this been discussed before? Yes, at least once (found by group-googling for "removing self" in this newsgroup):

Re: Problem with Property

2006-02-25 Thread Peter Hansen
"none <"@bag.python.org wrote: > I'm trying to implement a simple repeateable property mechansism so I > don't have to write accessors for every single instance variable I have. ... > Any ideas? Yes, don't write accessors for every single instance variable you have. In some languages that mig

Re: Multiple threaded download streams?

2006-02-25 Thread Peter Hansen
Diez B. Roggisch wrote: >>Use a separate thread for downloading. > > Or the twisted select-reactor. No threads needed. Although depending on what the GUI is like, and what platform is involved, one might still want at least a second thread for the reactor itself. -Peter -- http://mail.python

  1   2   3   4   5   6   7   8   9   10   >