Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Bas
Try this, don't know if this works for al versions: from pylab import * x=10**linspace(0,5,100) y=1/(1+x/1000) loglog(x,y) show() If you only need a logarithm along one axis you can use semilogx() or semilogy(). For more detailed questions go to the matplotlib mailing list. Cheers, Bas -- http

Re: Kill forked processes

2006-02-27 Thread kmkz
I didn't mean that you'd have to write it for me, I meant that if what you said works (atexit, signal) I will paypal you $10 for your generous contribution to my project. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best python module for Oracle, but portable to other RDBMSes

2006-02-27 Thread Jonathan Gardner
I've never seen the points of those tools. Just lay it out on paper or document it somewhere. Be consistant with your naming scheme and it shouldn't be hard to see the relations. If found that the people who don't understand how tables should relate to one another are also the same people who don't

Re: type = "instance" instead of "dict"

2006-02-27 Thread Kent Johnson
Cruella DeVille wrote: > So what you are saying is that my class Dict is a subclass of Dict, and > user defined dicts does not support iteration? I don't know what your class Dict is, I was guessing. The built-in is dict, not Dict. > > What I'm doing is that I want to write the content of a dict

Re: spaces at ends of filenames or directory names on Win32

2006-02-27 Thread Roel Schroeven
rtilley schreef: > This will at least allow me to ID folders that start with whitespace... > from within Windows too :) yet I still cannot rename the folders after > stripping the whitespace... attempting to gives an [Errno 2] No such > file or directory. The strip seems to work right too accord

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Derek Basch
Thanks for the reply. I need a scatter plot though. Can that be done? -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode question

2006-02-27 Thread Edward Loper
Walter Dörwald wrote: > Edward Loper wrote: > >> [...] >> Surely there's a better way than converting back and forth 3 times? Is >> there a reason that the 'backslashreplace' error mode can't be used >> with codecs.decode? >> >> >>> 'abc \xff\xe8 def'.decode('ascii', 'backslashreplace') >> Trac

Re: bsddb3 database file, are there any unexpected file size limits occuring in practice?

2006-02-27 Thread Klaas
Claudio writes: > I am on a Windows using the NTFS file system, so I don't expect problems > with too large file size. how large can files grow on NTFS? I know little about it. > (I suppose it in having only 256 MB RAM available that time) as it is > known that MySQL databases larger than 2 GByt

PyQT: QDialog and QMainWindow interacting with each other

2006-02-27 Thread Fabian Steiner
Hello! I have got a QMainWindow with a QListView, in which the different entries of a database are shown to the user. Moreover it has got a QPushButton, so that another QDialog can be opened where the user is able to add a new entry: ... self.connect(self.btnNew, SIGNAL('clicked()'), self.ope

Re: Firebird and Python

2006-02-27 Thread Ray Cote
At 5:07 PM +0100 2/27/06, Magnus Lycka wrote: > > I'm still interested >in experiences from Pythonistas using Firebird-- >especially embedded. Works great. Python and Firebird embedded (at least on Windows) is very simple to use. Not currently using it on other platforms. --Ray -- Raymond Cote

Re: ''.join() with encoded strings

2006-02-27 Thread Sandra-24
Sorry, this was my mistake, I had some unicode strings in the list without realizing it. I deleted the topic within 10 minutes, but apparently I wasn't fast enough. You're right join works the way it should, I just wasn't aware I had the unicode strings in there. -Sandra -- http://mail.python.or

Re: type = "instance" instead of "dict"

2006-02-27 Thread Cruella DeVille
I created a class Dict (not dict), but since it only complicates things for me I implemented my program without it. when I wrote myDictionary = dictionary.__dict__.iteritems() it worked better... what does the __dict__ mean? -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread I V
Paul Rubin wrote: > Hmm, I also see the PEP doesn't specify what's supposed to happen with > > Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat') > Solar_system = enum('sun', 'mercury', 'venus', 'earth',) # etc. > print Weekdays.sun == Solar_system.sun > > so that's another sho

Re: type = "instance" instead of "dict"

2006-02-27 Thread Steve Juranich
Cruella DeVille wrote: > I created a class Dict (not dict), but since it only complicates things > for me I implemented my program without it. > > when I wrote myDictionary = dictionary.__dict__.iteritems() it worked > better... > what does the __dict__ mean? This is something else entirely and

MySQLdb compile error with AMD64

2006-02-27 Thread keith
Hi, I have been using MySQLdb on a 32-bit processor, no worries. Love it. I went to install on an AMD64 running the 64-bit version of SUSE 10.0. I get the following error during the "python setup.py build" gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE

Re: sort one list using the values from another list

2006-02-27 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Ron Adam wrote: >> This probably should be: >> >> def psort11(s1, s2): >> d = dict(zip(s2,s1)) >> assert len(d) == len(s1) >> s1[:] = list(d[v] for v in sorted(d)) > > You could do this to avoid all of those lookups: > > def psort_

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread John Hunter
> "Derek" == Derek Basch <[EMAIL PROTECTED]> writes: Derek> Thanks for the reply. I need a scatter plot though. Can Derek> that be done? You can set the scale of xaxis and yaxis to either log or linear for scatter plots In [33]: ax = subplot(111) In [34]: ax.scatter( 1e6*rand(1000),

Re: str.count is slow

2006-02-27 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: > It seems to me that str.count is awfully slow. Is there some reason > for this? > Evidence: > > str.count time test > import string > import time > import array > > s = string.printable * int(1e5) # 10**7 character string > a = array.array('c', s) > u =

Catch exceptions

2006-02-27 Thread Cruella DeVille
In my application of bookmarks I get a filename as a parameter in one of my methods. I want to catch the "FileNotFoundException" if the user types an invalid filename. My code (that doesn't do what I want it to do - namely print a nicely formatted error message, and no stack trace) def openFile(se

Re: spaces at ends of filenames or directory names on Win32

2006-02-27 Thread rtilley
Roel Schroeven wrote: > rtilley schreef: > >> This will at least allow me to ID folders that start with >> whitespace... from within Windows too :) yet I still cannot rename the >> folders after stripping the whitespace... attempting to gives an >> [Errno 2] No such file or directory. The strip

Re: str.count is slow

2006-02-27 Thread Fredrik Lundh
Ben Cartwright wrote: > > On my machine, the output is: > > > > str: 0.29365715475 > > array: 0.448095498171 > > unicode: 0.0243757237303 > This tactic typically avoids most (sometimes all) of the calls to > memcmp. Other string search functions, including unicode.count, > unicode.index, a

Dr. Dobb's Python-URL! - weekly Python news and links (Feb 27)

2006-02-27 Thread Cameron Laird
QOTW: "Actually, Python has the distinction of being both a great tool language *and* a great Zen language. That's what makes Python so cool ;-)))" - Ron Stephens "It is probably possible to do the whole thing with a regular expression. It is probably not wise to do so." - John Zenger (among MANY

Re: Catch exceptions

2006-02-27 Thread Crutcher
Without seeing more of your code, I'm not sure what you are doing wrong. This works: ex.py vv def xopen(path): try: return open(path) except IOError, e: print 'Error:', e.args[1] xopen('xyzzy') ^^ $ python ex.py Error: No such file or direct

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
"I V" <[EMAIL PROTECTED]> writes: > I think it does, doesn't it? From the PEP: > > "Values within an enumeration cannot be meaningfully compared *except > with values from the same enumeration*. The comparison operation > functions return ``NotImplemented`` [#CMP-NOTIMPLEMENTED]_ when a > value f

Re: sort one list using the values from another list

2006-02-27 Thread bearophileHUGS
Following Ron Adam solution (and using [] instead of list() in the last line), this may be a possible solution of the problem, that is often quite fast: def psort16(s1, s2): try: d = dict(izip(s2, s1)) except TypeError: _indices = range(len(s1)) _indices.sort(key=s2

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Derek Basch
Great! That worked fine after I played with it for a bit. One last question though. How do I label the ticks with the product of the exponentiation? For instance: 100 instead of 10**2 Thanks for all the help, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: str.count is slow

2006-02-27 Thread Terry Reedy
"Ben Cartwright" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Your evidence points to some unoptimized code in the underlying C > implementation of Python. As such, this should probably go to the > python-dev list (http://mail.python.org/mailman/listinfo/python-dev). > > The pro

Re: Catch exceptions

2006-02-27 Thread Cruella DeVille
I put the try catch in my main-method, and it worked to some extent (except from when I try to read from a file with no content) Any idea how to solve that? And is it a good place to have a try-except in main instead of in the class methods? My code is at http://nibbler.no/blog/wp-includes/Bookma

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Kay Schluehr wrote: >> Ben Finney wrote: >>> One motivation for having a class (rather than an instance) for >>> each enumeration is to allow subclasses of enumerations, extending >>> and altering an existing enumeration. A class, though, implies >>> t

Re: type = "instance" instead of "dict"

2006-02-27 Thread Jonathan Gardner
You should probably spend a bit more time in the documentation reading things for yourself. Read http://www.python.org/doc/2.4.2/ref/types.html under "Class Instances" for your answer. -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
Paul Rubin writes: > Ben Finney <[EMAIL PROTECTED]> writes: >> Enumerations with no values are meaningless. The exception >> ``EnumEmptyError`` is raised if the constructor is called with no >> value arguments. > > Why are empty enumerations not allowed? Empty sets, emp

Re: Catch exceptions

2006-02-27 Thread Jonathan Gardner
(A) You'll have to be more specific about your problem if you want us to help. Under which circumstances did it work or not? What exactly is the problem? (B) Where you put your error-handling is up to you. It depends on what the function does and how it is to respond. Do you want the function to t

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
Paul Rubin writes: > Hmm, I also see the PEP doesn't specify what's supposed to happen with > > Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat') > Solar_system = enum('sun', 'mercury', 'venus', 'earth',) # etc. > print Weekdays.sun == Solar_system.s

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
"Terry Reedy" <[EMAIL PROTECTED]> writes: > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote >> A list is a container. > > I think it is misleading, if not wrong, to refer to Python > collections as 'containers', 'boxes', or similar. A object in a box > cannot be in another disjoint box. A object in a

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Mikalai
Steven D'Aprano wrote: > Paul Rubin wrote: > > What is an empty enum? How and when would you use it? > > The best I can come up with is that an empty enum would > be the enumerated values you have when you don't > actually have any enumerated values. This is not to be > confused with an empty list:

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes: > If an enumeration object were to be derived from, I would think it > just as likely to want to have *fewer* values in the derived > enumeration. Subclassing would not appear to offer a simple way to do > that. pentium_instructions = enum('add', 'sub', 'mul'

changing params in while loop

2006-02-27 Thread robin
hi, i'm a newbie, but please bear with me for a second. i have this function inside a while-loop, which i'd like to loop forever, but i'm not sure about how to change the parameters of my function once it is running. what is the best way to do that? do i have to use threading or is there some simp

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Ben Finney wrote: >> Values within an enumeration cannot be meaningfully compared except >> with values from the same enumeration. The comparison operation >> functions return ``NotImplemented`` [#CMP-NOTIMPLEMENTED]_ when a >> value from an enumeratio

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Ben Finney
Tim Chase <[EMAIL PROTECTED]> writes: > Just a couple thoughts: Appreciated. >> An enumeration is an exclusive set of symbolic names bound >> to arbitrary unique values. > > Uniqueness imposes an odd constraint that you can't have synonyms in > the set: > > >>> shades = enum({white:100, grey:50,

Re: PEP 354 -- "in" operator?

2006-02-27 Thread Ben Finney
[fixing References field. Please reply in the original thread so I can find you easily.] Roy Smith <[EMAIL PROTECTED]> writes: > If I have an enum, how can I verify that it's a legal value? Can I > do: > > Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat') > > def foo (day): >if

Re: spaces at ends of filenames or directory names on Win32

2006-02-27 Thread [EMAIL PROTECTED]
rtilley wrote: > Roel Schroeven wrote: > > rtilley schreef: > > > >> This will at least allow me to ID folders that start with > >> whitespace... from within Windows too :) yet I still cannot rename the > >> folders after stripping the whitespace... attempting to gives an > >> [Errno 2] No such fi

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes: > By way of explanation, my earlier implementations of this didn't have > enumerations as sequences. Now that the design has converged more on a > sequence and container idiom, I agree with you. say that Weekdays = enum('mon', 'tue', ...) What is the typ

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > I'll amend the specification so empty enumerations are not an > error. (This will also remove the last remaining exception class from > the specification, making it cleaner still. Good.) And once you've done that, we can bui

Re: sort one list using the values from another list

2006-02-27 Thread Simon Sun
Magnus Lycka wrote: > Is there something here I can't see, or did you just > change a variable name and present that as another > solution? Heh, I have use python for a very short time. Base your statements, I test in python, found `_' is a valid variable name. So I don't know it is a just a plain

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Roy Smith
A few random questions: a = enum ('foo', 'bar', 'baz') b = enum ('foo', 'bar', 'baz') what's the value of the following: a == b a is b a.foo == b.foo a.foo is b.foo len (a) str (a) repr (a) hash (a) type (a) Can you make an enum from a sequence? syllables = ['foo', 'bar', 'baz'] c = enum (syll

Re: sort one list using the values from another list

2006-02-27 Thread Kent Johnson
Simon Sun wrote: > Magnus Lycka wrote: > >>Is there something here I can't see, or did you just >>change a variable name and present that as another >>solution? > > Heh, I have use python for a very short time. Base your statements, I test > in python, found `_' is a valid variable name. So I don

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C The following should work: j = dict((k, dict2[dict1[k]]) for k in dict1 if dict1[k]

Dr. Dobb's Python-URL! - weekly Python news and links (Feb 27)

2006-02-27 Thread Cameron Laird
QOTW: "Actually, Python has the distinction of being both a great tool language *and* a great Zen language. That's what makes Python so cool ;-)))" - Ron Stephens "It is probably possible to do the whole thing with a regular expression. It is probably not wise to do so." - John Zenger (among MANY

Re: Use of __slots__

2006-02-27 Thread Alex Martelli
MrJean1 <[EMAIL PROTECTED]> wrote: > An example of the RARE use case may be this particular one > > A benchmark is not a use case. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: ... > I suspect that the notion of empty set was once controversial. Yep: Reverend Dodgson (best known by his pen name of Lewis Carroll, and as the author of the Alice novels, but a logician and mathematician IRL) fought long and hard against Cantor's set

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Alex Martelli
Ben Finney <[EMAIL PROTECTED]> wrote: ... > The Python parser knows what to do when a comparison returns > NotImplemented. The parser has nothing to do with it, but the bytecode interpreter sure does;-). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flash

2006-02-27 Thread SamFeltus
Why not just have the Python on the server send a JSON string to the Flash ap? Easy easy. Just use LoadVars on the Flash side. All that SOAP and XML-RPC sounds might be an needless overcomplication. Sam the Gardener http://sonomasunshine.com -- http://mail.python.org/mailman/listinfo/python-

Re: Python and Flash

2006-02-27 Thread SamFeltus
PS. Here is an example... http://sonomasunshine.com/sonomasunshine/FrontPage.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flash

2006-02-27 Thread SamFeltus
PS. Here is an example... http://sonomasunshine.com/sonomasunshine/FrontPage.html -- http://mail.python.org/mailman/listinfo/python-list

Re: type = "instance" instead of "dict"

2006-02-27 Thread James Stroud
Cruella DeVille wrote: > I'm trying to implement a bookmark-url program, which accepts user > input and puts the strings in a dictionary. Somehow I'm not able to > iterate myDictionary of type Dict{} > > When I write print type(myDictionary) I get that the type is > "instance", which makes no sens

Re: changing params in while loop

2006-02-27 Thread Ben Cartwright
robin wrote: > i have this function inside a while-loop, which i'd like to loop > forever, but i'm not sure about how to change the parameters of my > function once it is running. > what is the best way to do that? do i have to use threading or is there > some simpler way? Why not just do this in

Re: type = "instance" instead of "dict"

2006-02-27 Thread Steve Holden
James Stroud wrote: > Cruella DeVille wrote: > >>I'm trying to implement a bookmark-url program, which accepts user >>input and puts the strings in a dictionary. Somehow I'm not able to >>iterate myDictionary of type Dict{} >> >>When I write print type(myDictionary) I get that the type is >>"insta

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Carl Banks
Ben Finney wrote: > This PEP specifies an enumeration data type for Python. -1 for this particular proposal as a builtin. I feel it's not a great design of something that isn't terribly useful to begin with. +0 for the standard library, only after a couple changes. As I see it, this whole propo

Re: newbie

2006-02-27 Thread Steve Holden
Brain Murphy wrote: [...] > also i have heard that there are no crackers using python why is this?? > Because the Python Secret Underground seeks hackers out and -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006

Re: type = "instance" instead of "dict"

2006-02-27 Thread Fredrik Lundh
James Stroud wrote: > Perhaps you did not know that you can inheret directly from dict, which > is the same as {}. For instance: > > class Dict({}): >pass > > Is the same as > > class Dict(dict): >pass it is ? >>> class Dict({}): ... pass ... Traceback (most recent call last): File

<    1   2