Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
Yeah hash(hash(immutable))=hash(immutable) it seems. Not sure this is a specification but it happens that way: -- $ >>> hash('abc') -1600925533 $ >>> hash(hash('abc')) -1600925533 $ >>> hash(hash(hash(('abc' -1600925533 >>> ---

Re: Determining if an object is a class?

2006-07-12 Thread Michele Simionato
[EMAIL PROTECTED] wrote: > I need to find out if an object is a class. > Which is quite simply awful...does anyone know of a better way to do > this? inspect.isclass M.S. -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with "&" charater in xml.

2006-07-12 Thread Kirt
How do i append characters to a string? actually my entire handler code is class oldHandler(ContentHandler): def __init__(self): self.fn = 0 self.dn = 0 self.i=[] self.x=""

Re: Determining if an object is a class?

2006-07-12 Thread placid
[EMAIL PROTECTED] wrote: > I need to find out if an object is a class. Using new style classes > this is very easy: > > class Test(object): pass > > obj = Test >or > obj = Test() > > if type(obj) == type: > # this is a class object.. > else: > # this not a class object > > But this fa

Re: Problem with "&" charater in xml.

2006-07-12 Thread Stefan Behnel
Kirt wrote: > i have walked a directory and have written the foll xml document. > one of the folder had "&" character so i replaced it by "&" > #--test1.xml > > C:\Documents and Settings\Administrator\Desktop\1\bye > w&y > > def.txt > 200607130417 > > > > C:\Docum

Re: stderr, stdout, and errno 24

2006-07-12 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, Wesley Henwood <[EMAIL PROTECTED]> wrote: >To capture output from python scripts run from a C++ app I've added the >following code at the beggening of the C++ app: > >PyRun_SimpleString("import grabber"); >PyRun_SimpleString("import sys"); >PyRun_SimpleString("class

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Paul Rubin
Ganesan Rajagopal <[EMAIL PROTECTED]> writes: > hash is a number. It's sufficient to do > > while d.has_key(key): > key += 1 This is called linear probing and is not considered that great a collision resolution strategy for hash tables. Really, if you want an exhaustive study about hashing,

Problem with "&" charater in xml.

2006-07-12 Thread Kirt
i have walked a directory and have written the foll xml document. one of the folder had "&" character so i replaced it by "&" #--test1.xml C:\Documents and Settings\Administrator\Desktop\1\bye w&y def.txt 200607130417 C:\Documents and Settings\Administrator\Deskt

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Ganesan Rajagopal
> "Terry" == Terry Hancock <[EMAIL PROTECTED]> writes: > Note that it is trivial to catch collisions on entry and correct them: > key = hash(url_string) > i = 0 > if d.has_key(key): >while d.has_key(key): >i += 1 hash is a number. It's sufficient to do while d.has_key(key):

Re: testing array of logicals

2006-07-12 Thread Paul Rubin
"John Henry" <[EMAIL PROTECTED]> writes: > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test print (False not in map(bool, logflags)) Possibly more "pure" alternative (untested): from operator import and_ print reduce(and_, map(bo

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Terry Hancock
Nick Vatamaniuc wrote: > The original post just said that he wanted to index some values by > their urls and didn't really care about the urls themselves, so I > suggested that he just use the hash of the key as the key. The > dictionary will then take a hash of that [note that: > hash(string)

Re: Accessors in Python (getters and setters)

2006-07-12 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: ... > I'm not sure about which languages you are talking (pretty much all that > allow public methods also allow public attributes), but in general I think Smalltalk is a very well known object-oriented language that behaves otherwise, just as one exam

Re: testing array of logicals

2006-07-12 Thread Alex Martelli
John Henry <[EMAIL PROTECTED]> wrote: > Hi list, > > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test test = sum(bool(x) for x in logflags)==len(logflags) is yet another possibility (without t

RE: Determining if an object is a class?

2006-07-12 Thread Dino Viehland
The first check is also off - it should if issubclass(type(Test), type): otherwise you miss the metaclass case: class foo(type): pass class Test(object): __metaclass__ = foo obj = Test if type(obj) == type: 'class obj' else: 'not a class' just on the off-chance you run into a metaclass :)

Deadline for abstracts in two days - Python-Workshop September 8, 2006 in Leipzig, Germany

2006-07-12 Thread mmueller
=== Reminder=== The deadline for submitting abstracts for the the workshop on September 8 in Leipzig is July 15. It is only two days away!! If you would like to give a presentation, please send your abstract to [EMAIL PROTECTED] The workshop topics are listed at http://www.python-academy.de/wor

Re: What is a type error?

2006-07-12 Thread Chris Smith
Marshall <[EMAIL PROTECTED]> wrote: > David Hopwood wrote: > > Marshall wrote: > > > Mightn't it also be possible to > > > leave it up to the programmer whether a given contract > > > was compile-time or runtime? > > > > That would be possible, but IMHO a better option would be for an IDE to give

Re: statistical analysis tools in python?

2006-07-12 Thread gblais
And there is a python interface to R, so that you can call R routines from Python. R is a free stat language that has all the tests you've mentioned, Gerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-12 Thread Gerhard Fiedler
On 2006-07-12 06:17:27, mystilleef wrote: > But developers tend to pay more attention to given methods/functions > less crappy names, at least when compared to data attributes. This > stems from the fact that in many languages data attributes aren't > usually part of the API, as well as the whole

Re: What is a type error?

2006-07-12 Thread Marshall
David Hopwood wrote: > Marshall wrote: > > > Wouldn't it be possible to do them at compile time? (Although > > this raises decidability issues.) > > It is certainly possible to prove statically that some assertions cannot fail. > > The ESC/Java 2 (http://secure.ucd.ie/products/opensource/ESCJava2/d

Re: Find and Delete all files with .xxx extension

2006-07-12 Thread John McMonagle
On Wed, 2006-07-12 at 16:12 -1000, normt's subject read: > Find and Delete all files with .xxx extension How ? In the current directory/folder ? Recursively search through all the directories/folders from a certain path ? I suggest you look at the os module (section about Files and Directorie

Re: What is a type error?

2006-07-12 Thread Marshall
Joachim Durchholz wrote: > Marshall schrieb: > > Joachim Durchholz wrote: > >> Marshall schrieb: > >>> I can see the lack of a formal model being an issue, but is the > >>> imperative bit really all that much of an obstacle? How hard > >>> is it really to deal with assignment? Or does the issue hav

Find and Delete all files with .xxx extension

2006-07-12 Thread normt
Please do so. No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.10/386 - Release Date: 07/12/2006 -- http://mail.python.org/mailman/listinfo/python-list

Re: stderr, stdout, and errno 24

2006-07-12 Thread Dave Hansen
On 12 Jul 2006 18:09:42 -0700 in comp.lang.python, "Wesley Henwood" <[EMAIL PROTECTED]> wrote: >To capture output from python scripts run from a C++ app I've added the >following code at the beggening of the C++ app: > >PyRun_SimpleString("import grabber"); >PyRun_SimpleString("import sys"); >PyRu

Re: statistical analysis tools in python?

2006-07-12 Thread Robert Kern
Thomas Nelson wrote: > Sorry if this is a FAQ, but I couldn't find a good summary through > google. What kinds of statistical analysis tools exist in python? The third hit for "python statistics" is a good overview of what's available: http://www.astro.cornell.edu/staff/loredo/statpy/ > I >

statistical analysis tools in python?

2006-07-12 Thread Thomas Nelson
Sorry if this is a FAQ, but I couldn't find a good summary through google. What kinds of statistical analysis tools exist in python? I really just need t-tests, chi-squared test, and other such tests of statistical significance. A few things point to numpy and scipy, but I was surprised to find

stderr, stdout, and errno 24

2006-07-12 Thread Wesley Henwood
To capture output from python scripts run from a C++ app I've added the following code at the beggening of the C++ app: PyRun_SimpleString("import grabber"); PyRun_SimpleString("import sys"); PyRun_SimpleString("class a:\n\tdef write(self,s):\n\t\tograbber.grab(s)\n"); PyRun_SimpleString("import s

Re: Execute Commands on Remote Computers over Network

2006-07-12 Thread dylpkls91
I'm sorry, I should have clarified. I want to execute commands on networked computers running Windows XP. Thank you for you concern anyway. Does this mean that the Paramiko module only works on Unix systems? -- http://mail.python.org/mailman/listinfo/python-list

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread kdotsky
> depending on your application, a bloom filter might be a good enough: > > http://en.wikipedia.org/wiki/Bloom_filter > Thanks (everyone) for the comments. I like the idea of the bloom filter or using an md5 hash, since a rare collision will not be a show-stopper in my case. -- http://mail

Re: What is a type error?

2006-07-12 Thread David Hopwood
Marshall wrote: > Joachim Durchholz wrote: [...] >>Preconditions/postconditions can express anything you want, and they are >>an absolutely natural extensions of what's commonly called a type >>(actually the more powerful type systems have quite a broad overlap with >>assertions). >>I'd essentially

Re: Inheritance error: class Foo has no attribute "bar"

2006-07-12 Thread [EMAIL PROTECTED]
I checked my code today and your suggestion did fix the problem. I used your second idea of having the default class attributes with individual instance attributes. I ran into one problem where I kept getting the error " File "\\user1\jacksocl\Python_stuff\CMRPG\CharCreation.py", line 262, in __

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Paul Rubin
[EMAIL PROTECTED] writes: > do it this way am I going to get the memory savings I am after? Will > the hash function always generate unique keys? Also, would the same > technique work for a set? A hash function that always generates unique hashes is called a perfect hash. They tend to be slow,

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Diez B. Roggisch
Please don't top post. I had to fix that below. >>> Any other thoughts or considerations are appreciated. >> You could try and create a md5 sum of your strings and use that as key. It >> _should_ be good enough, but I'm no crypto expert so take that with a grain >> of salt. > It should be enoug

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Fredrik Lundh
Nick Vatamaniuc wrote: > I never said there will be no collisions. For clarity, can you quote > the exact phrase where I mentioned that? the text I quoted is only true if you can guarantee that there will be no collisions. -- http://mail.python.org/mailman/listinfo/python-list

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
Fred, I never said there will be no collisions. For clarity, can you quote the exact phrase where I mentioned that? To say that there will be no collision is nonsense because the # of possible long url strings is certainly larger than 2^32, applying the pigeon hole principle you could easily show

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
Skip, I agree. Some kind of a manifest or log file would be great and probably not that hard to implement. Nick [EMAIL PROTECTED] wrote: > Nick> Uninstall support is hard, you would turn distutils (setup.py) > Nick> into a package management system, but wait...! there are already > Nick>

Re: Determining if an object is a class?

2006-07-12 Thread Clay Culver
Ahh much better. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Determining if an object is a class?

2006-07-12 Thread infidel
>>> import types >>> class OldStyle: pass ... >>> type(OldStyle) == types.ClassType True -- http://mail.python.org/mailman/listinfo/python-list

Determining if an object is a class?

2006-07-12 Thread Clay_Culver
I need to find out if an object is a class. Using new style classes this is very easy: class Test(object): pass obj = Test or obj = Test() if type(obj) == type: # this is a class object.. else: # this not a class object But this fails for old style classes. For example: class OldS

Re: Generating all ordered substrings of a string

2006-07-12 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, > I want to generate all non-empty substrings of a string of length >=2. > Also, > each substring is to be paired with 'string - substring' part and vice > versa. > Thus, ['abc'] gives me [['a', 'bc'], ['bc', 'a'], ['ab', 'c'], ['c', > 'ab'], ['b', 'ac'], ['ac', 'b

Re: How to delete a Python package

2006-07-12 Thread Jack
I'd second Skip's point. Now that setup.py does install, and it knows what to uninstall (because it copied the files in the first place) I think it's a good idea to have "setup.py uninstall" support. :) <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >Nick> Uninstall support i

Re: What is a type error?

2006-07-12 Thread Darren New
Joachim Durchholz wrote: > Actually, in a functional programming language (FPL), you write just the > postconditions and let the compiler generate the code for you. Certainly. And my point is that the postcondition describing "all valid chess boards reachable from this one" is pretty much going

Re: How to delete a Python package

2006-07-12 Thread skip
Nick> Uninstall support is hard, you would turn distutils (setup.py) Nick> into a package management system, but wait...! there are already Nick> package managers that do exactly that (rpm, deb, Windows Nick> Installer). Note that I don't really care about uninstall support, cert

Re: What is a type error?

2006-07-12 Thread Joachim Durchholz
Darren New schrieb: > There are also problems with the complexity of things. Imagine a > chess-playing game trying to describe the "generate moves" routine. > Precondition: An input board with a valid configuration of chess pieces. > Postcondition: An array of boards with possible next moves for

Re: What is a type error?

2006-07-12 Thread Joachim Durchholz
Marshall schrieb: > Joachim Durchholz wrote: >> Marshall schrieb: >>> I can see the lack of a formal model being an issue, but is the >>> imperative bit really all that much of an obstacle? How hard >>> is it really to deal with assignment? Or does the issue have >>> more to do with pointers, alias

Re: Compiling Python using the Portland Group compiler

2006-07-12 Thread Nick Vatamaniuc
Konrad, I would try to find out if pgcc has any compatibility switches. I saw you turned optimization "off" but sometimes there is more you can do disable some of the advanced behind the scenes magic. So apply all those switches, run the tests and then try them one by one to find out how many you

Re: scipy

2006-07-12 Thread Terry Reedy
"Aage Andersen" <[EMAIL PROTECTED] (REMOVE)> wrote in message news:[EMAIL PROTECTED] >I am exploring the modules scipy and linalg using python under Win XP and >IDLE. [...] > Comments welcome. scipy questions are best discussed on the scipy list. -- http://mail.python.org/mailman/listinfo/

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
Skip, Uninstall support is hard, you would turn distutils (setup.py) into a package management system, but wait...! there are already package managers that do exactly that (rpm, deb, Windows Installer). If no distro installer package is available for your Python module -- build it yourself and w

Re: scipy

2006-07-12 Thread Robert Kern
Aage Andersen wrote: > I am exploring the modules scipy and linalg using python under Win XP and > IDLE. > > Defining m=matrix( .. ) and trying to compute the inverse of m: > inverse(m) > > I get an array: > array( .. ) > > This is unfortunate. I would rather have a matrix returned

Re: testing array of logicals

2006-07-12 Thread Gary Herron
John Henry wrote: > Hi list, > > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test > > -- > Thanks, > > The builtin "reduce" does that kind of thing for any function you wish to apply across the

Re: testing array of logicals

2006-07-12 Thread Ant
John Henry wrote: > Hi list, > > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test There's reduce, but it's not as explicit, and see F's post RE efficiency: >>> x = [True, True, True] >>> y = [Tr

Re: testing array of logicals

2006-07-12 Thread Stefan Behnel
John Henry wrote: > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test Py2.5: test = all( logflags ) Py2.4 (although somewhat ugly): try: test = itertools.ifilterfalse( logflags ).next()

Re: testing array of logicals

2006-07-12 Thread Fredrik Lundh
John Henry wrote: > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test your code checks all members, even if the first one's false. that's not very elegant. here's a better way to do it:

Re: How to display name of elements in list?

2006-07-12 Thread [EMAIL PROTECTED]
Pretty sure he meant 1.5.1. Found the documentation for the program he's using here: http://www.hpcu.uq.edu.au/Manuals/MSC/msc/docs/marc/python/python_manual.pdf It looks like the PyTensor object *should* have .xx, .xy, etc properties, but they may be accessible through a matrix, i.e. .t(i,j) -

Re: PDF with nonLatin-1 characters

2006-07-12 Thread Stefan Behnel
victor wrote: > I want to generate a report and the PDF fits perfectly. Though there is > an issue of using different encoding in the doc. I tried PyPS with no > success. I need a lib that can make PDFs with an arbitrary set of fonts > (possibly embed them into the document). What would you suggest

Re: What is a type error?

2006-07-12 Thread Marshall
Joachim Durchholz wrote: > Marshall schrieb: > > I can see the lack of a formal model being an issue, but is the > > imperative bit really all that much of an obstacle? How hard > > is it really to deal with assignment? Or does the issue have > > more to do with pointers, aliasing, etc.? > > Actual

testing array of logicals

2006-07-12 Thread John Henry
Hi list, Is there a more elagant way of doing this? # logflags is an array of logicals test=True for x in logflags: test = test and x print test -- Thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all ordered substrings of a string

2006-07-12 Thread Thorsten Kampe
* [EMAIL PROTECTED] (2006-07-11 10:20 +) > I want to generate all non-empty substrings of a string of length >=2. > Also, > each substring is to be paired with 'string - substring' part and vice > versa. > Thus, ['abc'] gives me [['a', 'bc'], ['bc', 'a'], ['ab', 'c'], ['c', > 'ab'], ['b', 'ac

Re: What is a type error?

2006-07-12 Thread Joachim Durchholz
Marshall schrieb: > So, what exactly separates a precondition from a postcondition > from an invariant? I have always imagined that one writes > assertions on parameters and return values, and those > assertions that only reference parameters were preconditions > and those which also referenced ret

scipy

2006-07-12 Thread Aage Andersen
I am exploring the modules scipy and linalg using python under Win XP and IDLE. Defining m=matrix( .. ) and trying to compute the inverse of m: >>> inverse(m) I get an array: >>>array( .. ) This is unfortunate. I would rather have a matrix returned as the rules for manipulating matrices and

Re: What is a type error?

2006-07-12 Thread Joachim Durchholz
Marshall schrieb: > I can see the lack of a formal model being an issue, but is the > imperative bit really all that much of an obstacle? How hard > is it really to deal with assignment? Or does the issue have > more to do with pointers, aliasing, etc.? Actually aliasing is *the* hard issue. Just

Re: Advice for Python Reporting Tool

2006-07-12 Thread Mike Kent
rwboley wrote: > My question is: how can I make that graphing step easier? Ideally I'd > like the chart to exist on it's own page, but I have no idea where to > even begin to implement this. Any thoughts would be appreciated. I've seen several people recommend matplotlib for this kind of thing.

Re: Editing File

2006-07-12 Thread D
Thanks to all for the suggestions - I am going to give them a try this afternoon. I am still fairly new to Python, so this will definitely be a good learning experience. :) Maric Michaud wrote: > Le mercredi 12 juillet 2006 17:00, D a écrit : > > Thanks, guys. So overall, would it just be easier

Advice for Python Reporting Tool

2006-07-12 Thread rwboley
I'm currently learning my way through Python and in the process developing a reporting tool for the company I'm working for. Basically the tool rips through an existing .XML file to grab the information needed and spits it out in a nicely formated html page that is easily read by anyone. This par

Re: What is a type error?

2006-07-12 Thread Darren New
Marshall wrote: > So, what exactly separates a precondition from a postcondition > from an invariant? A precondition applies to a routine/method/function and states the conditions under which a function might be called. For example, a precondition on "stack.pop" might be "not stack.empty", and

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Tim Chase
> how come you're so sure that there will never be any collisions ? because none of his strings want their insurance to go up... :*) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Fredrik Lundh
Nick Vatamaniuc wrote: > If you don't really want to store the keys, just use > dic[hash(key)]=value, this way the dictionary will have the same shape > and distribution of keys as dic[key]=value because > hash('abc')=hash(hash('abc')) but the long string of actual keys are > not referenced by th

Re: threading troubles

2006-07-12 Thread sreekant
Oh dear. For the time being I will leave it with fork and leave it at that. Ta sree > You may be missing nothing. If I recall correctly a similar problem was > once reported on the pygtk-list. Some investigation showed that some > programs couldn't be reliably run from a thread, using os.system.

Re: How to delete a Python package

2006-07-12 Thread skip
>> As a rule, if you use a Linux distribution, you should just install >> the package and then remove the package using the package manager. Grant> That's fine except a lot of python packages aren't available in Grant> any of the various Linux distro package formats. And one or t

Re: first book about python

2006-07-12 Thread gregarican
Once you are ready to take the plunge another good document is the Python tutorial written by Guido Von Rossum himself (http://docs.python.org/tut/). It's not a full fledged 300 page manifesto but it's covers the basic of the language. IOANNIS MANOLOUDIS wrote: > I guess it's better to wait for th

Re: How to delete a Python package

2006-07-12 Thread Grant Edwards
On 2006-07-12, Nick Vatamaniuc <[EMAIL PROTECTED]> wrote: >> Installing a Python package is easy, most of time just >> "Setup.py install" However, setup.py doesn't seem to support >> an uninstall command. If I want to delete a package that I >> do not use any more, should I just manually delete th

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
Jack, As a rule, if you use a Linux distribution, you should just install the package and then remove the package using the package manager. Distutils uninstallation is not supported. Of course you could manually delete the directory in site-packages in most, but not all (!) cases, that should re

Re: PDF with nonLatin-1 characters

2006-07-12 Thread Nick Vatamaniuc
victor, Have you tried Reportlab ( http://www.reportlab.org/rl_toolkit.html )? That sounds like what you might need. -Nick Vatamaniuc victor wrote: > I want to generate a report and the PDF fits perfectly. Though there is > an issue of using different encoding in the doc. I tried PyPS with no >

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
Dictionaries are hash tables in Python. If you don't really want to store the keys, just use dic[hash(key)]=value, this way the dictionary will have the same shape and distribution of keys as dic[key]=value because hash('abc')=hash(hash('abc')) but the long string of actual keys are not reference

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
It should be enough but it might be a little slower than hash(string). Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > > > Hello, > > I am using some very large dictionaries with keys that are long strings > > (urls). For a large dictionary these keys start to take up a > > significant amoun

Re: check type when assignment

2006-07-12 Thread Nick Vatamaniuc
pipe, In general it is not possible in one line. You have to do it before hand or after with an if statement. As a sidenote though you probably shouldn't use isinstance(), you might need it less than you think you do, especially if you are using it to check for some interface. For example, do you

Re: What is a type error?

2006-07-12 Thread Marshall
Joachim Durchholz wrote: > Marshall schrieb: > > > I can certainly see how DbC would be useful without subtyping. > > But would there still be a reason to separate preconditions > > from postconditions? I've never been clear on the point > > of differentiating them (beyond the fact that one's covar

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello, > I am using some very large dictionaries with keys that are long strings > (urls). For a large dictionary these keys start to take up a > significant amount of memory. I do not need access to these keys -- I > only need to be able to retrieve the value associat

PDF with nonLatin-1 characters

2006-07-12 Thread victor
I want to generate a report and the PDF fits perfectly. Though there is an issue of using different encoding in the doc. I tried PyPS with no success. I need a lib that can make PDFs with an arbitrary set of fonts (possibly embed them into the document). What would you suggest? -- http://mail.

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I just realized that of course the hash is not always going to be > unique, so this wouldn't really work. And it seems a hash table would > still need to store the keys (as strings) so that string comparisons > can be done when a collision occurs. btw, Python's diction

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Will the hash function always generate unique keys? no. hash() is designed for dictionaries (hash tables), not for use as a cryptographic hash. depending on your application, a bloom filter might be a good enough: http://en.wikipedia.org/wiki/Bloom_filter (see

Re: What is a type error?

2006-07-12 Thread Marshall
Joachim Durchholz wrote: > Darren New schrieb: > > As far as I understand it, Eiffel compilers don't even make use of > > postconditions to optimize code or eliminate run-time checks (like null > > pointer testing). > > That's correct. > > I think a large part of the reasons why this isn't done is

How to delete a Python package

2006-07-12 Thread Jack
Installing a Python package is easy, most of time just "Setup.py install" However, setup.py doesn't seem to support an uninstall command. If I want to delete a package that I do not use any more, should I just manually delete the corresponding sub directory under Lib\site-packages? -- http://ma

Re: Sets and Membership Tests

2006-07-12 Thread Nick Vatamaniuc
JK, As a general rule, let Python call the "magic" __method__ methods behind the scenes. So don't call obj.__hash()__ or obj.__len__ or obj.__le__ just use hash(obj), len(obj) or <=. Of course there are exceptions, for example when calling the __init__() method of a supercalass inside the __init__

Re: check type when assignment

2006-07-12 Thread Bruno Desthuilliers
Diez B. Roggisch wrote: > pipehappy wrote: > > >>Hello everyone: >> >>Is there a way to check the type when do assignment? >> >>if I write: >>ab = bc >>and want to make sure the return value of isinstance(bc, klass) is True >>or I will raise >>a exception. > > > In general, not doable. The assi

Re: Data access from multiple code modules

2006-07-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Jeremy Jones wrote: > > >>What does main.py do? Are you creating an instance of the gui thingy? >>If so, you could just pass DataObject into your gui thingy either into >>the constructor or to a setter once you create an instance of it. > > > It's a wxPython app. I c

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread kdotsky
[EMAIL PROTECTED] wrote: > Hello, > I am using some very large dictionaries with keys that are long strings > (urls). For a large dictionary these keys start to take up a > significant amount of memory. I do not need access to these keys -- I > only need to be able to retrieve the value associate

Re: Multi-threaded FTP Question

2006-07-12 Thread dbandler
Thanks so much for your help on this. The server that I'm connecting to is the culprit. They only allow five connections at a time. I assumed that it was a code issue. I think that we're conditioned to expect that the problem is on the software side of things. -Derek [EMAIL PROTECTED] wrote:

Re: Editing File

2006-07-12 Thread Maric Michaud
Le mercredi 12 juillet 2006 17:00, D a écrit : > Thanks, guys. So overall, would it just be easier (and not too rigged) > if any changes were made by just editing the text file? I want to do > this project the right way, but if it's going to be a big pain to > implement the edit function, just mo

Re: Editing File

2006-07-12 Thread Tal Einat
akameswaran gmail.com gmail.com> writes: > > > D wrote: > > Thanks, guys. So overall, would it just be easier (and not too rigged) > > if any changes were made by just editing the text file? [snip] > have you used pickle? if the data is as simple as you say it is, you > will be able to read

Re: How to display name of elements in list?

2006-07-12 Thread Diez B. Roggisch
> rlcompleter is overrated, and only works on Unix/Linux/etc. > > IDLE's interpreter has an auto-completion extension, which is bundled in > Python2.5. I don't use idle, and don't want to. So for me rlcomlpeter2 is a good thing. And under windows, it at least works under cygwin. Diez -- http:/

Re: check type when assignment

2006-07-12 Thread Diez B. Roggisch
pipehappy wrote: > Hello everyone: > > Is there a way to check the type when do assignment? > > if I write: > ab = bc > and want to make sure the return value of isinstance(bc, klass) is True > or I will raise > a exception. In general, not doable. The assignment operator is not overloadable.

don't need dictionary's keys - hash table?

2006-07-12 Thread kdotsky
Hello, I am using some very large dictionaries with keys that are long strings (urls). For a large dictionary these keys start to take up a significant amount of memory. I do not need access to these keys -- I only need to be able to retrieve the value associated with a certain key, so I do not w

Re: check type when assignment

2006-07-12 Thread Tal Einat
pipehappy gmail.com> writes: > > Hello everyone: > > Is there a way to check the type when do assignment? > > if I write: > ab = bc > and want to make sure the return value of isinstance(bc, klass) is True > or I will raise > a exception. > > Any suggestion? > 1. Check your condition before

Re: timeit module for comparing the performance of two scripts

2006-07-12 Thread Georg Brandl
3c273 wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> You appear to know what a switch is. I'm therefore surprised that you >> appear not to >> know that the convention is that any program that uses >> command-line switches should do something informative whe

Re: Data access from multiple code modules

2006-07-12 Thread Jeremy Jones
[EMAIL PROTECTED] wrote: > Doh! How simple. Why didn't I think of that? I'm too used to procedural > scripts where you'd just put everything in a global data structure. I > know this is bad, but it's hard to get out of that mentality. Sounds like you got it. Just pass it on down as needed. -

Re: Editing File

2006-07-12 Thread Jeremy Jones
D wrote: > Thanks, guys. So overall, would it just be easier (and not too rigged) > if any changes were made by just editing the text file? I want to do > [EMAIL PROTECTED] wrote: > > Might be overkill - but pickle the data memeber that contains the > > information. If you use text inste

Re: How to display name of elements in list?

2006-07-12 Thread Tal Einat
Diez B. Roggisch nospam.web.de> writes: > > What you should do is to install rlcompleter2... [snip] > > Another option is to look into the source of that module and identify the > objects created. Documentation is overrated - use the source, Luke! rlcompleter is overrated, and only works on Uni

check type when assignment

2006-07-12 Thread pipehappy
Hello everyone: Is there a way to check the type when do assignment? if I write: ab = bc and want to make sure the return value of isinstance(bc, klass) is True or I will raise a exception. Any suggestion? -- http://mail.python.org/mailman/listinfo/python-list

Re: Editing File

2006-07-12 Thread [EMAIL PROTECTED]
D wrote: > Thanks, guys. So overall, would it just be easier (and not too rigged) > if any changes were made by just editing the text file? I want to do > this project the right way, but if it's going to be a big pain to > implement the edit function, just modifying the text file directly > isn'

Re: Editing File

2006-07-12 Thread D
Thanks, guys. So overall, would it just be easier (and not too rigged) if any changes were made by just editing the text file? I want to do this project the right way, but if it's going to be a big pain to implement the edit function, just modifying the text file directly isn't that big of a deal

  1   2   >