re if I understand you fully, but if what you are after is how to
pass named parameters analog to positional args, do it as dict:
def foo(name=None):
print name
foo(**{name: "Fuzzy"})
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
only recreate them and rebind them to new variables. This
prevents whole classes of errors - but of course it also introduces all
kinds of other constraints on your programming style, e.g. using monads and
so on.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>> It's not only that way in python, but in java too. So it seems that there
>> is a fundamental principle behind it: In a language that allows
>> sideeffects, these will actually happen.
d hopfully comprehending...) your post. Sorry.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
k the urls - so copy and pasting yields only start or end of the
urls, depending on the browser/edit control your pasting into.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
lf, instance, attribute, value=1):
"""Value and multiplier must be readonly"""
try:
setattr(instance, attribute, value)
self.fail("Value is not read only")
except AttributeError:
pass
Then the testing becomes one line:
self.test_readonly(self.combat, "value")
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
rd unix is a millisecond. And time.time() actually delivers a float
with sub-second precision.
import time
t = time.time()
time.sleep(.25)
print time.time() - t
gives for me (also debian) 0.249767065048 secs.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mail
seq = [[] for i in xrange(10)]
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
ght help. It has a free
evaluation version, and python bindings.
If it's only about text, maybe pdf2text helps.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Danny skrev:
> Does anyone know of a good python tutorial?
> I was also looking for some non-trivial projects to do in python.
There's a lot of projects on Sourceforge that are written in Python,
where you're free to study the code and maybe participate, if you've
got what it takes.
> Basicall
.org/sf/1126208 opened by Kurt B. Kaiser
subprocesss module retains older license header (2005-02-17)
http://python.org/sf/1138653 opened by Tres Seaver
Python syntax is not so XML friendly! (2005-02-18)
CLOSED http://python.org/sf/1143855 opened by Colbert Philippe
inspect.getso
Sandman wrote:
> How would I run a shell command in Python?
>
> Here is what I want to do:
> I want to run a shell command that outputs some stuff, save it into a
> list and do stuff with the contents of that list.
There's a Python Cookbook example that should fit nicely with what
you're trying
e in effect flat 3 element Numeric arrays,
and Numeric ararys can be constructed with Float64 specified as the
datatype.
"""
It was embedded in some disgressing comments (he himself says so, btw.) so
you might have missed it.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
def depth_first(self):
if self.childs:
for child in self.childs:
for node in child.depth_first():
yield node
yield self.payload
tree = Node('root', [Node('child1'), Node('child2')])
for n in tree.depth_firs
e.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
tlines.
>
> Any ideas?
Maybe [c]StringIO can be of help. I don't know if it's iterator is lazy. But
at least it has one, so you can try and see if it improves performance :)
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
7;, 'timedelta', 'tzinfo']
>>>
Maybe this is a clash between a custom datetime module and the python one?
What does
python2.4 -v -c "import datetime"
give you?
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
abuse.
A module is a unit of code that (should) encapsulate a certain
functionality. So it's perfect for your needs. There is no law or even rule
of thumb that makes claims about module size (or the lack of, for this
matter). So create a module - it doesn't cost you anything.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
I'm using wget from Python to get extactly one line from a reports page.
I made this function that works for me:
def wgetline(exp): # see Python Cookbook p. 228
print "Getting result from server ..."
command = 'wget -q -O - \
http://www.foobar.com/report.pl\?UserID=xxx\&UserPW=xxx
don see why implicitly calling one
> of these methods would be any more difficult when they are autonomous
> objects than when they are attributes.
I still don't see how that is supposed to work for "a lot of interesting
things". Can you provide examples for one of these in
ming.html#id12
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
all for some part of the code,
then you'd most probably even go for a local variable binding to avoid the
lookups in the different scopes - thus the issue of import format gets
unimportant again :)
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
PEP, an implementation and a
> champion with some persuasive ability :)
Go wild :)
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Patch / Bug Summary
___
Patches : 303 open ( -5) / 2764 closed ( +9) / 3067 total ( +4)
Bugs: 849 open (+11) / 4837 closed ( +3) / 5686 total (+14)
RFE : 169 open ( +1) / 148 closed ( +0) / 317 total ( +1)
New / Reopened Patches
__
New fpcon
>>>> b = a.strip(r'\\\x00')
>>>> b
> 'A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00'
>>>> b = a.split(r'\\\x00')
>>>> b
> ['A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00']
>
> I'm a bit of a novice at
le
are supported; both are needed to actually retrieve a resource at an https:
URL.
'''
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
DENG wrote:
> ok
>
> i find it
>
> map :!d:\python24\python.exe %
>
>
> but it comes with a new pop-up windowsdame~
I'm no windows expert - but maybe pythonw.exe helps here?
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
> widget["filename"]
>
> Is this possible to do?
Yes. Use dicts to store these buttons so that you can later refer to them.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
e.
A variable in python is just a name refering to an object. So this
>>> a = 'a'
>>> b = a
>>> print a, b
a a
will make a and b both refer to the string 'a'. Now assigning a different
value to b will not affect the binding of a:
>>> b =
> Both filelist and self.checkbox are the same size (4 items btw). Is
> there any way to get this done?
Use zip:
a, b = [1,2,3], ['a', 'b', 'c']
for i,j in zip(a,b):
print i,j
Or from itertools izip - which should be slightly more performant and less
mem
fig(enabled=False)
Of course this means that cbs has to be a global var. But there exist other
options of course - as part of a object or whatever. that depends on your
code.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
people here usually tend not to be too helpful when asked to do an obvious
homework task. So if you really want help, provide some code you've already
written and that has actual problems. Then we're glad to help. But don't
expect others to do your work.
--
Regards,
D
S)
Evaluate(u'wsdl:description/wsdl:documentation', context=ctx)
"""
Should give you a start.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
n
conjunction with zeo as it has no idea of whatever storage is needed - all
it does is indexing zodb objects - which you get from zeo as well. Of
course that means that you have to keep a catalog for every thread/process
that accesses the objects. Alternatively, you maybe can make the
IndexedCata
what commands actually fail would certainly help.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
inserted.add(e)
listA = res
Or, with a little helperfunction:
inserted = set()
def foo(e):
inserted.add(e)
return e
listA = [foo(e) for e in listA if not e in inserted]
But ist's not really much better.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
problem - e.g. DNS is often a candidate than can slow down network
experience a lot. So maybe thats causing your trouble?
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
; :-)
I usually use much more telling variable names - from the source I just
wrote a minute ago:
self.selection_color_map = {}
self.selection_color = (255,255,0)
self.assigned_color_map = {}
self.default_color = (0,0,0)
self.known_names = sets.Set()
As you can see
7;d have
> to use: "from some import *", because mainly I'm interrested in assigning
> to self: self.x = "blah"
> self.y = "uhm"
Okay, I try and guess: From your two posts I infer that you want to set
variables in instances. But you
'size': 367415L,
> 'orientation' : (0x0112) Short=1 @ 42}
You can't sort dicts - they don't impose an order on either key or value.
There are ordered dict implementations out there, but AFAIK the only keep
the keys sorted, or maybe the (key,values) in t
o is to convert your
pattern to a regex:
rex = re.compile(r"/dir/dir/.*/dir/.*/dir/.*")
Then create a list of dirs with os.walk:
dirs = [dirpath for dirpath, foo, bar in os.walk(topdir) if
rex.match(dirpath)]
This is untested, but should do the trick.
--
Regards,
Diez B. Roggisch
> Will anything else work here?
Use %%
print "%%s %s" % "foo"
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Patch / Bug Summary
___
Patches : 279 open (-24) / 2797 closed (+33) / 3076 total ( +9)
Bugs: 851 open ( +2) / 4853 closed (+16) / 5704 total (+18)
RFE : 173 open ( +4) / 150 closed ( +2) / 323 total ( +6)
New / Reopened Patches
__
Fix for w
> is there another way to convert a string with quoted sub entries into a
> list of strings?
try the csv-module.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
l end
immediately after the main thread terminated.
Read the threading modules docs.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Untestet:
def foo(base, depth=2):
for root, dirs, files in os.walk(base, True):
if len(root.split(os.sep)) < depth:
yield root, dirs, files
for root, dirs, files in foo("/tmp"):
print root, dirs, files
--
Regards,
Diez B. Roggisch
--
http://ma
phone = {'mike':10,'sue':8,'john':3}
print [key for key, value in phone.items() if value == 3]
-> ['john']
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Hello all,
>
> I need to create 6 buffers in python and keep track of it.
> I need to pass this buffer, say buffer 1 as an index to a test app. Has
> any one tried to do this. Any help with buffer management appreciated.
Use the module array.
--
R
u observe seems to be a result of your "abuse" of classmethod
outside a class scope.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
rrent frame of execution,
so
def foo():
bar = "baz"
makes the bar part of the frames local variables. Scopes just exchange or
stack the dicts for name lookup.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
n't be much more than a few lines of code, more or
less only subclassing your server from Pyro.core.ObjBase instead of
SimpleXMLRPCServer.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
t "--data--", data[key_size:]
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
"C:\\somedir\\test.xbm"
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
the network than soap/xmlrpc. So while the local loopback _might_ be slower
(I'm not even sure about that) than the unix socket, marshalling data as
xml has its own cost overhead.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Stephen Waterbury wrote:
> Diez B. Roggisch wrote:
>> ... corba is 10-100 times faster over
>> the network than soap/xmlrpc. ...
>
> I'm not challenging these statistics (because I don't know),
> but I would be interested in the source. Are you referring
>
rap the module - which is possible in
several ways, including hand-written code, pyrex, swig and sip. Maybe even
more, I don't know.
Or you access it using the module ctypes that allows to invoke arbitrary
methods/funtctions of C-libs. google for it.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
> accessible with normal development tools since it's stuck in the ZODB.
Plain wrong. You can access them via FTP and WEBDAV. In kde under linux, all
file-io can be done through these protocols, so you can operate on them as
if they were local files.
--
Regards,
Diez B. Roggisch
--
http://
tly using ftp as storage
backend. (x)emacs for example.
> Besides, how to have the
> source code under source control if it's stuck in the ZODB?
You can still fetch it using webdav and ftp and stick it into CVS/SVN.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
u a great deal here)
and create an instance of the desired struct. A third way could be to
create an extension type that resembles your struct and use that to create
the "real" struct by getting the types instance values.
HTH
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
If you can use a linux server, you can create a linux user mode file system
- there is a python binding for that - which in turn you could then share
using samba.
http://www.freenet.org.nz/python/lufs-python/
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
2" or --enable-unicode=ucs4. You can't set it to utf-8
or utf-16.
> 2. how to convert string to UCS-2
s = ... # some ucs-2 string
s.decode("utf-16")
might give you the right results for most cases:
http://mail.python.org/pipermail/python-dev/2002-May/024193.h
eed to call them os.getcwd(), as you do
in the second call to it.
- the join is supposed to work on a list of arguments, like this:
os.path.join("a", "b", "c")
will yield
a/b/c
But you concatenate two strings using +, and thus have only one argument at
all, whi
Peter A. Schott wrote:
> PostGreSQL - good feature set, open source. Not sure on speed, but it
> should run natively on Unix, Linux, and Win32 (not sure about BSD or
> others).
A lot of the core developers of PostgreSQL are apparently running *BSD.
On the PostgreSQL-General mailing list, I've no
guity.
Soo, in the end it boils down to some explicitness - where IMHO an
additional comma is pretty much no problem at all. Another option would of
course be the introduction of different parentheses for tuples - but I
can't find some on my keyboard.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
reasoning before - I remember you
wanting to shave off microseconds by optimising constant expressions like
5*4 whilst at the same time arguing in another thread that you'd like to
have mutable keys for dicts that needed copying the very same keys - at
much greater costs, per case and even more so in general as using dicts is
common where pure constant arithmetic expressions aren't.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
5' etc.
>
> I find this 'creative use of overloading' rather awful. But what the
> heck, I find list comprehension rather awful.
Well, the number of operators built into the language is limited - and I
actually prefer to have the possibility to overload these if I want to.
No
had you
> would have known that if the objects one had to work with were at
> the same time mutable and usefull as keys, you have to turn them
> into an immutable now for use as a key. This is a copy operation.
> So compared to the situation now, no extra copying would b
Timothy Smith skrev:
> has anyone got some hard numbers on which pg access module is the
> fastest, i currently use pypgsql, but i can't help but feel it's a
> little slow.
> 3 seconds to connect, send one query, get th return data.
> i'm on a adsl 1.5mbit/256kbit link, the server is on a 10/10mbi
Timothy Smith skrev:
> my only issue with psycopg, is last time i looked they had no win32
> port?
Uh, in that case, maybe you should consider changing platform? 8^)
--
Leif Biberg Kristensen
just another global village idiot
--
http://mail.python.org/mailman/listinfo/python-list
tfor urllib.urlopen(path, async=True)
> outfile = waitfor open(path.split('/')[-1], async=True)
> waitfor outfile.write(waitfor infile.read(async=True), async=True)
> infile.close()
> outfile.close()
>
> def main():
> a = get_and_save("htt
Peter Moscatt wrote:
> UnboundLocalError: local variable '_nntp' referenced before assignment
This pretty much says what your problem is: you haven't a variable called
_nntp
> def callconnect():
> if b["text"]=="Connect":
>
"",re.VERBOS)
> ^
> SyntaxError: invalid syntax
No problem here. Is your indentation correct?
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
ven't I restored the interpreter to a virgin
> state?
You can't unload modules, or at least reload is not always working properly.
So - you'd gotta go the road IDLE has gone before I assume.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Patch / Bug Summary
___
Patches : 286 open ( +7) / 2801 closed ( +4) / 3087 total (+11)
Bugs: 870 open (+19) / 4867 closed (+14) / 5737 total (+33)
RFE : 175 open ( +2) / 150 closed ( +0) / 325 total ( +2)
New / Reopened Patches
__
inspect.p
don't bother if
ini-Files are popular on linux or not - on linux a great deal of different
formats is popular, and nobody seems to care too much. E.g. samba uses
ini-style config, too.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
s not working fully as expected
in some cases.
> state at point A and point B the same?
>
> --- point A:
> import os
> del __main__.__dict__['os']
> --- point B
>
> I guess my question boils down to, is the state of the python
> interpret
Bryan wrote:
> is there a way to determine the operating system's language? i can't seem
> to find a method that returns the value.
Try the module locale.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
>
> Personally I could live with that, but the diagram is a bit special
> because of the restriction of the = operation. I do not know if PHP
> supports this operational view by enabling iterations: $a, $$a, $$$a
> ... ?
It does.
--
Regards,
Diez B. Roggisch
--
http://mail.pyt
rser, ...]:
mo = m.match(data)
if mo:
break
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
condition:
# do something
pass
If that running-condition is queried often enough, you can stop the thread
by setting it to false.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
alternative, as it lets specify you the format by a string.
> print ed , '-', bd , '=', (ed-bd).days
I can't imagine what could possibly be easier than subtracting two dates -
in fact, most times one has to jump through much more hoops to achieve
these results, e.g. in j
.
Then your expression gets translated to:
0 in l and l is False
which yields False of course.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
mmercial license makes sense - it does for
trolltech :) And there is nothing in GPL that forces you to integrate code
you've been offered - otherwise, killing a GPL lib would mean to delete all
from a CVS checkout and submit a patch from that - obviouly nobody would
enforce that.
-
preter in case of an exception. Unindenting the
last while will wait in every case, so you can inspect the output
nonetheless.
Apart from that, there might be some hidden "keep this damn window open
after the executed progam terminated"-checkbox. Happy hunting.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
This is to inform those interested in compiling Python in MinGW that
an updated version of pyMinGW is now available.
Get it from here:
http://jove.prohosting.com/iwave/ipython/pyMinGW.html
Regards
Khalid
--
http://mail.python.org/mailman/listinfo/python-list
Patch / Bug Summary
___
Patches : 258 open ( +4) / 2701 closed ( +1) / 2959 total ( +5)
Bugs: 812 open (+28) / 4642 closed (+13) / 5454 total (+41)
RFE : 160 open ( +4) / 136 closed ( +1) / 296 total ( +5)
New / Reopened Patches
__
#1074261
parts that's already available, e.g.
for debian which handles dependencies usually much better and is easier to
use for online updates. I think we have to wait until consistent dependency
checking and so on are established - maybe LSB helps us there.
--
Regards,
Diez B. Roggisch
--
http:
less a general scheme is adopted, no
software project will burden itself with the task of doing this. So you
have to wait for your distribution to do that for them - which may result
in not-so-latest verisons. Or even none at all
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/m
ebian nearly all libs come with an extra
dev-package you need when compiling against them. No big deal, but
compiling software yourself usually means to downtrack these packages by
making multiple configure runs, until all missing headerfiles are there.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
> A couple of other bits of info.
> - a and b are ordered smallest to largest (could bisect module be used?)
> - in the future I will want to round the second number of closest 0.25
> rather than whole number.
>
> Would the sets module be more efficient?
>
> I'm
> How about sys.byteorder?
This doesn't help, as he wants to read files from varying endianess - what
the _current_ endianess is doesn't matter here.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
olutely no way of telling the endianess.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
> But, in fact, he says the files are always big endian. So, code like
> the following should address his problem. Note I use type 'h' as an
> example so I can easily read samples.
I'm sorry, I confused that he asked for machine endianess. Then of course
you are righ
rpretation efficiency is comparable to most
> popular interpreters.
I'd say that's pretty much standard interpreter technique - an expression
like this:
foo = a + b * c
is translated and reduced to an abstract-syntax-tree something like this:
Assignment("foo", BinaryOp("+&
f I import in in a 'higher-level'
> module. For example:
In the psyco doc it says that you can do full() - but it will bloat the
memory consumption, so its better to use either explicit or profile-based
optimization. I suggest reading the docs for psyco on thate.
>
> A.py
>
Any way I will continue to improve that interpreter,
> it's an interesting thing for me.
I don't have negative opinions about yuan and by no meants want to
discourage you developing it. Its a nice project.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
> Sorry maybe I didn't understand that part correctly
> and took grant that it would be implemented in
> recursive way. I just wondered if the following can be
> extended for arbitrary length arithmetic expressions:
> Assignment("foo", BinaryOp("+", Get("a&q
for scenarios such as yours.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Patch / Bug Summary
___
Patches : 259 open ( +1) / 2705 closed ( +4) / 2964 total ( +5)
Bugs: 800 open (-12) / 4662 closed (+20) / 5462 total ( +8)
RFE : 160 open ( +0) / 137 closed ( +1) / 297 total ( +1)
New / Reopened Patches
__
add key
h a stack/lifo as node
container, deepth-first is using a queue/fifo instead - but there is _no_
gain in terms of speed here - both have to visit all nodes.
There is no reason to change you running system - but your hopes for more
performance that way aren't fulfilled either.
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
601 - 700 of 4459 matches
Mail list logo