Re: [path-PEP] Path inherits from basestring again

2005-07-29 Thread Peter Hansen
Tony Meyer wrote: > Would you really choose this: > p = Path() / "build" / "a" / "very" / "very" / "long" / "path" > > Over this: > p = Path(os.path.join("build", "a", "very", "very", "long", "path")) I'd choose neither, because both are contrived examples (who builds paths out of six li

Re: os._exit vs. sys.exit

2005-07-29 Thread Peter Hansen
Andrew Dalke wrote: > sys.exit() is identical to "raise SystemExit()". It raises a Python > exception which may be caught at a higher level in the program stack. And which *is* caught at the highest levels of threading.Thread objects (which Timer is based on). Exceptions raised (and caught or n

Re: pySerial Windows write problem

2005-07-29 Thread Peter Hansen
Bob Greschke wrote: > "Peter Hansen" <[EMAIL PROTECTED]> wrote in message > >>I'd call it very unusual >>(in my experience) to have a program open and close a serial port >>repeatedly. > > One of the serial ports (there are actually two) is

Async PySerial (was Re: pySerial Windows write problem)

2005-07-29 Thread Peter Hansen
Neil Benn wrote: > PySerial doesn;t have any kind of event firing to notify you when data > is available. The way I get round this is to have a loop polling (in a > seperate thread) to see if any data is available (it's a method on the > interface), then read all the data in and fire this off t

Re: os._exit vs. sys.exit

2005-07-29 Thread Peter Hansen
Bryan wrote: > Thanks for the clarifications. One more question, can I catch this > exception in my main thread and then do another sys.exit() to kill the whole > process? Not as such. Exceptions can be caught only in the thread in which they are raised. There are tricky techniques to change

Re: Ten Essential Development Practices

2005-07-29 Thread Peter Hansen
Dan Sommers wrote: > [EMAIL PROTECTED] (Aahz) wrote: >>Dan Sommers <[EMAIL PROTECTED]> wrote: >>>Was Tim writing about developing Python itself, or about developing >>>other programs with Python? > >>Yes. > > It was a rhetorical question. :-) That's all right... Aahz gave a rhetorical answer.

Re: Hiding

2005-07-29 Thread Peter Hansen
Jason Drew wrote: > Also, I think > using file("C:\file.txt") is now preferred to open("C:\file.txt"). As others have noted, "open" is preferred as the method for opening files, while "file" is the _type_ involved, for testing or subclassing or what-have-you. But neither file("C:\file.txt") nor

Re: Adding code and methods to a class dynamically

2005-07-29 Thread Peter Hansen
Sarir Khamsi wrote: > Peter Hansen <[EMAIL PROTECTED]> writes: >>I'm not sure what "completion" means in this case, and I'm not aware >>of any "command-line completion" support in cmd.Cmd though it may well >>be there, so I can't say

Re: Async PySerial (was Re: pySerial Windows write problem)

2005-07-29 Thread Peter Hansen
phil wrote: > I use PySerial in a 16 line data collection system > with LOTS of threads, and yes am frustrated by read(). > This sounds excellent, keep us updated. > > BTW, haven't done any event driven Python except Tkinter. > Would this a class library which would let you > define an event and

Re: Path inherits from basestring again

2005-07-29 Thread Peter Hansen
NickC wrote: > I'm usually not much of a purist, but C++ has convinced me that > overloading an operator to mean something entirely unrelated to its > mathematical meaning can be very unwise. Me too. In general. I've yet to overload a single operator that way in years of writing Python code, th

Re: Comparison of functions

2005-07-30 Thread Peter Hansen
Steven D'Aprano wrote: > Playing around with comparisons of functions (don't ask), I discovered an > interesting bit of unintuitive behaviour: > (lambda y: y) < (lambda y: y) > False > > Do the comparison again and things become even more bizarre: > (lambda y: y) < (lambda y: y) > True >

Re: PEP on path module for standard library

2005-07-30 Thread Peter Hansen
Reinhold Birkenfeld wrote: > Mike Orr wrote: >>- I saw in a thread that .name and .parent were removed. I use them >>very frequently, along with .ext and .namebase. I don't want to call >>methods for these. > > They are now named .basename and .directory. Reinhold, is ".parent" now ".directory"

Re: PEP on path module for standard library

2005-07-30 Thread Peter Hansen
Reinhold Birkenfeld wrote: > Mike Orr wrote: >>- Who needs .open()? open(myPath) is fine. But it can stay for >>backward compatibility. > > Right. I think it's nice for people who like a more OO approach. There's one very good reason to use .open() on a Path object, and in fact it's a (for me)

The state of OO wrappers on top of wxPython (was Re: Wheel-reinvention with Python)

2005-07-30 Thread Peter Hansen
Ed Leafe wrote: > On Saturday 30 July 2005 12:28, Peter Decker wrote: >>It would be great if the wxPython folks would adopt Dabo, > > Thanks for the vote of encouragement! > > Our goal isn't to muddy the waters; it is simply to create a consistent API > for coding. There is already a great G

Re: string methods

2005-07-30 Thread Peter Hansen
Brian Beck wrote: > anthonyberet wrote: >>I know this touches on immutability etc, but I can't find string methods >>to return the first 3 characters, and then the last 2 characters, which >>I could concatenate with newchar to make a new string. > > As tiissa said, you want slicing: > > py> s = "

Re: 2-player game, client and server at localhost

2005-07-30 Thread Peter Hansen
Michael Rybak wrote: > I'm writing a 2-players game that should support network mode. I'm now > testing it on 1 PC since I don't have 2. I directly use sockets, and > both client and server do computations, the only data transfered is > user mouse/kbd input. > > It works synchronously, but

Re: Comparison of functions

2005-07-30 Thread Peter Hansen
Steven D'Aprano wrote: > Python already allows you to compare "this is not a number" with the float > 5.0. Mathematically, that is meaningless, but I would bet money that > 99.9% of programmers would demand that they should be able to sort the > list ["this is not a number", 5.0]. Do you think that

Re: A replacement for lambda

2005-07-30 Thread Peter Hansen
Paul Rubin wrote: > How's this: f{args} (curly braces instead of parens) is the same as > f(lambda: args). > > Examples: > > launch_thread{targetfunc(a,b,c)} > b = Button{callback=pressed()} # Button remembers callback() > sign_of_a = ternary{a < 0, -1, 1} I'd consider this an inte

Re: Thaughts from an (almost) Lurker.

2005-07-31 Thread Peter Hansen
Paddy wrote: > Sometimes when reading c.l.p. I mentally stand off from what I have > been reading and get an odd feeling that 'WE ARE BEING TESTED'. That > someone else is purposefully posting a near repetitive post, or obvious > flame bait etc - not for the usual reasons, but to track the dynamic

Re: Is this Pythonic?

2005-08-01 Thread Peter Hansen
phil hunt wrote: > Suppose I'm writing an abstract superclass which will have some > concrete subclasses. I want to signal in my code that the subclasses > will implement certan methods. Is this a Pythonic way of doing what > I have in mind: > > class Foo: # abstract superclass >def bar(sel

Re: Newer than a Newbe

2005-08-02 Thread Peter Hansen
gene tani wrote: > Truthfully, the number of frameworks is staggering, tho some are > specialized for blogs/wiki, search engine, PIM, etc. [snip massive yet even so incomplete list] It's called biodiversity and, while generally this is a good thing, I think it's high time for some of these Python

Re: time.clock() or time.time()

2005-08-02 Thread Peter Hansen
Magnus Lycka wrote: > On Windows, you're likely to prefer time.clock(), to > measure relative times, since time.time() will have too low resolution > for measuring short thingies. Specifically, using the NT/XP family of Windows operating systems time.time() has a resolution of approximately 0.01

Re: Art of Unit Testing

2005-08-02 Thread Peter Hansen
Christoph Zwerschke wrote: > I completely agree and I think it makes a lot of sense that unittest > calls setUp and tearDown for every single test. However, the fact that > this is *generally* the best way doesn't exclude the fact that there are > *exceptions* when it makes sense to setUp and te

Re: Pickle, __init__, and classes

2005-08-02 Thread Peter Hansen
Russell Blau wrote: > Try __new__(). http://docs.python.org/ref/customization.html This isn't > the usual application of __new__, but since it returns an object it should > be ideal for your purposes. Or simply create a factory function to return your instances -- which is in effect what __new_

Re: Python for embedded linux?

2005-08-02 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Where can I find a minimal version of python (less than 2 MB) suitable for > a web server on an embedded linux system? The small size is required > because the system lives on flash memory. Such things have been discussed in this list/newsgroup before. I suggest tryin

Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote: > - unittest is for *unit* testing (only) ;-) Why would you say that? We've used it extensively for a wide ranging of testing, not limited to unit tests. > - use mock objects to mimic the behaviour of external components like > databases ...when doing unit testing.

Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote: > I think wanting to have a more global initialization > indicates that you are acutally not wanting to do a "unit" test, but a > more global test of the overall system, something like an acceptance or > integration test, i.e. you are trying to abuse unittest for somet

Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
phil hunt wrote: > On Tue, 02 Aug 2005 21:26:28 +0200, Christoph Zwerschke <[EMAIL PROTECTED]> > wrote: >>According to the "extreme programming" paradigm, testing should be done >>several times a day. So a requirement for extreme programm is that tests >>are fast enough. If the testing needs too

Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote: >>> - unittest is for *unit* testing (only) ;-) >> >> Why would you say that? We've used it extensively for a wide ranging... > > That was actually only a quote from this thread that summarizes some of > the answers I got: unittest has no support for "global" fixtures,

Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
phil hunt wrote: > I think we might be talking at cross purposes here. To me > "acceptance test suite" means a test suite that has to be passed > each time before a new version of the software is released to the > users. I don't see that 10 minutes is a sensible limit here, unless > you are rel

Re: socket and os.system

2005-08-03 Thread Peter Hansen
mfaujour wrote: > I HAVE THIS PYTHON PROGRAMM: [snip] > socket.error: (98, 'Address already in use') > > DOES SOMEONE HAS AN IDEA ? PLEASE learn to format your questions more appropriately! Your post is simply _awful_ to read

Re: Is there a way to determine -- when parsing -- if a word contains a builtin name or other imported system module name?

2005-08-04 Thread Peter Hansen
Casey Hawthorne wrote: > Is there a way to determine -- when parsing -- if a word contains a > builtin name or other imported system module name? As David pointed out, the keys in sys.modules are the names of all imported modules throughout the interpreter (but not just those in the current scop

Re: Making a timebomb

2005-08-05 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I have a server that right now runs infinitely. I'd like to make it > die after some amount of time. I was thinking of having a timebomb > thread that starts when the server starts. The timebomb sits, and > sleeps for the specified timeout period (e.g., 5 hours), then

Re: socket and os.system

2005-08-05 Thread Peter Hansen
Donn Cave wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: >>PLEASE learn to format your questions more appropriately! Your post is >>simply _awful_ to read. ... > > For heaven's sake, it wasn't that hard to read. My apologies to the original poster.

Re: Making a timebomb

2005-08-05 Thread Peter Hansen
Cantankerous Old Git wrote: > [EMAIL PROTECTED] wrote: > >> I have a server that right now runs infinitely. I'd like to make it >> die after some amount of time. > > The proper way to do it is to have the timer set a flag that the other > threads check regularly. The threads can then clean up

Re: Problem with new python (2.4.1) installation

2005-08-05 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > After installing python 2.4.1 (previous version 2.3.4), and installing > pygtk 2.6.2, I get the following error message (almost with any program > I try to run): > > ImportError: could not import atk [snip...] > "/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/g

Re: Syntax error after upgrading to Python 2.4

2005-08-06 Thread Peter Hansen
Fernando wrote: > I reinstalled version 2.3.5 and everything works fine now. It's > definately something related to the latest version. No problem in software is definite until you actually know what the solution is. I'd suspect something other than a simple problem in 2.4 itself, since otherwi

Fat and happy Pythonistas (was Re: Replacement for keyword 'global' good idea? ...)

2005-08-06 Thread Peter Hansen
John Roth wrote: > It's not going to happen because the Python community is fat and happy, > and is not seeing the competition moving up on the outside. Characteristics > that make a great language one day make a mediocre one a few years > later, and make a has-been a few years after that. And her

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-06 Thread Peter Hansen
Paolino wrote: > [EMAIL PROTECTED] wrote: > def enclosing(): > var=[] > var[0]=2 > def enclosed(): > var[0]=4 > which is like saying python is not working > > It's ok to mark non locals,but why var=4 is not searched outside and > var[0]=4 yes? Because "var=4" rebinds the name "var", wh

Re: Fat and happy Pythonistas (was Re: Replacement for keyword 'global' good idea? ...)

2005-08-06 Thread Peter Hansen
Mike Meyer wrote: > "John Roth" <[EMAIL PROTECTED]> writes: >>The world is moving on, in ways that I think you're not seeing. >>And Python is standing still in many of those same ways. > > I find it hilarious that this arrived at my news server the same day > that Peter Hansens rant (look for the

Re: Fat and happy Pythonistas (was Re: Replacement for keyword 'global' good idea? ...)

2005-08-06 Thread Peter Hansen
; So we have one (count him, 1) user who complains that it's changing to > fast. I suspect most readers here would disagree with him. Although both Mike and John by this time are aware of Mike's mistaken attribution of the "rant" to me, I feel compelled to point out for pos

Re: Making a timebomb

2005-08-07 Thread Peter Hansen
Cantankerous Old Git wrote: > Peter Hansen wrote: >> Cantankerous Old Git wrote: >>> The dirty way, which can leave corrupt half-written files and other >>> nasties, is something like sys.exit(). >> >> sys.exit() won't help you if your server is runnin

Re: Python -- (just) a successful experiment?

2005-08-08 Thread Peter Hansen
Paul Rubin wrote: > I dunno about PyGTK but one of the more common complaints about > wxPython is that it's not Pythonic enough. And wxPython is probably > the most popular Python GUI toolkit after Tkinter. So people don't > want C wrappers. I think what they mostly want is a wide choice of > go

Re: zipped socket

2005-08-08 Thread Peter Hansen
John wrote: > > Is there anyway open a socket so that every send/listen/recv > goes thru a zipping/unzipping process automatically? You ought to be able to do this easily by wrapping a bz2 compressor around the socket (maybe using socket.makefile() to return a file object first) and probably us

Re: How to determine that if a folder is empty?

2005-08-08 Thread Peter Hansen
could ildg wrote: > I want to check if a folder named "foldername" is empty. > I use os.listdir(foldername)==[] to do this, > but it will be very slow if the folder has a lot of sub-files. > Is there any efficient ways to do this? I'm just curious to know under what circumstances where it's import

Re: python for microcontrollers

2005-08-08 Thread Peter Hansen
Evil Bastard wrote: > Benji York wrote: >>Perhaps porting Pyrex would be easier. > Pyrex totally rocks. But for the PIC targetting, no can do: ... > Any other suggestions? Yes, port Lua instead. Lua is pretty much designed for this sort of application, and is probably "Pythonic" enough to pro

Re: How to determine that if a folder is empty?

2005-08-09 Thread Peter Hansen
could ildg wrote: > On 8/8/05, Peter Hansen <[EMAIL PROTECTED]> wrote: >>could ildg wrote: >>>I want to check if a folder named "foldername" is empty. >>>I use os.listdir(foldername)==[] to do this, >>>but it will be very slow if the folder has a

Re: .pth files

2005-08-09 Thread Peter Hansen
Neil Benn wrote: >* Site.py is prompted to load a sitecustomise.py file which is > located in the Lib directory - if it is there. This file is > automatically executed on the start up of python. Here you can > look for a command line argument (or a local config file) passed >

Re: python for microcontrollers

2005-08-09 Thread Peter Hansen
Evil Bastard wrote: > Paul Rubin wrote: >> Pick a different language. > > Maybe I should clean up my forth compiler instead, and get it ready for > the prime time. In searching for an existing Lua virtual machine** for the PIC, following on my previous posting, I came across several references t

Re: python for microcontrollers

2005-08-10 Thread Peter Hansen
Evil Bastard wrote: > Peter Hansen wrote: >>grabbing >>an off the shelf Forth might be a more productive use of your time. > > Heh, methinks one might be misunderstanding the Forth culture. Lacking entirely in any knowledge of it whatsoever would be a more accurate descr

Re: Bizarre error from help()

2005-08-10 Thread Peter Hansen
Ben Finney wrote: > Roy Smith <[EMAIL PROTECTED]> wrote: > >>I've got a directory where I keep all sorts of little snippets of >>python code for testing. When I start up python in that directory, >>I get the error I reported. It turns out, I've got a file called >>"string.py" in it [...] >> >>so

Re: What are modules really for?

2005-08-10 Thread Peter Hansen
Dan wrote: > You might think of modules in Python as like packages in Java. However, > putting classes in the same module doesn't give them any additional > powers to interact with each other. (At least, not that I know of.) Use of "global" to rebind shared module-scope names... -Peter -- http:/

Re: Catching stderr output from graphical apps

2005-08-10 Thread Peter Hansen
Bryan Olson wrote: > Here's a module to show stderr output from console-less Python > apps, and stay out of the way otherwise. I plan to make a ASPN > recipe of it, but I thought I'd run it by this group first. For what it's worth, I believe you've basically duplicated the functionality available

Re: What is Python?!

2005-08-10 Thread Peter Hansen
Robert Wierschke wrote: > Having read that python is object orientated, I start wondering if > python is the right choice and what it is... > > a scripting language or a "normal" language like C++ etc. Ignore the "scripting language" label and just treat Python as a general purpose "normal"

Re: wxPython and threads again

2005-08-10 Thread Peter Hansen
David E. Konerding DSD staff wrote: > Further, calling wx from a thread other than the one running the event > loop is deep voodoo and should typically be avoided. "Typically"? Let's just say "always" and maybe use the phrase "certain to corrupt wx and crash the app" instead of "deep voodoo".

Re: interpreter frame

2005-08-10 Thread Peter Hansen
Leo wrote: > Why is it not possible to get the frame from the interpreter using the > inspect library? Because sys._getframe() does the job instead? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: interpreter frame

2005-08-11 Thread Peter Hansen
Leo wrote: > Good try, but that doesn't seem to work either. Maybe I should have > emphasized that what I really want is the line of code, as opposed to > the entire frame. Ah, it wasn't clear from your first post that you were specifically interested in a line you entered at the *interactive pr

Re: PEP 328, absolute/relative import

2005-08-11 Thread Peter Hansen
Ben Finney wrote: > Aahz <[EMAIL PROTECTED]> wrote: >>Ben Finney <[EMAIL PROTECTED]> wrote: >>>So, under PEP 328 rules, the original poster's current-directory >>>module could only be imported (a) if the current directory was in >>>sys.path, or (b) if the code specified a relative import. The >>>a

Re: Creating Palm OS programs with python?

2005-08-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > QUick question: > > Is it possible to create a palm os program to use on a PDA with > python? Practically speaking, no. I did find it relatively easy to install and learn enough of Plua to write a useful app for my old Palm V, however, and Lua isn't so far from Pytho

Re: client server question

2005-08-11 Thread Peter Hansen
John wrote: > I have a simple script that runs a server where one client can connect. > I would like to make it so that many clients can connect to one server > on the same port. Where can I find how to do this? Start by reading http://www.catb.org/~esr/faqs/smart-questions.html to learn how to a

Re: read function in python serial

2005-08-11 Thread Peter Hansen
sinan . wrote: > hi i`m developing a program that reads the serial device. i like the > readline() function, but readline() depends on \n character, i want a > similar function that waits for a specific character or string that i > gave like [ETX] (hex03) how can i do this ? > thank you. def seria

Re: Creating Palm OS programs with python?

2005-08-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > There are some links to Python on Palm web resources at my href="http://www.awaretek.com/pymo.html";>Python for Mobile Devices > page. It's nice to see there are still traces of activity but, unfortunately, all those links show is that there's no way to write a real P

Re: wxPython and threads again

2005-08-11 Thread Peter Hansen
David E. Konerding DSD staff wrote: > http://wxwidgets.org/manuals/2.6.1/wx_threadfunctions.html#threadfunctions > > This strongly suggests you can arbitrarily grab the wx GUI lock and call GUI > functions from any thread. It's still voodoo. But we're adults here, and > practicing > voodoo isn'

Re: PEP 328, absolute/relative import

2005-08-11 Thread Peter Hansen
Bengt Richter wrote: > Will/should an __init__.py in the current directory be required, > to control what happens (and lessen the probability of accidental > collision from a random working directory)? I don't think so. That would simply shift the possibility of mysterious behaviour from the iss

Re: command line reports

2005-08-11 Thread Peter Hansen
Darren Dale wrote: > Is there a module somewhere that intelligently deals with reports to the > command line? I would like to report the progress of some pretty lengthy > simulations, and currently I have the new reports written on a new line > rather rather than overwriting the previous report. Y

Re: command line reports

2005-08-11 Thread Peter Hansen
Darren Dale wrote: > Thanks, I didnt realize that \r is different from \n. \r has is a byte with value 13, which is the Carriage Return (CR) control character in ASCII. \n has value 10 and is the Line Feed (LF) character. CR is named after the old teletypewriter operation involving moving the

Re: thread limit in python

2005-08-12 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > and sorry to continue to post here. since this is occurring in both c > and python, i think there's no question i'm running into an os limit. Probably, but I haven't yet seen anyone ask the real important question. What possible use could you have for more than 1000

Re: thread limit in python

2005-08-13 Thread Peter Hansen
Bryan Olson wrote: > Peter Hansen wrote: > > Probably, but I haven't yet seen anyone ask the real important question. > > What possible use could you have for more than 1000 *simultaneously > > active* threads? There are very likely several alternative approaches &

Re: thread limit in python

2005-08-13 Thread Peter Hansen
Bryan Olson wrote: > Peter Hansen wrote: > > My question was in the context of the OP's situation. What possible use > > for 1000 OS threads could he have? > > Is this a language thing? Surely you realize that "what possible > use could be" carries an

Re: sniffer in python

2005-08-15 Thread Peter Hansen
billiejoex wrote: > For python exist a porting called pcapy: > http://oss.coresecurity.com/projects/pcapy.html > ...that I'd like to use BUT... all the examples reported on the sites don't > works!! It usually helps to describe *in what way* things don't work. Do they crash? If so, provide the

Re: sniffer in python

2005-08-15 Thread Peter Hansen
billiejoex wrote: > Thank you for your fast reply. You're right. I'll be more specific, sorry. > The example source is the one you can find on the 'Impacket' page on the > same site of pcapy: > http://oss.coresecurity.com/impacket/sniff.py > I use a Win XP prof sp2 system, python ver. 2.4.1. > Her

Re: __del__ pattern?

2005-08-15 Thread Peter Hansen
Tom Anderson wrote: > Only one socket can be bound to a given port at any time, so the second > instance of SpecialClass will get an exception from the bind call, and > will be stillborn. This is a bit of a crufty hack, though - you end up > with an open port on your machine for no good reason.

Re: __del__ pattern?

2005-08-16 Thread Peter Hansen
Tom Anderson wrote: > On Mon, 15 Aug 2005, Peter Hansen wrote: >> Using '' instead of 'localhost' means bind to *all* interfaces, not >> just the loopback one. > > Doesn't '' mean 'bind to the *default* interface'? What does &q

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-16 Thread Peter Hansen
Antoon Pardon wrote: > Why has one made a difference in search policy for finding a > variable based on whether the variable is rebound or not > in the first place. Do you really not understand the reason, or do you simply disagree with it? It's a choice with rational thought behind it. Whether

Re: How to obtain GMT offset?

2005-08-16 Thread Peter Hansen
Erik Max Francis wrote: > time.timezone gives you the timezone offset in minutes. Dang, that means I'm twelve days in the past! >>> import time >>> time.timezone 18000 >>> 18000/60 300 (So that would be hours? ;-) ) >>> 18000/60/24 12 Wait up guys! -Peter -- http://mail.python.org/mailman

Re: looping list problem

2005-08-16 Thread Peter Hansen
Jon Bowlas wrote: > Ok so I changed it to this: > > attobject = context.get_attobject() > navstring = context.get_uclattribute(attobject, 'ucl_navhide') > hiddennavelements = navstring.split(' ') > for hiddennavelement in hiddennavelements: > yield hiddennavelements > > But I get the followi

Re: __del__ pattern?

2005-08-16 Thread Peter Hansen
Dan wrote: > someSocket.bind(('localhost', somePort)) means accept only connections > from the local machine. Almost: accept only attempts to connect *to* localhost, from the local machine. Attempting to connect -- even locally -- using one of the IP addresses bound to an external interface wil

Re: stopping a python windows service

2005-08-17 Thread Peter Hansen
DK wrote: > I may have taken your code example too literally. I tried putting in > the check for 'shutdownEvent.isset()' but it's failing at run time. > It's looking for a global variable, I guess. Or perhaps "it" is just looking for correct capitalization, since Python is case sensitive. Try sh

Re: Python for Webscripting (like PHP)

2005-08-18 Thread Peter Hansen
Alessandro Bottoni wrote: > (Python has even been told to be used by Yahoo! and Google, among others, > but nobody was able to demonstrate this, so far) Nobody, except Google's founders? http://www-db.stanford.edu/~backrub/google.html (Among many other references.) -Peter -- http://mail.python

Re: Put a url in a browsers address bar

2005-08-18 Thread Peter Hansen
Colin Gillespie wrote: >> >>> I would like to place a url in my browsers address bar, then execute. >>> How can do this? >>> >> >> def goToGoogle(): >> import webbrowser >> webbrowser.open("www.google.com"); >> > > Thanks for the quick reply. Do you know what module I would use to fill >

Re: question about binary and serial info

2005-08-18 Thread Peter Hansen
[EMAIL PROTECTED] wrote: import serial ser = serial.Serial('/dev/ttyS0', 2400, timeout= 10, bytesize=8, stopbits=1) a = ser.read(1) print a It sounds like you want to convert characters into their corresponding integer values. To do this, use the ord() builtin function. >>> ord

Re: question about binary and serial info

2005-08-18 Thread Peter Hansen
Peter Hansen wrote: > ASCII, however, they represent these three characters: "Foo". Your data > looks like chunk when treated as ASCII, so it's probably just bytes. Weird. I think I meant "junk" (not "chunk"), but obviously was writing v

Re: Module Name Conflicts

2005-08-18 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Robert Kern wrote: >>That doesn't work. The first module is recorded as 'cmd' in sys.modules >>and gets reused on the second import. > > Exactly. And clearing sys.modules doesn't fix the problem. Once it's > imported something from the first cmd package, it can no longer

Re: how do i add a new path into sys.path?

2005-08-19 Thread Peter Hansen
Steve Holden wrote: > The method I outlined works only for the duration of a single program > run, because the sys.path variable is set up each time you run the > Python interpreter. You need to look at the suggestions you've had for > setting the PYTHONPATH environment variable to effect change

Re: Python on Palm??

2005-08-19 Thread Peter Hansen
Kalle Anke wrote: > Is there some implementation of Python that runs on Palm OS? > > I've found "Python to Palm Pilot Port" > and Pippy > which both seem to be based on Python > 1.5 > > Is there some imple

Re: Sandboxes

2005-08-21 Thread Peter Hansen
42 wrote: > Thoughts? Still gaping holes? Certainly. And rather than rehash them all here, I'm going to suggest you check the comp.lang.python archives for any of the many past discussions about this before you spend too much time thinking (repeatedly) that you've nailed that one last hole onl

Re: Best way to 'touch' a file?

2005-08-21 Thread Peter Hansen
Kenneth McDonald wrote: > I could've sworn python had such a command, but now I can't find it... > > I'm looking for an easy way to perform a UNIX-style "touch", to update > the modification time of a file without actually modifying it. I could > do something (I imagine) like opening the file

Re: Sandboxes

2005-08-22 Thread Peter Hansen
42 wrote: > But for what its worth, I *am* curious what sorts of holes persist. I > did try googling the archives, but with no idea what I'm looking for -- > python security brings up a mess of unrelated issues... Python in > Apache, rexec/bastion stuff, xss, issues with infinite loops and many

Re: sending binary files to a 16 micro controller.

2005-08-22 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I'm going to try the timed wait alternative, if i get it the > application to work properly i'll post the results in this group and > the code if anyone want's it. It's such a contrast to code a tcp-server > for the microcontroller (MC9S12NE64) in C and coding in python :

Re: loop in python

2005-08-22 Thread Peter Hansen
km wrote: > ya i am sorry i tried with an empty loop first and then one which > emits a value as the snippet. I have tested it on my machine > and now ... > > what more do i need to accept python is slow when it comes to > loops concept ? You've sort of missed some of the points being made,

Re: split function

2005-08-22 Thread Peter Hansen
Mohammed Altaj wrote: > I am reading data from file using readlines() to list , my question > is how to deal with space between any two numbers , I mean , my data What do you mean by "deal with"? Please describe the input and the desired output, or what operations you are trying to perform,

Re: loop in python

2005-08-22 Thread Peter Hansen
km wrote: >>thing. If *all* your loops are going to do is print stuff, then you're >>doing the right thing with the version that "emits values". > > ya most of the loops print values. No, you missed my point. I said if *all* the loops are going to do is print stuff. In other words, no other

Re: combining namespaces when importing two modules

2005-08-22 Thread Peter Hansen
Donnal Walter wrote: > I would like to be able to write something like: > > import dcw as dw > import xyz as dw > > such that the 'dw' namespace includes definitions from both dcw and xyz, > but in the script above names from dcw1 are lost. How can I combine the > two? (I'd rather not use 'impo

Re: Sandboxes

2005-08-22 Thread Peter Hansen
42 wrote: > I was planning on "sanitizing" the language instead of relying on rexec > and bastion so issues with them shouldn't be relevant. I think in dealing with security, deciding what might be relevant before you fully understand the problem is somewhat premature... but it's your neck. :-)

Re: Best way to 'touch' a file?

2005-08-22 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: >>from path import path >>path('myfile').touch() > > import os > os.utime('myfile', None) > > is a bit shorter, of course. And, depending on your needs, quite ineffective: >>> import os >

Re: Best way to 'touch' a file?

2005-08-22 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: >>I guess it depends on whether "touch" implies creation-when-missing, as >>with the command line version, or just updating the time. > > the OP wanted "to update the modification time of a file without actually >

Re: Best way to 'touch' a file?

2005-08-23 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: > >>You've quoted selectively. He also said "Unix-style 'touch'", from >>which one could quite legitimately infer > > nope. read his post again. Sigh. You're being tiring, Fredrik: ''

Re: Sorta noob question - file vs. open?

2005-08-24 Thread Peter Hansen
Peter A. Schott wrote: > Thanks to all who replied. If open is still preferred, I will > stick with that. FWIW, that's not an unqualified "preferred". To demonstrate by example, neither of the above is considered preferred, though they both work: outputFile = file('path.to.file') if i

Re: Exploring outlook using python

2005-08-24 Thread Peter Hansen
Subir wrote: > I am new to this group. I am trying to build an application to see > all the contents of the outlook accounts (USING MAPI). Does anyone has > any information regarding this ? Did you try checking the list archives yet? Go to Google Groups (groups.google.com) and search in the co

Re: Newbie question: Sub-interpreters for CAD program

2005-08-24 Thread Peter Hansen
Terry Hancock wrote: >>I have a strong EE and hardware background (hence my need to write a >>CAD program that doesn't piss me off), but not a CS background. > > Cool. If you do write it and release it, I'd be interested in finding out > about it. > > You probably ought to consider starting with

<    1   2   3   4   5   6   7   8   9   10   >