is open(...).read() a resource leak?

2005-11-02 Thread Benjamin Rutt
/* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)file_repr,/* tp_repr */ 0, /* tp_as_number */ [...] Thanks, -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: is open(...).read() a resource leak?

2005-11-02 Thread Benjamin Rutt
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Benjamin Rutt wrote: > >> If I did the following in an infinite loop, would the host system/user >> account soon run out of file descriptors? (I'm thinking no, since I'd >> imagine that a file object

Re: Making a persistent HTTP connection

2005-11-14 Thread Benjamin Niemann
7;s called 'keep-alive'. > And even if it works - what is the problem with connections being created? Performance, network load... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: can modules be dynamically reloaded

2005-11-16 Thread Benjamin Niemann
t; > For example you import a module, programatically edit it, then have the > file reload the module? > > Does anyone have any ideas about this? > Steve -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda as declarative idiom (was RE: what is lambda used for in real code?)

2005-01-03 Thread Dave Benjamin
Roman Suzi wrote: I wish lambdas will not be deprecated in Python but the key to that is dropping the keyword (lambda). If anybody could think of a better syntax for lambdas _with_ arguments, we could develop PEP 312 further. Well, my vote is still with Ruby-style codeblock syntax, but as a compro

Re: One-Shot Property?

2005-01-18 Thread Dave Benjamin
Kevin Smith wrote: I have many cases in my code where I use a property for calculating a value on-demand. Quite a few of these only need to be called once. After that the value is always the same. In these properties, I set a variable in the instance as a cached value and return that value on

Re: delay and force in Python

2005-01-19 Thread Dave Benjamin
Will Stuyvesant wrote: . def delay(exp): return lambda: exp If you look at the definition of "delay" in SICP, you'll notice that it's defined as "syntax sugar", in other words, a macro. Since Python does not have macros, you'll have to just use "lambda", because by defining "delay" as a function

Re: Zen of Python

2005-01-21 Thread Dave Benjamin
Paul Rubin wrote: Tim Peters <[EMAIL PROTECTED]> writes: But at that time, Python didn't have lexical scoping, and it wasn't clear that it ever would. So what's the bigger wart? Making listcomps exactly equivalent to an easily-explained Python for-loop nest, or introducing a notion of lexical sco

Re: python without OO

2005-01-27 Thread Dave Benjamin
Davor wrote: Is it possible to write purely procedural code in Python, or the OO constructs in both language and supporting libraries have got so embedded that it's impossible to avoid them? Also, is anyone aware of any scripting language that could be considered as "Python minus OO stuff"? (As you

Nested scopes and class variables

2005-01-30 Thread Dave Benjamin
like Python is determining at that point that "x" is a class variable, and refuses to search any further. At the top-level, it works as expected: >>> x = 5 >>> class C(object): ... x = x ... >>> C.x 5 Any implementation gurus have some insight into w

implicit conversion

2005-01-31 Thread Benjamin Schmeling
cally into an bigint. The other way round, turning an bigint into long can be realized by defining __long__. Can someone help me please? Benjamin -- http://mail.python.org/mailman/listinfo/python-list

Re: implicit conversion

2005-01-31 Thread Benjamin Schmeling
Alex Martelli wrote: Benjamin Schmeling <[EMAIL PROTECTED]> wrote: ... I don't know how to achieve implicit conversion at this point, turning an long automatically into an bigint. The other way round, turning an bigint into long can be realized by defining __long__. Perhap

Type inference, lessons learned from Vyper

2005-02-03 Thread Dave Benjamin
verifiable. -- .:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:. "talking about music is like dancing about architecture." -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested scopes and class variables

2005-02-03 Thread Dave Benjamin
Thanks, Nick and Alex, for the nice, detailed explanations. My understanding of Python bytecode is not deep enough to comment at this time. ;) -- .:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:. "talking about music is like dancing about architecture."

getting list of all available modules

2005-06-20 Thread Benjamin Rutt
cgitb mailcap smtplib [...] I want to do the same (get all such modules in a python list); how can I do so? Or where is the code for the REPL for help() itself so I can find out myself? This is to build a code introspection tool BTW. Thanks, -- Benjamin Rut

Thoughts on Guido's ITC audio interview

2005-06-25 Thread Dave Benjamin
Guido gave a good, long interview, available at IT Conversations, as was recently announced by Dr. Dobb's Python-URL! The audio clips are available here: http://www.itconversations.com/shows/detail545.html http://www.itconversations.com/shows/detail559.html I'd like to comment on a few parts of

Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Dave Benjamin
Stephen Kellett wrote: > In message <[EMAIL PROTECTED]>, Simon > Brunning <[EMAIL PROTECTED]> writes > >> Eclipse's refactorings are a great boon, I find. Refectoring is never >> *fully* automatic, of course, but the ability to, for example, select >> a chunk of code and have it extracted into a

Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Dave Benjamin
Sakesun Roykiattisak wrote: > >> What's being ignored is that type information is useful for other things >> than compile type checking. The major case in point is the way IDEs >> such as IntelliJ and Eclipse use type information to do refactoring, code >> completion and eventually numerous other

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Dave Benjamin
BORT wrote: > I am toying with the idea of teaching my ten year old a little about > programming. I started my search with something like "best FREE > programming language for kids." After MUCH clicking and high-level > scanning, I am looking at Python and Forth. Both have advocates that > say e

Re: Inheriting from object

2005-06-29 Thread Dave Benjamin
Steven Bethard wrote: > Guido also suggests that the explicit: > > class C(object): > pass > > is "much preferred"[2] over: > > __metaclass__ = type > > class C: > pass Really? I have been toying with the idea of using the __metaclass__ trick, since it results in c

Re: nested lists - utter newbie

2005-07-01 Thread Benjamin Niemann
] > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'x' is not defined Because the right hand side ('[1,2,x]') is evaluated *before* the value is bound to the name 'x' - and at this point there is obviously no name 'x' defined. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Better console for Windows?

2005-07-01 Thread Dave Benjamin
Brett Hoerner wrote: > Is there a different shell I can use (other than cmd.com) to run Python > in, where I can full-screen the window (if I pleased), etc? As it is, > things that would run far off the right have to be word wrapped after > very few characters. I have a pretty exotic setup but I

Re: Existance of of variable

2005-07-04 Thread Benjamin Niemann
Better use the generator syntax (requires python 2.4): minDist, closestPlace = min(((place.pos-pos).len(), place) for place in galaxy.places.itervalues()) -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Regular Expressions: re.sub(regex, replacement, subject)

2005-07-05 Thread Benjamin Niemann
nterpreted by the parser, e.g. r"\x" == "\\x". Using r"" when working with the re module is not required but pretty useful, because re has it's own rules for backslash handling). For more details see the docs for re.sub(): http://docs.python.org/lib/node114.html -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp development with macros faster than Python development?..

2005-07-05 Thread Benjamin Niemann
o learn a new programming language for every program I'd like to apply a minor fix/customization to: not a good idea. Probably not just for the casual hacker like me, but also for the maintainance phase of a project, when the former lead gurus lost interest and/or employment. -- Benjami

question about introspection using inspect module

2005-07-07 Thread Benjamin Rutt
27;somefunction', )] trying istraceback: [] I was trying to use inspect.getmembers(foo, ) with an appropriate predicate ("is" function). it looks like I am able to discover that 'someclass' is a class, and that 'somefunction' is a function (and also a routine, apparently). However, I cannot seem to discover that 'someglobal' is a global. How to do so? Thanks, -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: question about introspection using inspect module

2005-07-07 Thread Benjamin Rutt
ting what in the code what is for the GUI, what is for the Web server, and what does the introspection. I have actually borrowed the ModuleScanner class already, to build the list of modules. It is just inspecting those modules further where I'm having trouble. thanks, -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating anonymous functions using eval

2005-07-12 Thread Dave Benjamin
Joseph Garvin wrote: > Robert Kern wrote: > >> Not everyone is reading this list in a conveniently threaded form >> >> > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. My newsreader supports threading, but the first message I see in this thread

Re: Jython Released

2005-07-19 Thread Dave Benjamin
Ramza Brown wrote: > This is an update from Brian Zimmer of the Jython group, new release: Great news! > - new installer How do I use it? Thanks, Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: Jython Released

2005-07-19 Thread Dave Benjamin
Dave Benjamin wrote: > Ramza Brown wrote: > >> This is an update from Brian Zimmer of the Jython group, new release: > > Great news! > >> - new installer > > How do I use it? I figured it out. You might want to document this somewhere. ;) java

Re: Jython Released

2005-07-19 Thread Dave Benjamin
Ramza Brown wrote: >> >> I figured it out. You might want to document this somewhere. ;) >> java -cp jython_Release_2_2alpha1.jar >> org.python.util.install.Installation > > Did you try double clicking on the jar. That is what most do or at > least the last package supported that. Yeah. It ope

Re: dictionary as property

2005-07-20 Thread Benjamin Niemann
t_changed(key, value) self.d[key] = value def __getitem(self, key): return self.d[key] .... And in A.__init__ self.d = WrappedDict(self, {}) You may also subclass WrappedDict from dict... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between " and '

2005-07-21 Thread Benjamin Niemann
"That's my house" == 'That\'s my house' "You say: \"Hello\"" == 'You say: "Hello"' -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Stupid question: Making scripts python-scripts

2005-07-21 Thread Benjamin Niemann
reate a setup.py script for distribution. IIRC setup.py will recognize the shebang of your scripts and replace it with the proper path to python of the target system during installation. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting TypeError in Changing file permissions

2005-07-22 Thread Benjamin Niemann
ject (that you got from an open() call) as the first parameter. What you need is a string with the path to the file. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: python SMTP server

2005-07-31 Thread Benjamin Niemann
). But you should be aware of the fact that (if you send mail from a dialup machine without going through a relay server) your mails will quickly be marked as spam - I hope you do not intend to send spam... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: python SMTP server

2005-08-01 Thread Benjamin Niemann
Cliff Wells wrote: > On Sun, 2005-07-31 at 13:14 +0200, Benjamin Niemann wrote: > >> But you should be aware of the fact that (if you send mail from a dialup >> machine without going through a relay server) your mails will quickly be >> marked as spam - I hope you do

Re: python SMTP server

2005-08-01 Thread Benjamin Niemann
Cliff Wells wrote: > On Mon, 2005-08-01 at 12:28 +0200, Benjamin Niemann wrote: >> Cliff Wells wrote: > >[snip] > >> > By using a local SMTP server to proxy, your app can >> > queue up a large amount of mail in a much shorter period. It won't >>

Re: trying to parse non valid html documents with HTMLParser

2005-08-02 Thread Benjamin Niemann
tmllib and see, which parser is more forgiving. You might pipe the document through an external tool like HTML Tidy <http://www.w3.org/People/Raggett/tidy/> before you feed it into HTMLParser. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Art of Unit Testing

2005-08-02 Thread Benjamin Niemann
use unittest (because this was the API the textbook was using that introduced me to this topic) and I also had the problem of heavy setup costs. I deal with it by using a script around my testsuite (instead of calling just unittest.main()) that does the setup/teardown of the environment. -- Benjami

Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
Christoph Zwerschke wrote: > Benjamin Niemann wrote: >> Some (many?) people don't like the unittest module, because it is not >> very pythonic - nothing to wonder as it has its root in the Java world. >> That's probably one of the reasons why there are other

Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
Michael Hoffman wrote: > Benjamin Niemann wrote: >> Christoph Zwerschke wrote: >> >> >>>Benjamin Niemann wrote: >>> >>>>Some (many?) people don't like the unittest module, because it is not >>>>very pythonic - nothing to won

Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Benjamin Niemann
ne of my favourite programming adventures, I do not have such a personal relationship with my classes ;) -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Py: a very dangerous language

2005-08-03 Thread Benjamin Niemann
into much smaller steps, each step finalized with a 'all tests passed - your code works *exactly* as specified' (if you treat the testsuite as the formal specification, which I do), then you are tempted to celebrate all these small successes with a small reward. Baaad thing, if you smoke like I do... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Reliable destruction

2005-08-04 Thread Benjamin Niemann
wn() method try: m = measurement() try: m.setup() m.run() finally: m.tearDown() except KeyboardInterrupt: # user pressed ctrl-C print "***BREAK" sys.exit(1) except: # you should at least log the exception for later debugging traceback.print_exc() and remove the calls to setup() and run() from the constructor. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Reliable destruction

2005-08-04 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote: > Hello Benjamin, > > What would happen if an exception was thrown in the middle of setup()? > tearDown could not handle this case without having a list of the > objects already constructed (Or I would have to rely on the automatic > call to __del__,

Re: Py: a very dangerous language

2005-08-05 Thread Benjamin Niemann
Luis M. Gonzalez wrote: > This is great! > It's absolutely useless, like a real therapist, but it's free! Never heard of Eliza? Even Emacs has it built in (Menu Help -> Emacs Psychiatrist). -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- htt

Re: minidom xml & non ascii / unicode & files

2005-08-05 Thread Benjamin Niemann
this module does not have that method.. i'm left no choice but to edit > the site.py file manually to change "ascii" to "utf-8", but i won't be > able to do that on the client computers so.. > Anyways i don't know if it would help my script at all.. There was just recently a discussing on setdefaultencoding() on various pythonistic blogs, e.g. http://blog.ianbicking.org/python-unicode-doesnt-really-suck.html > > any help will be greatly appreciated > thx > > Marc -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a timebomb

2005-08-05 Thread Benjamin Niemann
ag that is polled by the main thread. You could also try to send a signal to yourself, but I'm not sure what will happen then... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: about coding

2005-08-06 Thread Benjamin Niemann
ses a format that is automatically recognized by the emacs editor. If you are using another editor, you'll have to search its menus for the proper way to save files as utf-8. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Putting function references in a Queue

2005-08-06 Thread Benjamin Niemann
phores etc.), there should not be any greater problems. The function will be executed in the thread that is called it of course (and not in the thread that sent the reference to it). -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with Regular Expressions

2005-08-10 Thread Benjamin Niemann
write '\\', if you need a backslash in the string, e.g. r'\w+' == '\\w+'. Useful for regular expression (because the re module parses the '\X' sequences itself) or Windows pathes (e.g. r'C:\newfile.txt'). And you should append a '$' to the re

Re: "Compile time" checking?

2005-08-10 Thread Benjamin Niemann
Qopit wrote: > [snip] > > My questions are: > - Am I missing something with my tester example? > - Are there other code-checking options other than PyChecker? Try pylint -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/m

Re: "Compile time" checking?

2005-08-13 Thread Benjamin Niemann
uperset of static code checking - all type bugs are found be the testsuite even in the absence if static type checking. So you won't loose anything, if you drop static typing. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: stopping a python windows service

2005-08-16 Thread Benjamin Niemann
er is slw, you'll still have a significant delay... To avoid this, you would need a http client based on select() that allows you to check shutdownEvent.isset() at certain intervals - instead of urlopen which just blocks. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Adobe COM with Python

2005-08-19 Thread Benjamin Niemann
tributes from the JS documentation to COM calls (the JS members start with lowercase - e.g. 'properties' -, while COM need uppercase - 'Properties'). -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Save Binary data.

2005-08-19 Thread Benjamin Niemann
ges are uncompressed anyway, you could have a look at the netpbm suite and its fileformat (which is pretty simple, but uncompressed and would bloat JPEGs to a multiple of the original filesize) which supports 'image sequences'. Perhaps a DivX encoder could even support this fileformat d

Re: loop in python

2005-08-22 Thread Benjamin Niemann
rogram would really suprising. Python suprises me often, but in different ways ;) Perhaps you could try to use sys.stdout.write() directly, avoiding the overhead of 'print'. Perhaps there are differences between the (default) output buffering settings of perl and python. -

Re: DeprecationWarning: Non-ASCII character '\xf3'

2005-08-23 Thread Benjamin Niemann
ge of this) - if you use anything else, then you'll have to declare it. This will be important, if you use unicode strings: u"stränge characters" Python must know the encoding of the file in order to decode the string literal into an unicode string. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Warning when doubly linked list is defined gloablly

2005-08-24 Thread Benjamin Niemann
hree lines above? (These would trigger a SyntaxError because of the typo...) You should provide a more complete example, so we can tell you where the problem is. Try to build a minimal file that reproduces the problem. Often you will find the line causing the error yourself - and the fix might be

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-26 Thread Benjamin Niemann
consecutive positions. If that's the cause, then here's another reason to use long, descriptive names instead of C64-BASIC style a, b, c, i, j... - with long names the chances of hash collisions are pretty low. Or everyone will start optimizing their programs by using long, *random* names

Re: Dynamic image creation for the web...

2005-08-28 Thread Benjamin Niemann
;) (Your prints above are mostly equivalent, but do not output the correct \r\n as line terminator - at least on UNIX style systems. Most webservers tolarate this, if it's coming from a CGI - but doing it right and not relying on a certain server behaviour is not bad anyway ;) Then check the PIL docs to find out, how to output the image to sys.stdout (instead of writing to a file). -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic image creation for the web...

2005-08-28 Thread Benjamin Niemann
Tompa wrote: > Benjamin Niemann odahoda.de> writes: >> You are almost there. > I don't feel so... > >> Your create_image.py does not return anything to the >> browser yet. > Yes, I am aware of that but I do not what to return. > >> First return pr

Re: time.strptime() for different languages

2005-08-31 Thread Benjamin Niemann
by month name, I suppose I could just substitute the month name using > a translation table for English to Dutch month names. Have you tested it with the proper locale setting and strptime(dateString, "%c")? I have not ;) -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odah

Re: Is my thread safe from premature garbage collection?

2005-09-01 Thread Benjamin Niemann
finite statement on whether threads > are safe from unwanted garbage collection, that'd be really great. > Thanks in advance for any helpful replies! The threading module does already take care of keeping references to all running threads, so there's no need to do it yourself and y

Re: Decrypting GPG/PGP email messages

2005-09-01 Thread Benjamin Niemann
to a email message? I can't help you with Thunderbird. In the worst case, you'll have to encrypt your command file manually and attach the encrypted version to your mail. KMail does have checkboxes for encrypt/sign every attachment separately... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Is my thread safe from premature garbage collection?

2005-09-01 Thread Benjamin Niemann
Sion Arrowsmith wrote: > In article <[EMAIL PROTECTED]>, Benjamin Niemann <[EMAIL PROTECTED]> > wrote: >>[EMAIL PROTECTED] wrote: >>> However, in my current project I'm creating a bunch of threads which >>> are supposed to run until they've co

Re: is there a better way to check an array?

2005-09-01 Thread Benjamin Niemann
se > except ValueError: > pass > > # throw expception if field is required and is empty > if(product[k] == '' and fieldIsRequired): > raise GMError(k + ' is required') if product[k] == '' and k in fieldIsRequired: raise GMError(k + ' is re

.pth files question

2005-09-02 Thread Benjamin Rutt
"/tmp/bar"? Thanks, -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: ~ after script filename?

2005-09-07 Thread Benjamin Niemann
me you save a new file), the existing version is renamed with the ~ suffix. After some time, you will learn to simply ignore these files ;) Many file managers have already learnt this lesson and have options to hide such backup files. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: epydoc CLI and many files

2005-09-07 Thread Dave Benjamin
Terry Hancock wrote: > On Monday 05 September 2005 08:10 am, Laszlo Zsolt Nagy wrote: > >>The problem is that now I have so many modules that the shell (cmd.exe) >>cannot interpret this as a one command. > > In POSIX systems, the shell expands wildcards into multiple files on > the command line

Re: Question about consistency in python language

2005-09-08 Thread Dave Benjamin
[EMAIL PROTECTED] wrote: > Let's say I define a list of pairs as follows: > >>>l = [('d', 3), ('a', 2), ('b', 1)] > > > Can anyone explain why this does not work? > >>>h = {}.update(l) > > > and instead I have to go: > >>>h = {} >>>h.update(l) > > to initialize a dictionary with the given l

Re: Question about consistency in python language

2005-09-08 Thread Dave Benjamin
Mike Meyer wrote: > Dave Benjamin <[EMAIL PROTECTED]> writes: > >>Python is actually quite consistent in this regard: methods that >>modify an object in-place return None; > > Um, no. list.pop comes to mind as an immediate counterexample. It may > be th

Re: how to get the return value of a thread?

2005-09-09 Thread Benjamin Niemann
esult = 1 elif num>50: result = 2 fooResult.put(result) t = thread.start_new_thread(foo,(12,)) # do other stuff, foo is running in background r = fooResult.get() # guaranteed to block until result is available print r -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Problem with nested lists as arrays

2005-02-14 Thread benjamin . cordes
Hello, For a class modeling the block puzzle I use nested lists as arrays. Within this class there is a method for swaping elements. I have lots of trouble with that method but can't figure it out. It has probably to do with my unuseful approach to nested lists, but I don't want to write the code

Re: namespace collisions

2005-02-17 Thread Dave Benjamin
Will McGugan wrote: I'm accumulating a number of small functions, which I have sensibly put in a single file called 'util.py'. But it occurs to me that with such a generic name it could cause problems with other modules not written by myself. Whats the best way of handling this? If I put it in a

Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Dave Benjamin
Jeremy Bowers wrote: I'd point out that the Zen that can be comprehended by checking off items in a list is not the true Zen. The Zen that can be imported is not the eternal Zen. =) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to wrap a class's methods?

2005-02-17 Thread Dave Benjamin
Michael Spencer wrote: Grant Edwards wrote: Thanks. The stuff provided by the "new" module is what I was missing. No magic in the 'new' module - new.instancemethod is just a synonym for the method type: >>> import new, types >>> new.instancemethod is types.MethodType True (Assuming you're usin

Re: Making things more functional in Python

2005-03-04 Thread Dave Benjamin
On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote: > Is there a better, more FP style, more Pythonic way to > write this: > > def compute_vectors(samples, dset): > vectors = {} > for d in dset: > vectors[d] = [sample.get_val(d) for sample in > samples] > return vectors

Re: Making things more functional in Python

2005-03-04 Thread Dave Benjamin
On Sat, 2005-03-05 at 00:00 -0700, Dave Benjamin wrote: > On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote: > > Is there a better, more FP style, more Pythonic way to > > write this: > > > > def compute_vectors(samples, dset): > > vectors = {} > > f

tkinter: always scroll to show last line of text

2005-03-13 Thread Benjamin Rutt
I have a tkinter 'Text' and 'Scrollbar' connected and working normally. When a new line of text is inserted (because I'm monitoring an output stream), I'd like the text and scrollbar to be scrolled to the bottom, so the latest line of text is always shown. How to

Re: tkinter: always scroll to show last line of text

2005-03-13 Thread Benjamin Rutt
Martin Franklin <[EMAIL PROTECTED]> writes: > text.yview_pickplace("end") Thank you, works perfectly! -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

tkinter: call root.after from a thread?

2005-03-17 Thread Benjamin Rutt
root.after() would be safe? I'm doing this in a GUI without any problems, so far. Thanks, -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: pdb with emacs

2004-12-01 Thread Benjamin Rutt
this helps: #!/bin/sh exec python $HOME/opt/python-2.3/lib/python2.3/pdb.py "$@" -- Benjamin Rutt -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3000 and "Python Regrets"

2004-12-01 Thread Dave Benjamin
Steve Holden wrote: Brad Tilley wrote: Matt Gerrans wrote: Anyway, what's to worry about?When the time comes just whip out a little script that converts Python 1.6 (or whatever you like) to Python3K; it will only take seven lines of P3K code. How about 'import classic' ... or from __past__

Audio interviews of Guido or other Python advocates?

2004-12-04 Thread Dave Benjamin
27;s about the closest I've found so far. -- .:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:. "talking about music is like dancing about architecture." -- http://mail.python.org/mailman/listinfo/python-list

Re: Audio interviews of Guido or other Python advocates?

2004-12-04 Thread Dave Benjamin
In article <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Dave Benjamin wrote: > >> I looked around for recordings of Guido, but couldn't find any. > > http://www.python.org/~guido/guido.au I found a few--slightly longer--video interviews here today: http://technet

Re: Audio interviews of Guido or other Python advocates?

2004-12-04 Thread Dave Benjamin
In article <[EMAIL PROTECTED]>, Jimmy Retzlaff wrote: > Dave Benjamin wrote: >> I looked around for recordings of Guido, but couldn't find any. Does >> anyone know of any streamable audio (or video) interviews or speeches >> featuring Guido, the bots, or any

Re: lies about OOP

2004-12-15 Thread Dave Benjamin
t across all styles of programming. Interestingly, Python's main unit of modularity is the "module", not the "class". A direct translation of a typical Python module to Java would look something like a Java class containing only static methods and inner classes. Even this would

Re: A rational proposal

2004-12-19 Thread Dave Benjamin
t impression that the results of the operation are > precise. Decimals will be converted to rationals before the > operation. [Open question: is this the right thing to do?] Sounds right to me. Cheers, Dave -- .:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:

Re: Why no list heritable type?

2004-12-22 Thread Dave Benjamin
Mike Meyer wrote: "Robert Brewer" <[EMAIL PROTECTED]> writes: Why aren't built in lists and dictionaries real heritable types that can save this kind of patchwork? They are since Python 2.2 (IIRC): And before Python 2.2 there was the UserList class in the standard library. Which is still there in

Re: IronPython 0.7 released!

2005-03-23 Thread Benjamin Niemann
; > > I'm also a bit puzzled that www.ironpython.com has no mention of this > release. > Curious that J Hugunin didn't announce it himself. Jim Hugunin announced it himself in a keynote at PyCon. You can read a lot about it on Python centric blogs - just one example: http://

Re: string join() method

2005-03-23 Thread Benjamin Niemann
whereas the second script outputs --- Content-type: text/plain\r\n \n Allele... --- The (required) "\n" - that should also be an "\r\n" - seperating the headers from the content is added by the first print. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: IronPython 0.7 released!

2005-03-24 Thread Benjamin Niemann
just go to planetpython.org > Or check out the Daily Python URL (http://www.pythonware.com/daily/) which has a pretty high signal to noise ratio. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggesting methods with similar names

2005-03-30 Thread Benjamin Niemann
ions = raise AttributeError("'Surface' object has no attribute '%s'. Did you mean %s?" % (name, suggestions)) I leave it to the experts to wrap this into a generic metaclass, decorator etc. ;) -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

SSL via Proxy (URLLIB2) on Windows gives Unknown Protocol error?

2005-04-20 Thread Benjamin Schollnick
Folks, With Windows XP, and Python v2.41 I am running into a problem The following code gives me an unknown protocol error And I am not sure how to resolve it... I have a API written for DocuShare for a non-SSL server, and I wanted to update it to support the SSL/S3 login So here's

Re: (PHP or Python) Developing something like www.tribe.net

2005-04-26 Thread Dave Benjamin
n popping up quite a bit lately, and they don't seem unreasonably slow to me. (CPUs have of course exploded in speed in the past few years.) -- .:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:. "talking about music is like dancing about architecture." -- http://mail.python.org/mailman/listinfo/python-list

Re: anonymous functions/expressions without lambda?

2005-04-28 Thread Dave Benjamin
Michael Hoffman wrote: Paul Miller wrote: > I see lambda is "going away", so I want to use something that will be > around for awhile. > > All I want to do is provide an "inline function" as an argument to > another function. That's what lambda does. But it's going away, you'll have to use d

Re: anonymous functions/expressions without lambda?

2005-04-28 Thread Dave Benjamin
Paul Miller wrote: Michael Hoffman wrote: Dave Benjamin wrote: I think you meant to write something like this: def attrsetter(obj, name, value): def _return_func(): return setattr(obj, name, value) return _return_func Sure did. Sorry. You guys have been very helpful! While on the

Re: anonymous functions/expressions without lambda?

2005-04-28 Thread Dave Benjamin
Dave Benjamin wrote: You could use a combination of bound methods and the "curry" function defined in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 The examples in the discussion do just that. Also, in the CVS version of Python, there's a ne

<    3   4   5   6   7   8   9   10   11   12   >