Re: 10GB XML Blows out Memory, Suggestions?

2006-06-07 Thread Diez B. Roggisch
fuzzylollipop wrote: > > Fredrik Lundh wrote: >> fuzzylollipop wrote: >> >> > you got no idea what you are talking about, anyone knows that something >> > like this is IO bound. >> >> which of course explains why some XML parsers for Python are a 100 times >> faster than other XML parsers for Pyt

Re: creating and naming objects

2006-06-07 Thread Diez B. Roggisch
Brian wrote: > I have a question that some may consider silly, but it has me a bit > stuck and I would appreciate some help in understanding what is going > on. > > For example, lets say that I have a class that creates a student > object. > > Class Student: > def setName(self, name) >

Re: Newbie question about updating multiple objects ...

2006-06-08 Thread Diez B. Roggisch
t; left = curve(pos=[(minx, miny),(minx, maxy)], color = color.white) > top = curve(pos = [(minx, maxy),(maxx, maxy)], color = color.white) > right = curve(pos = [(maxx, maxy),(maxx, miny)], color = color.white) > bottom = curve(pos = [(maxx, miny),(minx,miny)], color = color.white) > &

Re: Terminateable thread

2006-06-08 Thread Diez B. Roggisch
Laszlo Nagy wrote: > > I wote a TThread class that is 'soft terminateable'. For example: > > class MyProcessor(TThread): > def run(self): >while not self.terminated(): > self.process_one_item() > > > My question is that, do I really need to use events for this? Because

Re: Interacting with a process that I ran with subprocess module

2006-06-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi folks, > > I'm trying to use the nmap runtime interaction feature while using it > with the subprocess module. For those not familiar with nmap, the > runtime interaction feature allow users to get informations about the > scan stats during the nmap execution. More

Re: Killing a thread

2006-06-10 Thread Diez B. Roggisch
> Are there any plans in the future to add the capability to kill threads > from the outside? Better yet, an interruptable thread so instead of > using a polling loop you could send a DIE_THREAD_DIE signal or > something. I think at present its not possible (or a really bad idea) > to put sig

Re: Killing a thread

2006-06-10 Thread Diez B. Roggisch
> Python uses the underlying OS thread implementation. It does _not_ spawn > new threads. Obviously that was meant to be "spawn processes" Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: unsubscriptable object

2006-06-11 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Can anybody tell me why am I getting this error message while trying to > print a part of a string. Is there a better approach for this... Because you don't use a string? The error message is pretty clear: TypeError: unsubscriptable object So - what are Function[:10]

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > What's the difference between initializing class variables within the > class definition directly versus initializing them within the class's > __init__ method? Is there a reason, perhaps in certain situations, to > choose one over the other? You are confusing class va

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Diez B. Roggisch
> No need to be obnoxious. I do appreciate your efforts to help, but you > must admit, your last statement is a bit snide and certainly not > useful. > I'm telling you that the code runs differently on my laptop. It certainly doesn't. There is absolutely no imaginable way how this behavior could

Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function

2006-06-12 Thread Diez B. Roggisch
Dennis Lee Bieber schrieb: > I don't know? How does "SetTimeout" actually behave? Asynchronously? > Synchronously? That is... would The former. It is the poor-mans threading of JavaScript so to speak. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Using PHP in Python

2006-06-12 Thread Diez B. Roggisch
Tgone wrote: > Hello, > > I've come across sites that discuss embedding Python in PHP, but is it > possible to access PHP functions in Python? I'm not aware of a generic wrapper thingy. Which doesn't mean there is none. But which functions are you interested in? I can't believe there is much tha

Re: Using PHP in Python

2006-06-12 Thread Diez B. Roggisch
> I have some custom PHP functions that I didn't want to re-write in > Python. But maybe I should just rewrite them :) Certainly yes. And you'd be amazed how easier it is in python, I believe. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: (pre)forking server framework?

2006-06-12 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > > Hi! > > I'm quite new to Python development. Can someone advise me a framework > useful for building (pre-)forking or threaded TCP servers, other than > SocketServer ? I've seen source code of a few python-based app servers, > all of theme seem to reinvent the wheel,

Re: What's wrong in this HTML Source file of a Bank

2006-06-13 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > > They don't know whats happeing despite sending them several e-mails. So what? How are _we_ supposed to know? Even if somebody here found a bug in their java script (this is a Python NG, btw...) - now _how_ exactly are you planning to update their website with that in

Re: Combining The Best Of Python, Ruby, & Java??????

2006-06-13 Thread Diez B. Roggisch
> But semantically it is a proper functional language. The features may > not attract Python users who might prefer Boo/Jython/IronPython. But it > does offer something to disillusioned Groovy users. Are they disillusioned? Just wondering. Diez -- http://mail.python.org/mailman/listinfo/python-l

Re: What's wrong in this HTML Source file of a Bank

2006-06-13 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > > I have posted the same question in alt.html but no one yet replied. No wonder. -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimals

2006-06-13 Thread Diez B. Roggisch
Tgone wrote: > Sybren Stuvel wrote: >> Tgone enlightened us with: >> > Sorry, when I print out the variable it displays as '15.0'. The >> > price is '15.00' in the database though. >> >> That's the same thing, isn't it? 15.0 == 15.0 > > Yes, they're both mathematically the same. I never s

Re: question on dict subclassing and overriding __setitems__

2006-06-13 Thread Diez B. Roggisch
Eric S. Johansson schrieb: > I apologize if this is an FAQ but googling has not turned up anything, > at least to my keywords. > > I need to parse a configuration file from an existing application and > I'm treating it as a dictionary. I created my class with a parent class > of dict. Everyth

Re: determining file type

2006-06-14 Thread Diez B. Roggisch
Ritesh Raj Sarraf schrieb: > Also, > f = file ('some_file.jpg') > > throws an error. > "str object is not callable" I bet you have rebound "file" to a string, like this: file = "some name" And PLEASE don't top-quote: http://www.redballoon.net/~snorwood/quote-rant.shtml Diez -- http://mail.

Re: File read and writing in binary mode...

2006-06-14 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi, > > I'm trying to open a file (any file) in binary mode and save it inside > a new text file. > After that I want to read the source from the text file and save it > back to the disk with its original form. The problem is tha the binary > source that I extract from

Re: Using "external" vars on module load time

2006-06-14 Thread Diez B. Roggisch
Marco Aschwanden schrieb: > Marvelous that was the solution I was looking for. > >> I think you should consider a class instead of a module, though. > > What I don't get: Why should I consider using a class? Because sharing state in such a way that several functions need to access some later bo

Re: Tiddlywiki type project in Python?

2006-06-14 Thread Diez B. Roggisch
> Well, that may be an/the answer, since another form of my question > would be 'how can I write a TiddlyWikiLike using Python instead of JS' > ;-). I appreciate that it might involve, for instance, a local server. > Does the idea of embedding python in a browser instead of Javascript > make any se

Re: distutils `requires' tag

2006-06-15 Thread Diez B. Roggisch
jimburton schrieb: > Hi, I'm using python 2.3.5 and want to use distutils to distribute a > module that depends on another - is there any way to specify that? Use setuptools. It can do such a thing. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is fun (useless social thread) ;-)

2006-06-15 Thread Diez B. Roggisch
Sybren Stuvel schrieb: > John Salerno enlightened us with: >> Did you have to learn it for a job? > > Nope, but I do most of my job in Python nowadays. I heard rumours > about it being a nice language. After my first look at it, I was > hooked! > >> Also, how did you go about learning it? > > I

Re: code folding, a unique problem to python?

2006-06-15 Thread Diez B. Roggisch
John Salerno schrieb: > Specifically, I'm using UltraEdit and perhaps there's no way perfect way > to implement code folding with it, given how it uses its syntax > highlighting file to do so (i.e., you have to specify an "Opening" and > "Closing" character in which to enfold code, such as brace

Re: Video capture from webcam on Mac?

2006-06-16 Thread Diez B. Roggisch
Joseph Chase schrieb: > Is there a cross-platform solution for video capture from a webcam? > > I am aware of the Win32 videocapture library, but am unaware of how to > accomplish the same functionality on the Mac side. You could try and make OpenCV work - it has a part called anygui that allo

Re: add elements to indexed list locations

2006-06-16 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi, > > I have a very simple problem, but do not know an elegant way to > accomplish this. > ### > # I have a list of names: > names = ['clark', 'super', 'peter', 'spider', 'bruce', 'bat'] > > # and another set of names that I want to insert into > # the names list at

Re: any subway experiences

2006-06-17 Thread Diez B. Roggisch
The berlin subway is great - especially during the worldcup the sheer amount of people from all over the world makes things interesting. HTH, Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting key presses

2006-06-18 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Ok, I'm pretty new to python, so this might be a stupid question. I'm > trying to write a simple text-based pong clone, and I can't figure out > how to read key presses to move the paddles. I just need something that > does the same thing as getch() and kbhit(). I can't

Re: comparing two arrays

2006-06-19 Thread Diez B. Roggisch
ork but this example proves > otherwise: >>>> a = [0,1,2,5,6,6] >>>> b = [5,4,1,6,4,6] >>>> Numeric.logical_and(a==6,b==6) > 0 >>>> Numeric.where(a==b,1,0) > 0 >>>> Numeric.where(a==6 and b==6,1,0) > 0 > > The where() sta

Re: comparing two arrays

2006-06-19 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > print [i for i, _ in enumerate((None for v in zip(a, b) where v == > (1,1)))] > > should give you the list of indices. I musunderstood your question. Use print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == y))] instead. D

Re: [OT] code is data

2006-06-19 Thread Diez B. Roggisch
>> because lots of people know how to describe XML transformations, and >> there are plenty of tools that implement such transformations efficiently ? > > Efficiently enough for dynamic (runtime) use ? Using XML-transformation for AST manipulation isn't my first choice either - yet efficiency co

Re: [OT] code is data

2006-06-20 Thread Diez B. Roggisch
bruno at modulix wrote: > Diez B. Roggisch wrote: >>>> because lots of people know how to describe XML transformations, and >>>> there are plenty of tools that implement such transformations >>>> efficiently ? >>> >>> >>> E

Re: comparing two arrays

2006-06-20 Thread Diez B. Roggisch
>> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == >> y))] >> >> instead. >> >> Diez > > Hi Diez, > > I wish I say that I understood what you wrote here but I can't. > Do you mind explaining a little more? I actua

Re: Specifing arguments type for a function

2006-06-20 Thread Diez B. Roggisch
Paolo Pantaleo wrote: > I have a function > > def f(the_arg): > ... > > and I want to state that the_arg must be only of a certain type > (actually a list). Is there a way to do that? Yes and no. You can ensure that the passed object is a list, by calling e.g. def f(arg): if not isinstance

Re: Specifing arguments type for a function

2006-06-20 Thread Diez B. Roggisch
> What about > def f(arg): > if type(arg)=='list': > #do something Several things: - list is a string in your code - which wont work: >>> type([]) == 'list' False It needs to be list w/o quotes. - you won't get sublclasses of list: >>> class Foo(list): ...pass ... >>> type

Re: comparing two arrays

2006-06-20 Thread Diez B. Roggisch
Maric Michaud wrote: > Le Mardi 20 Juin 2006 12:09, Diez B. Roggisch a écrit : >> [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals] > > No needs to nest comprehensions, should be : > > [ i for i, v in enumerate(zip(a, b)) if v[0] == v[1] ] You&

Re: [OT] code is data

2006-06-20 Thread Diez B. Roggisch
>> While the _result_ of a transformation might be a less efficient piece of >> code (e.g. introducing a lock around each call to enable concurrent >> access), the transformation itself is very - if not totally - static - > > really ? See below. > Nope, it's runned each time the module is loade

Re: comparing of python GUI´s

2006-06-20 Thread Diez B. Roggisch
Bayazee wrote: > Hi > i want some info ... > plz tell me the benefit (or any data) of each gui (pyqt , pyqtk , > wxpython , tkinter ..) > in the other hand wich one you offer (and why ?) ? They are solely offered to confuse newbies - especially the ones google'cally challenged that can't search

Re: Is it possible to split a class definition?

2006-06-21 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hi, > > Is it possible to split a Class definition over two or more text files? > (if so, how:) Not in that sense. But if you must, you can use several classes and then a resulting class that inherits from all of these. Diez -- http://mail.python.org/mailman/listi

Weekly Python Patch/Bug Summary

2006-06-21 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs: 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open ( +7) / 227 closed ( +7) / 451 total (+14) New / Reopened Patches __ Improve s

Re: Can PyObjC be used on shared Mac OS X hosting?

2006-06-22 Thread Diez B. Roggisch
weston schrieb: > Does anyone have experience with (or failing that, theoretical > knowledge about) installing using the PyObjC bridge on a Mac OS X > machine in a context where one doesn't have root/admin access (and > therefore can't install things in conventional locations)? Can such a > thing

Re: serial port servo control

2006-06-22 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > So I ordered a mini SSC II (the servo controller), in order to > control some servos from the computer. I was hoping to use python to > do the control but have two questions... > > 1) How should I write to the serial port with python? I found the > module "pyserial":

Re: Reuseable iterators - which is better?

2006-06-23 Thread Diez B. Roggisch
zefciu schrieb: > In the tutorial there is an example iterator class that revesrses the > string given to the constructor. The problem is that this class works > only once, unlike built-in types like string. How to modify it that it > could work several times? I have tried two approaches. They

Re: Unicode problem with exec

2006-06-23 Thread Diez B. Roggisch
Thomas Heller schrieb: > I'm using code.Interactive console but it doesn't work correctly > with non-ascii characters. I think it boils down to this problem: > > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" fo

Re: USB and Python

2006-06-24 Thread Diez B. Roggisch
Sybren Stuvel schrieb: > Philippe Martin enlightened us with: >> I need to talk to a USB device (PC or other) from Python - I am not >> talking about mounting a file system but sharing information as you >> would though a TCP-IP socket layer or an RS232 interface. > > You could wrap libusb on Linu

Re: 2Qs

2006-06-24 Thread Diez B. Roggisch
if x>10 and y>10 and z>10 and sum((x,y,z)): print "OK" Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: MSoffice metadata

2006-06-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > hi > is there a module in Python to extract metadata in MS office documents You can automate MS Office using the python win32 com extensions of Mark Hammond. They come bundled with the active-state python build, or can be obtained separately. Diez -- http://mail.py

Re: Interactive debugging

2006-06-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, is there a way in python to place some sort of keyboard() type > statement which stops the script and puts you back at the console? I'm > looking for something like in matlab, where you place a keyboard() > command (I think), then you're in debug mode in the console

Re: How do I limit access to objects in Python?

2006-06-27 Thread Diez B. Roggisch
Tommytrojan schrieb: > Hi, > > I have an application that embeds the Python interpreter. My users have > access to the interpreter through a console like window and they can run > Python scripts. For my application I use some Python modules (say module > Restricted) that I don't want to give my

Re: Unbound Local error? How?

2006-06-27 Thread Diez B. Roggisch
Hari Sekhon wrote: > import re > re_regexname = re.compile('abc') > > . > . various function defs > . > > def func1(): > ... > func2() > ... > > def func2(): > if re_regexname.match('abc'): > > > if __name__ == '__main__': > func1() The above clearly is not what you have. See th

Re: What is Expressiveness in a Computer Language

2006-06-27 Thread Diez B. Roggisch
>> The C++ type system is Turing complete, although in practical terms >> it limits how much processing power it will spend on types at >> compile time. > > I think templates only have to expand to seven levels, so you are > severely limited here. You can adjust the iteration-depth. However, as t

Re: Beginner question? Classes, variables, ...

2006-06-28 Thread Diez B. Roggisch
x27;x'. Is there a way to refer > to the Y class from the X? To make things easier :), each class is in a > different file, so class X is imported. Or the only way I have is to > pass 'a' as a variable in each method call of 'b' ('a' can take different

Re: Beginner question? Classes, variables, ...

2006-06-28 Thread Diez B. Roggisch
Dennis Lee Bieber wrote: > On Wed, 28 Jun 2006 10:35:10 +0200, "Diez B. Roggisch" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> class X: >> def __init__(self, my_y): >> self.my_y > self.my_y = my_y *arg

Re: Immutability

2006-06-28 Thread Diez B. Roggisch
> Sigh. No. It's terrible. What it documents is the use of the property > FUNCTION. It does not document what properties ARE, and how they interact > with the rest of the language. Until you know that, it is so ambiguous > as to be almost totally useless - and it is THAT information that needs

Re: Problem with sets and Unicode strings

2006-06-28 Thread Diez B. Roggisch
> But says: > > Strings are compared lexicographically using the numeric equivalents > (the result of the built-in function ord()) of their characters. Unicode > and 8-bit strings are fully interoperable in this behavior. > > Doesn't this mean that Un

Re: Problem with sets and Unicode strings

2006-06-28 Thread Diez B. Roggisch
keys; they need to define both __hash__ and __eq__ methods. ... And it has to hold that a == b => hash(a) == hash(b) but NOT hash(a) == hash(b) => a == b Thus if the hashes vary, the set doesn't bother to actually compare the values. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator naming convention?

2006-06-28 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I use generators a lot. E.g. > > > def gen_words(text) > ... parse text ... > yield each word in text > > for word in gen_words(text): > print word > > > I don't like the name gen_xxx() very much. Looking for some inspiration > to name generators. Here are so

Re: Event notification system - where to start ?

2006-06-29 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > We have been asked to develop and application for a client that is a > 'notification" system. We would like to use python, but are struggling > to find the right starting point. Any suggestions, tips or sample code > would be appreciated. > We also looked at the a

Re: python for windows internet filter / firewall

2006-06-29 Thread Diez B. Roggisch
> 2) Is this even reasonable in python and how might I get started? (e.g. > win32 COM?) Don't know much (not to say nothing) about windows firewalling & the interfaces one needs to talk to them. But _what_ I know is: a firewall needs to be fast. The big guys in networking put a lot of effort int

Re: Odd behavior with staticmethods

2006-07-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > ya know, I've searched for these "new classes" at least five times. > I've heard all the wonderful things about how they make your life into > a piece of chocolate with rainbows sprinkled in it. Never once have I > found a site that explains what syntax to use to make

Re: Program analysis (pseudocode if possible)

2006-07-03 Thread Diez B. Roggisch
http://www.catb.org/~esr/faqs/smart-questions.html -- http://mail.python.org/mailman/listinfo/python-list

Re: sending binary data over sockets

2006-07-03 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Greetings, since there was no reponse to my previous post about an > existing FastCGI server in python, I've taken to writing my own. (which > of course I'll share--*if* there's something to share ;) > > My problem now, is that I need to send certain binary data over a

Re: sending binary data over sockets

2006-07-03 Thread Diez B. Roggisch
Premature sending syndrome... Diez B. Roggisch schrieb: > [EMAIL PROTECTED] schrieb: >> Greetings, since there was no reponse to my previous post about an >> existing FastCGI server in python, I've taken to writing my own. (which >> of course I'll share--

Re: classes and interfaces

2006-07-04 Thread Diez B. Roggisch
Rene Pijlman schrieb: > Bruno Desthuilliers: >> Java interfaces are a workaround > > Troll alert. No idea how you come to that conclusion - but he is actually right with that. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested scopes, and augmented assignment

2006-07-04 Thread Diez B. Roggisch
Tim N. van der Leeuw wrote: > Hi, > > The following might be documented somewhere, but it hit me unexpectedly > and I couldn't exactly find this in the manual either. > > Problem is, that I cannot use augmented assignment operators in a > nested scope, on variables from the outer scope: > Is

Re: List Manipulation

2006-07-04 Thread Diez B. Roggisch
> p[j] does not give you a reference to an element inside p. It gives > you a new sublist containing one element from p. You then append a > column to that sublist. Then, since you do nothing more with that > sublist, YOU THROW IT AWAY. Not correct. p = [[]] p[0].append(1) print p yields [[1

Re: python list/array question...

2006-07-05 Thread Diez B. Roggisch
Sybren Stuvel wrote: > Bruno Desthuilliers enlightened us with: >> Python has lists (which AFAIK really are arrays not linked lists, >> but they are called 'lists'). > > An array is generally understood as a list of items of the same type, > hence Python lists aren't arrays. Only in the same sen

Re: iterate over a series of nodes in an XML file

2006-07-05 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, I have an XML file which contains entries of the form: > > > 1 > 2 > > 1 > > > Currently, I have written a SAX based handler that will read in all the > entries and return a list of the contents of these > entries. However this is not scalable and fo

Re: Help Needed !!! Browsing and Selecting More Than One File

2006-07-06 Thread Diez B. Roggisch
Kilicaslan Fatih schrieb: > Dear All, > > I am trying to create a GUI, using Tkinter on Windows > 2000/XP using Python 2.2. Through buttons this GUI > interacts with another program and assigns argument to > that program. > > I managed to browse a ".c" file and assign this file > as an argument t

Weekly Python Patch/Bug Summary

2006-07-09 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 393 open (+15) / 3315 closed (+17) / 3708 total (+32) Bugs: 908 open (+22) / 5975 closed (+49) / 6883 total (+71) RFE : 223 open ( -1) / 229 closed ( +2) / 452 total ( +1) New / Reopened Patches __ test_grp.

Re: Accessors in Python (getters and setters)

2006-07-10 Thread Diez B. Roggisch
mystilleef wrote: > Hello, > > What is the Pythonic way of implementing getters and setters. I've > heard > people say the use of accessors is not Pythonic. But why? And what is > the alternative? I refrain from using them because they smell > "Javaish." > But now my code base is expanding and I'

Re: Accessors in Python (getters and setters)

2006-07-10 Thread Diez B. Roggisch
mystilleef wrote: > I decided to change the name of an attribute. Problem is I've used the > attribute in several places spanning thousands of lines of code. If I > had encapsulated the attribute via an accessor, I wouldn't need to do > an unreliable and tedious search and replace accross several

Re: function that modifies a string

2006-07-10 Thread Diez B. Roggisch
> Of course, another right way would be to have mutable strings in Python. > I understand why strings need to be immutable in order to work with dicts, > but is there any reason why (hypothetical) mutable strings should be > avoided in situations where they aren't needed as dictionary keys? Python

Re: function that modifies a string

2006-07-10 Thread Diez B. Roggisch
tac-tics wrote: > > Diez B. Roggisch wrote: >> > Of course, another right way would be to have mutable strings in >> > Python. I understand why strings need to be immutable in order to work >> > with dicts, but is there any reason why (hypothetical) mutable

Re: Mechanize/Browser question

2006-07-10 Thread Diez B. Roggisch
bruce schrieb: > hi... > > i can do the following > br = Browser > br.open("www.yahoo.com") > br.open("file:///foo") > > but can i do > s = "..." qualified html text > br.open(s) > > i'm curious, if i have html from someother source, is there a way to simply > get it into the "B

Re: function that modifies a string

2006-07-10 Thread Diez B. Roggisch
>>> Arrays of chars are dangerous. If you insist, use Python lists of >>> Python "chars" (strings of length 1). >> Why are they more dangerous than a self-written mutable string? > > I didn't say that. I meant that arrays in the C++ sense are dangerous. So what? Python's arrays are backed by arra

Re: function that modifies a string

2006-07-11 Thread Diez B. Roggisch
> I'm sorry, perhaps I'm being slow today, but just why are they dangerous? > More dangerous than, say, mutable lists and mutable dicts? Unless I'm > missing something, the worst that can happen is that people will write > inefficient code, and they'll be caught out by the same sort of things > tha

Re: Restricted Access

2006-07-11 Thread Diez B. Roggisch
iapain wrote: > >> my_innocent_object = __import__(''.join([chr(110+x) for x in [1, 5]])) > > Thats really smart way, yeah i had plan to scan and detect but I think > its not gonna work. > >> Creating a restricted execution environment is *hard*. As far as I know, >> even Microsoft has never at

Re: Pygame, mouse events and threads

2006-08-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Ben Sizer wrote: >> [EMAIL PROTECTED] wrote: >> >>> When I put the content of the run and input functions in the main >>> thread, it's working, why not in the thread? >> Because event handling needs to be done in the main thread. So does >> rendering. This is a limitati

Re: String formatting with nested dictionaries

2006-08-24 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I've got a bit of code which has a dictionary nested within another > dictionary. I'm trying to print out specific values from the inner > dict in a formatted string and I'm running into a roadblock. I can't > figure out how to get a value from the inner dict into the

Re: telnetlib thread-safe?

2006-08-24 Thread Diez B. Roggisch
Jerry schrieb: > Fredrik Lundh wrote: >> define thread-safe. how do you plan to use it? > > I would like to write a program that spawns ~10 threads. Each thread > would get a host to connect to from a Queue object and run then do it's > thing (i.e. connecting to the host, running some commands,

Re: OS X and Python - what is your install strategy?

2006-08-24 Thread Diez B. Roggisch
metaperl schrieb: > I'm about to get a new OS X box on which I will rewrite a bunch of data > munging scripts from Perl to Python. I know that there are several port > services for OS X (fink, darwin ports, opendarwin). So I am not sure > whether to use their port of Python or whether to build from

Re: OS X and Python - what is your install strategy?

2006-08-25 Thread Diez B. Roggisch
> These days, I install the OS X universal binary provided on the Python > language web site. You can find it at > http://www.python.org/download/releases/2.4.3. It's more comprehensive > and much more up-to-date than the version included in OS X. It is. But don't fall for the temptation to remove

Re: Consistency in Python

2006-08-25 Thread Diez B. Roggisch
Hendrik van Rooyen schrieb: > Hi, > > for S where S is a Standard Python type: > The slice notation S[n] returns either: > The n'th element of S, or > The value of the dictionary entry whose key is n. > > This is beautiful because as a programmer you don't have to worry what S

Re: rollover effect

2006-08-26 Thread Diez B. Roggisch
groves schrieb: > Thanks a lot Ill have a look > and try solving my problem Ah, the summer ends and all of a sudden punctuation symbols are short. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: unpaking sequences of unknown length

2006-08-27 Thread Diez B. Roggisch
>I keep working around a little problem with unpacking in cases in which I > don't know how many elements I get. Consider this: > > def tabulate_lists (*arbitray_number_of_lists): > table = zip (arbitray_number_of_lists) > for record in table: >#

Re: How to let a loop run for a while before checking for break condition?

2006-08-27 Thread Diez B. Roggisch
Claudio Grondi schrieb: > > Sometimes it is known in advance, that the time spent in a loop will be > in order of minutes or even hours, so it makes sense to optimize each > element in the loop to make it run faster. > One of instructions which can sure be optimized away is the check for > the

Re: avoiding file corruption

2006-08-27 Thread Diez B. Roggisch
Amir Michail schrieb: > Paolo Pantaleo wrote: >> 27 Aug 2006 00:44:33 -0700, Amir Michail <[EMAIL PROTECTED]>: >>> Hi, >>> >>> Trying to open a file for writing that is already open for writing >>> should result in an exception. >>> >>> It's all too easy to accidentally open a shelve for writing t

Re: unpaking sequences of unknown length

2006-08-27 Thread Diez B. Roggisch
>> Question: Is there an unpacking mechanism for cases in which I don't >> know--and don't need to know--how many elements I get, or an >> argument passing mechanism that is the inverse of the tuplifier (*args)? > > No. > > It looks a little bit as if you aren't aware of the symetry behind the *

Re: How to let a loop run for a while before checking for break condition?

2006-08-27 Thread Diez B. Roggisch
> The idea is to speed up a loop by using a timer interrupt interfering > with the loop, so that only after the timer interrupt would occur, the > loop will start to check its break condition in each iteration. > No checking of any kind in the loop should happen up to that time to > minimize the

Weekly Python Patch/Bug Summary

2006-08-27 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 407 open ( +3) / 3393 closed (+17) / 3800 total (+20) Bugs: 888 open (+28) / 6145 closed (+14) / 7033 total (+42) RFE : 232 open ( +3) / 236 closed ( +1) / 468 total ( +4) New / Reopened Patches __ most miss

Re: avoiding file corruption

2006-08-27 Thread Diez B. Roggisch
Amir Michail schrieb: > Diez B. Roggisch wrote: >> Amir Michail schrieb: >>> Paolo Pantaleo wrote: >>>> 27 Aug 2006 00:44:33 -0700, Amir Michail <[EMAIL PROTECTED]>: >>>>> Hi, >>>>> >>>>> Trying to open a file

Re: How to let a loop run for a while before checking for break condition?

2006-08-27 Thread Diez B. Roggisch
Fredrik Lundh schrieb: > Diez B. Roggisch wrote: > >> A while loop has a condition. period. The only thing to change that is >> to introduce a uncoditioned loop, and use self-modifying code to make >> it a while-loop after that timer interrupt of yours. > &g

Re: How to let a loop run for a while before checking for break condition?

2006-08-27 Thread Diez B. Roggisch
Fredrik Lundh schrieb: > Diez B. Roggisch wrote: > > > No doubt that changing the flag asynchronously is a gain by delegating > > the timing code to the OS. Yet the while loop still has a condition - > > you could as well set a flag in the signal handler an do it like

Re: Truly platform-independent DB access in Python?

2006-08-28 Thread Diez B. Roggisch
> > Yes, you excactly got my point. The thing is that I can't rely on > Python 2.5 to be installed soon. > So the only solution for me at this moment is to use jython and from > there use Java JDBC API (sorry :-) But it would be great if the Python > DB API compliant-modules would become parts of

Re: unit test for a printing method

2006-08-28 Thread Diez B. Roggisch
noro wrote: > What is the proper way to test (using unit test) a method that print > information? > for example: > > def A(s): > print '---'+s+'---' > > and i want to check that A("bla") really print out "---bla---" You can replace sys.stdout with a cStringIO-object or any other file-p

Re: inet_aton and struct issue

2006-08-30 Thread Diez B. Roggisch
David Bear schrieb: > I found this simple recipe for converting a dotted quad ip address to a > string of a long int. > > struct.unpack('L',socket.inet_aton(ip))[0] > > trouble is when I use this, I get > > struct.error: unpack str size does not match format > > I thought ip addresses were unsi

Re: disgrating a list

2006-09-01 Thread Diez B. Roggisch
jwaixs schrieb: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] Why do you wrap a in a list? Just c = a + [b] will do it. Diez -- http://mail.python.org/mailman/listinfo/python-list

<    7   8   9   10   11   12   13   14   15   16   >