[issue23041] csv needs more quoting rules

2022-02-23 Thread Samwyse
Samwyse added the comment: I just signed the contributor agreement. (Thought I had done that last year but I don’t see any emails. Is there any place to check?) I agree that round-tripping should Bebe possible for any value of quoting. Hopefully this will finally get done before its eighth

[issue45656] argparse bug: prefix_chars argument to add_argument_group doesn't really work

2021-10-28 Thread Samwyse
New submission from Samwyse : Using the prefix_chars argument to parser.add_argument_group causes usage information to print correctly, but the resulting parser doesn't recognize the options. The included program reproduces the issue; it produces the following output on my system

[issue44882] add FileInput.rollback() for in-place filters

2021-08-10 Thread Samwyse
Change by Samwyse : -- title: add .rollback() for in-place filters -> add FileInput.rollback() for in-place filters ___ Python tracker <https://bugs.python.org/issu

[issue44882] add .rollback() for in-place filters

2021-08-10 Thread Samwyse
New submission from Samwyse : Sometimes bad things happen when processing an in-place filter, leaving an empty or incomplete input file and a backup file that needs to recovered. The FileInput class has all the information needed to do this, but it is in private instance variables

[issue43556] fix attr names for ast.expr and ast.stmt

2021-03-19 Thread Samwyse
New submission from Samwyse : In Doc/library/ast.rst, the lineno and end_col attributes are repeated; the second set should have 'end_' prefixed to them. Also, there's a minor indentation error in the RST file. # diff ast.rst ast.rst~ 78c78 < col_off

[issue33158] Add fileobj property to csv reader and writer objects

2018-03-27 Thread Samwyse
New submission from Samwyse <samw...@gmail.com>: Many objects have properties that allow access to the arguments used to create them. In particular, file objects have a name property that returns the name used when opening a file. A fileobj property would be convenient, as you oth

[issue29940] Add follow_wrapped=True option to help()

2017-03-29 Thread Samwyse
New submission from Samwyse: The help(obj) function uses the type of obj to create its result. This is less than helpful when requesting help on a wrapped object. Since 3.5, inspect.signature() and inspect.from_callable() have a follow_wrapped option to get around similar issues. Adding

[issue26299] wsgiref.util FileWrapper raises ValueError: I/O operation on closed file.

2016-02-05 Thread Samwyse
New submission from Samwyse: While developing, I am using wsgiref.simple_server. Using to serve static content isn't working. The attached program demonstrates the issue. Run it and connect to http://127.0.0.1:8000/. You will see three buttons. Clicking on 'wsgi.filewrapper' causes

[issue25760] TextWrapper fails to split 'two-and-a-half-hour' correctly

2015-11-28 Thread Samwyse
New submission from Samwyse: Single character words in a hyphenated phrase are not split correctly. The root issue it the wordsep_re class variable. To reproduce, run the following: >>> import textwrap >>> textwrap.TextWrapper.wordsep_re.split('two-and-a-hal

[issue23041] csv needs more quoting rules

2014-12-15 Thread Samwyse
Samwyse added the comment: Yes, it's based on a real-world need. I work for a Fortune 500 company and we have an internal tool that exports CSV files using what I've described as the QUOTE_NOTNULL rules. I need to create similar files for re-importation. Right now, I have to post-process

[issue23059] sort misc help topics in cmd

2014-12-15 Thread Samwyse
New submission from Samwyse: I've discovered that do_help method of cmd.Cmd prints the documented and undocumented commands in sorted order, but does not sort the miscellaneous topics. This would be an easy fix, just change self.print_topics(self.misc_header, help.keys(),15,80) to use

[issue23041] csv needs more quoting rules

2014-12-15 Thread Samwyse
Samwyse added the comment: Skip, I don't have any visibility into how the Java program I'm feeding data into works, I'm just trying to replicate the csv files that it exports as accurately as possible. It has several other quirks, but I can replicate all of them using Dialects

[issue23059] cmd module should sort misc help topics

2014-12-15 Thread Samwyse
Changes by Samwyse samw...@gmail.com: -- title: sort misc help topics in cmd - cmd module should sort misc help topics ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23059

[issue23041] csv needs more quoting rules

2014-12-12 Thread Samwyse
New submission from Samwyse: The csv module currently implements four quoting rules for dialects: QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC and QUOTE_NONE. These rules treat values of None the same as an empty string, i.e. by outputting two consecutive quotes. I propose the addition of two

[issue23041] csv needs more quoting rules

2014-12-12 Thread Samwyse
Samwyse added the comment: David: That's not a problem for me. Sorry I can't provide real patches, but I'm not in a position to compile (much less test) the C implementation of _csv. I've looked at the code online and below are the changes that I think need to be made. My use cases don't

[issue21413] urllib.request.urlopen dies on non-basic/digest auth schemes

2014-05-01 Thread Samwyse
New submission from Samwyse: In Python 2.x, this opens an NTLM protected URL: opener = urllib2.build_opener(proxy_handler, auth_NTLM, auth_digest, auth_basic) urllib2.install_opener(opener) response = urllib2.urlopen(url) In Python 3.x, this raises an error: opener

[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-07-22 Thread Samwyse
Samwyse added the comment: Fixes Serhiy Storchaka's complaints, removes duplicate test. -- nosy: +samwyse Added file: http://bugs.python.org/file31013/test_urlparse.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18191

[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-07-22 Thread Samwyse
Samwyse added the comment: Handles raw IPv6 URLs -- Added file: http://bugs.python.org/file31015/urllib.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18191

[issue17229] unable to discover preferred HTTPConnection class

2013-02-18 Thread Samwyse
New submission from Samwyse: When a URL is opened, the opener-director is responsible for locating the proper handler for the specified protocol. Frequently, an existing protocol handler will be subclassed and then added to the collection maintained by the director. When urlopen is called

[issue15350] {urllib,urllib.parse}.urlencode.__doc__ is unclear

2012-10-12 Thread samwyse
samwyse added the comment: Look good. I'd fix the last line, however: sent the quote_plus - sent to the quote_plus function, maybe. On Fri, Sep 28, 2012 at 6:18 AM, Brian Brazil rep...@bugs.python.org wrote: Brian Brazil added the comment: How does the attached patch look? I also

[issue16122] Allow *open* to accept file-like objects

2012-10-03 Thread samwyse
New submission from samwyse: I'm once again frustrated by a third-party module that only accepts filenames, not already-opened file-like objects. This prevents me from passing in StringIO objects or any of the standard file streams. Currently, *open()* function accepts strings or (in Python

[issue13866] {urllib, urllib.parse}.urlencode should not use quote_plus

2012-07-14 Thread samwyse
samwyse samw...@gmail.com added the comment: Since no one else seems willing to do it, here's a patch that adds a 'quote_via' keyword parameter to the urlencode function. import urllib.parse query={foo: + } urllib.parse.urlencode(query) 'foo=%2B+' urllib.parse.urlencode(query, quote_via

[issue15350] {urllib,urllib.parse}.urlencode.__doc__ is unclear

2012-07-14 Thread samwyse
New submission from samwyse samw...@gmail.com: The doc string for url encode states: The query arg may be either a string or a bytes type. When query arg is a string, the safe, encoding and error parameters are sent to the quote_via function for encoding IMHO, this implies

[issue15327] Argparse: main arguments and subparser arguments indistinguishable

2012-07-14 Thread samwyse
samwyse samw...@gmail.com added the comment: The Namespace object contains a combined list of all of the arguments, from both the main parser and the subparser. I don't see any way to resolve identically name augments without breaking a lot of code that relies on the current behavior. I

[issue15327] Argparse: main arguments and subparser arguments indistinguishable

2012-07-14 Thread samwyse
samwyse samw...@gmail.com added the comment: One change and one minor problem with my suggestion. First, you don't need the second alias, since it's a prefix of the argument name. Also, HelpFormatter._format_actions_usage ends with a bit of code labeled clean up separators for mutually

[issue13866] {urllib, urllib.parse}.urlencode should not use quote_plus

2012-07-13 Thread samwyse
Changes by samwyse samw...@gmail.com: -- nosy: +samwyse ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13866 ___ ___ Python-bugs-list mailing list

[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-10 Thread samwyse
samwyse samw...@gmail.com added the comment: Thanks, Eric. Based on what you said, I was able to get the desired behavior by creating a metaclass. -- Added file: http://bugs.python.org/file26343/Issue15289.py ___ Python tracker rep

[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-07 Thread samwyse
New submission from samwyse samw...@gmail.com: I'm using a class as a decorator, and saving information in a class variable. I wanted to access the information via a __getitem__ class method, but using conventional syntax doesn't work on a class. The following exception is thrown when

[issue6321] Reload Python modules when running programs

2011-12-20 Thread samwyse
samwyse samw...@gmail.com added the comment: [issue5847] fixed in 2.7/3.1 -- resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6321

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: Proposed changes to logging defaults

2010-12-14 Thread samwyse
On Dec 9, 6:12 pm, Vinay Sajip vinay_sa...@yahoo.co.uk 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

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

[issue10178] PEP 378 uses replace where translate may work better

2010-10-23 Thread samwyse
New submission from samwyse samw...@gmail.com: PEP 378 states; format(n, 6,f).replace(,, X).replace(., ,).replace(X, .) This is complex and relatively slow. A better technique, which IMHO the proposal should high-lighted, would be: swap_commas_and_periods = bytes.maketrans(b',.', b

[issue10178] PEP 378 uses replace where translate may work better

2010-10-23 Thread samwyse
samwyse samw...@gmail.com added the comment: The text in question is also talking about the problems with using 'replace' to swap pairs of characters, so a better, alternate, process would be valuable, especially for anyone unaware of the translate method

[issue6321] Reload Python modules when running programs

2010-08-15 Thread samwyse
samwyse samw...@gmail.com added the comment: As it happens, I do use Windows and almost exclusively start IDLE via right-clicks on .py files. I've never seen the behavior you describe documented anywhere. On Aug 15, 2010, at 1:37 PM, Cherniavsky Beni rep...@bugs.python.org wrote

Re: simple (I hope!) problem

2010-08-05 Thread samwyse
On Aug 5, 4:32 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: samwyse wrote: On Aug 3, 1:20 am, Steven D'Aprano steve-REMOVE- t...@cybersource.com.au 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

Re: simple (I hope!) problem

2010-08-04 Thread samwyse
On Aug 3, 1:20 am, Steven D'Aprano steve-REMOVE- t...@cybersource.com.au 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 quickest way

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

Re: simple integer subclass

2010-08-02 Thread samwyse
On Aug 2, 6:52 pm, Andreas Pfrengle a.pfren...@gmail.com 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

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

2010-08-02 Thread samwyse
On Aug 2, 12:34 pm, John Nagle na...@animats.com 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

[issue3058] Let SimpleXMLRPCServer pass client_address to called functions.

2010-07-11 Thread samwyse
samwyse samw...@gmail.com added the comment: More importantly, the dispatch method is now part of the SimpleXMLRPCDispatcher, which (as a mix-in class) has no direct access to the RequestHandler instance that comprises the request. This breaks Victor's and my idea, unless one is willing

Re: enhancing 'list'

2010-01-18 Thread samwyse
On Jan 18, 1:56 am, Terry Reedy tjre...@udel.edu 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 happens. Lately, I've slinging around

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 number of i‘s for which s[i] == x.  'cmp' specifies a custom

Re: enhancing 'list'

2010-01-18 Thread samwyse
On Jan 17, 11:30 pm, Asun Friere afri...@yahoo.co.uk wrote: On Jan 18, 9:37 am, samwyse samw...@gmail.com 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. Lately, I've

Re: The answer

2010-01-18 Thread samwyse
On Jan 17, 8:30 pm, Jive Dadson notonthe...@noisp.com 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

Re: enhancing 'list'

2010-01-18 Thread samwyse
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't it be nice if '...' could be used in more

Re: Parse a log file

2010-01-18 Thread samwyse
On Jan 18, 6:52 am, kak...@gmail.com 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

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

Re: Bare Excepts

2009-12-30 Thread samwyse
On Dec 30, 7:23 am, Jean-Michel Pichavant jeanmic...@sequans.com 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

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 brianden...@gmail.com 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

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 da...@ieee.org 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 in general, but consider

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 st...@remove-this- cybersource.com.au 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

Re: python simply not scaleable enough for google?

2009-11-12 Thread samwyse
On Nov 11, 3:57 am, Robert P. J. Day rpj...@crashcourse.ca 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

Re: New syntax for blocks

2009-11-11 Thread samwyse
On Nov 10, 1:23 pm, r rt8...@gmail.com 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

Re: Python C api: create a new object class

2009-11-11 Thread samwyse
On Nov 10, 1:09 pm, lallous lall...@lgwm.org 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

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

2009-10-13 Thread samwyse
On Oct 13, 9:13 pm, Peng Yu pengyu...@gmail.com 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

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

Re: best way to display photos

2009-08-25 Thread samwyse
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: I have several thousand photographs that I need to quickly classify, all

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'

Re: setting Referer for urllib.urlretrieve

2009-08-10 Thread samwyse
On Aug 9, 9:41 am, Steven D'Aprano st...@remove-this- cybersource.com.au 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,

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)

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,

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

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

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 gnperu...@gmail.com 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 --

[issue6321] Reload Python modules when running programs

2009-06-21 Thread samwyse
New submission from samwyse samw...@gmail.com: Every time IDLE is asked to run a program, it doesn't ensure that the modules referenced by the program are completely loaded. This can cause problems if one of those modules is also being edited, because once it is loaded, any subsequent

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

2009-06-09 Thread samwyse
On Jun 8, 10:06 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Jun 8, 2009 at 6:57 PM, samwysesamw...@gmail.com wrote: On Jun 8, 7:37 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jun 8, 4:43 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: m...@pixar.com writes: Is there any

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

2009-06-09 Thread samwyse
On Jun 9, 12:30 am, Emile van Sebille em...@fenx.com 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

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

2009-06-08 Thread samwyse
On Jun 8, 7:37 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jun 8, 4:43 pm, Ben Finney ben+pyt...@benfinney.id.au 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

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 generator object genexpr at 0x01BAF508. Googling only found one reference, a posting elsewhere by one Carl Johnson (aka carlj7,

Re: py3k printing generators -- not!

2009-06-06 Thread samwyse
On Jun 6, 7:58 am, Carl Banks pavlovevide...@gmail.com wrote: On Jun 6, 5:28 am, samwyse samw...@gmail.com 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

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

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 samw...@gmail.com 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 key bindings

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 gabr...@opensuse.org 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

[issue3058] Let SimpleXMLRPCServer pass client_address to called functions.

2009-05-16 Thread samwyse
samwyse samw...@gmail.com added the comment: A more general solution would be to pass the RequestHandler instance as a parameter to the dispatch function. This would allow the function to pick out more than just the client address. To avoid breaking pre-existing code, this should be made

Re: creating classes with mix-ins

2009-05-12 Thread samwyse
On May 11, 9:01 pm, Carl Banks pavlovevide...@gmail.com wrote: On May 11, 11:16 am, samwyse samw...@gmail.com 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

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 samw...@gmail.com 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_list

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

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 14, 7:01 pm, Aaron Brady castiro...@gmail.com 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

Re: sharing/swapping items between lists

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

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 15, 8:56 am, Aaron Brady castiro...@gmail.com 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

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:

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

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, and return

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 sake

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 have the time to find and download the source to my laptop

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 expressions into a single DFA. Once that's done, the input

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

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

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

[issue1491] BaseHTTPServer incorrectly implements response code 100

2008-05-10 Thread samwyse
samwyse [EMAIL PROTECTED] added the comment: Although any given implementation of an HTTP server is likely to serve up its headers in a predicable, repeatable, order, I don't think that we should specify a particular order in the test suite. Section 4.2 of RFC 2616 specifically states

[issue1491] BaseHTTPServer incorrectly implements response code 100

2008-05-10 Thread samwyse
samwyse [EMAIL PROTECTED] added the comment: In the attached file, I've refactored the entire BaseHTTPRequestHandlerTestCase class. In doing so, I couldn't help but notice that we're expecting HTTP/1.1 responses when sending HTTP/1.0 requests. RFC 2616 is unclear about whether

  1   2   >