Hey Josiah,
I just spent a couple hours with your example, and it explains a lot. Some
of your interactive session got garbled, so am reposting your
merged_namespace example, with tweaks:
#-
def merged_namespace(*ns):
try:
__builti
y project?
Perhaps a few lines of script to add CamelBack support, using an amplitude
increase for initial caps and maybe lingering on the initial phoneme for an
extra 100 milliseconds. So then, the above example would read:
"camel link dot set Parse Action between parens emit Link H T M L j
# huh?
a
>>> [i() for i in c] # too long and ...huh?
a
b
[None,None]
#--
Why? Because I want to make Python calls from a cell phone.
Every keystroke is precious; even list comprehension is too much.
Is there something obvious that I'm mis
oster)
...
\~/
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-list-
> [EMAIL PROTECTED] On Behalf Of Carsten Haese
> Sent: Wednesday, May 30, 2007 12:55 PM
> To: python-list@python.org
> Subject: Re: c[:]()
>
> On Wed, 2007-05-30 at 11:48 -0700, Warren Stringer wrote:
> &g
; [EMAIL PROTECTED] On Behalf Of Brian van den Broek
> Sent: Wednesday, May 30, 2007 3:00 PM
> To: python-list@python.org
> Subject: Re: c[:]()
>
> Warren Stringer said unto the world upon 05/30/2007 05:31 PM:
> > Hmmm, this is for neither programmer nor computer; this is f
python list.
Cheers,
\~/
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-list-
> [EMAIL PROTECTED] On Behalf Of Dustan
> Sent: Wednesday, May 30, 2007 4:14 PM
> To: python-list@python.org
> Subject: Re: c[:]()
>
> On May 30, 5:37 pm, "Warre
Oops! guess I should have tested my rather hasty complaint about executable
containers. This is nice:
def a(): return 'b'
def b(): print 'polly! wakey wakey'
c = {}
c['a'] = b
c[a()]() #works!
c[a()]() is a switch statement with an amorphous selector- very handy in its
own right. But, using a()
Hey Douglas,
Perhaps I was being too abstract? Here goes:
,---
| def selector():
|...
|return funcKey #get down get down
|
| def func():
|...
| funcSwitch = {}
| funcSwitch[funcKey] = func
| ...
| funcSwitch[selector()]()
even more intere
On Behalf Of Mikael Olofsson
> Sent: Thursday, May 31, 2007 1:52 AM
> To: python-list@python.org
> Subject: Re: c[:]()
>
> Warren Stringer wrote:
> > I want to call every object in a tupple, like so:
> > [snip examples]
> > Why? Because I want to make Python call
Hey Marc,
> > [d() for d in c]
>
> If you are using the list comprehension just for the side effect of
> calling `d` then consider this bad style. You are building a list of
> `None` objects just to have a "cool" one liner then.
Yep, you're right
> for func in funcs:
> func()
>
> Becaus
> >
> > But that still isn't as simple or as direct as:
> >
> > c[:]()
>
> Why do you always use a _copy_ of c in your examples? As long
> as you're wishing, why not just
>
> c()
Oh hey Grant, yes, I misunderstood your question for a bit. I thought you
meant the difference between List compr
Perhaps a foot pedal? Hmmm
My two cellphones don't like underbars very much. And the shift key -- while
much easier -- still is cumbersome. If outlook didn't autocaps on me, this
message would be in all lowercase. In fact, when communicating with friends
from outlook, to their sms, I take the
> How is it more expressive? In the context you're concerned
> with, c[:] is the exactly same thing as c. You seem to be
> worried about saving keystrokes, yet you use c[:] instead of c.
>
> It's like having an integer variable i and using ((i+0)*1)
> instead of i.
Nope, different.
c[:] holds
Hello,
Let's say I have a function with a variable number of arguments (please ignore
syntax errors):
def myfunc(a,b,c,d,...):
and I have a tuple whose contents I want to pass to the function. The number
of elements in the tuple will not always be the same.
T = A,B,C,D,...
Is there a way th
I was just setting up some logging in a make script and decided to
give the built-in logging module a go, but I just found out that the
base StreamHandler always puts a newline at the end of each log.
There is a comment in the code that says "The record is then written
to the stream with a trailin
Both are very good responses... thanks! I had forgotten the ease of
"monkey-patching" in python and the Stream class is certainly cleaner
than the way I had been doing it.
On Oct 3, 3:15 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Russell Warren wrote:
> > All I'
> While we're at it, do any of these debuggers implement a good way to
> debug multi-threaded Python programs?
Wing now has multi-threaded debugging.
I'm a big Wing (pro) fan. To be fair, when I undertook my huge IDE
evaluation undertaking it was approx 2 years ago... at the time as far
as what
I just did a comparison of the copying speed of shutil.copy against the
speed of a direct windows copy using os.system. I copied a file that
was 1083 KB.
I'm very interested to see that the shutil.copy copyfileobj
implementation of hacking through the file and writing a new one is
significantly f
I've been driven crazy by this type of thing in the past. In my case
it was with the same application (not two like you), but on different
machines, with all supposedly having the same OS load. In some cases I
would get short path names and in others I would get long path names.
I could never fig
Does anyone have an easier/faster/better way of popping from the middle
of a deque than this?
class mydeque(deque):
def popmiddle(self, pos):
self.rotate(-pos)
ret = self.popleft()
self.rotate(pos)
return ret
I do recognize that this is not the intent of a deque, given the
clear
Thanks for the responses.
> It seems to work with my Python2.4 here. If you're
> interested in efficiency, I'll leave their comparison as an
> exercise to the reader... :)
Ok, exercise complete! :) For the record, they are pretty much the
same speed...
>>> s = """
... from collections import d
> So does the speed of the remaining 0.001 cases really matter? Note
> that even just indexing into a deque takes O(index) time.
It doesn't matter as much, of course, but I was looking to make every
step as efficient as possible (while staying in python).
As to indexing into a deque being O(inde
The Python byte-code files are already pretty dense, so compressing them
further is unlikely to work if you try to put them in a zip.
WMM
On Feb 7, 2008 11:39 AM, Furkan Kuru <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have been developing an application in C++ that embeds Python
> interpreter.
>
/me no longer wishes to know about your dreams.
WMM
On Feb 12, 2008 4:56 PM, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote:
>
> > What is dream hardware for the Python interpreter?
>
> I'm not sure that the Python interpreter actually does dream
A Cray?
What are you trying to do? "dream" hardware is a very wide question.
WMM
On Feb 12, 2008 1:05 PM, <[EMAIL PROTECTED]> wrote:
> What is dream hardware for the Python interpreter?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://warrenmyers.com
"God may not play
I've got a case where I would like to know exactly what IP address a
client made an RPC request from. This info needs to be known inside
the RPC function. I also want to make sure that the IP address
obtained is definitely the correct one for the client being served by
the immediate function call
Argh... the code wrapped... I thought I made it narrow enough. Here
is the same code (sorry), but now actually pasteable.
---
import SimpleXMLRPCServer, xmlrpclib, threading, sys
def GetCallerNameAndArgs(StackDepth = 1):
"""This function returns a tuple (a,b) where:
a = The name of the ca
> That is just madness.
What specifically makes it madness? Is it because sys._frame is "for
internal and specialized purposes only"? :)
> The incoming ip address is available to the request handler, see the
> SocketServer docs
I know... that is exactly where I get the address, just in a mad wa
> How about a dictionary indexed by by the thread name.
Ok... a functional implementation doing precisely that is at the
bottom of this (using thread.get_ident), but making it possible to
hand around this info cleanly seems a bit convoluted. Have I made it
more complicated than I need to? There
convincing argument yet on why crawling the stack is considered
bad? I kind of hoped to come out of this with a convincing argument
that would stick with me...
On Feb 25, 12:30 pm, Ian Clark <[EMAIL PROTECTED]> wrote:
> On 2008-02-25, Russell Warren <[EMAIL PROTECTED]> wrote:
>
>
&
> OK, if you crawl the stack I will seek you out and hit you with a big
> stick. Does that affect your decision-making?
How big a stick? :)
> Seriously, crawling the stack introduces the potential for disaster in
> your program, since there is no guarantee that the calling code will
> provide the
preserve compatibility with existing third-party scripts &
infrastructure which routinely rely upon "as" as an object method.
Sigh.)
Cheers,
Warren
--
http://mail.python.org/mailman/listinfo/python-list
> Because it can be used at the import statement to let the imported
thing
> be known under another name?
> Something like:
>
> >>> import xml.etree.ElementTree as ET
Yes, but that syntax worked fine for years without "as" actually having
to be a keyword. There must be something more going on h
ut an "as" keyword. I do sincerely hope I am
wrong about this, but it is seems quite possible that C/Python's glory
days are now behind us.
And if so, then thank you all for so many wonderful years of effort and
participation! C/Python has had a great run, and Python syntax, i
thon
will easily transcend the limitations of its flagship implementation (if
or to the extent that such an implementation cannot keep pace with the
times). That's all well and good -- it may even end up being the next
great leap forward for the language. I believe Guido has even said as
much himself.
Warren
--
http://mail.python.org/mailman/listinfo/python-list
e indeed the optimal solution to certain problems,
and those problems are still not solvable with CPython 3.0.
Is it too much to hold out hope for a native Pythonic solution to the
multithreading performance issues inside of the CPython VM itself? Only
time will tell... but time is rapidly running out.
Warren
--
http://mail.python.org/mailman/listinfo/python-list
> Yet Another Python Troll (the ivory tower reference, as well as the
> abrupt shift from complaining about keywords to multiprocessing), I
> have to point out that Python does add new keywords, it has done so in
> the past, and there was a considerable amount of warning, including an
> automated d
> I still would have to call your management of the problem considerably
> into question - your expertise at writing mathematical software may
> not be in question, but your skills and producing and managing a
> software product are. You have nobody at your organization, which
> sells a product tha
on, I recognize that there will be ancillary casualties in
every major battle.
Though I may whine incessantly about all of our pre-2.5
log-file/documents being one such casualty (your various accusations
notwithstanding, we did indeed patch our own code as soon as the
deprecation warnings appeared
'll put this more bluntly: Warren's messages to date
> egregiously break the flow of discussion.
>
> Warren, in the interest of sane discussion in these forums, please:
>
> * preserve attribution lines on quoted material so we can see who
> wrote what.
>
> * use the conve
standalone keyword " as ". It seems to me
that it should be possible to unambiguously separate the two without
ambiguity or undue complication of the parser.
So, assuming I now wish to propose a corrective PEP to remedy this
situation for Python 3.1 and beyond, what is the best way to get started
on such a proposal?
Cheers,
Warren
--
http://mail.python.org/mailman/listinfo/python-list
ot;, as a Python keyword, is a here to stay: Love it or leave it.
-> Likewise ditto for the GIL: if you truly need Python concurrency
within a single process, then use a Python implementation other than
CPython.
Season's greetings to all! Peace.
Cheers,
Warren
--
http://mail.python.org/mailman/listinfo/python-list
above approach is NOT secure since
object attributes can still be accessed...
So is there an equally convenient yet secure alternative available for
parsing strings containing Python data structure definitions?
Thanks in advance for any pointers!
Cheers,
Warren
--
http://mail.python.org/mailman/listinfo/python-list
ay's
web apps wouldn't exist without safe forms of untrusted eval/exec (Javascript
anyone?). Such dogma is appropriate when dealing with the CPython VM, but not
as a general principle.
"Rocket fuel may be dangerous, but you ain't shooting the moon without it!"
Cheers,
Wa
done much more easily from
Python than from C (e.g. data organization, U.I. survey/present tasks,
rarely used transformations, ad hoc scripting experiments, etc.).
Cheers,
Warren
--
http://mail.python.org/mailman/listinfo/python-list
I'm running python 2.5.1 and it seems that SimpleXmlRpcServer is not
setup to support the base datetime module in the same way xmlrpclib
has been with "use_datetime". I see that someone (Virgil Dupras) has
recently submitted a fix to address this, but I don't want to patch my
python distro. I wan
d"< instruction count was significantly higher for C++. I expect any sort
> of C++ objects you used to implement Python structures will be slower
> than the equivalent in C. So even if writing it in C++ would reduce
> the overhead for deleting from a list, I expect you would lose a lot
> more.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Warren Myers
http://warrenmyers.com
--
http://mail.python.org/mailman/listinfo/python-list
After some digging it seems that python does not have any equivalent to
C's #if directives, and I don't get it...
For example, I've got a bit of python 2.3 code that uses
collections.deque.pop(0) in order to pop the leftmost item. In python
2.4 this is no longer valid - there is no argument on po
> the collections module was added in 2.4
Ah... sorry about that. I should have checked my example more closely.
What I'm actually doing is rebinding some Queue.Queue behaviour in a
"safe" location like this:
def _get(self):
ret = self.queue.popleft()
DoSomethingSimple()
return ret
And se
Thanks guys - all great responses that answered my question in a few
different ways with the addition of some other useful tidbits!
This is a nice summary:
> In general the idea is to move the test from 'every time I need to do
> something' to 'once when some name is defined'.
Gotta love the resp
Yes, I definitely should have done that for that case. I'm not
entirely sure why I didn't. If I had, though, I may not have been
prompted to ask the question and get all the other great little
tidbits!
--
http://mail.python.org/mailman/listinfo/python-list
Is there a reason that this is fine:
>>> def f(a,b,c):
... return a+b+c
...
>>> f(1, *(2,3))
6
but the code below is not?
>>> x = (3, 4)
>>> (1, 2, *x) == (1, 2, 3, 4)
Traceback (most recent call last):
File "", line 1, in
invalid syntax: , line 1, pos 8
Why does it only work when unpackin
On Nov 29, 11:09 am, Christian Heimes wrote:
> The feature is available in Python 3.x:
>
> >>> a, b, *c = 1, 2, 3, 4, 5
> >>> a, b, c
> (1, 2, [3, 4, 5])
> >>> a, *b, c = 1, 2, 3, 4, 5
> >>> a, b, c
>
> (1, [2, 3, 4], 5)
Interesting... especially the recognition of how both ends work with
the "a,
I'm having trouble understanding when variables are added to
namespaces. I thought I understood it, but my nested function
examples below have me very confused.
In each test function below I have an x variable (so "x" is in the
namespace of each test function). I also have a nested function in
e
My tests were run in python 2.6.5.
--
http://mail.python.org/mailman/listinfo/python-list
tell me if a more serious problem is
looming.
--- warren.
--
http://mail.python.org/mailman/listinfo/python-list
101 - 156 of 156 matches
Mail list logo