PEP proposal: sequence expansion support for yield statement: yield *

2016-04-20 Thread Ken Seehart
spacing is different: yield* sequence ). Examples: yield *(1,2,3) ... instead of : yield 1; yield 2; yield 3 ... or: for x in (1,2,3): yield x yield *chain(seq1, seq2) ... instead of : for x in chain(seq1, seq2) yield x ~ Ken Seehart -- https://mail.python.org/mailman/listinfo/python

Re: Trees

2015-01-21 Thread Ken Seehart
, and a library (even the standard library) doesn't have to expose which one was picked as long as the performance is good. -- Devin On Tue, Jan 20, 2015 at 12:15 PM, Ken Seehart k...@seehart.com wrote: Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit

Re: Trees

2015-01-20 Thread Ken Seehart
Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit in a library, especially a standard one. Instead, we prefer to provide people with the tools they need to grow their own trees. http://caseytrees.org/programs/planting/ctp/

Re: Yet another attempt at a safe eval() call

2013-03-14 Thread Ken Seehart
On 1/4/2013 5:33 AM, Steven D'Aprano wrote: On Fri, 04 Jan 2013 07:24:04 -0500, Terry Reedy wrote: On 1/3/2013 6:25 PM, Grant Edwards wrote: I've written a small assembler in Python 2.[67], and it needs to evaluate integer-valued arithmetic expressions in the context of a symbol table that

Re: avoid the redefinition of a function

2012-09-12 Thread Ken Seehart
Use lambda expressions to define some constraints: gt = lambda x: lambda y: xy eq = lambda x: lambda y: x==y constraints = [gt(2), eq(1)] data = [3,1] for i,c in enumerate(constraints): print c(data[i]) On 9/12/2012 5:56 AM, Jabba Laci wrote: Hi, I have an installer script that

Re: Boolean function on variable-length lists

2012-09-12 Thread Ken Seehart
Putting a few of peoples ideas together... gt = lambda x: lambda y: xy eq = lambda x: lambda y: x==y def constrain(c,d): return all({f(x) for f, x in zip(c, d)}) constraints = [gt(2), eq(1)] data0 = [1,1] data1 = [3,1] print constrain(constraints, data0) print constrain(constraints,

Re: something about performence

2011-06-21 Thread Ken Seehart
月21日 下午1:50,Ken Seehart k...@seehart.com mailto:k...@seehart.com写 道: On 6/20/2011 10:31 PM, Ken Seehart wrote: On 6/20/2011 7:59 PM, king6c...@gmail.com mailto:king6c...@gmail.com wrote: Hi, I have two large files,each has more than 2 lines,and each line

Re: something about performence

2011-06-20 Thread Ken Seehart
with the same index value. Be sure to test your code on a few short test files. I recommend psyco to make the whole thing faster. Regards, Ken Seehart -- http://mail.python.org/mailman/listinfo/python-list

Re: something about performence

2011-06-20 Thread Ken Seehart
On 6/20/2011 10:31 PM, Ken Seehart wrote: On 6/20/2011 7:59 PM, king6c...@gmail.com wrote: Hi, I have two large files,each has more than 2 lines,and each line consists of two fields,one is the id and the other a value, the ids are sorted. for example: file1 (uin_a y) 1 1245

Re: Function __defaults__

2011-04-25 Thread Ken Seehart
On 4/25/2011 4:59 AM, Colin J. Williams wrote: On 24-Apr-11 13:07 PM, Ken Seehart wrote: On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? This is

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure features against all potential target platforms. In this case, I would argue that**Benjamin's test demonstrates a bug in Jython. One could counter by

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Oops, I must correct myself. Please ignore my previous post. As Daniel points out, Writable is specified in the Python 3 documentation. Apparently I was reading the documentation with only my right eye open, and the Writable tag fell on my blind spot. I concur that this unambiguously implies

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Gotta love that email latency. :-D Ken On 4/24/2011 2:47 PM, Daniel Kluev wrote: On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehartk...@seehart.com wrote: Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure

Re: PyCon

2011-03-11 Thread Ken Seehart
On 3/11/2011 7:45 AM, Rita wrote: http://us.pycon.org/2010/ http://us.pycon.org/2009/ Try the wayback machine: http://replay.waybackmachine.org/20100701160843/http://us.pycon.org/2010/about/ -- http://mail.python.org/mailman/listinfo/python-list

IMAP mail filters tool

2010-03-04 Thread Ken Seehart
I'm thinking of possibly making a simple client-agnostic tool for filtering and processing IMAP email. I'm a Thunderbird user, but I'm interested in a tool that is not client software specific. So I am is checking for prior art. Does anyone know of a filter tool with most of these features?

Re: python and http POST

2010-02-11 Thread Ken Seehart
Use tamperdata to view and modify HTTP/HTTPS headers and post parameters... https://addons.mozilla.org/en-US/firefox/addon/966 Enjoy, Ken galileo228 wrote: Hey All, Been teaching myself Python for a few weeks, and am trying to write a program that will go to a url, enter a string in one of

regex to match python string literal syntax

2010-02-10 Thread Ken Seehart
I found this: http://code.activestate.com/recipes/475109/ But it is incorrect in some cases, such as: * foo \ bar* / (incorrectly matches foo \)/ * '''* /(incorrectly matches the second two single quotes)/ * foo bar * / (incorrectly matches quote containing newline/) Anyone know a

Re: regex to match python string literal syntax

2010-02-10 Thread Ken Seehart
\ [^\\]* (?: (?: \\. | (?!) ) [^\\]* )* (?: \ )? |[^\\\n]* (?: \\. [^\\\n]* )* ? | ''' [^'\\]* (?: (?: \\. | '(?!'') ) [^'\\]* )* (?: ''' )? | ' [^'\\\n]* (?: \\. [^'\\\n]* )* '? , re.VERBOSE | re.DOTALL).match Problem solved. Ken Ken Seehart wrote: I found this: http

Buffered streaming

2009-11-26 Thread Ken Seehart
I need to create a pipe where I have one thread (or maybe a generator) writing data to the tail while another python object is reading from the head. This will run in real time, so the data must be deallocated after it is consumed. Reading should block until data is written, and writing

Re: Help with database planning

2009-11-14 Thread Ken Seehart
Good idea to use Django. I've just started using it and I really like it. However, I should give you a heads-up: You will probably want to use a Django migration tool (I'm using South) because the alternative is basically to rebuild your database each time your model changes. Unfortunately,

Re: Help with database planning

2009-11-14 Thread Ken Seehart
Oops, forgot the blank arg. Anyway, this is of course untested code... # Only one of the following is used. The other two are blank. concept = models.ForeignKey(Concept, blank=True) slot = models.ForeignKey(Slot, blank=True) filler = models.ForeignKey(Filler, blank=True) Ken Seehart

Re: Authentication session with urllib2

2009-11-11 Thread Ken Seehart
Jon Clements wrote: On 11 Nov, 07:02, Ken Seehart k...@seehart.com wrote: I'm having some difficulty implementing a client that needs to maintain an authenticated https: session. I'd like to avoid the approach of receiving a 401 and resubmit with authentication, for two reasons

Authentication session with urllib2

2009-11-10 Thread Ken Seehart
I'm having some difficulty implementing a client that needs to maintain an authenticated https: session. I'd like to avoid the approach of receiving a 401 and resubmit with authentication, for two reasons: 1. I control the server, and it was easy for me to make a url that receives a POST

cgi and POST

2009-08-28 Thread Ken Seehart
I can't seem to find an answer to this simple question on the web, and the documentation doesn't seem to indicate how to do this... On the client I have: urllib.urlopen(uri, data) This does a POST, but it's not obvious to me how this maps onto the various cgi examples which assume that

Re: cgi and POST

2009-08-28 Thread Ken Seehart
D'Arcy J.M. Cain wrote: On Fri, 28 Aug 2009 13:59:57 -0700 Ken Seehart k...@seehart.com wrote: Using cgi, how do I get the /data /(not the uri arguments) originating from a POST that did not originate from a form. You don't care where it came from. Just treat it exactly as if it came

decorators - would be nice if...

2009-07-14 Thread Ken Seehart
Almost every time I use decorators, I find myself wishing I had access to the local namespace of the context from which the decorator is executed. In practice, decorator is being applied to a method, so the namespace in question would be the dictionary of the class being created. Similarly,

Re: Regarding Python is scripting language or not

2009-06-17 Thread Ken Seehart
abhishek goswami wrote: Hi, I have very basic question about Python that do we consider pyhton as script language. I searched in google but it becomes more confusion for me. After some analysis I came to know that Python support oops . Can anyone Guide me that Python is Oject oriented

Re: unsuccessful post request hangs, what gives?

2009-06-15 Thread Ken Seehart
Travis Altman wrote: i'm trying to use a post request to authenticate to a web application. let's say username = alice is valid but username = bob does not exits. making the request with alice works like a charm but when i try username = bob it hangs? any suggestions? Can you show us the

xmlrpclib and generators

2009-06-10 Thread Ken Seehart
It would be really cool if an rpc call could return a generator. I know that there are a few reasons why one would not expect it to be part of the library (e.g. the client would need to receive asynchronous messages, and it's not part of the rpc standard), however below I show a possible

Re: xmlrpclib and generators

2009-06-10 Thread Ken Seehart
Hendrik van Rooyen wrote: Ken Seehart wrote: 8 implementation -- The practical constraints of my specific application are: 1. The rpc server is a highly specialized slave system that does heavy duty work. 2. The rpc client is itself a web server

Browser based Canvas UI?

2009-05-30 Thread Ken Seehart
A couple years ago I stumbled upon an interesting technology but I can't seem to find it, and I can remember what it is called. Unfortunately this makes it difficult to search for. I am am aware of several partial matches (items that meet a subset of the requirement listed below). Does

Re: How does Python's OOP feel?

2009-05-30 Thread Ken Seehart
Benjamin Kaplan wrote: On Fri, May 29, 2009 at 9:41 PM, Lie Ryan lie.1...@gmail.com mailto:lie.1...@gmail.com wrote: Ikon wrote: I'm rather new to Python. I have PHP for my main language and I do some Java. They all have a very strict OO schema. As I red through Python's

Re: Browser based Canvas UI?

2009-05-30 Thread Ken Seehart
CTO wrote: On May 30, 4:12 am, Ken Seehart k...@seehart.com wrote: A couple years ago I stumbled upon an interesting technology but I can't seem to find it, and I can remember what it is called. Unfortunately this makes it difficult to search for. I am am aware of several partial matches

Re: What is the difference between init and enter?

2009-05-26 Thread Ken Seehart
Diez B. Roggisch wrote: John wrote: I'm okay with init, but it seems to me that enter is redundant since it appears that anything you want to execute in enter can be done in init. About what are you talking? Diez Presumably, the 'with' statement.

Re: What text editor is everyone using for Python

2009-05-26 Thread Ken Seehart
Lacrima wrote: I am new to python. And now I am using trial version of Wing IDE. But nobody mentioned it as a favourite editor. So should I buy it when trial is expired or there are better choices? It's my favorite. Buy it. I'm not aware of any better choices. If you can afford the Pro

Re: large array in a single line

2009-05-26 Thread Ken Seehart
Arnaud Delobelle wrote: karthik...@gmail.com writes: I would like to have a txt file of single line with [1 2 3 .100] I try something like q=arange(100) fl=file('tmp.ext','w') fl.writelines(str(q)) fl.close() Unfortunately my output is [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13

Re: What text editor is everyone using for Python

2009-05-26 Thread Ken Seehart
Lacrima wrote: I am new to python. And now I am using trial version of Wing IDE. But nobody mentioned it as a favourite editor. So should I buy it when trial is expired or there are better choices? Jean-Michel Pichavant wrote: Why buy an IDE when you just need a text editor ? I don't get

Re: Can I get a value's name

2009-05-15 Thread Ken Seehart
jalanb3 wrote: Context for this question arises from some recent code. In particular the replace_line method, which takes in a regexp to look for, and a replacement for when it matches. It is supposed to work for single lines only (we add ^ and $ to the regexp), so arguments which have '\n'

Re: Non-secure execution environment

2009-04-17 Thread Ken Seehart
roge...@gmail.com wrote: Hi, I am C++ guy for the most part and don't know much of Python, so, please, bear with me if I am asking errrm..idiotic question. Old rexec module provided kinda 'secure' execution environment. I am not looking for security at this point. What I need an execution

Re: December 21, 2012: Judgment Day

2009-04-16 Thread Ken Seehart
MRAB wrote: Mensanator wrote: On Apr 16, 2:46 am, Thara tharasurya@gmail.com wrote: Science can neither confirm nor discredit the validity of many religiously or prophetically deemed judgment days of the future, the soonest of which will be arriving December 21, 2012, the final day of the

Re: Python inside C++

2009-04-14 Thread Ken Seehart
AJ Mayorga wrote: Hello all, I am looking for a way to statically compile pythonxx.dll into my C++ application, so that I can use It as an internal scripting language and either run the native python code or take an ELF from py2exe/pyinstaller and run that. The machines that will have

Re: How do I count the distance between strings in a list?

2009-02-27 Thread Ken Seehart
collin wrote: For example, if I were to have the code randomlist = [1, 2, 3, 4] And I want to count the distance between strings 1 and 4 which is 3, what command can I use to do this? -- http://mail.python.org/mailman/listinfo/python-list randomlist.index(4) - randomlist.index(1) Ken --

Re: some question about python2.6 and python3k

2009-01-04 Thread Ken Seehart
Michael Yang wrote: Hi,guys i am a new guy for python world,i have some question want to ask 1.should i learn about python2.6 or python3k?i heard of it has some difference from them . I think you should go directly to 3K to save your self the extra work of learning the differences. The

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Ken Seehart
hope this helps. Ken Seehart -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-15 Thread Ken Seehart
-*ε* Admittedly a tough call. I see the attraction of the proposed syntax. Maybe somewhat more readable since the declaration syntax matches the usage syntax, which is nice. I think it would have been superior to the current syntax if it had been done that way in the first place. However,

Memory problems

2008-11-27 Thread Ken Seehart
an application use less memory? Any good overview articles on this subject? Thanks (and Happy Thanksgiving), - Ken Seehart -- http://mail.python.org/mailman/listinfo/python-list

Re: Weirdness comparing strings

2008-09-30 Thread Ken Seehart
Instance comparison is not necessarily the same as string comparison. Neither __str__ nor __repr__ are implicitly used at all for comparison. In fact, by default a pair of instances are not equal unless they are the same object. To define comparison to mean something, you need to define

Advice for a replacement for plone.

2008-09-30 Thread Ken Seehart
I want a new python based CMS. ... One that won't keep me up all night I've been fooling around with zope and plone, and I like plone for some things, such as a repository for online project documentation. However for general-purpose web development it is too monolithic. Is there

Re: Newbie question...

2008-09-30 Thread Ken Seehart
Ken D'Ambrosio wrote: First, apologies for such a newbie question; if there's a better forum (I've poked around, some) feel free to point it out to me. Anyway, a mere 25-odd years after first hearing about OOP, I've finally decided to go to it, by way of Python. But this puzzles me: import

Re: Python String Immutability Broken!

2008-08-25 Thread Ken Seehart
You can also use ctypes to globally change the value of integers less than 101. Personally, I don't particularly like the number 14. I changed it to 9 and I am much happier now. I love ctypes. So cool. It's not supposed to be safe. Life is either a daring adventure or nothing.

Re: Python String Immutability Broken!

2008-08-25 Thread Ken Seehart
Hendrik van Rooyen wrote: ... Actually, I am not complaining - I am asking for advice on the side effects of what I am doing, which is replacing a bunch of bits in what is essentially an output bit field with the corresponding input bits at the same addresses read back from a simulated i/o

SocketServer and long-polling connections

2008-08-25 Thread Ken Seehart
I apologize if this message is a repeat. It looks like didn't get received. I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think. More than that

SocketServer max connections

2008-08-25 Thread Ken Seehart
I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think. More than that and it seems to block on opening more connections until one of the other

Re: automatically import modules upon interpreter invocation

2008-06-25 Thread Ken Seehart
Daniel Fetchinson wrote: Hi folks, this seems like a very basic thing but I couldn't find a solution. I always do the following after starting the python interpreter (on linux): import rlcompleter import readline readline.parse_and_bind(tab: complete) Is there a way of making python execute

opinion - file.readlines blemish

2007-11-03 Thread Ken Seehart
. Besides, it's not a good idea to stuff extra semantics like that. Better would be a separate way to identify *universal-newlines *mode. Ken Seehart -- http://mail.python.org/mailman/listinfo/python-list

UnicodeDecodeError

2007-07-21 Thread Ken Seehart
I get this whenever I encounter a non-ascii character in a non-unicode string: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 23: ordinal not in range(128) The string in question is ... ESPA\xd1OL ... I completely understand why I get the error, and my solution will be

Re: UnicodeDecodeError

2007-07-21 Thread Ken Seehart
Um, never mind. The recent unicode conversation gave me my answer :-) unicode(s, 'Windows-1252') Ken Seehart wrote: I get this whenever I encounter a non-ascii character in a non-unicode string: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 23: ordinal not in range

C wrappers and the proxy dilemma

2007-06-22 Thread Ken Seehart
Anyone who has wrapped C or C++ libraries has encountered the proxy dilemma. A long time ago, I naively thought that I could start by deriving my high level python class from the c-python type, but this leads to many difficult problems because several of the underlying methods return the low

audio video streaming communications

2007-01-07 Thread Ken Seehart
Hello, I am looking for a good audio/video conferencing library. Ideally it should work with wxPython (or have some means of making it work there). So far my main difficulty in my attempt at searching for such a package is that there is so much stuff out there on downloading music and videos.

Re: Registration Code

2006-04-03 Thread Ken Seehart
Math wrote: Hello, I wonder if I can ask this particular question here... I'm writing this piece of Python Software and I'm almost done...:-) But now I want the end-user to register this software with a registration code or perhaps something like an evaluation demo version which expires

Re: Creating Pie Chart from Python

2005-09-15 Thread Ken Seehart
Thierry Lam wrote: Let's say I have the following data: 500 objects: -100 are red -300 are blue -the rest are green Is there some python package which can represen the above information in a pie chart? Thanks Thierry What is the user interface context? Is it a web page? Do you

Re: Need help with C extension module

2005-09-13 Thread Ken Seehart
chris wrote: This is my first attempt at undertaking a C extension module. I want to wrap an existing C library so I can call the functions from Python. There are only two functions I'm interested in calling. I did mess with Pyrex a bit and Swig, to no avail, so I turned to doing it by

Python for ARM7?

2005-09-13 Thread Ken Seehart
Hello. Where might I find python binaries for ARM7 (Linux 2.4)? I don't have an ARM7 compiler, and I probably don't have enough disk space (about 3MB of flash available) for the complete build anyway. My plan is to just copy the files I need. This approach seems to work on Windows XP, where I

Re: Python for ARM7?

2005-09-13 Thread Ken Seehart
Sybren Stuvel wrote: Ken Seehart enlightened us with: Hello. Where might I find python binaries for ARM7 (Linux 2.4)? Check http://www.vanille.de/projects/python.spy If I absolutely have to build my own python, I would probably use a cygwin (or maybe linux) cross-compiler for ARM7

Re: Python for ARM7?

2005-09-13 Thread Ken Seehart
Sybren Stuvel wrote: Ken Seehart enlightened us with: 1. How do I know whether to use sharprom or modern? If it works, use it. That makes sense :) 2. What do I do with ipk files? I surfed around and found that in one example, the command is ipkg install foo.ipk, but ipkg doesn't seem

Re: which is more 'pythonic' / 'better' ?

2005-09-13 Thread Ken Seehart
Will McGugan wrote: gabor wrote: hi, there are 2 versions of a simple code. which is preferred? === if len(line) = (n+1): text = line[n] else: text = 'nothing' === === try: text = line[n] except IndexError: text = 'nothing' === which is the one you would