2.X functools.update_wrapper dislikes missing function attributes

2011-04-26 Thread samwyse
I noticed a behavior in Jython 2.5.2 that's arguably an implementation bug, but I'm wondering if it's something to be fixed for all versions of Python. I was wanting to decorate a Java instance method, and discovered that it didn't have a __module__ attribute. This caused the following message:

Re: 2.X functools.update_wrapper dislikes missing function attributes

2011-04-26 Thread samwyse
I just noticed an old issue that relate to this: http://bugs.python.org/issue3445 This dates back to 2008 and is marked as fixed, but my copies of Python 2.5.4 and 2.7.1 don't seem to implement it. I'll try to dig further. -- http://mail.python.org/mailman/listinfo/python-list

Re: Microsoft Hatred FAQ

2005-11-01 Thread samwyse
David Schwartz wrote: > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Morally, lying in court is a tough one. For example, suppose you are in > a court case with someone who is definitely lying in court. You are in the > right, but it's clear the court won't bel

Python 3000: Standard API for archives?

2007-06-04 Thread samwyse
I'm a relative newbie to Python, so please bear with me. There are currently two standard modules used to access archived data: zipfile and tarfile. The interfaces are completely different. In particular, script wanting to analyze different types of archives must duplicate substantial piece

Re: need help with re module

2007-06-22 Thread samwyse
Gabriel Genellina wrote: > En Wed, 20 Jun 2007 17:56:30 -0300, David Wahler <[EMAIL PROTECTED]> > escribió: > >> On 6/20/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> [snip] >> I agree that BeautifulSoup is probably the best tool for the job, but >> this doesn't sound right to me. Since th

Re: Re-raising exceptions with modified message

2007-07-07 Thread samwyse
On Jul 5, 8:53 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > What is the best way to re-raise any exception with a message > supplemented with additional information (e.g. line number in a > template)? Let's say for simplicity I just want to add "sorry" to every > exception message. My naive

Re: Re-raising exceptions with modified message

2007-07-07 Thread samwyse
On Jul 7, 4:13 pm, samwyse <[EMAIL PROTECTED]> wrote: > On Jul 5, 8:53 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > > What is the best way to re-raise any exception with a message > > supplemented with additional information (e.g. line number in a > >

Re: Re-raising exceptions with modified message

2007-07-07 Thread samwyse
On Jul 5, 8:53 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > What is the best way to re-raise any exception with a message > supplemented with additional information (e.g. line number in a > template)? Let's say for simplicity I just want to add "sorry" to every > exception message. OK, thi

Re: what is wrong with that r"\"

2007-07-08 Thread samwyse
On Jul 4, 7:15 am, Matthieu TC <[EMAIL PROTECTED]> wrote: > May I suggest giving the possibility to use any delimiter for a raw string? > just like in Vi or ruby. > > Vi: > %s_a_b_g is valid and so is %s/a/b/g > > Ruby: > %q{dj'\ks'a\'"} or %q-dj'\ks'a\'"- > > So as long as your regex does

Re: allow scripts to use .pth files?

2007-07-08 Thread samwyse
On Jul 3, 9:35 am, Alan Isaac <[EMAIL PROTECTED]> wrote: > Suppose I have a directory `scripts`. > I'd like the scripts to have access to a package > that is not "installed", i.e., it is not on sys.path. > On this list, various people have described a variety > of tricks they use, but nobody has pr

Re: Rats! vararg assignments don't work

2007-07-12 Thread samwyse
On May 30, 7:29 am, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > samwyse <[EMAIL PROTECTED]> wrote: > >>samwysewrote: > >>>I thought that I'd try this: > >>> first, *rest = arglist > >>>Needless to say, it didn't wor

Re: allow scripts to use .pth files?

2007-07-12 Thread samwyse
On Jul 8, 3:53 pm, John Machin <[EMAIL PROTECTED]> wrote: > I got the impression that the OP was suggesting that the interpreter > look in the directory in which it found the script. [...] > I got the impression that the problem was that the package was not > only not on sys.path but also not in t

Re: Re-raising exceptions with modified message

2007-07-12 Thread samwyse
On Jul 8, 8:50 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Did you run this? > With Py < 2.5 I get a syntax error, and with Py 2.5 I get: > > new.__class__ = old.__class__ > TypeError: __class__ must be set to a class > > -- Chris Damn, I'd have sworn I ran the final copy that I post

Re: allow scripts to use .pth files?

2007-07-12 Thread samwyse
On Jul 8, 3:53 pm, John Machin <[EMAIL PROTECTED]> wrote: > I'm curious whether you think that the OP's use of ".pth" was a typo, > and whether you have read this: >http://docs.python.org/lib/module-site.html I've read it, but not recently; the syntax of the .pyh files was in the back of my h

Re: allow scripts to use .pth files?

2007-07-12 Thread samwyse
On Jul 12, 7:20 am, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 12, 9:55 pm, samwyse <[EMAIL PROTECTED]> wrote: > > > On Jul 8, 3:53 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > > I got the impression that the OP was suggesting that the interpret

Re: Re-raising exceptions with modified message

2007-07-12 Thread samwyse
On Jul 12, 6:31 am, samwyse <[EMAIL PROTECTED]> wrote: > On Jul 8, 8:50 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > > With Py 2.5 I get: > > > new.__class__ = old.__class__ > > TypeError: __class__ must be set to a class Hmmm, under Py

Assignments to __class_ broken in Python 2.5?

2007-07-12 Thread samwyse
On Jul 12, 11:48 am, samwyse <[EMAIL PROTECTED]> wrote: > On Jul 12, 6:31 am,samwyse<[EMAIL PROTECTED]> wrote: > > > On Jul 8, 8:50 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > > > With Py 2.5 I get: > > > > new.__class__ = old

Re: Assignments to __class_ broken in Python 2.5?

2007-07-13 Thread samwyse
(Yes, I probably should have said CPython in my subject, not Python. Sorry.) On Jul 13, 12:56 am, samwyse <[EMAIL PROTECTED]> wrote: > OK, in classobject.h, we find this: > > #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) > > That seems straightforwa

Re: Re-raising exceptions with modified message

2007-07-13 Thread samwyse
On Jul 13, 12:45 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > samwyse wrote: > > TypeError: __class__ must be set to a class > > > Excpt ceratinly appears to be a class. Does anyone smarter than me > > know what's going on here? > > Not that

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread samwyse
On Jul 13, 1:05 pm, Chris Carlen <[EMAIL PROTECTED]> wrote: > John Nagle wrote: > > Chris Carlen wrote:[edit] > >> Hence, being a hardware designer rather than a computer scientist, I > >> am conditioned to think like a machine. I think this is the main > >> reason why OOP has always repelled me.

Rats! vararg assignments don't work

2007-05-29 Thread samwyse
I'm a relative newbie to Python, so please bear with me. After seeing how varargs work in parameter lists, like this: def func(x, *arglist): and this: x = func(1, *moreargs) I thought that I'd try this: first, *rest = arglist Needless to say, it didn't work. That leaves me with tw

Re: Rats! vararg assignments don't work

2007-05-30 Thread samwyse
Gary Herron wrote: > samwyse wrote: > >>I'm a relative newbie to Python, so please bear with me. After seeing >>how varargs work in parameter lists, like this: >> def func(x, *arglist): >>and this: >> x = func(1, *moreargs) >>I thought t

Re: Rats! vararg assignments don't work

2007-05-30 Thread samwyse
George Sakkis wrote: > On May 29, 11:33 pm, Matimus <[EMAIL PROTECTED]> wrote: > > >>Your attemtp: >> >>[code] >>first, rest = arglist[0], arglist[1:] >>[/code] >> >>Is the most obvious and probably the most accepted way to do what you >>are looking for. As for adding the fucntionality you first

Python 2.5.1 can't find win32file?

2007-07-28 Thread samwyse
I just upgraded from 2.4.something to 2.5.1. I get the stuff below. I tried easy-installing pywin32; same results. Anyone know what's going on? Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

Re: How to programmatically insert pages into MDI.

2007-07-28 Thread samwyse
On Jul 28, 7:46 am, fynali iladijas <[EMAIL PROTECTED]> wrote: > On Jul 24, 4:36 pm, fynali iladijas <[EMAIL PROTECTED]> wrote: > > > > > Hi, this query is regarding automating page insertions in Microsoft > > Document Imaging. > [...] > > > All help and advice will be most appreciated. > > > Thank

Re: Python 2.5.1 can't find win32file?

2007-07-28 Thread samwyse
On Jul 28, 8:16 am, samwyse <[EMAIL PROTECTED]> wrote: > I just upgraded from 2.4.something to 2.5.1. I get the stuff below. > I tried easy-installing pywin32; same results. Anyone know what's > going on? > Interestingly enough, this works: C:\Python25>path=%path%;C:\

Re: Python 2.5.1 can't find win32file?

2007-07-29 Thread samwyse
On Jul 28, 12:14 pm, Jay Loden <[EMAIL PROTECTED]> wrote: > samwyse wrote: > > Interestingly enough, this works: > > > C:\Python25>path=%path%;C:\Python25\Lib\site-packages\pywin32-210- > > py2.5-win32.eg > > g\pywin32_system32 > > > C:\Python25>p

Re: wxPython before MainLoop

2007-08-15 Thread samwyse
Chris Mellon wrote: > On 8/9/07, Heikki Toivonen <[EMAIL PROTECTED]> wrote: > >>[david] wrote: >> >>>I'd like to refresh the display before I start the main loop. If your window isn't able to interact with the user, then I'd consider it a splash screen, no matter if it does look exactly like you

Re: clarification

2007-08-17 Thread samwyse
Scott David Daniels wrote: > lefts = set() > rights = set() > with open('sheet1', 'r') as fh: > for line in fh: > trimmed = line.strip() > if trimmed: # Skip blanks (file end often looks like that) > left, right = line.strip().split('\t') >

Re: unexpected optparse set_default/set_defaults behavior

2007-08-18 Thread samwyse
[EMAIL PROTECTED] wrote: > Some rather unexpected behavior in the set_default/set_defaults > methods for OptionParser that I noticed recently: [...] > Why does set_default not raise an exception when passed a key that it > doesn't recognize? > > Bad typysts bewaer. > > The only reason I can think

Re: clarification

2007-08-18 Thread samwyse
samwyse wrote: > Scott David Daniels wrote: > >> lefts = set() >> rights = set() >> with open('sheet1', 'r') as fh: >> for line in fh: >> trimmed = line.strip() >> if trimmed: # Skip blanks (file end of

Re: clarification

2007-08-19 Thread samwyse
Alex Martelli wrote: > Of course, hoisting the unbound method out of the loops can afford the > usual small optimization. But my point is that, in Python, these > operations (like, say, the concatenation of a sequence of lists, etc) > are best performed "in place" via loops calling mutator method

Re: Symbolic Link

2007-08-19 Thread samwyse
mosscliffe wrote: > I am trying to create a link to a file, which I can then use in an > HTML page. > > The system is Linux on a hosted web service, running python 2.3. > Other than that I have no knowledge of the system. > > The link is created OK, but when I try to use it as filename for the >

Re: Parser Generator?

2007-08-19 Thread samwyse
Jack wrote: > Thanks for all the replies! > > SPARK looks promising. Its doc doesn't say if it handles unicode > (CJK in particular) encoding though. > > Yapps also looks powerful: http://theory.stanford.edu/~amitp/yapps/ > > There's also PyGgy http://lava.net/~newsham/pyggy/ > > I may also giv

Re: Searching for pixel color

2007-08-19 Thread samwyse
michael maver wrote: > Hello, I was just wondering if anyone knew of a way to search the screen > for a certain color in Python. I know of lots of ways to do this... > I know it is possible to do this in other languages, but I'm not sure > how I'd go about doing this in Python. Just to let you

Re: 1)URL QueryString Parsing 2)Search Engine Spiders

2007-08-19 Thread samwyse
mosscliffe wrote: > I am trying to create a back link, equivalent to the browser back > action and I can not use java script. The target user does not allow > java script. > > I am using HTTP_REFERER. > > I need to add the original Query String values. > > Is there a way to get the QueryString e

Re: Development for dual core machine

2007-08-19 Thread samwyse
Andy wrote: > Hi guys, > > I'm sorry, I'm not sure this is the correct group to be asking this > kind of question... > > I'm going to develop a software package that includes a web server > (and PHP code) , a database, and some Python code of course. I am > being strongly suggested to make it to

Re: Symbolic Link

2007-09-09 Thread samwyse
mosscliffe wrote: > On 22 Aug, 00:05, Ian Clark <[EMAIL PROTECTED]> wrote: >> >>>On Aug 19, 4:29 pm,mosscliffe<[EMAIL PROTECTED]> wrote: >>> The source file is in an area which python can see, but not the browser. I am trying to make a link in a browser friendly area so I can use it to

Re: Symbolic Link

2007-10-10 Thread samwyse
On Sep 9, 10:05 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>,samwysewrote: > > > A hard-link, OTOH, allows > > direct access to the contents of a file, as long as it is on the same > > filesystem. No extra steps are required, so the pr

BaseHTTPServer issues

2007-11-23 Thread samwyse
I've just now submitted two issues to the issue tracker: 1491BaseHTTPServer incorrectly implements response code 100 RFC 2616 sec 8.2.3 states, "An origin server that sends a 100 (Continue) response MUST ultimately send a final status code, once the request body is received and processed, u

Re: the annoying, verbose self

2007-11-24 Thread samwyse
On Nov 23, 7:16 pm, "Patrick Mullen" <[EMAIL PROTECTED]> wrote: > Most of the time self doesn't bother me in the slightest. The one > time it does bother me however, is when I am turning a function into a > method. In this case, often I have many local variables which I > actually want to be inst

setting attributes on external types (was Re: eof)

2007-11-24 Thread samwyse
On Nov 23, 2:06 am, greg <[EMAIL PROTECTED]> wrote: > There's a fair amount of overhead associated with providing > the ability to set arbitrary attributes on an object, which > is almost never wanted for built-in types, so it's not > provided by default. > > You can easily get it if you want it by

Re: the annoying, verbose self

2007-11-24 Thread samwyse
On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote: > > I've had the same thought, along with another. You see, on of my pet > > peeves about all OO languages that that when creatin

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread samwyse
On Nov 24, 5:44 am, Licheng Fang <[EMAIL PROTECTED]> wrote: > Yes, millions. In my natural language processing tasks, I almost > always need to define patterns, identify their occurrences in a huge > data, and count them. [...] So I end up with unnecessary > duplicates of keys. And this can be a gr

Re: the annoying, verbose self

2007-11-24 Thread samwyse
On Nov 24, 7:50 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote: > > On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Sat, 24 Nov 2007 01:55:38 -0800, samw

Re: the annoying, verbose self

2007-11-24 Thread samwyse
On Nov 24, 10:07 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > Ton van Vliet <[EMAIL PROTECTED]> wrote: > > > It would boil down to choice: explicit/speed vs implicit/readability > > No, it would boil down to explicit+speed+readability+maintainability vs > implicit+error prone. > > It would mean th

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread samwyse
On Nov 24, 10:35 am, Licheng Fang <[EMAIL PROTECTED]> wrote: > Thanks. Then, is there a way to make python treat all strings this > way, or any other kind of immutable objects? The word generally used is 'atom' when referring to strings that are set up such that 'a == b' implies 'a is b'. This is

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread samwyse
On Nov 24, 5:44 am, Licheng Fang <[EMAIL PROTECTED]> wrote: > Yes, millions. In my natural language processing tasks, I almost > always need to define patterns, identify their occurrences in a huge > data, and count them. Say, I have a big text file, consisting of > millions of words, and I want to

Re: the annoying, verbose self

2007-11-25 Thread samwyse
On Nov 24, 1:10 pm, "Patrick Mullen" <[EMAIL PROTECTED]> wrote: > If there were a "using" or if the with statement would handle > something like this, I wouldn't use it. "s." is only 2 characters. I > saw chained dots mentioned. Chained dots are 2 characters. Why are > we still discussing this?

__iadd__ useless in sub-classed int

2007-12-06 Thread samwyse
For whatever reason, I need an inproved integer. Sounds easy, let's just subclass int: >>> class test(int): pass Now let's test it: >>> zed=test(0) >>> zed.__class__ >>> zed 0 So far, so good. Now let's try incrementing: >>> zed+=1 >>> zed 1 >>> zed.__class__ WTF??! Is this a bug

Re: How can I create customized classes that have similar properties as 'str'?

2007-12-06 Thread samwyse
On Nov 24, 6:38 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > samwyse <[EMAIL PROTECTED]> writes: > > create a hash that maps your keys to themselves, then use the values > > of that hash as your keys. > > The "atom" function you describe already exist

Re: __iadd__ useless in sub-classed int

2007-12-06 Thread samwyse
On Dec 6, 1:12 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > samwyse schrieb: > > > For whatever reason, I need an inproved integer. Sounds easy, let's > > just subclass int: > > >>>> class test(int): > >pass >

Re: Terminology: "script" versus "program"

2008-01-24 Thread samwyse
Ben Finney wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > >>On Jan 23, 8:14 pm, [EMAIL PROTECTED] wrote: >> >>>The annual Linux Journal survey is online now for any Linux users >>>who want to vote for Python. >>>http://www.linuxjournal.com/node/1006101 >> >>... >>18. What is your favorite

Re: Python noob SOS (any [former?] Perlheads out there?)

2008-02-02 Thread samwyse
nerates boilerplate for a Python script. It accepts a single argument consisting of a string of option letters that you wish the script to recognize, with options that require an argument followed by a colon (i.e., the same format that Unix getopt() uses). Written by samwyse Created on Feb 02, 2

Re: Does anyone else use this little idiom?

2008-02-03 Thread samwyse
[EMAIL PROTECTED] wrote: > My apologies if any attributions are messed up. > > On Feb 3, 1:28 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > >>If you want an explicit name, try a variation of "dontcare". Assuming >>that you're an English speaker. I'm with Steven here. I t

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 14, 7:01 pm, Aaron Brady wrote: > Here is an idea.  Create a list of all possible pairs, using > itertools.combinations.  You'll notice everyone gets equal play time > and equal time against each other on a pair-by-pair basis.  Then, call > random.shuffle until one player isn't playing on t

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 15, 8:13 am, Aaron Brady wrote: > On Apr 15, 6:57 am, samwyse wrote: > > > Here's my idea: generate all possible pairs: > > > >>> import itertools > > >>> players = [chr(c) for c in xrange(ord('a'),ord('z')+1)] >

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 15, 8:56 am, Aaron Brady wrote: > > The randomizing solution isn't quite suitable for 16 teams.  With 5 > teams/1 court, and 5 teams/2 courts, 6 teams/2 courts, the solution > comes within seconds.  For 7 teams/3 courts, the solution takes a few > minutes. 7 teams/3 courts is the same as 8

How do I change the behavior of the 'python-docs' action in IDLE?

2009-04-16 Thread samwyse
In the Windows version of Python 2.5, pressing F1 brought up the python.chm file. I've just installed 2.6, and the same action opens http://www.python.org/doc/current/. I'd prefer the former behavior. I know how to change the key bindings in config-keys.def, but I think I want to change the actio

creating classes with mix-ins

2009-05-11 Thread samwyse
I'm writing a class that derives it's functionality from mix-ins. Here's the code: def boilerplate(what): # This used to be a decorator, but all of the ##what = f.__name__ # function bodies turned out to be 'pass'. 'Validate the user, then call the appropriate plug-in.'

Re: creating classes with mix-ins

2009-05-11 Thread samwyse
On May 11, 1:16 pm, samwyse wrote: > I'm writing a class that derives it's functionality from mix-ins. While waiting, I gave a try at using class decorators. Here's what I came up with: def add_methods(*m_list, **kwds): def wrapper(klass): for m_name in m_lis

Re: creating classes with mix-ins

2009-05-12 Thread samwyse
On May 11, 9:01 pm, Carl Banks wrote: > On May 11, 11:16 am, samwyse wrote: > > > Should I use a class decorator, or a metaclass? > > Here's the thing: unless you have advance knowledge of the methods > defined by self.blog, you can't get the attr_list at class

Re: How do I change the behavior of the 'python-docs' action in IDLE?

2009-05-31 Thread samwyse
On Apr 16, 2:02 pm, samwyse wrote: > In the Windows version of Python 2.5, pressing F1 brought up the > python.chm file.  I've just installed 2.6, and the same action > openshttp://www.python.org/doc/current/.  I'd prefer the former behavior. > I know how to change the

Turning HTMLParser into an iterator

2009-05-31 Thread samwyse
I'm processing some potentially large datasets stored as HTML. I've subclassed HTMLParser so that handle_endtag() accumulates data into a list, which I can then fetch when everything's done. I'd prefer, however, to have handle_endtag() somehow yield values while the input data is still streaming

Re: how to find the last decorator of a chain

2009-05-31 Thread samwyse
On May 30, 6:16 pm, Gabriel wrote: > I have something like this: > > @render(format="a") > @render(format="b") > @ > def view(format, data): >   return data > In my understanding this equivalent to: > > render('a', >  render('b', >   view(***))) Not quite. 'render' is a function of one arg

Missing codecs in Python 3.0

2009-06-02 Thread samwyse
I have a Python 2.6 program (a code generator, actually) that tries several methods of compressing a string and chooses the most compact. It then writes out something like this: { encoding='bz2_codec', data = '...'} I'm having two problems converting this to Py3. First is the absence of the bz2

Logging to zero or more destinations

2008-07-08 Thread samwyse
In the Python 2.5 Library Reference, section 14.5.3 (Logging to multiple destinations), an example is given of logging to both a file and the console. This is done by using logging.basicConfig() to configure a log file, and then calling logging.getLogger('').addHandler(console) to add the console.

Re: re.search much slower then grep on some regular expressions

2008-07-08 Thread samwyse
On Jul 4, 6:43 am, Henning_Thornblad <[EMAIL PROTECTED]> wrote: > What can be the cause of the large difference between re.search and > grep? > While doing a simple grep: > grep '[^ "=]*/' input                  (input contains 156.000 a in > one row) > doesn't even take a second. > > Is this a bu

Re: numeric emulation and __pos__

2008-07-08 Thread samwyse
On Jul 7, 6:12 pm, Ethan Furman <[EMAIL PROTECTED]> wrote: > Greetings, List! > > I'm working on a numeric data type for measured values that will keep > track of and limit results to the number of significant digits > originally defined for the values in question. > > I am doing this primarily bec

Re: numeric emulation and __pos__

2008-07-09 Thread samwyse
On Jul 8, 12:34 pm, Ethan Furman <[EMAIL PROTECTED]> wrote: > Anybody have an example of when the unary + actually does something? > Besides the below Decimal example.  I'm curious under what circumstances > it would be useful for more than just completeness (although > completeness for it's own s

Re: Logging to zero or more destinations

2008-07-09 Thread samwyse
On Jul 8, 3:01 pm, Rob Wolfe <[EMAIL PROTECTED]> wrote: > samwyse <[EMAIL PROTECTED]> writes: > > P.S.  I tried researching this further by myself, but the logging > > module doesn't come with source (apparently it's written in C?) and I > > don't

Re: Impossible to change methods with special names of instances of new-style classes?

2008-07-09 Thread samwyse
On Jul 8, 4:56 pm, Joseph Barillari <[EMAIL PROTECTED]> wrote: > My question is: did something about the way the special method names are > implemented change for new-style classes? Just off the top of my head, I'd guess that it's due to classes already having a default __call__ method, used when

Re: re.search much slower then grep on some regular expressions

2008-07-09 Thread samwyse
On Jul 8, 11:01 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: > samwyse wrote: > > You might want to look at Plex. > >http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ > > > "Another advantage of Plex is that it compiles all of the regular > > expres

Re: Loading just in time

2008-07-10 Thread samwyse
On Jul 10, 9:45 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > I am trying to create a utility module that only loads functions when > they are first called rather than loading everything.  I have a bunch > of files in my utility directory with individual methods and for each I > have lines li

Re: Problems Returning an HTTP 200 Ok Message

2008-07-10 Thread samwyse
On Jul 10, 1:50 pm, Guy Davidson <[EMAIL PROTECTED]> wrote: > Hi Folks, > > I'm having some issues with an small socket based server I'm writing, > and I was hoping I could get some help. > > My code (attached below) us supposed to read an HTTP Post message > coming from a power meter, parse it, an

Re: Problems Returning an HTTP 200 Ok Message

2008-07-14 Thread samwyse
On Jul 10, 4:10 pm, Guy Davidson <[EMAIL PROTECTED]> wrote: > I try to send the following message, using the socket.send() command: > > 'HTTP/1.1 200 OK\r\nDate: Thu, 10 July 2008 14:07:50 GMT\r\nServer: > Apache/2.2.8 (Fedora)\r\nX-Powered-By: PHP/5.2.4\r\nContent-Length: 4\r > \nConnection: clos

Re: Problems Returning an HTTP 200 Ok Message

2008-07-14 Thread samwyse
On Jul 11, 3:46 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > As Guy Davidson has already pointed out, this is a problem in the meter   > TCP implementation, and you should ask the vendor to fix it. That would have been me, not Guy. -- http://mail.python.org/mailman/listinfo/python-list

creating ZIP files on the cheap

2009-12-23 Thread samwyse
I've got an app that's creating Open Office docs; if you don't know, these are actually ZIP files with a different extension. In my case, like many other people, I generating from boilerplate, so only one component (content.xml) of my ZIP file will ever change. Instead of creating the entire ZIP

class version of func_globals?

2009-12-29 Thread samwyse
Is there any way to get the global namespace of the module in which a class was defined? Answers for both Python 2.x and 3.x will be cheerfully accepted. -- http://mail.python.org/mailman/listinfo/python-list

Re: class version of func_globals?

2009-12-29 Thread samwyse
On Dec 29, 5:18 am, Dave Angel wrote: > samwyse wrote: > > Is there any way to get the global namespace of the module in which a > > class was defined?  Answers for both Python 2.x and 3.x will be > > cheerfully accepted. > > I don't know if it's the same i

Re: Bare Excepts

2009-12-30 Thread samwyse
On Dec 30, 7:23 am, Jean-Michel Pichavant wrote: > Rule N°2: > dont use BARE EXCEPT, or you'll piss off MRAB for good :o). Beside from > kidding, don't use bare except. I inherited some code that used bare excepts *everywhere*. There were about 4K lines of code, IIRC, and I think that they were

Re: How to test a URL request in a "while True" loop

2009-12-30 Thread samwyse
On Dec 30, 10:00 am, Brian D wrote: > What I don't understand is how to test for a valid URL request, and > then jump out of the "while True" loop to proceed to another line of > code below the loop. There's probably faulty logic in this approach. I > imagine I should wrap the URL request in a fu

enhancing 'list'

2010-01-17 Thread samwyse
Consider this a wish list. I know I'm unlikely to get any of these in time for for my birthday, but still I felt the need to toss it out and see what happens. Lately, I've slinging around a lot of lists, and there are some simple things I'd like to do that just aren't there. s.count(x[, cmp[, ke

Re: enhancing 'list'

2010-01-18 Thread samwyse
On Jan 18, 1:56 am, Terry Reedy wrote: > On 1/17/2010 5:37 PM, samwyse wrote: > > > > > > > Consider this a wish list.  I know I'm unlikely to get any of these in > > time for for my birthday, but still I felt the need to toss it out and > > see what happ

Re: enhancing 'list'

2010-01-18 Thread samwyse
On Jan 18, 3:06 am, Peter Otten <__pete...@web.de> wrote: > samwyse wrote: > > Lately, I've slinging around a lot of lists, and there are some simple > > things I'd like to do that just aren't there. > > > s.count(x[, cmp[, key]]) > > - return nu

Re: enhancing 'list'

2010-01-18 Thread samwyse
On Jan 17, 11:30 pm, Asun Friere wrote: > On Jan 18, 9:37 am, samwyse wrote: > > > Consider this a wish list.  I know I'm unlikely to get any of these in > > time for for my birthday, but still I felt the need to toss it out and > > see what happens. > > >

Re: The answer

2010-01-18 Thread samwyse
On Jan 17, 8:30 pm, Jive Dadson wrote: > Okay, with your help I've figured it out.  Instructions are below, but > read the caveat by Ben Fenny in this thread.  All this stuff is good for > one default version of Python only.  The PYTHONPATH described below, for > example, cannot specify a version

Re: enhancing 'list'

2010-01-18 Thread samwyse
e App Engine, which is stuck at 2.5. :( (Curiously, no matter how I order my PATH, the wrong version seems to appear first more than half the time! I'm seriously considering renaming all my Python 3 code to use a .py3 file extension.) > samwyse wrote: > > As a side note, wouldn&#x

Re: Parse a log file

2010-01-18 Thread samwyse
On Jan 18, 6:52 am, "kak...@gmail.com" wrote: > Hello to all! > I want to parse a log file with the following format for > example: >               TIMESTAMPE            Operation     FileName > Bytes > 12/Jan/2010:16:04:59 +0200   EXISTS       sample3.3gp   37151 > 12/Jan/2010:16:04:59 +0200  EXI

Looking for a buffered/windowed iterator

2009-10-12 Thread samwyse
I have Python program that lets me interact with a bunch of files. Unfortunately, the program assumes that the bunch is fairly small, and I have thousands of files on relatively slow storage. Just creating a list of the file names takes several minutes, so I'm planning to replace the list with an

Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread samwyse
On Oct 13, 9:13 pm, Peng Yu wrote: > Bash is easy to use on manipulating files and directories (like change > name or create links, etc) and on calling external programs. For > simple functions, bash along is enough. However, bash does not support > the complex functions. Python has a richer libra

Re: New syntax for blocks

2009-11-11 Thread samwyse
On Nov 10, 1:23 pm, r wrote: > Forgive me if i don't properly explain the problem but i think the > following syntax would be quite beneficial to replace some redundant > "if's" in python code. > > if something_that_returns_value() as value: >     #do something with value > > # Which can replace t

Re: Python C api: create a new object class

2009-11-11 Thread samwyse
On Nov 10, 1:09 pm, "lallous" wrote: > Hello > > I have 3 questions, hope someone can help: > > 1) > How can I create an instance class in Python, currently I do: > > class empty: >   pass > > Then anytime I want that class (which I treat like a dictionary): > > o = empty() > o.myattr = 1 > etc...

Re: python simply not scaleable enough for google?

2009-11-12 Thread samwyse
On Nov 11, 3:57 am, "Robert P. J. Day" wrote: > http://groups.google.com/group/unladen-swallow/browse_thread/thread/4... > >   thoughts? Google's already given us its thoughts: http://developers.slashdot.org/story/09/11/11/0210212/Go-Googles-New-Open-Source-Programming-Language -- http://mail.py

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread samwyse
On Nov 24, 4:43 pm, Steven D'Aprano wrote: > Oh yes, and people using Windows can't use maildir because (1) it doesn't > allow colons in names, and (2) it doesn't have atomic renames. Neither of > these are insurmountable problems: an implementation could substitute > another character for the co

optparse/argparse for cgi/wsgi?

2010-12-10 Thread samwyse
Has anyone ever built some sort of optparse/argparse module for cgi/ wsgi programs? I can see why a straight port wouldn't work, but a module that can organize parameter handling for web pages seems like a good idea, especially if it provided a standard collection of both client- and server-side v

Re: Proposed changes to logging defaults

2010-12-14 Thread samwyse
On Dec 9, 6:12 pm, Vinay Sajip wrote: > Some changes are being proposed to how logging works in default > configurations. > > Briefly - when a logging event occurs which needs to be output to some > log, the behaviour of the logging package when no explicit logging > configuration is provided will

simple (I hope!) problem

2010-08-02 Thread samwyse
I'm writing for the Google app engine and have stubbed my toe yet again on a simple obstacle. Non-trivial app engines programs require the import of several modules that aren't normally in my PYTHONPATH. I'd like to be able to test my code outside of the app engine framework. I've tried several s

Re: simple integer subclass

2010-08-02 Thread samwyse
On Aug 2, 6:52 pm, Andreas Pfrengle wrote: > I'm trying to define a subclass of int called int1. An int1-object > shall behave exactly like an int-object, with the only difference that > the displayed value shall be value + 1 (it will be used to display > array indices starting at 1 instead of 0).

Re: Behavior of re.split on empty strings is unexpected

2010-08-02 Thread samwyse
On Aug 2, 12:34 pm, John Nagle wrote: > The regular expression "split" behaves slightly differently than string > split: I'm going to argue that it's the string split that's behaving oddly. To see why, let's first look at some simple CSV values: cat,dog ,missing,,values, How many fields are on e

  1   2   >