Re: function in a function accessing vars

2007-06-06 Thread Diez B. Roggisch
): > some_var = 1 > def B(): > some_var += 1 > > B() > > > But this does not work, the function B does not recognize the > some_var. In my mind I thought the scope would propagate to the new > function and the vars would still be accessible. > &g

Re: PATH or PYTHONPATH under Windows ???

2007-06-06 Thread Diez B. Roggisch
> but why is everybody alwasy talking about the "environment variable > PYTHONPATH" ?? Because that variable can be used to additionally customize the search path. But that doesn't imply that it is _all_ there is about python search paths - and it would be pretty crappy if it was, because you can

Re: lists - append - unique and sorted

2007-06-06 Thread Diez B. Roggisch
rhXX wrote: > hi, > > can i append a item to a list using criterias: > > - UNIQUE - if there already exist don't append > - SORTED - INSERT in the correct place using some criteria? Both can be accomplished using the bisect-module. It will give you the leftmost/rightmost insertion point for

Re: Can os.remove followed by os.path.isfile disagree?

2007-06-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Can os.path.isfile(x) ever return True after os.remove(x) has > successfully completed? (Windows 2003, Python 2.3) > > We had a couple of failures in a server application that we cannot yet > reproduce in a simple case. Analysis of the code suggests that the > only po

Re: Running a process every N days

2007-06-07 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > What's the best way to run either an entire python process or a python > thread every N days. I'm running Python 2.4.3 on Fedora Core 5 Linux. > My code consists of a test and measurement system that runs 24/7 in a > factory setting. It collects alot of data and I'd lik

Re: compiling python and calling it from C/C++

2007-06-08 Thread Diez B. Roggisch
Russ schrieb: > Is it possible to compile python code into a library (on unix), then > link to it and call it from C/C++? If so, where can I learn how. You can't compile python, but what you can do is create a library-wrapping around it using elmer which will make it C-callable. http://elmer.sou

Re: how to do reading of binary files?

2007-06-08 Thread Diez B. Roggisch
jvdb schrieb: > Hi all, > > I need some help on the following issue. I can't seem to solve it. > > I have a binary (pcl) file. > In this file i want to search for specific codes (like <0C>). I have > tried to solve it by reading the file character by character, but this > is very slow. Especially

Re: how to do reading of binary files?

2007-06-08 Thread Diez B. Roggisch
jvdb schrieb: > On 8 jun, 14:07, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> jvdb schrieb: > .. >> What has the searching to do with the reading? 10MB easily fit into the >> main memory of a decent PC, so just do >> >> contents = open

Re: converting an int to a string

2007-06-08 Thread Diez B. Roggisch
Sean Farrow schrieb: > Hi: > I have the folling code: > def parseTime(self, time): > minutes =int(float(time)/60) > seconds =int(float(time)-minutes*60) > minutes =str(minutes) > seconds =str(minutes) > the statements that convert the m

Re: matching objects by a tuple field criterion

2007-06-10 Thread Diez B. Roggisch
g. given the following python objects: > > object A includes tuple (1,2,3,4,5,6) > object B includes tuple (1,4,4,4,11,1) > object C includes tuple (1,3,9,1,1,1) > > all tuples are unique. for what it's worth, the values in each field > are independent of t

Re: matching objects by a tuple field criterion

2007-06-10 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: > bullockbefriending bard schrieb: >> i have a large collection of python objects, each of which contains an >> integer 6-tuple as part of its data payload. what i need to be able to >> do is select only those objects which meet a simple tuple element

Re: How can I obtain the exception object on a generlized except statement?

2007-06-10 Thread Diez B. Roggisch
Chris Allen schrieb: > I am confused on one aspect of exception handling. If you specify the > exception object type to match in an except statement it is possible > to also obtain the exception object itself, but I can't figure out how > to get the exception object when I don't specify a match. >

Re: matching objects by a tuple field criterion

2007-06-10 Thread Diez B. Roggisch
bullockbefriending bard schrieb: >> Instead of passing a wild-card tuple like (*,*,*,4,*,*) simply pass the >> integer you want to match and the position you want to match it in. > > for sure. that was more for expository purpose rather than how i was > planning to go about it. > > >> As a gener

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-11 Thread Diez B. Roggisch
>It's hard to optimize Python code well without global analysis. > The problem is that you have to make sure that a long list of "wierd > things", like modifying code or variables via getattr/setattr, aren't > happening before doing significant optimizations. Without that, > you're doomed to a

Re: skip next item in list

2007-06-11 Thread Diez B. Roggisch
ahlongxp wrote: > list=('a','d','c','d') > for a in list: > if a=='a' : > #skip the letter affer 'a' > > what am I supposed to do? First - don't use list as name, as it is a builtins-name and shadowing is likely to produce errors at some point. list_iterator = iter(('a','d','c','d')

Re: A gotcha: Python pain point?

2007-06-12 Thread Diez B. Roggisch
James Stroud wrote: > Beorn wrote: >> Consider this example: >> >> >>> def funcs(x): >> ... for i in range(5): >> ... def g(): return x + i >> ... yield g >> >> I would expect the value of x used in g to be that at the function >> declaration time, as if you've pass g

Re: A gotcha: Python pain point?

2007-06-12 Thread Diez B. Roggisch
Beorn wrote: > Consider this example: > > >>> def funcs(x): > ... for i in range(5): > ... def g(): return x + i > ... yield g > > I would expect the value of x used in g to be that at the function You mean i here, don't you? > declaration time, as if you've pass g a

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-12 Thread Diez B. Roggisch
John Nagle wrote: > Diez B. Roggisch wrote: >> Regardless of the possibility of speeding it up - why should one want >> this? Coding speed is more important than speed of coding in 90%+ of all >> cases. > > When you have to start buying more servers for the serv

Re: Pattern Classification Frameworks?

2007-06-12 Thread Diez B. Roggisch
Evan Klitzke wrote: > Hi all, > > What frameworks are there available for doing pattern classification? > I'm generally interested in the problem of mapping some sort of input > to one or more categories. For example, I want to be able to solve > problems like taking text and applying one or more

Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread Diez B. Roggisch
gt; same syntax will get a generator, not a tuple. Here is my example: >> >> In [147]: a = (i for i in range(10)) >> >> In [148]: b = [i for i in range(10)] >> >> In [149]: type(a) >> Out[149]: >> >> In [150]: type(b) >> Out[150]: >>

Re: Method much slower than function?

2007-06-14 Thread Diez B. Roggisch
Grant Edwards schrieb: > On 2007-06-14, Leo Kislov <[EMAIL PROTECTED]> wrote: >> On Jun 13, 5:40 pm, [EMAIL PROTECTED] wrote: >>> Hi all, >>> >>> I am running Python 2.5 on Feisty Ubuntu. I came across some code that >>> is substantially slower when in a method than in a function. >>> >> cProfi

Re: qt4 setFlags

2007-06-14 Thread Diez B. Roggisch
luca72 schrieb: > Hello > > I make this code: > row = self.tableWidget.rowCount() > for a in range(row): > self.tableWidget.item(row, 0).setFlags(Qt.IsSelectable) > > i have this erroror : > > global name Qt is not definied import Qt might help. And reading the python tutori

Re: using Mac OS X CoreGraphics via ctypes

2007-06-14 Thread Diez B. Roggisch
Daniel schrieb: > I'm trying to implement a routine that converts a PDF document to > image files using ctypes and the Apple CoreGraphics library as per the > 'Splitting a PDF File' example on Apple's web site [0]. Unfortunately > I cannot use the CoreGraphics module used in that example because I'

Re: save class

2007-06-15 Thread Diez B. Roggisch
> of having to keep track of a separate dictionary file. I am new to > this, but I thought that this would be a regular thing to do in > python, because people must make classes in the interactive console > and then export them somehow for later use. No. That's not how things work. One does dabble

Re: using Mac OS X CoreGraphics via ctypes

2007-06-18 Thread Diez B. Roggisch
Daniel wrote: >> > # the next line causes a segfault - what's the right way to do this? >> > #GCS_RGB = cglib.kCGColorSpaceGenericRGB() >> >> Usually, things in the OSX lib that start with k* are a constant - not a >> function. As is this. >> >> Diez > > That's what I thought too. But when I try

Re: Having lots of fun passing parameters ... help!

2007-06-18 Thread Diez B. Roggisch
t to add to the fun, once I've reached this stage I would like > to either a) be able to execute this .py file from a HTML environment > or b) execute this file as a .exe and embed into HTML (which I can > do). You get the parameters to a script executed at the shell using import sys pr

Re: static python classes ?

2007-06-19 Thread Diez B. Roggisch
Tom Gur wrote: > Hi, > > I'm new to python, and I can't seem to find in the docs how to create > the python equivalent of what's called in most OOP languages "static > classes", can you give me a hint ? With other OOP languages you mean Java. Which does have static methods because they lack the

Re: static python classes ?

2007-06-20 Thread Diez B. Roggisch
Bjoern Schliessmann wrote: > Diez B. Roggisch wrote: > >> With other OOP languages you mean Java. Which does have static >> methods because they lack the notion of a function by its own, so >> the shoehorned them into their "everything is inside a >> class

Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Diez B. Roggisch
> What about JSON? You can serialize your dictionary, for example, in > JSON format and then unserialize it in any language that has a JSON > parser (unless it is Javascript). There is an implementation available for python called simplejson, available through easy_install. Diez -- http://mail.p

Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Diez B. Roggisch
Joe Riopel wrote: >> Precisely what? You complained that the OP didn't provide the location >> of the event, which he did. > > Well, where is DFW? Google, first hit: The Dallas Ft. Worth Pythoneers They even have their own website. So - what's the fuss about? The BayPIGgies also announce their

Re: How to hide a program?

2007-06-20 Thread Diez B. Roggisch
jvdb wrote: > Hi all, > > I've created a program that receives files and opens the corresponding > program (for example adobe acrobat). However, when started, i would > like to see nothing of the running program. I only want to see the > program that will be opened. > Is it possible to start a pr

Re: class attributes & data attributes

2007-06-20 Thread Diez B. Roggisch
james_027 wrote: > hi everyone, > > I am now in chapter 5 of Dive Into Python and I have some question > about it. From what I understand in the book is you define class > attributes & data attributes like this in python > > class Book: > > total # is a class attribute > > def __init__

RE: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Looney, James B
Short answer: DFW = Dallas-Fort Worth Longer answer: I'm not pointing fingers or making opinions, I just wanted to point out that after reading Jeff's original email (in its entirity), I found: Jeff wrote: > at the usual location of Nerdbooks.com bookstore in Richardson. For So, after looking

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-20 Thread Diez B. Roggisch
> > Of course I understand the virtue of writing code with good > doctests, etc. But my question is why we can't get some more > static typing as well. Given the tools that'll be in Python > 3.0, that doesn't seem unreasonable to ask. That is exactly the problem - there is no "some more" static t

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-21 Thread Diez B. Roggisch
kaens schrieb: > On 6/20/07, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > >> That is exactly the problem - there is no "some more" static typing. >> There is static typing - or not. You can't have it "just a bit". > > Couldn't a l

Re: possible to preserve subprocess.Popen objects for later?

2007-06-21 Thread Diez B. Roggisch
Ratko schrieb: > Hi all, > > I have a python gui app that launches multiple applications using > subprocess.Popen class and prints their output in the gui (using > PIPEs, threads and wxPython). Everything works great but the problem > is that some applications should run in the background (ie they

Weekly Python Patch/Bug Summary

2007-06-22 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs: 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches __ syslog sy

Re: how to query/test the state of a qt widget?

2007-06-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi, > > I'm writing a simple Python/Qt3 application and I am trying to write > some code in which the user presses a button and the program performs > action A or B depending upon the state of a pair of radio buttons. I > would therefore like P

Client -> web server communication

2007-06-25 Thread Looney, James B
I'm trying to understand how to write an app that runs on my local machine, and talks to a hosted website to get access to the MySQL database I have stored there. I've read a few articles on Basic Authentication, so at least that part I partially understand (I plan on having username/password pair

Re: Face Recognition

2007-06-26 Thread Diez B. Roggisch
Henrik Lied wrote: > Hi there! > > Has anyone made effort to try to create a python binding to a facial > recognition software [1]? > > For those of you with some experience - would this be very hard? OpenCV has a python-binding. And a ctypes-binding. Diez -- http://mail.python.org/mailman/l

Re: Installing python under the linux

2007-06-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello, > >>No. The only way to change the keywords would be to edit the >>Python source and re-compile it. > > This was very helpful information , I already know that but I don't > know how > to that.PLEASE HELP ME ABOUT THIS, I WILL BE VERY GRATEFUL TO YOU. > > ( I

Re: Reversing a string

2007-06-27 Thread Diez B. Roggisch
Scott wrote: > Yeah I know strings == immutable, but question 1 in section 7.14 of "How > to think like a computer Scientist" has me trying to reverse one. > > I've come up with two things, one works almost like it should except that > every traversal thru the string I've gotten it to repeat the

Re: exception from a thread

2007-06-28 Thread Diez B. Roggisch
_spitFIRE schrieb: > assume a scenario, where there is a class that for doing some work, > spawns lot of threads. > > class X: > def __init__(self): > # Spawns some threads to > # do some work > > now, assuming that at least one of the threads encounters a problem > while doin

Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
> You apparently didn't look very hard. On the wxPython end of things > (which I have experience with), there is wxGlade, XRCed, Boa > Constructor, Dabo, etc. I don't know about Tkinter (I don't use it), > but I know that at least Qt has a very nice GUI designer and builder > (from Trolltech

Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
Thorsten Kampe schrieb: > Hi, > > I've already sent this to the Komodo mailing list (which seemed to me > the more appropriate place) but unfortunately I got no response. > > I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor > PyQT are actually what I want (because the lack o

Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
Sebastian Wiesner schrieb: > [ "Diez B. Roggisch" <[EMAIL PROTECTED]> ] >> And as it has been said in this thread already, Qt has an excellent free >> GUI-builder. > > Free as long as you develop free software. Development of proprietary, > non-gpl softwa

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Diez B. Roggisch
> > wrt/ proofs of correctness, I'll just point to the spectacular failure > of Ariane, which was caused by a *runtime* type error in a system > programmed in ADA - one of the languages with the most psychorigid > declarative static type systems. That's simply not true. The problem hadn't to d

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-01 Thread Diez B. Roggisch
> > """ > Because of the different flight path, a data conversion from a 64-bit > floating point to 16-bit signed integer value caused a hardware > exception (more specifically, an arithmetic overflow, as the floating > point number had a value too large to be represented by a 16-bit signed >

Re: Reading image dimensions before it is loaded from a web form using python.

2007-07-01 Thread Diez B. Roggisch
> > Without running some special client-side application, I think you'd > have to do some trickery with the web server involving artificially > stopping the upload after receiving enough bytes to constitute the > image header, and then deciding whether or not to proceed with the > upload at that p

Re: Python + Google Calendar API issue

2007-07-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi, > > I was trying to hook into Google Calendar today using their gdata > module for Python, but I can't seem to get Python to work with it. > When I run the setup.py from the command line, I get the following: > > Traceback (most recent call last): > File "J:\Pyt

Re: how to send files via bluetooth with python to a mobile

2007-07-01 Thread Diez B. Roggisch
Drex schrieb: > Hey, > >>> I'm not sure but try this: ( py_s60 ) >>> http://sourceforge.net/projects/pyed/ > >> and also try this: >> >> http://sourceforge.net/projects/pys60 > > thanks, but I am affraid this is not what I was looking for. I need to > have some library on my pc (linux) that w

Re: how to send files via bluetooth with python to a mobile

2007-07-01 Thread Diez B. Roggisch
morphine schrieb: > Diez B. Roggisch wrote: > >> Wrap this >> >> http://www.zuckschwerdt.org/apidocs/ > > seams that python bindings are already there? > http://dev.zuckschwerdt.org/openobex/wiki/ObexFtpExampleClientPython Cool, didn't find that. d

Re: try/finally in threads

2007-07-03 Thread Diez B. Roggisch
George Sakkis wrote: > I posted this on the Pyro list but I'm not sure if it's related > specifically to Pyro. The "finally" clause below is not executed when > f() runs on on a (daemon) thread and the program exits. DAEMON here is > a global Pyro.code.Daemon instance. > > def f(): >try: DAEM

Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-04 Thread Diez B. Roggisch
Siegfried Heintze schrieb: > I love the typing assist I get when using C# in VS2005 to write COM clients. > > I need to write a program to automate some tasks in outlook. Givin that the > typing assist feature is very important to me, what would be the best > combination of IDE and language for

Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-04 Thread Diez B. Roggisch
"M��" schrieb: > Hi! > >> I love the typing assist I get when using C# in VS2005 to write COM >> clients. > > But this run only for static-COM-servers. Dynamic-COM-servers are not > supported by these assists. No. The IDIspatch-interface explicitely list

Re: Expandable 2D Dictionaries?

2007-07-06 Thread Diez B. Roggisch
Robert Dailey wrote: > Hi, > > I am interested in creating an expandable (dynamic) 2D dictionary. For > example: > > myvar["cat"]["paw"] = "Some String" > > The above example assumes "myvar" is declared. In order for this to > work, I have to know ahead of time the contents of the dictionary. F

Re: C++ Modules for python: How to?

2007-07-06 Thread Diez B. Roggisch
Robert Dailey schrieb: > Hi, > > I'm interested in making a C++ library of mine usable through python. > Python does a similar thing with Expat (the non-validating XML > parser). I notice that with Expat, python is importing a C++ header > file into a PY file and the interface is available to pyth

Re: C++ Modules for python: How to?

2007-07-07 Thread Diez B. Roggisch
> > How do I install SIP? I can't seem to do this. I've downloaded the > package and read the README file, but I don't see a way of installing > it on windows. I ran the configure.py file but then it generates > makefiles to run which can't be run on windows. I also attempted to > download QT but

Re: Decorating instance methods

2007-07-09 Thread Diez B. Roggisch
lasses with reference to the instances. For example: > > I have a class A: > > class A(object): >def __init__(self, name): >self.name=name > >@logging >def hello(self, name): > print 'Hello World.' > > > > >&g

Re: A clean way to program an interface

2007-07-09 Thread Diez B. Roggisch
rh0dium wrote: > Hi all, > > I got this new radio scanner (toy!!) this weekend and I can access it > via a serial cable. I want to write a interface around it but I am > looking for some suggestions. I thought at first I would simply class > the Scanner and write the various methods as attibutes

Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Diez B. Roggisch
Bjoern Schliessmann wrote: > Paul Rubin wrote: >> lex <[EMAIL PROTECTED]> writes: > >>> list = [1, True, True, False, False, True] >>> status = True >>> for each in list: >>> status = status and each >>> >>> but what is your best way to test for for False in a list? >> >> status = all(list)

Re: A clean way to program an interface

2007-07-09 Thread Diez B. Roggisch
rh0dium wrote: > On Jul 9, 3:53 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> THROW IT AWAY >> >> Seriously. That's one of the most convoluted, incomprehensible pieces of >> python I've seen. Ever. >> >> All the sys._getf

Re: catching empty strings (I guess that's what they are)

2007-07-09 Thread Diez B. Roggisch
brad wrote: > I've began accepting user input :( in an old program. The input comes > from a simple text file where users enter filenames (one per line). What > is the appropriate way to handle blank lines that hold whitespace, but > not characters? Currently, I'm doing this: > > for user_f

Re: Python ghost compile

2007-07-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I split a large python (2.5.1) program into three modules. Let's call > them mainmod, submod1, and submod2. mainmod imports submod1 and submod2. > When I make changes to any of these modules, it is not reflected in the > compile. Only if exit idle and re-run idle. I

Weekly Python Patch/Bug Summary

2007-07-09 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 392 open ( +7) / 3792 closed ( +2) / 4184 total ( +9) Bugs: 1042 open (+13) / 6757 closed (+13) / 7799 total (+26) RFE : 263 open ( +1) / 292 closed ( +1) / 555 total ( +2) New / Reopened Patches __ "%d" form

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-10 Thread Diez B. Roggisch
Paul Rubin schrieb: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >>> Which implies that even in ADA, runtime type errors are in fact >>> expected - else there would be no handler for such a case. >> Well, yes, runtime errors occur - in statically typ

Re: Get a filename list of a web site

2007-07-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Thanks, faulkner, > years ago I used on Windows Teleport, which had the possibilty to > download > only the file list. I hoped that in Linux with the aid of python & > wget ssh. Runs on nearly all linuxes. Diez -- http://mail.python.org/mailman/listinfo/python-li

Re: Visualizing a wav file?

2007-07-11 Thread Diez B. Roggisch
kaens wrote: > On 7/11/07, Wim Vogelaar <[EMAIL PROTECTED]> > wrote: >> Perhaps you can use parts/routines of Audacity. >> See: http://en.wikipedia.org/wiki/Audacity >> >> Wim Vogelaar, http://home.wanadoo.nl/w.h.vogelaar/ >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >

Re: stripping the first byte from a binary file

2007-07-11 Thread Diez B. Roggisch
> > Forgive my newbie ignorance, but I am wondering why the other method > would not work? I mean it may not be very safe, > but I guess it may perform a lot better, than having to read the whole > file just to cut out the first byte. Because seeking is not moving? Shifting data bytewise isn't so

Re: stripping the first byte from a binary file

2007-07-11 Thread Diez B. Roggisch
Alex Popescu wrote: > On Jul 11, 4:15 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> > Forgive my newbie ignorance, but I am wondering why the other method >> > would not work? I mean it may not be very safe, >> > but I guess it may perfo

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-13 Thread Diez B. Roggisch
John Nagle schrieb: > Chris Mellon wrote: >> You can't prove a program to be correct, in the sense that it's proven >> to do what it's supposed to do and only what it's supposed to do. > > Actually, you can prove quite a bit about programs with the right > tools. > For example, proving that a

Re: Class decorators do not inherit properly

2007-07-13 Thread Diez B. Roggisch
oblem? class Meta(type): def __init__(cls, *args): print "Meta.__init__ called" return super(Meta, cls).__init__(*args) class A(object): __metaclass__ = Meta def decorator(f): print "decorator called" return f @decorator def foo(s

Re: Fetching a clean copy of a changing web page

2007-07-15 Thread Diez B. Roggisch
John Nagle schrieb: >I'm reading the PhishTank XML file of active phishing sites, > at "http://data.phishtank.com/data/online-valid/"; This changes > frequently, and it's big (about 10MB right now) and on a busy server. > So once in a while I get a bogus copy of the file because the file > was

Re: Accessing Python variables in an extension module

2007-07-16 Thread Diez B. Roggisch
MD wrote: > Hi Alex, >Thanks for your reply. It was exactly what I was looking for. Two > additional questions > 1) Is there anyway to find out which modules a variable belongs to > when I have only its name (and its not qualified with the complete > name like module.varname) No. > 2) Is the

Re: Private functions and inheritance

2007-07-16 Thread Diez B. Roggisch
eturn self.__bar() > def __bar(self): return "A::__bar()" > def bar(self): return "A::bar()" > > class B(A): > def __bar(self): return "B::__bar()" > def bar(self): return "B::bar()" > > b = B() > print &q

Re: how to read python-doc in ubuntu?

2007-07-16 Thread Diez B. Roggisch
ZelluX wrote: > Hi all, > I'm a new comer to Python. > I've installed python-doc module, but just don't know how to open it. > Could you help me? > > Many thanks ^_^ dpkg -L will list the contents of the package at question. Doc packages usually reside under /usr/shar/doc/ diez -- http://

Re: The ** operator ambiguous?

2007-07-16 Thread Diez B. Roggisch
Robert Dailey schrieb: > I noticed that the ** operator is used as the power operator, however > I've seen it used when passing variables into a function. For example, > I was researching a way to combine dictionaries. I found that if you > do this: > > a = {"t1&qu

Re: Is it possible to run two "while 1:" loops in two threadings respectively?

2007-07-17 Thread Diez B. Roggisch
zxo102 schrieb: > Hi, >I would like to combine two python applications into a single one > with two threadings. Both of them have a "while 1:" loop respectively. > For example, one application is to monitoring serial port 'com1' and > another application is a TCP/IP server which has used thread

Re: Single-stepping through a python script

2007-07-17 Thread Diez B. Roggisch
Craig Howard schrieb: > Hello All: > > Is is possible to compile a code object and single-step through its > execution? import pdb; pdb.set_trace() Look up the pdb module documentation. Diez -- http://mail.python.org/mailman/listinfo/python-list

Weekly Python Patch/Bug Summary

2007-07-17 Thread Kurt B. Kaiser
maury Forgeot d'Arc Patch for [ 735515 ] urllib2 should cache 301 redir (2007-07-18) http://python.org/sf/1755841 opened by O.R.Senthil Kumaran Show Location of Unicode Escape Errors (2007-07-18) http://python.org/sf/1755885 opened by Kurt B. Kaiser Patches Closed

Re: Single-stepping through a python script

2007-07-18 Thread Diez B. Roggisch
Craig Howard wrote: > >>Craig Howard schrieb: > >> Hello All: > >> > >> Is is possible to compile a code object and single-step through its > >> execution? > > >import pdb; pdb.set_trace() > > > >Look up the pdb module documentation. > > > >Diez > > Sorry, I didn't give enough detail.

Re: Property Descriptor - Public Getter, Private Setter

2007-07-18 Thread Diez B. Roggisch
gamehack wrote: > Hi all, > > I was looking around the net to figure out how I can use the > property() descriptor to make a property readable by everyone and only > settable by the class or any derived classes. Thanks. Forget it. You can try and come up with an implementation that will check th

Re: New guy question - user form

2007-07-18 Thread Diez B. Roggisch
meg99 schrieb: > I am using a scheduling sw package that uses Python as its scripting > language much like Excel uses Visual Basic. I am fluent in VB but I > am just beginning in Python. > > What I need to do is this: I need to create a user form that will > contain some predefined data (capture

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-20 Thread Diez B. Roggisch
Paul Rubin schrieb: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> For example, SPARK does not support dynamic allocation of memory so >> things such as pointers and heap variables are not supported. > > Right, Spark uses a profile intended for embed

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-20 Thread Diez B. Roggisch
Paul Rubin wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> What does that buy you - where is "I'm crashed becaus I ran out of >> memory trying to evade the seventh mig" better than "sorry, you will >> be shot down because I&

Weekly Python Patch/Bug Summary

2007-04-18 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 357 open ( +8) / 3745 closed ( +8) / 4102 total (+16) Bugs: 958 open (+19) / 6657 closed ( +9) / 7615 total (+28) RFE : 251 open ( +2) / 280 closed ( +2) / 531 total ( +4) New / Reopened Patches __ Help with

Re: setDaemon problem.

2007-04-20 Thread Diez B. Roggisch
Ramashish Baranwal schrieb: > Hi, > > I am facing an issue in daemonizing a thread using setDaemon method. > Here is my code- > > import time > from threading import Thread > > class MThread(Thread): > def run(self): > f = open('/tmp/t.log', 'w') > for i in range(10): >

Re: Do other Python GUI toolkits require this?

2007-04-20 Thread Diez B. Roggisch
bout verticale clifs and such? > > The analogy with a walk is just silly because curves are not like walks. > Nobody will say something like: I won't invest in that company because > it has a steep profit curve or the reverse: I'll invest in this company > because it has a

Re: Do other Python GUI toolkits require this?

2007-04-21 Thread Diez B. Roggisch
Antoon Pardon schrieb: > On 2007-04-20, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>> So if you have the choice between a steep or a shalow income curve >>> you will prefer the shalow curve because a steep curve makes you >>> think about verticale clifs and s

Re: Convert from/to struct_time

2007-04-22 Thread Diez B. Roggisch
Florian Lindner schrieb: > Hello, > I have a struct_time and a datetime object and need compare them. Is there > any function that converts either of these two to another? datetime.datetime(*time.localtime()[:6]) Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes: how to make a structure pointer to point to a buffer

2007-04-23 Thread Diez B. Roggisch
人言落日是天涯,望极天涯不见家 wrote: > first, I'm try the POINTER to convesion the pointer type. but failed. > > class STUDENT(Structure): > _fields_ = [('name', c_int), > ('id', c_int), > ('addition',c_ubyte)] > > buffer = c_byte * 1024 > student_p = cast(bu

Re: Two syntax questions (newbie)

2007-04-23 Thread Diez B. Roggisch
> This is already better. Is it possible to define function composition > as an operator and have something like ([EMAIL PROTECTED]@sorted)(items) > or (list*reversed*sorted)(items) ? Not on functions, but on classes/instances. So something like this might work for you (untested): class FunctionC

Re: Do other Python GUI toolkits require this?

2007-04-23 Thread Diez B. Roggisch
> I had originally thought that learning PyObjC might preclude me from > having to learn Objective-C, but that seems not to be the case. I have > previously found the same to be true with PyQt and wxPython--not knowing > the toolkits as they are implemented in C++ is a serious handicap. I've > even

Re: Python Widget to read in user input box in blog

2007-04-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hey, > > I am helping to develop a project that displays images based on user > input. One possible way of implementing this is via a widget that > when it is run, would read in the users input from an input text field > (probably from a blog), and replace it with the

Re: adjust

2007-04-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, > How do i right adjust my output using python.I need a output > something like this: > DID= 0x01,0x02,0x03,0x05,0x06,0x07,0x2B,0x30,0x31,0x4D,0x4E, > 0x51,0x52,0x53,0x55, > minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1, > 2, 2, 1,

Re: getting scancodes

2007-04-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > On Tue, Apr 24, 2007 at 04:40:11AM -, Grant Edwards wrote: >> On 2007-04-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> >> > Anyone knows if its possible to get scan codes ??? >> >> What hardware? What OS? > > Debian Sarge/Etch, i386.. > > :P Gret.

Re: q: how to output a unicode string?

2007-04-24 Thread Diez B. Roggisch
Frank Stajano wrote: > A simple unicode question. How do I print? > > Sample code: > > # -*- coding: utf-8 -*- > s1 = u"héllô wórld" > print s1 > # Gives UnicodeEncodeError: 'ascii' codec can't encode character > # u'\xe9' in position 1: ordinal not in range(128) > > > What I actually want to

Re: PIL and font colours.

2007-04-24 Thread Diez B. Roggisch
Johny schrieb: > I use PIL to write some text to a picture.The text must be seen wery > clearly. > I write the text to different pictures but to the same position. As > pictures maybe different, colour, in the position where I write the > text, is also different. > Is there a way how to set the

Re: Blank rows resulting from simple csv script

2007-04-24 Thread Diez B. Roggisch
Drew schrieb: > Hi all - > > I've written a simple script to read a .csv file and then write out > rows to a new file only if the value in the 4th column is a 0. Here's > the code: > > import csv > > reader = csv.reader(open('table_export.csv','rb')) > > writer = csv.writer(open('new_jazz.csv',

Re: how to serialize a COM object ?

2007-04-24 Thread Diez B. Roggisch
vml schrieb: > I have a problem : > > I have a COM object. > > I would like to pass this com object from a server to a client through > a socket. > > I tried to put the com object into a stringIO with the pickle module > but : > > "can't pickle PyIDispatch objects" > > > Is there other possib

<    11   12   13   14   15   16   17   18   19   20   >