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

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: 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

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: simple (I hope!) problem

2010-08-05 Thread samwyse
On Aug 5, 4:32 am, Jean-Michel Pichavant wrote: > samwyse wrote: > > On Aug 3, 1:20 am, Steven D'Aprano > t...@cybersource.com.au> wrote: > > >> On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: > > >>> Fortunately, I don't need the functiona

Re: simple (I hope!) problem

2010-08-04 Thread samwyse
On Aug 3, 1:20 am, Steven D'Aprano wrote: > On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: > > Fortunately, I don't need the functionality of the object, I just want > > something that won't generate an error when I use it.  So, what is the > > quic

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

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).

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: 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

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: 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
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: 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 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

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: 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

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: 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

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

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

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

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: 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: 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 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

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

myparentclass.__subclasses__() not working for me

2009-09-14 Thread samwyse
### I've tried this under both Python 2.5.1 and 3.1.1, and it isn't working with either one. Here is my program: class Plugin(object): """This is the base object for a plug-in.""" pass def load_plugins(plugin_subdir='plugins'): import sys, pkgutil, imp, os.path try: # Us

Re: best way to display photos

2009-08-25 Thread samwyse
; > I don't think it will work on ms-windows, but it could be ported. > > Or you use mirage:http://mirageiv.berlios.de/index.html > > It is a pygtk image viewer. You can define shortcuts that execute user defined > commands. > >   Thomas > > samwyse schrieb: &g

best way to display photos

2009-08-24 Thread samwyse
I have several thousand photographs that I need to quickly classify, all by myself. After extensive searches, I have been unable to find anything to my liking, so desire to write something myself. I'm thinking about displaying a photo and waiting for keystrokes to tag it; 'i' for interior, 'e' fo

Re: setting Referer for urllib.urlretrieve

2009-08-10 Thread samwyse
On Aug 9, 9:41 am, Steven D'Aprano wrote: > On Sun, 09 Aug 2009 06:13:38 -0700,samwysewrote: > > Here's what I have so far: > > > import urllib > > > class AppURLopener(urllib.FancyURLopener): > >     version = "App/1.7" > >     referrer = None > >     def __init__(self, *args): > >         urllib

setting Referer for urllib.urlretrieve

2009-08-09 Thread samwyse
Here's what I have so far: import urllib class AppURLopener(urllib.FancyURLopener): version = "App/1.7" referrer = None def __init__(self, *args): urllib.FancyURLopener.__init__(self, *args) if self.referrer: addheader('Referer', self.referrer) urllib._url

Re: How to convert he boolean values into integers

2009-06-25 Thread samwyse
>>> int('1010100110', 2) 678 On Jun 25, 7:06 am, krishna wrote: > Hi Guys, > > I need to convert 1010100110 boolean value to some think like 2345, if > its possible then post me your comment on this > > Advanced thanks for all > > Narayana perumal.G -- http://mail.python.org/mailman/listinfo/py

I need a dict that inherits its mappings

2009-06-25 Thread samwyse
I need a dict-like object that, if it doesn't contain a key, will return the value from a "parent" object. Is there an easy way to do this so I don't have to define __getitem__ and __contains__ and others that I haven't even thought of yet? Here's a use case, if you're confused: en_GB=mydict() e

Re: Python simple web development

2009-06-25 Thread samwyse
I just started with web2py (http://www.web2py.com/) for an internal- use-only app that doesn't need to be very pretty. Been using it for about a week and after re-watching the tutorial, I've decided that I'm making things way too complicated. So today I'm going to replace a lot of my code with so

Re: Recipes for trace statements inside python programs?

2009-06-25 Thread samwyse
I use an @trace decorator. This (http://wordaligned.org/articles/ echo) will get you started but there are lots of others available. My personal preference is a decorator that catches, displays and re- raises exceptions as well as displaying both calling parameters and returned values. btw, here

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 9, 12:30 am, Emile van Sebille wrote: > On 6/8/2009 8:43 PM Ben Finney said... > > The fact that literal set syntax is a relative newcomer is the primary > > reason for that, I'd wager. > > Well, no.  It really is more, "that's odd... why use set?" Until I ran some timing tests this morni

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 8, 8:57 pm, samwyse wrote: > I conclude that using constructors is generally a bad idea, since the > compiler doesn't know if you're calling the builtin or something with > an overloaded name.  I presume that the compiler will eventually > optimize the second example

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 8, 10:06 pm, Chris Rebert wrote: > On Mon, Jun 8, 2009 at 6:57 PM, samwyse wrote: > > On Jun 8, 7:37 pm, Carl Banks wrote: > >> On Jun 8, 4:43 pm, Ben Finney wrote: > >> > m...@pixar.com writes: > >> > > Is there any reason t

Re: preferring [] or () in list of error codes?

2009-06-08 Thread samwyse
On Jun 8, 7:37 pm, Carl Banks wrote: > On Jun 8, 4:43 pm, Ben Finney wrote: > > m...@pixar.com writes: > > > Is there any reason to prefer one or the other of these statements? > > > >         if e.message.code in [25401,25402,25408]: > > >         if e.message.code in (25401,25402,25408): > > If

Re: py3k printing generators -- not!

2009-06-06 Thread samwyse
On Jun 6, 7:58 am, Carl Banks wrote: > On Jun 6, 5:28 am, samwyse wrote: > > Always saying "print(','.join(x))" gets tiresome in a hurry.   > > What about print(list(x)) Yeah, I like that. Or, to save some typing: prnt = lambda x: print(list(x)) > Int

py3k printing generators -- not!

2009-06-06 Thread samwyse
The one thing that's killing me in Python 3000 is that every time I try to print something, it seems like I get at 0x01BAF508>. Googling only found one reference, a posting elsewhere by one Carl Johnson (aka carlj7, http://www.artima.com/forums/flat.jsp?forum=106&thread=211200#275387), which appa

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

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

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 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

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: 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

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.'

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

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

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 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: 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

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-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: 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: 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: 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: 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: 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: 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: 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

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: 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: 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: 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: __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: 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

__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: 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?

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: 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: 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: 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: 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, 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

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 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

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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

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: 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.

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: 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

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

  1   2   >