Re: Single type for __builtins__ in Py3.0

2005-09-23 Thread Christopher Subich
Collin Winter wrote: > Hallo all, > I'd like to propose that in Py3.0 (if not earlier), __builtins__ will > be the same type regardless of which namespace you're in. Tim Peters > has said [1] that the reason __builtins__ in __main__ is a module so > that "the curious don't get flooded with output w

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Christopher Subich
Iyer, Prasad C wrote: > Thanks a lot for the reply. > But I want to do something like this > > class BaseClass: > def __init__(self): > # Some code over here > def __init__(self, a, b): > # Some code over here > def __init__(self, a, b, c): >

Re: Can't extend function type

2005-10-07 Thread Christopher Subich
Diez B. Roggisch wrote: > Paul Rubin wrote: > >> Oh well. I had wanted to be able to define two functions f and g, and >> have f*g be the composition of f and g. >> >> >>> func_type = type(lambda: None) >> >>> class composable_function(func_type): >> ... def __mult__(f,g): >> ..

Re: Python interpreter bug

2005-10-07 Thread Christopher Subich
[EMAIL PROTECTED] wrote: > No doubt you're right but common sense dictates that membership testing > would test identity not equality. > This is one of the rare occasions where Python defeats my common sense But object identity is almost always a fairly ill-defined concept. Consider this (Python

Re: socketServer questions

2005-10-07 Thread Christopher Subich
Paul Rubin wrote: > rbt <[EMAIL PROTECTED]> writes: > >>1. Do I need to use threads to handle requests, if so, how would I >>incorporate them? The clients are light and fast never sending more >>than 270 bytes of data and never connecting for more than 10 seconds >>at a time. There are currently

Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-19 Thread Christopher Subich
Chris Lambacher wrote: > The shell that comes with MSys (from the MinGW guys). Is pretty good, although > it does have a bit of a problem with stdout output before a process exits, ie > it will hold back output until the process exits. > > As a bonus, the file system is a little more sane, and if

Re: Would there be support for a more general cmp/__cmp__

2005-10-21 Thread Christopher Subich
Antoon Pardon wrote: > It would be better if cmp would give an indication it > can't compare two objects instead of giving incorrect > and inconsistent results. If two objects aren't totally comparable, then using 'cmp' on them is ill-defined to begin with. The Standard Thing To Do is throw an

Re: Would there be support for a more general cmp/__cmp__

2005-10-25 Thread Christopher Subich
Antoon Pardon wrote: > It *is* a definition of an ordering. > > For something to be an ordering it has to be anti symmetric and transitive. > > The subset relationships on sets conform to these conditions so it is a > (partial) > ordering. Check your mathematic books, Why you would think this is

Re: Would there be support for a more general cmp/__cmp__

2005-10-25 Thread Christopher Subich
Antoon Pardon wrote: > I also think there is the problem that people aren't used to partial > ordering. There is an ordering over sets, it is just not a total > ordering. But that some pairs are uncomparable (meaning that neither > one is smaller or greater) doesn't imply that comparing them is >

Re: Would there be support for a more general cmp/__cmp__

2005-10-25 Thread Christopher Subich
Antoon Pardon wrote: > Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>: > >>Which is exactly why a < b on sets returns True xor False, but cmp(a,b) >>throws an exception. > > > I don't see the conection. > > The documentation state

Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Christopher Subich
Antoon Pardon wrote: > Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>: >> >>My biggest complaint here is about returning None or IncomparableValue; >>if that happens, then all code that relies on cmp returning a numeric >>result will have to b

Re: textwidget.tag_bind("name", "", self.donothing) not working

2005-10-26 Thread Christopher Subich
shannonl wrote: > Hi all, > > For some reason this bind is calling the donothing function, like it > should, but is then allowing the text to be inserted into the Text > widget. [...] > This bind does work on the text widget as a whole, but on a individual > tag, it does not. You're trying to pre

Re: Would there be support for a more general cmp/__cmp__

2005-10-28 Thread Christopher Subich
Antoon Pardon wrote: > If you are concerned about sorting times, I think you should > be more concerned about Guido's idea of doing away with __cmp__. > Sure __lt__ is faster. But in a number of cases writing __cmp__ > is of the same complexity as writing __lt__. So if you then > need a __lt__, __l

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-28 Thread Christopher Subich
Steve Holden wrote: >> On Thu, 2005-10-27 at 14:00, Gregory PiƱero wrote: >> >>> Not quite because if something(3) fails, I still want something(4) to >>> run. > Then the obvious extension: > > for i in range(20): >... > > but I get the idea that Gregory was thinking of different statement

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Antoon Pardon wrote: > Op 2005-11-03, Stefan Arentz schreef <[EMAIL PROTECTED]>: >>The model makes sense in my opinion. If you don't like it then there are >>plenty of other languages to choose from that have decided to implement >>things differently. > > > And again this argument. Like it or lea

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Steven D'Aprano wrote: > On Thu, 03 Nov 2005 14:13:13 +, Antoon Pardon wrote: > > >>Fine, we have the code: >> >> b.a += 2 >> >>We found the class variable, because there is no instance variable, >>then why is the class variable not incremented by two now? > > > Because b.a += 2 expands to

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Antoon Pardon wrote: >>Since ints are immutable objects, you shouldn't expect the value of b.a >>to be modified in place, and so there is an assignment to b.a, not A.a. > > > You are now talking implementation details. I don't care about whatever > explanation you give in terms of implementation

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Antoon Pardon wrote: > Well I wonder. Would the following code be considered a name binding > operation: > > b.a = 5 Try it, it's not. Python 2.2.3 (#1, Nov 12 2004, 13:02:04) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-42)] on linux2 Type "help", "copyright", "credits" or "license" for more info

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Antoon Pardon wrote: > Except when your default is a list > > class foo: > x = [] # default > > a = foo() > a.x += [3] > > b = foo() > b.x > > This results in [3]. So in this case using a class variable x to > provide a default empty list doesn't work out in combination > with augmented oper

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Antoon Pardon wrote: > Well maybe because as far as I understand the same kind of logic > can be applied to something like > > lst[f()] += foo > > In order to decide that this should be equivallent to > > lst[f()] = lst[f()] + foo. > > But that isn't the case. Because, surprisingly enough, Pyt

Re: Class Variable Access and Assignment

2005-11-04 Thread Christopher Subich
Bengt Richter wrote: > > It might be interesting to have a means to push and pop objects > onto/off-of a name-space-shadowing stack (__nsstack__), such that the first > place > to look up a bare name would be as an attribute of the top stack object, i.e., > > name = name + 1 > Don't be

Re: Class Variable Access and Assignment

2005-11-06 Thread Christopher Subich
Bengt Richter wrote: > On Fri, 04 Nov 2005 10:28:52 -0500, Christopher Subich <[EMAIL PROTECTED]> > wrote: >>is very much within the language specification. Indeed, the language >>specification dictates that an instance variable b.a is created if one >>didn&#

Re: Class Variable Access and Assignment

2005-11-07 Thread Christopher Subich
Antoon Pardon wrote: > Op 2005-11-04, Christopher Subich schreef <[EMAIL PROTECTED]>: >>it's the Python >>idiosyncracy about operations on mutable types. In this case, += >>mutates an object, while + returns a new one -- as by definition, for >>mutables

Unifying Attributes and Names (was: Re: Death to tuples!)

2005-11-29 Thread Christopher Subich
Bengt Richter wrote: > If we had a way to effect an override of a specific instance's attribute > accesses > to make certain attribute names act as if they were defined in > type(instance), and > if we could do this with function instances, and if function local accesses > would > check if name

Unifying Attributes and Names (was: Re: Death to tuples!)

2005-11-29 Thread Christopher Subich
Bengt Richter wrote: > If we had a way to effect an override of a specific instance's attribute accesses > to make certain attribute names act as if they were defined in type(instance), and > if we could do this with function instances, and if function local accesses would > check if names were on

Re: ncurses' Dark Devilry

2005-11-29 Thread Christopher Subich
Jeremy Moles wrote: >>In article <[EMAIL PROTECTED]>, >> Jeremy Moles <[EMAIL PROTECTED]> wrote: >>>I have a focus "wheel" of sorts that allows the user to do input on >>>various wigets and windows and whatnot. However, if I want to quickly >>>call addstr somewhere else in the application I have to

Re: Is there no compression support for large sized strings in Python?

2005-12-02 Thread Christopher Subich
Fredrik Lundh wrote: > Harald Karner wrote: >>>python -c "print len('m' * ((2048*1024*1024)-1))" >> >>2147483647 > > > the string type uses the ob_size field to hold the string length, and > ob_size is an integer: > > $ more Include/object.h > ... > int ob_size; /* Number of items in va

Re: Is there no compression support for large sized strings in Python?

2005-12-05 Thread Christopher Subich
Fredrik Lundh wrote: > Christopher Subich wrote: >> >>I have access to an itanium system with a metric ton of memory. I >>-think- that the Python version is still only a 32-bit python > > > an ILP64 system is a system where int, long, and pointer are all 64 bits

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Christopher Subich
Paul McNett wrote: > Having .NET and Java in the world makes me into more of a hero when I > can swoop in and get the real business problem solved using Python. +1QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: hash()

2005-12-05 Thread Christopher Subich
John Marshall wrote: > I was actually interested in the mathematical/probability > side rather than the empirical w/r to the current > hash function in python. Although I imagine I could do > a brute force test for x-character strings. Hah. No. At least on the version I have handy (Py 2.2.3 on

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Christopher Subich
[EMAIL PROTECTED] wrote: > >>From "The Design of Everyday Things", docs are a sign of poor design. > Even a single word, such as the word "Push" on the face of a door, is > an indication that the design can be improved. Please, rethink the > design instead of trying to compensate with more docume

Re: Bitching about the documentation...

2005-12-07 Thread Christopher Subich
Fredrik Lundh wrote: > Steven D'Aprano wrote: > > >>"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo." > > > Did you mean: Badger badger Badger badger badger badger Badger badger > Mushroom! Mushroom! Thank you, I really needed that stuck in my head. :) -- http://mail.python.

Re: Calculating Elapsed Time

2005-12-07 Thread Christopher Subich
Peter Hansen wrote: > A few things. > > 1. "Precision" is probably the wrong word there. "Resolution" seems > more correct. > > 2. If your system returns figures after the decimal point, it probably > has better resolution than one second (go figure). Depending on what > system it is, your b

Re: Calculating Elapsed Time

2005-12-07 Thread Christopher Subich
Fredrik Lundh wrote: > if I run this on the Windows 2K box I'm sitting at right now, it settles > at 100 for time.time, and 1789772 for time.clock. on linux, I get 100 > for time.clock instead, and 262144 for time.time. Aren't the time.clock semantics different on 'nix? I thought, at least on

Re: Bitching about the documentation...

2005-12-07 Thread Christopher Subich
Steven D'Aprano wrote: > S > P > O > I > L > E > R > > S > P > A > C > E > > > > "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo." > > Buffalo from the city of Buffalo, which are intimidated by buffalo > from Buffalo, also intimidate buffalo from Buffalo. And to do a small

Re: Bitching about the documentation...

2005-12-07 Thread Christopher Subich
Steven D'Aprano wrote: > On Wed, 07 Dec 2005 11:45:04 +0100, Fredrik Lundh wrote: > >>Did you mean: Badger badger Badger badger badger badger Badger badger >>Mushroom! Mushroom! > > > Er... no, I can't parse that. I suffered a Too Much Recursion error about > the third Badger (I only have a lim

Re: Overloading

2005-12-09 Thread Christopher Subich
Johannes Reichel wrote: > Hi! > > In C++ you can overload functions and constructors. For example if I have a > class that represents a complex number, than it would be nice if I can > write two seperate constructors > > class Complex: Please do note, if you want this for the exact use of a Comp

Re: Text() tags and delete()

2005-06-27 Thread Christopher Subich
Bob Greschke wrote: > Does Text.delete(0.0, END) delete all of the tags too? Everything says it > does not delete marks, but nothing about tags. Note to everyone else: this is a TKinter question. Tags are attached to text ranges, in the Text widget. If you delete all of the text in the widget

DParser binaries on Win32 with Python 2.4?

2005-06-27 Thread Christopher Subich
From the documentation, it looks like DParser-python will do what I need, but I'm having trouble getting it installed properly. I'm using a win32 environment, with official 2.4 Python binaries. The official DParser for Python win32 binaries (staff.washington.edu/sabbey/dy_parser) fail, saying

Re: DParser binaries on Win32 with Python 2.4?

2005-06-28 Thread Christopher Subich
[EMAIL PROTECTED] wrote: > 1) http://mingw.org > 2) python setup.py build --compiler=mingw32 > 3) python setup.py install Thank you very much, it looks like this worked perfectly; it even picked up on the cygwin-mingw32 libraries and compiled with the cygwin compiler and -mno-cygwin. -- http

twisted: not doing DNS resolutions?

2005-06-30 Thread Christopher Subich
I'm building an application that makes several user-specified internet connections; twisted meets my needs more or less perfectly. I'm running into a problem, however, in that twisted is not allowing connections (reactor.connectTCP) by hostname, only IP address. [read: connections to IP address

Re: twisted: not doing DNS resolutions?

2005-06-30 Thread Christopher Subich
Christopher Subich wrote: > From what I can tell, the problem lies in that Twisted simply isn't > performing the DNS resolutions. From the connection factory's > startedConnecting method, print connector.getDestination() results in: > > IPv4Address(TCP, 'hostnam

Re: twisted: not doing DNS resolutions?

2005-06-30 Thread Christopher Subich
Christopher Subich wrote: > Christopher Subich wrote: > >> From what I can tell, the problem lies in that Twisted simply isn't >> performing the DNS resolutions. From the connection factory's ... right, finally figured it out after a very long time at de

Re: Scket connection to server

2005-06-30 Thread Christopher Subich
Steve Horsley wrote: > There is a higher level socket framework called twisted that everyone > seems to like. It may be worth looking at that too - haven't got round > to it myself yet. I wouldn't say 'like,' exactly. I've cursed it an awful lot (mostly for being nonobvious), but it does a da

Re: Splitting string into dictionary

2005-07-02 Thread Christopher Subich
Robert Kern wrote: > David Pratt wrote: > >> I have string text with language text records that looks like this: >> >> 'en' | 'the brown cow' | 'fr' | 'la vache brun' > translations = [x.strip(" '") for x in line.split('|')] > d = dict(zip(translations[::2], translations[1::2])) One caevat is th

Re: Favorite non-python language trick?

2005-07-02 Thread Christopher Subich
Steven D'Aprano wrote: > On Fri, 01 Jul 2005 12:24:44 -0700, Devan L wrote: > > >>With the exception of reduce(lambda x,y:x*y, sequence), reduce can be >>replaced with sum, and Guido wants to add a product function. > > > How do you replace: > > reduce(lambda x,y: x*y-1/y, sequence) > > with

Re: Favorite non-python language trick?

2005-07-02 Thread Christopher Subich
Devan L wrote: > sum(sequence[0] + [1/element for element in sequence[1:]]) > > I think that should work. That won't work, because it misses the x*y part of the expression (x[n]*x[n+1] + 1/x[n+1], for people who haven't immediately read the grandparent). Personally, I think demanding that it b

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-02 Thread Christopher Subich
Steven D'Aprano wrote: > comps. But reduce can't be written as a list comp, only as a relatively > complex for loop at a HUGE loss of readability -- and I've never used > Lisp or Scheme in my life. I'm surely not the only one. See my reply to your other post for a more detailed explanation, but I

Re: What are the other options against Zope?

2005-07-02 Thread Christopher Subich
Dennis Lee Bieber wrote: > The Windows registry is "a maze of twisty little passages, all > alike" ITYM "a maze of twisty little passeges, {058C1536-2201-11D2-BFC1-00805F858323}" > The registry a cryptic, bloated, system by which M$ can hide > details about anything they want... In

Re: Favorite non-python language trick?

2005-07-03 Thread Christopher Subich
Steven D'Aprano wrote: > On Sun, 03 Jul 2005 00:39:19 -0400, Christopher Subich wrote: >>Personally, I think demanding that it be writable as a sum (or product, >>or any, or all) is a false standard -- nobody's claimed that these would >>replace all cases of re

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-03 Thread Christopher Subich
Carl Banks wrote: > Listcomps et al. cannot do everything map, lambda, filter, and reduce > did. Listcomps are inferior for functional programming. But, you see, > functional is not the point. Streamlining procedural programs is the > point, and I'd say listcomps do that far better, and without

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-03 Thread Christopher Subich
Scott David Daniels wrote: > egbert wrote: >> How do you replace >> map(f1,sequence1, sequence2) >> especially if the sequences are of unequal length ? >> >> I didn't see it mentioned yet as a candidate for limbo, >> but the same question goes for: >> zip(sequence1,sequence2) > > OK, you guys are

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-03 Thread Christopher Subich
Carl Banks wrote: > > Christopher Subich wrote: >>I've heard this said a couple times now -- how can listcomps not >>completely replace map and filter? > If you're doing heavy functional programming, listcomps are > tremendously unwieldy compared to map et a

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-04 Thread Christopher Subich
Peter Hansen wrote: > [str(parrot) for parrot in sequence], for example, tells you much more > about what is going on than str(x) does. > > Exactly what, I have no idea... but it says _so_ much more. ;-) Yarr! Avast! Etc! -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-04 Thread Christopher Subich
Carl Banks wrote: > I suspect you're misunderstanding what I mean by heavily functional. > Heavily functional programming is a different mindset altogether. In > heavily functional programming, things like maps and filters and > function applications are actually what you're thinking about. map

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread Christopher Subich
[EMAIL PROTECTED] wrote: > concept quickly familiar. But "lambda" has a very clear meaning... it's > a letter of the greek alphabet. The connection between that letter and > anonymous functions is tenuous at best, and fails the test of making > Python read like "executable pseudocode". But 'lambda

Re: (Win32 API) callback to Python, threading hiccups

2005-07-05 Thread Christopher Subich
Francois De Serres wrote: > - so, on callback, I create a new thread, after checking that the > previous one has returned already (WaitOnSingleObject(mythread)) so we > only have one thread involved. Uh... to me, this looks like a frighteningly inefficient way of doing things. How about using

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Christopher Subich
Terry Hancock wrote: > With list comprehensions and generators becoming so integral, I'm > not sure about "unpythonic". And a syntax just occured to me -- > what about this: > > [y*x for x,y] > > ? > > (that is: > > [ for ] > > It's just like the beginning of a list comprehension or generator

Re: Tkinter grid layout

2005-07-07 Thread Christopher Subich
Eric Brunel wrote: > So you should either make your MainWindow class inherit from Tk, which > eliminates the unneeded container and the problems it may cause, or make > sure the pack or grid on your MainWindow instance actually tells the > container to grow with its container. With pack, it's q

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Christopher Subich
Ron Adam wrote: > Christopher Subich wrote: > >> As others have mentioned, this looks too much like a list >> comprehension to be elegant, which also rules out () and {}... but I >> really do like the infix syntax. > > > Why would it rule out ()? Generator e

Re: Legacy data parsing

2005-07-08 Thread Christopher Subich
gov wrote: > Hi, > > I've just started to learn programming and was told this was a good > place to ask questions :) > > Where I work, we receive large quantities of data which is currently > all printed on large, obsolete, dot matrix printers. This is a problem > because the replacement parts w

Re: decorators as generalized pre-binding hooks

2005-07-11 Thread Christopher Subich
Kay Schluehr wrote: > I think it would be a good idea to pronounce the similarity between > function decorators and metaclasses. Metaclasses were once introduced > as an arcane art of fuzzy bearded hackers or supersmart 'enterprise > architects' that plan at least products of Zope size but not as a

Re: Help with report

2005-07-11 Thread Christopher Subich
ChrisH wrote: > Oh. The one other thing I forgot to mention is that the data needs to be > already updated every 10 minutes or so automatically. You know, this is the most concise example of feature-creep in a specification that I've ever seen. -- http://mail.python.org/mailman/listinfo/python-

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Christopher Subich
Dark Cowherd wrote: > But one advise that he gives which I think is of great value and is > good practice is > "Always catch any possible exception that might be thrown by a library > I'm using on the same line as it is thrown and deal with it > immediately." That's fine advice, except for when it

Re: python parser

2005-07-12 Thread Christopher Subich
tuxlover wrote: > I have to write a verilog parser in python for a class project. I was > wondering if all you folks could advise me on choosing the right python > parser module. I am not comfortable with lex/yacc and as a result find > myself strugging with any module which use lex/yacc syntax/phi

Re: Slicing every element of a list

2005-07-12 Thread Christopher Subich
Gary Herron wrote: > Alex Dempsey wrote: >> for line in lines: >>line = line[1:-5] >>line = line.split('\"\t\"') > This, in fact, did do the operation you expected, but after creating the > new value and assigning it to line, you promptly threw it away. (Because > the loop then went back

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Christopher Subich
Thomas Lotze wrote: > Neither does it to me. What about > > try: > f=file('file_here') > except IOError: #File doesn't exist > error_handle > else: > do_setup_code > do_stuff_with(f) > > (Not that I'd want to defend Joel's article, mind you...) That works. I'm still not used to

Re: all possible combinations

2005-07-13 Thread Christopher Subich
rbt wrote: > Expanding this to 4^4 (256) to test the random.sample function produces > interesting results. It never finds more than 24 combinations out of the > possible 256. This leads to the question... how 'random' is sample ;) sample(population,k): Return a k length list of unique element

Re: Help - Classes and attributes

2005-07-13 Thread Christopher Subich
rh0dium wrote: > Hi all, > > I believe I am having a fundamental problem with my class and I can't > seem to figure out what I am doing wrong. Basically I want a class > which can do several specific ldap queries. So in my code I would have > multiple searches. But I can't figure out how to do

Re: threads and sleep?

2005-07-14 Thread Christopher Subich
Jp Calderone wrote: > On 14 Jul 2005 05:10:38 -0700, Paul Rubin > <"http://phr.cx"@nospam.invalid> wrote: > >> Andreas Kostyrka <[EMAIL PROTECTED]> writes: >> >>> Basically the current state of art in "threading" programming doesn't >>> include a safe model. General threading programming is unsaf

Re: Changing size of Win2k/XP console?

2005-07-14 Thread Christopher Subich
Sheeps United wrote: > I'm far from sure if it's the right one, but I think it could be > SetConsoleScreenBufferSize from Kernel32. Hrr, for some reason I have nasty > feeling in back of my head... That could also be totally wrong way of > approaching. I have the source code to a win32-console

Re: main window in tkinter app

2005-07-20 Thread Christopher Subich
William Gill wrote: > O.K. I tried from scratch, and the following snippet produces an > infinite loop saying: > > File "C:\Python24\lib\lib-tk\Tkinter.py", line 1647, in __getattr__ > return getattr(self.tk, attr) > > If I comment out the __init__ method, I get the titled window, and pr

Re: main window in tkinter app

2005-07-20 Thread Christopher Subich
William Gill wrote: > That does it!, thanks. > > Thinking about it, when I created a derived class with an __init__ > method, I overrode the base class's init. It should have been > intuitive that I needed to explicitly call baseclass.__init(self), it > wasn't. It might have hit me if the f

Re: Need to interrupt to check for mouse movement

2005-07-20 Thread Christopher Subich
Peter Hansen wrote: > stringy wrote: > >> I have a program that shows a 3d representation of a cell, depending on >> some data that it receives from some C++. It runs with wx.timer(500), >> and on wx.EVT_TIMER, it updates the the data, and receives it over the >> socket. > > > It's generally ina

Re: Need to interrupt to check for mouse movement

2005-07-20 Thread Christopher Subich
Jp Calderone wrote: > In the particular case of wxWidgets, it turns out that the *GUI* blocks > for long periods of time, preventing the *network* from getting > attention. But I agree with your position for other toolkits, such as > Gtk, Qt, or Tk. Wow, I'm not familiar with wxWidgets; how's

Re: Need to interrupt to check for mouse movement

2005-07-21 Thread Christopher Subich
Paul Rubin wrote: > Huh? It's pretty normal, the gui blocks while waiting for events > from the window system. I expect that Qt and Tk work the same way. Which is why I recommended Twisted for the networking; it integrates with the toolkit event loops so it automagically works: http://twistedm

Re: Help with regexp please

2005-07-22 Thread Christopher Subich
Scott David Daniels wrote: > Felix Collins wrote: >> I have an "outline number" system like >> 1 >> 1.2 >> 1.2.3 >> I want to parse an outline number and return the parent. > > Seems to me regex is not the way to go: > def parent(string): > return string[: string.rindex('.')] Absolute

Re: find a specified dictionary in a list

2005-07-22 Thread Christopher Subich
Odd-R. wrote: > On 2005-07-22, John Machin <[EMAIL PROTECTED]> wrote: > > Odd-R. wrote: > >> I have this list: > >> > >> [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] > >> > >> All the dictionaries of this list are of the same form, and all the oids > >> are distinct.

Re: Help with regexp please

2005-07-22 Thread Christopher Subich
Terry Hancock wrote: > I think this is the "regexes can't count" problem. When the repetition > count matters, you usually need something else. Usually some > combination of string and list methods will do the trick, as here. Not exactly, regexes are just fine at doing things like "first" and "l

Re: "Aliasing" an object's __str__ to a different method

2005-07-22 Thread Christopher Subich
ncf wrote: > Well, suffice to say, having the class not inherit from object solved > my problem, as I suspect it may solve yours. ;) Actually, I did a bit of experimenting. If the __str__ reassignment worked as intended, it would just cause an infinite recursion. To paste the class definition a

Re: Location of tk.h

2005-07-22 Thread Christopher Subich
none wrote: > Probably a stupid question, but... > > I was attempting to install the Tkinter 3000 WCK. It blew up trying to > build _tk3draw. The first error is a 'No such file or directory' for > tk.h. I can import and use Tkinter just fine, so I'm not sure what is > what here. You can imp

Re: return None

2005-07-23 Thread Christopher Subich
Grant Edwards wrote: > Personally, I don't really like the idea that falling off the > botton of a function implicitly returns None. It's just not > explicit enough for me. My preference would be that if the > function didn't execute a "return" statement, then it didn't > return anyting and attem

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Christopher Subich
Paolino wrote: > Little less ugly: > In [12]:class A(object): >: def __str__(self):return self.__str__() >: def str(self):return 'ciao' >: def setStr(self):self.__str__=self.str >: > > In [13]:a=A() > > In [14]:a.setStr() > > In [15]:str(a) > Out[15]:'

Re: return None

2005-07-23 Thread Christopher Subich
Christopher Subich wrote: > print '%s returns:', retval Not that it matters, but this line should be: print '%s returns:' % func.__name__, retval -- http://mail.python.org/mailman/listinfo/python-list

Re: consistency: extending arrays vs. multiplication ?

2005-07-24 Thread Christopher Subich
Soeren Sonnenburg wrote: > On Sat, 2005-07-23 at 23:35 +0200, Marc 'BlackJack' Rintsch wrote: >>Both operate on the lists themselves and not on their contents. Quite >>consistent if you ask me. > But why ?? Why not have them operate on content, like is done on > *arrays ? Because they're lists,

Re: return None

2005-07-24 Thread Christopher Subich
Repton wrote: > 'Well, there's your payment.' said the Hodja. 'Take it and go!' +1: the koan of None "Upon hearing that, the man was enlightened." -- http://mail.python.org/mailman/listinfo/python-list

Re: can list comprehensions replace map?

2005-07-28 Thread Christopher Subich
Andrew Dalke wrote: > Steven Bethard wrote: > >>Here's one possible solution: >> >>py> import itertools as it >>py> def zipfill(*lists): >>... max_len = max(len(lst) for lst in lists) > > > A limitation to this is the need to iterate over the > lists twice, which might not be possible if one o

Re: A replacement for lambda

2005-07-29 Thread Christopher Subich
Mike Meyer wrote: > My choice for the non-name token is "@". It's already got magic > powers, so we'll give it more rather than introducing another token > with magic powers, as the lesser of two evils. Doesn't work. The crux of your change isn't introducing a meaning to @ (and honestly, I prefe

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paul Rubin wrote: > Christopher Subich <[EMAIL PROTECTED]> writes: > >>My personal favourite is to replace "lambda" entirely with an >>"expression comprehension", using < and > delimeters. > > > But how does that let you get more tha

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Scott David Daniels wrote: > What kind of shenanigans must a parser go through to translate: > < > > this is the comparison of two functions, but it looks like a left- > shift on a function until the second with is encountered. Then > you need to backtrack to the shift and convert it to a pa

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paolino wrote: > why (x**2 with(x))<(x**3 with(x)) is not taken in consideration? Looks too much like a generator expression for my taste. Also, syntax could be used with 'for' instead of 'with' if PEP343 poses a problem, whereas (expr for params) is identically a generator expression. > If 'w

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paddy wrote: > Christopher Subich <[EMAIL PROTECTED]> writes: > >>Basically, I'd rewrite the Python grammar such that: >>lambda_form ::= "<" expression "with" parameter_list ">" > > > I do prefer my parameter list to com

Re: Thaughts from an (almost) Lurker.

2005-07-31 Thread Christopher Subich
Robert Kern wrote: > My experience with USENET suggests that there is always a steady stream > of newbies, trolls, and otherwise clueless people. In the absence of > real evidence (like traceable headers), I don't think there's a reason > to suspect that there's someone performing psychological

Re: Wheel-reinvention with Python

2005-08-01 Thread Christopher Subich
Paul Rubin wrote: > I think my approach is in some sense completely typical: I don't want > to install ANYTHING, EVER. I've described this before. I want to buy > a new computer and have all the software I'll ever need already on the > hard drive, and use it from that day forward. By the time th

Re: Standard Threads vs Weightless Threads

2005-08-01 Thread Christopher Subich
yoda wrote: > 1)What is the difference (in terms of performance, scalability,[insert > relevant metric here]) between microthreads and "system" threads? System-level threads are relatively heavyweight. They come with a full call stack, and they take up some level of kernel resources [generally

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

2005-08-02 Thread Christopher Subich
Michael Rybak wrote: > That's the problem - "or a player input comes in". As I've explained, > this happens a dozen of times per second :(. I've even tried not > checking for player's input after every frame, but do it 3 times more > rare (if framecount % 3 == 0 : process_players_input()). Well, I

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

2005-08-02 Thread Christopher Subich
Michael Rybak wrote: > CS> There's the key. How are you processing network input, specifically > CS> retrieving it from the socket? > > A "sock" class has a socket with 0.1 timeout, and every time I > want anything, I call it's read_command() method until it returns > anything. read_command(

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

2005-08-03 Thread Christopher Subich
Michael Rybak wrote: > As stated above, that's how I'm trying it right now. Still, if doing > it turn-base, I would have to create a new thread every time. >I have some other questions though - please see below. No, you should never need to create a new thread upon receiving input. What you

Re: HELP:sorting list of outline numbers

2005-08-03 Thread Christopher Subich
Felix Collins wrote: > Using Decorate, Sort , Undecorate... > > works like a charm. As a one-liner, you can also deconstruct and rebuild the outline numbers: new_outline = ['.'.join(v) for v in (sorted([k.split('.') for k in old_outline]))] -- http://mail.python.org/mailman/listinfo/python-list

Re: cut & paste text between tkinter widgets

2005-08-03 Thread Christopher Subich
William Gill wrote: > Is there a simple way to cut and paste from a tkinter text widget to an > entry widget? I know I could create a mouse button event that triggers > a popup (message widget) prompting for cut/paste in each of the widgets > using a temp variable to hold the text, but I don't

  1   2   >