Bad Code (that works) help me re-write!

2006-10-11 Thread Matthew Warren
I have the following piece of code, taken from a bigger module, that even as I was writing I _knew_ there were better ways of doing it, using a parser or somesuch at least, but learning how wasn't as fun as coding it... And yes alarm bells went off when I found myself typing eval(), and I'm sure th

RE: Bad Code (that works) help me re-write!

2006-10-11 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Giles Brown > Sent: 11 October 2006 12:38 > To: python-list@python.org > Subject: Re: Bad Code (that works) help me re-write! > > Matthew Warren wrote: >

RE: Any idea how to do this in Python?

2006-10-17 Thread Matthew Warren
> On 17 Oct 2006 02:56:45 -0700, Lad <[EMAIL PROTECTED]> wrote: > > > > Dennis, > > Thank you for your reply > > You say: > > >Pretend you are the computer/application/etc. How would YOU > > > perform such a ranking? > > That is what I do not know , how to perform such ranking. > > Do you have any

Return returns nothing in recursive function

2006-10-17 Thread Matthew Warren
Hallo people, I have the following code that implements a simple recursive tree like structure. The trouble is with the GetTreeBranch function, the print statement prints a valid value but the return immediatley afterward doesn't return anything. Can anyone help me with why? Thanks, Matt. Co

RE: Return returns nothing in recursive function

2006-10-17 Thread Matthew Warren
> break > else: > _DoThingsToTree(path[1:],value,item[path[0]],delete) > The '_' in front of DoThingsToTree shouldn't be there. That's what I get for trimming off the '_' elsewhere after I pasted the code in. Matt. This email is confidential and

RE: making a valid file name...

2006-10-18 Thread Matthew Warren
> > Hi I'm writing a python script that creates directories from user > input. > Sometimes the user inputs characters that aren't valid > characters for a > file or directory name. > Here are the characters that I consider to be valid characters... > > valid = > ':./,^0123456789abcdefghijklmno

RE: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-20 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Fredrik Lundh > Sent: 20 October 2006 06:43 > To: python-list@python.org > Subject: Re: Tkinter--does anyone use it for sophisticated > GUI development? > > Kevin Walzer wrote: > > > Comi

RE: [Tutor] How to get the width of teh button widget..??

2006-10-20 Thread Matthew Warren
    Folks,   Sorry for asking you such a trivial question.!!! But i want to size up all the buttons with the same size as the largest one in the interface.. And thats why I am asking this question..   Regards, Asrarahmed      Hi Asrarahmed.  I think, from yo

Telnetlib to twisted

2006-10-27 Thread Matthew Warren
Hallo, >>> import telnetlib >>> l=telnetlib.Telnet('dbprod') >>> l.interact() telnet (dbprod) Login: Could anyone show how the above would be written using the twisted framework? All I'm after is a more 'intelligent' interactive telnet session (handles 'vi' etc..) rather than the full capabilit

random.jumpahead: How to jump ahead exactly N steps?

2006-06-21 Thread Matthew Wilson
The random.jumpahead documentation says this: Changed in version 2.3: Instead of jumping to a specific state, n steps ahead, jumpahead(n) jumps to another state likely to be separated by many steps.. I really want a way to get to the Nth value in a random series started with a particu

Re: Pygame.draw challenge is over!

2006-06-26 Thread Matthew Nuzum
www.pyweek.org/ > -- > http://mail.python.org/mailman/listinfo/python-announce-list > > Support the Python Software Foundation: > http://www.python.org/psf/donations.html > -- Matthew Nuzum www.bearfruit.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Allowing ref counting to close file items bad style?

2006-08-30 Thread Matthew Woodcraft
Dan <[EMAIL PROTECTED]> wrote: > Is this discouraged?: > > for line in open(filename): > > > That is, should I do this instead?: > > fileptr = open(filename) > for line in fileptr: > > fileptr.close() One reason to use close() explicitly is to make sure tha

Re: Name of the file associated with sys.std*

2006-08-30 Thread Matthew Woodcraft
Henryk Modzelewski <[EMAIL PROTECTED]> wrote: >It might be a trivial question, but I seem to be lost. > >Is there a way to get names of the files associated with stdin/out/ >err if those are redirected to the files at the shell command-line? I doubt there is a portable way. On most linux-based s

Re: python extension modules within packages not loading

2006-09-07 Thread Matthew Woodcraft
tyler <[EMAIL PROTECTED]> wrote: > I've written a small python extension but I'm having difficulty loading > it at runtime. The source for my extension is a module which is a > member of a package is organized as follows. > > test/setup.py > test/myutils/__init__.py > test/myutils/netmodule.c [..

I wish I could add docstrings to vars.

2006-09-12 Thread Matthew Wilson
I build a lot of elaborate dictionaries in my interpreter, and then I forget exactly how they work. It would be really nice to be able to add notes to the dictionary. Is there some way to do this now? Matt -- A better way of running series of SAS programs: http://overlook.homelinux.net/wilso

Code to add docstrings to classes

2006-09-12 Thread Matthew Wilson
On Tue 12 Sep 2006 10:06:27 AM EDT, Neil Cerutti wrote: > Writing a thin wrapper around the dictionary might be beneficial, > and would also furnish a place for the docstrings. I wrote a function that hopefully does just that. I'm not very savvy at doing this class-factory stuff, so any advice w

eval(repr(object)) hardly ever works

2006-09-13 Thread Matthew Wilson
I understand that idea of an object's __repr__ method is to return a string representation that can then be eval()'d back to life, but it seems to me that it doesn't always work. For example it doesn't work for instances of the object class: In [478]: eval(repr(object())) --

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Matthew Wilson
On Wed 13 Sep 2006 10:38:03 AM EDT, Steve Holden wrote: > That's intentional. Would you have it return the code of all the methods > when you take the repr() of a class? I don't think that would be required. Couldn't you return a string with a call to the constructor inside? That's what sets.Se

Re: optparse docs

2006-09-27 Thread Matthew Woodcraft
tobiah <[EMAIL PROTECTED]> wrote: > In > http://docs.python.org/lib/optparse-terminology.html > > The GNU project introduced "-" followed by a series of hyphen-separated > words, e.g. "-file" or "-dry-run". These are the only two option > syntaxes provided by optparse. [...] > So my ques

BoaConstructor

2006-09-29 Thread Matthew Warren
..I'm just about to start a project, I have a threaded python app currently around 3000 lines / 12-15 source files that is cli driven, and I am about to start using boaConstructor to build a GUI around it.   Has anyone here any advice on wether boaConstructor is actually a good tool for this

RE: Problems with Python 2.5 installer.

2006-09-29 Thread Matthew Warren
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of paw Sent: 29 September 2006 11:01 To: python-list@python.org Subject: Re: Problems with Python 2.5 installer. John Machin wrote: > paw wrote: > > I have ran the MSI installer for Python 2.5 several times at

RE: Making sure script only runs once instance at a time.

2006-09-29 Thread Matthew Warren
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hari SekhonSent: 29 September 2006 14:55To: python-list@python.orgSubject: Re: Making sure script only runs once instance at a time. I'm not sure if that is a very old way of doing it, which is why I wa

How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread Matthew Wilson
I wrote a function that I suspect may already exist as a python builtin, but I can't find it: def chunkify(s, chunksize): "Yield sequence s in chunks of size chunksize." for i in range(0, len(s), chunksize): yield s[i:i+chunksize] I wrote this because I need to take a string of a

How to query a function and get a list of expected parameters?

2006-09-29 Thread Matthew Wilson
I'm writing a function that accepts a function as an argument, and I want to know to all the parameters that this function expects. How can I find this out in my program, not by reading the source? For example, I would want to know for the function below that I have to pass in two things: def f(

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Matthew Woodcraft
[EMAIL PROTECTED] wrote: > And so on. For every use of the for/else clause there exists a better > alternative. Which sums up my opinion about the construct -- if you > are using it, there's something wrong with your code. How do you transform this? height = 0 for block in stack: if block.is_

RE: Making sure script only runs once instance at a time.

2006-09-30 Thread Matthew Warren
Apologies for repost. not sure what happened.   This email is confidential and may be privileged. If you are not the intended recipient please notify the sender immediately and delete the email from your computer. You should not copy the email, use it for any purpose or disclose its contents

How to coerce a list of vars into a new type?

2006-10-02 Thread Matthew Wilson
I want to verify that three parameters can all be converted into integers, but I don't want to modify the parameters themselves. This seems to work: def f(a, b, c): a, b, c = [int(x) for x in (a, b, c)] Originally, I had a bunch of assert isinstance(a, int) statements at the top of

How can I make a class that can be converted into an int?

2006-10-02 Thread Matthew Wilson
What are the internal methods that I need to define on any class so that this code can work? c = C("three") i = int(c) # i is 3 I can handle the part of mapping "three" to 3, but I don't know what internal method is called when int(c) happens. For string conversion, I just define the __str__ me

Raw strings and escaping

2006-10-03 Thread Matthew Warren
Hi, I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. ..although writing this I think I have solved my own problem. Is \' the only thing escaped in a raw string so you can place ' in a raw string? Alt

RE: Escapeism

2006-10-03 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Kay Schluehr > Sent: 30 September 2006 18:02 > To: python-list@python.org > Subject: Re: Escapeism > > Sybren Stuvel wrote: > > Kay Schluehr enlightened us with: > > > Usually I struggle a

RE: Escapeism

2006-10-03 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Matthew Warren > Sent: 03 October 2006 16:07 > To: python-list@python.org > Subject: RE: Escapeism > > > > > -Original Message- > &

Improving telnetlib

2006-10-04 Thread Matthew Warren
Hi, I use telnetlib in an app I am writing, and would like to add functionality to it to support interactive terminal sessions , IE: be able to 'vi' a file. Currently it seems telnetlib isnt quite sophisticated enoguh to support such a thing. The trouble is, I havent got a clue where to start

RE: Raw strings and escaping

2006-10-04 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Scott David Daniels > Sent: 03 October 2006 18:11 > To: python-list@python.org > Subject: Re: Raw strings and escaping > > Matthew Warren wrote: > >

Asyncore Medusa Example

2006-11-29 Thread Graeme Matthew
Hi all does anyone know where you can find examples of how to write a native python webserver, I have looked at medusa and asyncore but there are no real examples and the doco is very light any help is appreciated regards graeme -- http://mail.python.org/mailman/listinfo/python-list

How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
hat I have is that the function that processes the archive expects a file object. So far the only solution I have found it to write the file to disk and then read it back. Is there an easy way to convert data, in the example above into a file object? Thanks -Matthew -- http://mail.python.org/ma

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
John Abel wrote: > Matthew Thorley wrote: > >> I'm writing a web app whereby a user uploads a tar acrhive which is then >> opened and processed. My web form reads the file like this: >> >> while 1: >>data = value.file.read(1024 * 8) # Read blocks

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
Esben Pedersen wrote: > Matthew Thorley wrote: > >> I'm writing a web app whereby a user uploads a tar acrhive which is then >> opened and processed. My web form reads the file like this: >> >> while 1: >> data = value.file.read(1024 * 8) # Read b

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
Peter Otten wrote: > Matthew Thorley wrote: > > >>Esben Pedersen wrote: >> >>>Matthew Thorley wrote: >>> >>> >>>>I'm writing a web app whereby a user uploads a tar acrhive which is then >>>>opened and pr

using tarfile with an open file object

2005-05-04 Thread Matthew Thorley
need to use tarfile to manipulate an already open file object. I searched in the docs but didn't find anything. Maybe I just over looked the obvious. Does any one know how to do this? Thanks -matthew -- http://mail.python.org/mailman/listinfo/python-list

Multiple-reader-one-writer (MROW) locking -- soliciting improvements

2005-05-05 Thread Matthew Scott
://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413393 I'm posting a link to it here in case others find it useful, and also to solicit feedback for improving the recipe. Enjoy! - Matthew -- http://mail.python.org/mailman/listinfo/python-list

object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
hat my problem *really* is I would appreciate it greatly. Thanks very much. -Matthew -- http://mail.python.org/mailman/listinfo/python-list

Re: object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
So is elementtree a module of modules? I didn't know you could do that. I just assumed that from elementtree import ElementTree imported a class from the module elementtree. It works now. Thanks guys. Fredrik Lundh wrote: > Matthew Thorley wrote: > > >>I am trying to inhe

ElemenTree and namespaces

2005-05-16 Thread Matthew Thorley
Does any one know if there a way to force the ElementTree module to print out name spaces 'correctly' rather than as ns0, ns1 etc? Or is there at least away to force it to include the correct name spaces in the output of tostring? I didn't see anything in the api docs or the list archive, but befo

Re: ElemenTree and namespaces

2005-05-16 Thread Matthew Thorley
Thanks Andrew & Oren, that should do the trick. -- http://mail.python.org/mailman/listinfo/python-list

ElementTree and xsi to xmlns conversion?

2005-05-18 Thread Matthew Thorley
p://www.chpc.utah.edu/~baites/mgacML"; />' If some one could please explain where I'm off I'd really appreciate it. I need to use xsi: to validate the document, and I'm not sure how to pass it on to the children when I reformat the doc. Thanks -Matthew -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree and xsi to xmlns conversion?

2005-05-19 Thread Matthew Thorley
I an told, I need the second namespace, so that I can point to the schema, so that I can validate the document. Is that the wrong way to link to the schema? Can I force both namespaces to be inherited by the child elements? Thanks for all the help -Matthew -- http://mail.python.org/mailman

how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
hangs, waiting for my program to exit 1 or 0. My program never does exits because its looping every 30 seconds. Is there a way I can pass an exit value with out actualy exiting? or is there are better way to do this? Thanks -- Matthew Thorley -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
thanks thats perfect! Grant Edwards wrote: > On 2005-05-23, Matthew Thorley <[EMAIL PROTECTED]> wrote: > > >>I wrote a simple python program that scrapes a web page every >>30 secons and dumps the result in a data base. I want to use >>my linux distros build i

Re: Python memory handling

2007-05-31 Thread Matthew Woodcraft
Josh Bloom <[EMAIL PROTECTED]> wrote: > If the memory usage is that important to you, you could break this out > into 2 programs, one that starts the jobs when needed, the other that > does the processing and then quits. > As long as the python startup time isn't an issue for you. And if python st

Return name of caller function?

2007-06-26 Thread Matthew Peter
For example, how do I get this to work? def func(): print "This is", __?__ return __caller__ def echo(): print "This is ", __?__ return func() >>> print echo() This is echo This is func echo _

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Stephen R Laniel <[EMAIL PROTECTED]> wrote: > On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __cal

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Jay Loden <[EMAIL PROTECTED]> wrote: > > Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __caller__ > > > > def echo(): > > pri

log caller

2007-06-27 Thread Matthew Peter
Is it possible to print the function calls to a module? Like: test.py import mymod print mymod.x() mymod.py # each time a function is called we print out the called function and module print 'Func call: %s from %s' % (???, ???) def x(): return 'hello' Where would I pick up the ??? variabl

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
> The code below doesn't do the trick for you? > > #!/usr/bin/python > import inspect > > def master(): > print "I am the master" > slave() > > def slave(): > stack = inspect.stack() > caller = stack[1][3] > print "I am the slave; my caller was %s" % caller > > def main(): >

Re: os.wait() losing child?

2007-07-11 Thread Matthew Woodcraft
greg <[EMAIL PROTECTED]> wrote: > I've figured out what's going on. The Popen class has a > __del__ method which does a non-blocking wait of its own. > So you need to keep the Popen instance for each subprocess > alive until your wait call has cleaned it up. I don't think this will be enough for

Re: profiling a C++ python extension

2007-07-12 Thread Matthew Woodcraft
rasmus <[EMAIL PROTECTED]> wrote: > I have used gprof to profile stand alone C++ programs. I am also > aware of pure python profilers. However, is there a way to get > profile information on my C++ functions when they are compiled in a > shared library (python extension module) and called from p

Re: os.wait() losing child?

2007-07-12 Thread Matthew Woodcraft
Jason Zheng <[EMAIL PROTECTED]> wrote: >Hrvoje Niksic wrote: >> Actually, it's not that bad. _cleanup only polls the instances that >> are no longer referenced by user code, but still running. If you hang >> on to Popen instances, they won't be added to _active, and __init__ >> won't reap them (

Re: Semantics of file.close()

2007-07-17 Thread Matthew Woodcraft
Donn Cave <[EMAIL PROTECTED]> wrote: > I don't think there's any remedy for it, other than the obvious - > either always flush, or wrap an explicit close in its own exception > handler. Even if you have flushed, close() can give an error with some filesystems. -M- -- http://mail.python.org/mai

Itertools question: how to call a function n times?

2007-07-19 Thread Matthew Wilson
I want to write a function that each time it gets called, it returns a random choice of 1 to 5 words from a list of words. I can write this easily using for loops and random.choice(wordlist) and random.randint(1, 5). But I want to know how to do this using itertools, since I don't like manually d

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Matthew Woodcraft
Thorsten Kampe <[EMAIL PROTECTED]> wrote: >* René Fleschenberg (Tue, 15 May 2007 14:35:33 +0200) >> I am talking about the stdlib, not about the very few keywords Python >> has. Are you going to re-write the standard library in your native >> language so you can have a consistent use of natural la

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Matthew Woodcraft
Eric Brunel <[EMAIL PROTECTED]> wrote: > Joke aside, this just means that I won't ever be able to program math in > ADA, because I have absolutely no idea on how to do a 'pi' character on my > keyboard. Just in case it wasn't clear: you could of course continue to use the old name 'Pi' instead

Re: Python Web Programming - looking for examples of solid high-traffic sites

2007-05-21 Thread Matthew Nuzum
and has good documentation (dead tree or online). The unfortunate news, I'm afraid to say, is that because of the python culture, you're still going to face tough decisions as there are several mature products who score high marks in the areas I've listed above. It seems the python

Re: Eval and raw string ??

2007-08-22 Thread Matthew Woodcraft
Mark <[EMAIL PROTECTED]> wrote: > Eval() doesn't seem to recognize the r'string' format. Is there a way > around this. > Example: > If I input: -> eval("r'C:\tklll\ndfd\bll'") > I get the output: > > Traceback (most recent call last): > File "", line 1, in > eval("r'C:\tklll\ndfd\bl

Subprocess module and unicode input

2007-09-07 Thread Matthew Lausch
I'd like to use the subprocess module with upper level characters in the process name or in the arguments to the process. Something like this: cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2' ] subprocess.call(cmd) But this gives the error: UnicodeEncodeError: 'ascii' codec can't en

Re: Modul (%) in python not like in C?

2007-09-11 Thread Matthew Woodcraft
J. Cliff Dyer <[EMAIL PROTECTED]> wrote: >Bryan Olson wrote: >> Not true. Here it is again: >> >> When integers are divided, the result of the / operator is >> the algebraic quotient with any fractional part discarded.(87) >> If the quotient a/b is representable, the expression >>

Re: Subprocess module and unicode input

2007-09-13 Thread Matthew Lausch
Thanks! That worked perfectly. Matt On Sep 7, 10:42 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 07 Sep 2007 18:46:26 -0300, Matthew Lausch <[EMAIL PROTECTED]> > escribi?: > > > I'd like to use thesubprocessmodule with upper level ch

Re: Project organization and import

2007-03-06 Thread Matthew Woodcraft
Martin Unsal <[EMAIL PROTECTED]> wrote: > We could discuss this till we're blue in the face but it's beside the > point. For any given project, architecture, and workflow, the > developers are going to have a preference for how to organize the > code structurally into files, directories, packages,

Re: 2 new comment-like characters in Python to aid development?

2007-03-09 Thread Matthew Woodcraft
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Nick Craig-Wood a ecrit : > I use # FIXME for this purpose or /* FIXME */ in C etc. > > I have an emacs macro which shows it up in bright red / yellow text > so it is easy to see > Thanks you both. For what it's worth, sufficien

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Matthew Woodcraft
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >In message <[EMAIL PROTECTED]>, John J. Lee wrote: >> Seriously for a moment, I read something recently (maybe here?) about >> an Apple study that claimed to show that people who perceived keyboard >> bindings as being much faster than mouseing did

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Matthew Woodcraft
Cristian <[EMAIL PROTECTED]> wrote: > To me, the biggest setback for new programmers is the different > syntax Python has for creating functions. Instead of the common (and > easy to grasp) syntax of foo = bar Python has the def foo(): syntax. [...] > in a program like Python there doesn't seem

Using closures and partial functions to eliminate redundant code

2007-09-26 Thread Matthew Wilson
I wrote some code to create a user and update a user on a remote box by sending emails to that remote box. When I was done, I realized that my create_user function and my update_user function were effectively identical except for different docstrings and a single different value inside: ### V

Need recommendations on mock object packages

2007-10-17 Thread Matthew Wilson
What are the most popular, easiest to use, and most powerful mock object packages out there? Thanks in advance. Matt -- http://mail.python.org/mailman/listinfo/python-list

I can't get minimock and nosetests to play nice

2007-10-18 Thread Matthew Wilson
I'm curious if anyone has ever tried using nosetests along with minimock. I'm trying to get the two to play nice and not making progress. I also wonder if I'm using minimock incorrectly. Here's the code I want to test, saved in a file dtfun.py. class Chicken(object): "I am a chicke

Re: Hiding tracebacks from end-users

2007-10-24 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I'm writing a command-line application that is meant to be relatively > user friendly to non-technical users. > Consequently, I'd like to suppress Python's tracebacks if an error does > occur, replacing it with a more friendly error message. I'm doin

python logging config file doesn't allow filters?

2007-10-26 Thread Matthew Wilson
The python logging module is a beautiful masterpiece. I'm studying filters and the config-file approach. Is it possible to define a filter somehow and then refer to it in my config file? TIA Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on using isinstance

2007-01-24 Thread Matthew Woodcraft
abcd <[EMAIL PROTECTED]> wrote: > Well my example function was simply taking a string and printing, but > most of my cases would be expecting a list, dictionary or some other > custom object. Still propose not to validate the type of data being > passed in? There are many people here who will in

assertions to validate function parameters

2007-01-25 Thread Matthew Wilson
Lately, I've been writing functions like this: def f(a, b): assert a in [1, 2, 3] assert b in [4, 5, 6] The point is that I'm checking the type and the values of the parameters. I'm curious how this does or doesn't fit into python's duck-typing philosophy. I find that when I detect inv

Re: Thoughts on using isinstance

2007-01-25 Thread Matthew Woodcraft
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Matthew Woodcraft a écrit : >> Adding the validation code can make your code more readable, in that >> it can be clearer to the readers what kind of values are being >> handled. > This is better expressed in the

Re: assertions to validate function parameters

2007-01-26 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > The less your function does, the more constrained it is, the less > testing you have to do -- but the less useful it is, and the more work > you put onto the users of your function. Instead of saying something > like > a = MyNumericClass(1) > b = MyNum

Can I undecorate a function?

2007-01-29 Thread Matthew Wilson
The decorator as_string returns the decorated function's value as string. In some instances I want to access just the function f, though, and catch the values before they've been decorated. Is this possible? def as_string(f): def anon(*args, **kwargs): y = f(*args, **kwargs)

Re: Synchronous shutil.copyfile()

2007-01-30 Thread Matthew Woodcraft
Hugo Ferreira <[EMAIL PROTECTED]> wrote: > I have a problem. I'm using calling shutil.copyfile() followed by > open(). The thing is that most of the times open() is called before > the actual file is copied. I don't have this problem when doing a > step-by-step debug, since I give enough time for t

Re: Create a cookie with cookielib

2007-02-03 Thread Matthew Franz
he code of cookie.php that i've create for this example: > > setcookie("user", "Alex Porter", time()+3600); > ?> > // Print a cookie > echo $_COOKIE["user"]; > // A way to view all cookies > print_r($_COOKIE); > ?> > > if anyone could help... Thank you > -- > http://mail.python.org/mailman/listinfo/python-list > -- Matthew Franz http://www.threatmind.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: python linux distro

2007-02-08 Thread Matthew Franz
> thanks guys > > when i wrote this, i thought that out there is some crazy guy like me. > i was hoping for more support but after these arguments, there is > nothing more then to say:you are right. the world doesnt need another > distro. but if one day I mange to do it, hope you will be glade that

Re: starship.python.net is down

2007-02-21 Thread Matthew . Cahn
Hi, Any news on starship.python.net? It still seems to be down. Matthew On Feb 16, 8:57 am, Tom Bryan <[EMAIL PROTECTED]> wrote: > One of the system administrators had to reboot starship.python.net last > night, but it appears that the machine did not come back

Curious UnboundLocalError Behavior

2007-02-28 Thread Matthew Franz
k.local', '8.8.5', 'Darwin Kernel Version 8.8.5: Mon Dec 11 19:39:17 PST 2006; root:xnu-792.16.5.obj~1/RELEASE_I386', 'i386') 2.4.3 (#1, Feb 24 2007, 23:01:32) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] {'__builtins__': , '__file__': 'unboundlocal.py', 'SOMEGLOBAL': 1, 'sys': , '__name__': '__main__', 'foo': , 'os': , '__doc__': None} SOMEGLOBAL: 0 -- Matthew Franz http://www.threatmind.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: starship.python.net is down

2007-03-01 Thread Matthew . Cahn
with the host company to > determine what's going on. I think that they are still in the > "investigation" stage at the moment, so it's hard to give an estimate of > when the problem will be fixed. > > Thanks for your patience, > ---Tom I appreciate the update. Thank

Re: Curious UnboundLocalError Behavior

2007-03-01 Thread Matthew Franz
, because that wasn't the behavior I wanted either.Thanks for the help. - mdf On 1 Mar 2007 00:20:05 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 28 fév, 18:15, "Matthew Franz" <[EMAIL PROTECTED]> wrote: > > I'm probably fundamentally misunders

Need help writing coroutine

2007-11-07 Thread Matthew Wilson
I'm working on two coroutines -- one iterates through a huge stream, and emits chunks in pieces. The other routine takes each chunk, then scores it as good or bad and passes that score back to the original routine, so it can make a copy of the stream with the score appended on. I have the code wo

Nested loops confusion

2006-05-10 Thread Matthew Graham
Hi, I expect this is very obvious for anyone who knows what they're doing - but I don't understand what's the problem with the following code. I was intending that the program cycle through all i and j (ie. all possible (i,j) coordinates, but the output when I run the program shows me up to

Re: Nested loops confusion

2006-05-10 Thread Matthew Graham
Oops, I forget to reset the j after the inner loop. Always manage to work these things out just after asking for help! ;-) Matthew Graham wrote: > Hi, > > I expect this is very obvious for anyone who knows what they're doing - > but I don't understand what's the

Re: Nested loops confusion

2006-05-11 Thread Matthew Graham
Thanks very much for the advice, have tidied it up and tested and seems to be working as needed. I'm still not sure what was stopping the inner loop from working earlier - but removing the redundancy in "j=0" and so on seems to have solved it. Matt Dennis Lee Bieber wrote: > If that wor

Re: Performance on local constants?

2007-12-27 Thread Matthew Franz
I get class Searcher(object) but can't for the life of me see why (except to be intentionally obtuse) one would use the def searcher(rex) pattern which I assure you would call with searcher(r)(t) right? - mdf > > > > 'Most flexible' in a different way is > > > > def searcher(rex): > > crex =

Re: Performance on local constants?

2007-12-27 Thread Matthew Franz
Thanks, that makes more sense. I got tripped up by the function returning a function thing and (for a while) thought _ was some sort of spooky special variable. - mdf > On Dec 28, 7:53 am, "Matthew Franz" <[EMAIL PROTECTED]> wrote: > > I get class Searcher(object) but

Re: Network Module

2008-01-01 Thread Matthew Franz
g and search at pythonorg but couldn't find any. > > Thanks > Sunil Kumar Ghai > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Matthew Franz http://www.threatmind.net/ -- http://mail.python.org/mailman/listinfo/python-list

shelve and nested dictionaries

2008-01-03 Thread Matthew Schibler
I'm a newbie to Python, with some experience using perl (where I used nested arrays and hashes extensively). I am building a script in python for a MUD I play, and I want to use the shelve module to store persistent information between script executions. The following code does not work for me, im

Re: I'm searching for Python style guidelines

2008-01-08 Thread Matthew Woodcraft
Paul McGuire <[EMAIL PROTECTED]> wrote: > While not required by any means, you will also find it handy to follow > *every* entry in the list with a comma, even the last one in the list > (this is legal Python). That is, in your example: > > foo =3D [ > 'too long', > 'too long too', >

Re: I'm searching for Python style guidelines

2008-01-08 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > A quick look (thorough analysis still required) shows that OLPC and > PyPy are, indeed, extensive standards. > one-laptop-per-child.html > (olpc),74.3,,http://wiki.laptop.org/go/Python_Style_Guide I think that's mostly PEP 8, with some notes added. -M- -- http://m

I don't understand what is happening in this threading code

2008-01-18 Thread Matthew Wilson
In this code, I tried to kill my thread object by setting a variable on it to False. Inside the run method of my thread object, it checks a different variable. I've already rewritten this code to use semaphores, but I'm just curious what is going on. Here's the code: import logging, threading,

Re: linux disc space

2008-02-15 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Available space is how much you can actually access as a non-root user. > Apparently (thank you Jean-Paul), space can be reserved for superuser > use only; such space is "free," but not "available." > I'm not sure how su

Re: Critique of first python code

2008-02-17 Thread Matthew Marshall
Dan Bishop wrote: > I will say, however, that hasattr(item, '__iter__') isn't a perfect > way of checking whether an object is iterable: Objects that just > define __getitem__ are iterable too (e.g., UserList). Speaking of which, what *is* the best way to check if an object is iterable? I always

<    1   2   3   4   5   >