Re: Sets and Membership Tests

2006-07-12 Thread Nick Vatamaniuc
JK, You are correct to implement __hash__ and __eq__. The problem is how you implemented them. Usually your __eq__ method should compare the necessary attributes of the objects for equality. The __hash__ should return a 32-bit integer. Your best bet is probably to return a hash of hashes of your a

Re: Object Persistence Using a File System

2006-07-12 Thread Nick Vatamaniuc
Chris, Interesting concept. But why is there a need for a human readable object persistence that is x10 slower than pickle? In other words present a good use case with a rationale (i.e. your "criteria" that you mentioned). The only one I can think of so far is debugging. Also some objects are inh

Re: hash() yields different results for different platforms

2006-07-12 Thread Nick Vatamaniuc
Using Python's hash as column in the table might not be a good idea. You just found out why. So you could instead just use the base url and create an index based on that so next time just quickly get all urls from same base address then do a linear search for a specific one, or even easier, impleme

Re: Object Persistence Using a File System

2006-07-12 Thread Nick Vatamaniuc
Good point about isinstance. Here is a good explanation why: http://www.canonical.org/~kragen/isinstance/ Also the frozenset should be added the list of immutable types. Nick Vatamaniuc Bruno Desthuilliers wrote: > Chris Spencer wrote: > > Before I get too carried away with somethi

Re: Sets and Membership Tests

2006-07-12 Thread Nick Vatamaniuc
know to be unique.) > > The "no luck" situation was that a set would accept the same object > multiple times, not recognizing that it was truly the same object. > > > Nick Vatamaniuc wrote: > > JK, > > > > You are correct to implement __hash__ and __eq__

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: 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: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
ng of actual keys are not referenced by the dictionary. Now you couldn't do dic.keys() and see your urls, and every time you want to do dic['abc'] you would get a KeyError exception. Hope this helps, Nick Vatamaniuc [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Hello,

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 w

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
remove all the files of the package. Nick Vatamaniuc Jack 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, sh

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: 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: 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: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
e=dic[hash(urlstring]]. Hopefully this make my point more clear, Nick V. Fredrik Lundh wrote: > 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 distrib

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

2006-07-12 Thread Nick Vatamaniuc
;>> hash(hash(hash(('abc' -1600925533 >>> - Of course then hash(0)=0, hash(1)=0 and also hash(2**32)=1, all this in standard CPython on IA32. Nick Vatamaniuc Ganesan Rajagopal wrote: > >>>>> "Terry" == Terry Hancock <[EMAI

Re: Determining if an object is a class?

2006-07-13 Thread Nick Vatamaniuc
Clay, Search Google for it. Here is one good explanation with code examples by Michael Fotsch: http://www.geocities.com/foetsch/python/new_style_classes.htm Nick V. placid wrote: > [EMAIL PROTECTED] wrote: > > I need to find out if an object is a class. Using new style classes > > this is very e

{} for set notation

2006-07-14 Thread Nick Vatamaniuc
been secondary in traditional programming languages. For simplicity in implementation arrays and lists have been used to mimic a set. Now that Python has a built in set it only makes sense to give it its own notation and maybe Python 3000 is just the right time for it. - Nick Vatamaniuc [EMAIL

Re: EuroPython 2006 and Py3.0

2006-07-14 Thread Nick Vatamaniuc
> The real problems with the Py3k list seem to be associated with a number > of people who, despite having had little apparent connection to the > language until now, have joined the list and started making > inappropriate suggestions, which then have to be (patiently) rejected. Steve, What does

Re: {} for set notation

2006-07-14 Thread Nick Vatamaniuc
7;d be surprised how many people would more likely to use than if they had to type set([...]). Regards, Nick Vatamaniuc tac-tics wrote: > Nick Vatamaniuc wrote: > > I really like the set notation idea. Now that sets are first class > > "citizens" along with dicts, lists a

Re: EuroPython 2006 and Py3.0

2006-07-14 Thread Nick Vatamaniuc
That is why we have PEPs and people who read forums and, of course, GvR. At this point it seems that Python is mainstream enough that it probably shouldn't be modified too much but it is also 'fresh' enough to accept some modifications and new ideas. The bottom line is that the more people are in

dict = no ordered keys = no slicing

2006-07-14 Thread Nick Vatamaniuc
e-order or post-order so how does slicing fit in there. Hope this helps, Nick Vatamaniuc Antoon Pardon wrote: > On 2006-07-14, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: > > Antoon Pardon <[EMAIL PROTECTED]> wrote: > > > >> These are just some ideas. Whether

Re: instances

2006-07-14 Thread Nick Vatamaniuc
very rare exceptions you don't even need to know about it (I don't even know what its parameters are, because in all these years I have never had to use it). Hope this helps, I assumed you are a new Python user that is why I presented a simplistic example. Please see some Python tutorials an

Re: reading specific lines of a file

2006-07-15 Thread Nick Vatamaniuc
;t be able to jump to line 15000 without reading lines 0-14999. You can either iterate over the rows by yourself or simply use the 'linecache' module like shown above. If I were you I would use the linecache, but of course you don't mention anything about the context of your project

Re: Capturing instant messages

2006-07-18 Thread Nick Vatamaniuc
idea from above won't work too well, you will have to capture all the traffic then decode each stream, for each side, for each protocol. 3) Recording or replay is easy. Save to files or dump to a MySQL table indexed by user id, timestamp, IP etc. Because of buffering issues you will probably

Re: question about what lamda does

2006-07-18 Thread Nick Vatamaniuc
Use it anywhere a quick definition of a function is needed that can be written as an expression. For example when a callback function is needed you could say: def callback(x,y): return x*y some_function(when_done_call_this=callback) But with lambda you could just write some_function(when_done_cal

Re: Dictionary question

2006-07-18 Thread Nick Vatamaniuc
Brian, You can try the setdefault method of the dictionary. For a dictionary D the setdefault work like this: D.setdefault(k, defvalue). If k not in D then D[k] is set to defvalue and defvalue is returned. For example: In [1]: d={} In [2]: d.setdefault(1,5) Out[2]:5 In [3]: d Out[3]:{1: 5} In y

Re: Cyclic class definations

2006-07-18 Thread Nick Vatamaniuc
John, Cycles are tricky. Python is an interpreted dynamic language, whatever object you instantiate in your methods is a different thing than class hierarchy. Your class hierarchy is fine: ClassA->ClassASubclass->ClassC and it should work. If it doesn't, create a quick mock example and post it alo

Re: Dispatch with multiple inheritance

2006-07-18 Thread Nick Vatamaniuc
Michael, You only need to call the __init__ method of the superclass if you need to do something special during initialization. In general I just use the SuperClass.__init__(self,...) way of calling the super class constructors. This way, I only initialize the immediate parents and they will in tur

Re: Capturing instant messages

2006-07-18 Thread Nick Vatamaniuc
Assuming a one person per one machine per one chat protocol it might be possible to recreate the tcp streams (a lot of packet capturing devices already do that). So the gateway would have to have some kind of a dispatch that would recognize the initialization of a chat loggon and start a capture pr

Re: No need to close file?

2006-07-18 Thread Nick Vatamaniuc
I think file object should be closed whether they will be garbage collected or not. The same goes for DB and network connections and so on. Of course in simple short programs they don't have to, but if someone keeps 1000 open files it might be better to close them when done. Besides open files (

Re: Should this be added to MySQLdb FAQ?

2006-07-18 Thread Nick Vatamaniuc
gmax2006, Yes, perhaps the MySQLdb project should mention that packages are usually available in the popular distributions. I am using Ubuntu and everything I needed for MySQL and Python was in the repositories , 'apt-get' one-lines is all that is needed. In general though, I found that more often

Re: Authentication

2006-07-18 Thread Nick Vatamaniuc
ject print msg.source I tried it before and it didn't work, it said login failed. Perhaps it will work for you. Looking at the source is always a GoodThing (especially if you give your password to a program you just downloaded as an input...). Nick Va

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
(...) #override some methods ... and so on. Of course I am not familiar with your problem in depth all this might not work for you, just use common sense. Hope this helps, Nick Vatamaniuc [EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a n

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
Dave, Python properties allow you to get rid of methods like c.getAttr(), c.setAttr(v), c.delAttr() and replace them with simple constructs like c.attr, c.attr=v and del c.attr. If you have been using Java or C++ you know that as soon as you code your class you have to start filling in the get()

Re: Warning when new attributes are added to classes at run time

2006-07-20 Thread Nick Vatamaniuc
Use __slots__ they will simply give you an error. But at the same time I don't think they are inheritable and in general you should only use slots for performance reasons (even then test before using). Or you could also simulate a __slots__ mechanism the way you are doing i.e. checking the attribu

Re: Using python code from Java?

2006-07-20 Thread Nick Vatamaniuc
I can't think of any project that does that. Calling stuff from Java is not easy to beging with you have to go through the native interface (JNI) anyway. I would suggest instead to create some kind of a protocol and let the applications talk using an external channel (a FIFO pipe file, a socket or

Re: using names before they're defined

2006-07-22 Thread Nick Vatamaniuc
Dave, Sometimes generating classes from .ini or XML files is not the best way. You are just translating one language into another and are making bigger headaches for your self. It is certainly cool and bragable to say that "my classes get generated on the fly from XML" but Python is terse and rea

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Nick Vatamaniuc
than using isinstance to check if it is of a partucular type. You are doing things 'the pythonic way' ;) Nick Vatamaniuc Tim N. van der Leeuw wrote: > Hi, > > I'd like to know if there's a way to check if an object is a sequence, > or an iterable. Something l

Re: httplib, threading, wx app freezing after 4 hours

2006-07-22 Thread Nick Vatamaniuc
and issue a warning. Also check the memory on your machine in case some buffer fills the memory up and the machine gets stuck. To understand what's really happening try to debug the program. Try Winpdb debugger you can find it here: http://www.digitalpeers.com/pythondebugger/ Nick Vatamaniuc

Re: BeautifulSoup to get string inner 'p' and 'a' tags

2006-07-24 Thread Nick Vatamaniuc
Quick-n-dirty way: After you get your whole p string: FOO Remove any tags delimited by '<' and '>' with a regex. In your short example you _don't_ show that there might be something between the and tags so I assume there won't be anything or if there would be something then you also want it i

Re: dicts vs classes

2006-07-25 Thread Nick Vatamaniuc
Don't optimize prematurely. Write whatever is cleaner, simpler and makes more sense. Such that if someone (or even yourself) looks at it 10 years from now they'll know exactly what is going on. As far as what is slower or what functionality you will use and what you won't -- well, if you won't us

Re: Missing rotor module

2006-07-25 Thread Nick Vatamaniuc
Unfortunately rotor has been deprecated but it hasn't been replaced with anything reasonable as far as encryption goes -- there are just a bunch of hashing funtions (sha, md5) only. If you need to replace rotor all together I would sugest the crypto library from: http://www.amk.ca/python/code/cryp

Re: how best to check a value? (if/else or try/except?)

2006-07-27 Thread Nick Vatamaniuc
tuff because f is callable... except TypeError: pass # ... if f is not callable, then I don't care... But of course it is much shorter to do: if callable(f): #...do stuff because f is callable... Hope this helps, Nick Vatamaniuc John Salerno wrote: > My code is below. The main

Re: Fastest Way To Loop Through Every Pixel

2006-07-27 Thread Nick Vatamaniuc
Hello Chaos, Whatever you do in "#Actions here ..." might be expressed nicely as a ufunction for numeric. Then you might be able to convert the expression to a numeric expression. Check out numpy/scipy. In general, if thisHeight, thisWidth are large use xrange not range. range() generates a list

Re: Threads vs Processes

2006-07-27 Thread Nick Vatamaniuc
It seems that both ways are here to stay. If one was so much inferior and problem-prone, we won't be talking about it now, it would have been forgotten on the same shelf with a stack of punch cards. The rule of thumb is 'the right tool for the right job.' Threading model is very useful for long C

Re: War chest for writing web apps in Python?

2006-07-28 Thread Nick Vatamaniuc
, PyGTK, PyQT and so on. In general though, the time spent learning how to design a gui with a designer could probably be used to just write the code yourself in Python (now for Java or C++ it is a different story... -- you can start a war over this ;-) Hope this helps, Nick Vatamaniuc Vi

Re: Comma is not always OK in the argument list?!

2006-07-28 Thread Nick Vatamaniuc
axError: invalid syntax >>> f(*[1,2]) >>> f(*[1,2],) File "", line 1 f(*[1,2],) ^ SyntaxError: invalid syntax >>> f(**{'a':1,'b':2}) >>> f(**{'a':1,'b':2},) File "", line 1 f(**{'a':1,'b':2},)

Re: Newbie..Needs Help

2006-07-28 Thread Nick Vatamaniuc
Your description is too general. The way to 'collect the results' depends largely in what format the results are. If they are in an html table you will have to parse the html data if they are in a simple plaintext you might use a different method, and if the site renders the numbers to images and a

Re: Comma is not always OK in the argument list?!

2006-07-28 Thread Nick Vatamaniuc
True, that is why it behaves the way it does, but which way is the correct way? i.e. does the code need updating or the documentation? -Nick V. [EMAIL PROTECTED] wrote: > Nick Vatamaniuc wrote: > > Roman, > > > > According to the Python call syntax definition > >

Re: Newbie..Needs Help

2006-07-28 Thread Nick Vatamaniuc
Graham, I won't write the program for you since I have my own program to work on but here is an idea how to do it. 1) Need to have a function to download the page -- use the urllib module. Like this: import urllib page=urllib.urlopen(URL_GOES_HERE).read() 2) Go to the page with your browser and v

Re: Newbie..Needs Help

2006-07-28 Thread Nick Vatamaniuc
What do you mean? The html table is right there (at least in Firefox it is...). I'll paste it in too. Just need to isolate with some simple regexes and extract the text... Nick V. --- #

Re: War chest for writing web apps in Python?

2006-07-28 Thread Nick Vatamaniuc
Aptitude, are you still using that? Just use Synaptic on Ubuntu. The problem as I wrote in my post before is that for some IDEs you don't just download an executable but because they are written for Linux first, on Windows you have to search and install a lot of helper libraries that often takes q

Re: Comma is not always OK in the argument list?!

2006-07-29 Thread Nick Vatamaniuc
you shoud be the one submitting the bug report! Here is PEP 3 page with the guidelines for bug reporting: http://www.python.org/dev/peps/pep-0003/ Just mark it as a very low priority since it is more of a cosmetic bug than a serious showstopper. -Nick V Roman Susi wrote: > Nick Vatamaniuc wr

Re: Comma is not always OK in the argument list?!

2006-07-29 Thread Nick Vatamaniuc
ctic_ consistency, as opposed to 'a surprise'. As in t=(1,2,3,) f(1,2,3,) f(1,*[2,3],) and f(1,*[2],**{'c':3},) should all be 'OK'. Perhaps more Python core developers would comment... Nick Vatamaniuc Dennis Lee Bieber wrote: > On 29 Jul 2006 07:26:57 -0700

Re: War chest for writing web apps in Python?

2006-07-29 Thread Nick Vatamaniuc
#x27;s Python Editor wrote: > Nick Vatamaniuc schreef: > > > I found Komodo to > > be too slow on my machine, SPE was also slow, was crashing on me and > > had strange gui issues, > > I hope you didn't install SPE from the MOTU repositories with synaptic > o

Re: Convert string to mathematical function

2006-08-01 Thread Nick Vatamaniuc
54529656e+68 >>> a**N 150130937545296572356771972164254457814047970568738777235893533016064L >>> #now call the function again. no compilation this time, the result was >>> cached! >>> ans=weave.inline(c_code, ['a','N'], support_code=includes) >>

Re: Programming newbie coming from Ruby: a few Python questions

2006-08-01 Thread Nick Vatamaniuc
For a tutorial try the Python Tutorial @ http://docs.python.org/tut/ For a book try "Learning Python" from O'Reilly Press For reference try the Python library reference @ http://docs.python.org/lib/lib.html For another good book try "Dive Into Python" @ http://diveintopython.org/ It is a book

Re: Is there an obvious way to do this in python?

2006-08-02 Thread Nick Vatamaniuc
atabase, but you probably know this already... Hope this helps, Nick Vatamaniuc H J van Rooyen wrote: > Hi, > > I want to write a small system that is transaction based. > > I want to split the GUI front end data entry away from the file handling and > record keeping. > > Now

Re: Is there an obvious way to do this in python?

2006-08-03 Thread Nick Vatamaniuc
but not in the case of a user desktop. Hope this helps, Nick Vatamaniuc H J van Rooyen wrote: > "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote: > > > |H J van Rooyen a écrit : > |> Hi, > |> > |> I want to write a small system that is transaction base

Re: Is there an obvious way to do this in python?

2006-08-03 Thread Nick Vatamaniuc
rypy, Turbogears and others). If your GUI will be more complicated in the future, just stick with what you know (Tkinter for example). Good luck, Nick Vatamaniuc H J van Rooyen wrote: > "Nick Vatamaniuc" <[EMAIL PROTECTED]> wrote: > > > |HJ, > | > |As far as

Re: Everything is a distributed object

2006-10-10 Thread Nick Vatamaniuc
See here: http://wiki.python.org/moin/DistributedProgramming -Nick V. Martin Drautzburg wrote: > Hello all, > > I've seen various attempts to add distributed computing capabilities on top > of an existing language. For a true distributed system I would expect it to > be possible to instantiate o

Re: Python component model

2006-10-10 Thread Nick Vatamaniuc
Edward Diener No Spam wrote: > Michael wrote: > > Edward Diener No Spam wrote: > > > >> Has there ever been, or is there presently anybody, in the Python > >> developer community who sees the same need and is working toward that > >> goal of a common component model in Python, blessed and encourag

Re: Python component model

2006-10-10 Thread Nick Vatamaniuc
Edward Diener No Spam wrote: > Nick Vatamaniuc wrote: > > Edward Diener No Spam wrote: > >> Michael wrote: > > > > Python does not _need_ a component model just as you don't _need_ a RAD > > IDE tool to write Python code. The reason for having a componen

Re: Reverse function python? How to use?

2006-10-29 Thread Nick Vatamaniuc
ts in a list then apply reverse() on it. Hope this helps, Nick Vatamaniuc frankie_85 wrote: > Ok I'm really lost (I'm new to python) how to use the reverse function. > > > I made a little program which basically the a, b, c, d, e which I have > listed below and basic

Re: Observation on "Core Python Programming"

2006-10-29 Thread Nick Vatamaniuc
should be right there with the integers, strings, files, lists and dictionaries. Another important point to stress, in my opinion, is that functions are first-class objects. In other words functions can be passes around just like strings and numbers! -Nick Vatamaniuc John Coleman wrote: > Greet

Re: Event driven server that wastes CPU when threaded doesn't

2006-10-29 Thread Nick Vatamaniuc
Snor, The simplest solution is to change your system and put the DB on the same machine thus greatly reducing the time it takes for each DB query to complete (avoid the TCP stack completely). This way you might not have to change your application logic. If that is not an option, then you are fac

Re: Observation on "Core Python Programming"

2006-10-29 Thread Nick Vatamaniuc
t; off with functional programming the last few years (mostly SML) and am > interested in seeing the extend to which Python is genuinely > "multi-paradigm" - able to blend the functional and imperative (and OO) > paradigms together. > > -John Coleman > > Nick Vatamaniuc

Re: Observation on "Core Python Programming"

2006-10-29 Thread Nick Vatamaniuc
? Have you read it from beginning to end. What did you think about functions being introduced later than files and exceptions? -Nick V. Fredrik Lundh wrote: > Nick Vatamaniuc wrote: > > > I would consider that an omission. Functions are very important in > > Python. I think the

Re: Event driven server that wastes CPU when threaded doesn't

2006-10-29 Thread Nick Vatamaniuc
Try the --skip-networking option for mysqld Paul Rubin wrote: > "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes: > > The simplest solution is to change your system and put the DB on the > > same machine thus greatly reducing the time it takes for each DB query >

Re: Event driven server that wastes CPU when threaded doesn't

2006-10-29 Thread Nick Vatamaniuc
Good point. enterprise.adbapi is designed to solve the problem. The other interface was deprecated. Thanks, Nick Vatamaniuc Jean-Paul Calderone wrote: > On 29 Oct 2006 13:13:32 -0800, Nick Vatamaniuc <[EMAIL PROTECTED]> wrote: > >Snor wrote: > >> I'm attempting to

Open Source?

2006-10-29 Thread Nick Vatamaniuc
You can always start with open source. Find a project that you really like based on Python, and get involved -- look at the source, create add-ons, fix bugs. This way you get to learn, and you get to contribute and help others out as well. After a while you will have under your belt and perhaps i

Re: scared about refrences...

2006-10-30 Thread Nick Vatamaniuc
I think you are afraid of references because you are not trusting your own code. You are afraid it will do "magic" behind the scenes and mess everything up. One way around that is to simply write better code and test often. If everything was copied when passed around it would be pretty awful -- i

Re: checking if a sqlite connection and/or cursor is still open?

2006-10-30 Thread Nick Vatamaniuc
I am not familiar with SQLite driver, but a typical Pythonic way to check if you can do something is to just try it, and see what happens. In more practical terms: try to just use the cursor or the connection and see if an exception will be raised. Nick V. John Salerno wrote: > John Salerno wr

Re: NEWBIE: Script help needed

2006-11-05 Thread Nick Vatamaniuc
If the other commands work but 3) doesn't, it means there is something different (wrong?) with the command. So try running 3) , then one of the other ones and see the difference. The getCommandOutput() , I suspect, just waits for the data from the actual command and the command is not returnin

Re: Finding Nonzero Elements in a Sparse Matrix

2006-11-07 Thread Nick Vatamaniuc
ments flatnonzero() returns the non-zero elements of the flattened version of the array. Cheers, Nick Vatamaniuc deLenn wrote: > Hi, > > Does scipy have an equivalent to Matlab's 'find' function, to list the > indices of all nonzero elements in a sparse matrix? > > Cheers. -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding Nonzero Elements in a Sparse Matrix

2006-11-07 Thread Nick Vatamaniuc
A[2,0]=-10 >>> print A (1, 2)10 (2, 0)-10 >>> The only way it could be helpful is if you get a lil_matrix returned as an object from some code and you need to list all the elements... Hope this helps, Nick Vatamaniuc deLenn

Re: unpickling Set as set

2006-11-07 Thread Nick Vatamaniuc
The two are not of the same type: - In : import sets In : s1=sets.Set([1,2,3]) In : s2=set([1,2,3]) In: type(s1) Out: In : type(s2) Out: In : s1==s2 Out: False # oops! In: s2==set(s1) Out: True # aha! -- You'll have to ju

Re: PDF to text script

2006-11-10 Thread Nick Vatamaniuc
Vyz wrote: > I am looking for a PDF to text script. I am working with multibyte > language PDFs on Windows Xp. I need to batch convert them to text and > feed into an encoding converter program > > Thanks for any help in this regard Multibyte languages are not easy. I do text extraction from PDF

Re: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-01 Thread Nick Vatamaniuc
> 1 - golden handcuffs. Breaking old code is bad 90% of the time I agree with you on that, mostly for code that counted on list methods of result of keys() - like you later show with sort. But there is a side note: old code that assumed a particular ordering of the keys or values is broken any

Re: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-01 Thread Nick Vatamaniuc
You are correct I should have thought of that. I still think the keys() method should return a set() though. Robert Kern wrote: > [EMAIL PROTECTED] wrote: > > The same thing goes for the values(). Here most people will argue that > > values are not necessarily unique, so a list is more appropriate

Re: wxPython and Linux dependencies

2006-07-06 Thread Nick Vatamaniuc
"cannot get it to work." is pretty broad, you are more likely to get help if you post an error message or any other details. [EMAIL PROTECTED] wrote: > Hi, > > I wrote a small app using wxPython on a Linux distro called Ubuntu (it > is a debain derivative). I ran it on windows and it just worked >

Re: wxPython and Linux dependencies

2006-07-06 Thread Nick Vatamaniuc
John, To see where Python is looking for libraries open an interactive Python prompt and type >>> import sys >>> print sys.path You will get a list of paths where Python will look for modules. Also check to see if you have the PYTHONPATH environment variable set. If /usr/lib is not in the path list

Re: best split tokens?

2006-09-08 Thread Nick Vatamaniuc
It depends on the language as it was suggested, and it also depends on how a token is defined. Can it have dashes, underscores, numbers and stuff? This will also determine what the whitespace will be. Then the two main methods of doing the splitting is to either cut based on whitespace (specify w

Re: Building Python Based Web Application

2006-09-09 Thread Nick Vatamaniuc
The most modest way is to use pure Python and interface via CGI with the web. I would start there. As you code you will find yourself saying "I wonder if a framework is out there that already has automated this specific process (say templating)?", well then you can search and find such a framework

How about assignment to True and False...

2006-09-23 Thread Nick Vatamaniuc
Perhaps it will be addressed in 3.0... I hope True and False could become keywords eventually. That would stop silliness like: - In [1]: False=True In [2]: not False Out[2]: False In [3]: False Out[3]: True - Nick V. John Roth wrote: > Saizan wrote: >

Re: grabbing random words

2006-09-23 Thread Nick Vatamaniuc
Jay, Your problem is specific to a particular internet dictionary provider. UNLESS 1) The dictionary page has some specific link that gets you a random word, OR 2) after you click through a couple of word definitions you find in the URLs of the pages that the words are indexed usin

Re: Difficulty with maxsplit default value for str.split

2006-09-23 Thread Nick Vatamaniuc
f' code as - result=S.split(sep) if maxsplit is None else S.split(sep,maxsplit) ----- -Nick Vatamaniuc Steven D'Aprano wrote: > I'm having problems passing a default value to the maxsplit argument of > str.split. I'm trying to write a function which act

Re: Query regarding grep!!

2006-09-26 Thread Nick Vatamaniuc
Of course you can always use grep as an external process (if the OS has it). For example: --- In [1]: import subprocess In [2]: out=subprocess.Popen( 'grep -i blah ./tmp/*', stdout=subprocess.PIPE, shell=True ).communicate()[0] In [

Re: Logfile analysing with pyparsing

2006-09-26 Thread Nick Vatamaniuc
be fairly easy. Note: I am not familiar with the syntax of the mail log so I presented a general idea only. My assumptions about the syntax might have been wrong. Hope this helps, Nick Vatamaniuc Andi Clemens wrote: > Hi, > > we had some problems in the last weeks with our mailserver.

Re: analyzing removable media

2006-09-29 Thread Nick Vatamaniuc
glenn wrote: > Hi > can anyone tell me how given a directory or file path, I can > pythonically tell if that item is on 'removable media', or sometype of > vfs, the label of the media (or volume) and perhaps any other details > about the media itself? > thanks > Glenn It won't be trivial because

Re: wxPython and threading issue

2006-09-29 Thread Nick Vatamaniuc
If your thread is long running and it is not possible to easily set a flag for it to check and bail out, then how does it display the progress in the progress dialog. How often does that get updated? If the progress dialog is updated often, then at each update have the thread check a self.please_di

Re: vector and particle effects

2006-09-29 Thread Nick Vatamaniuc
Panda3D is pretty good http://www.panda3d.org/ . It is very well documented and it comes with many examples. There is also pygame. Jay wrote: > I'd like to experiment a little bit with vector graphics in python. > When I say 'vector graphics' I don't mean regular old svg-style. I > mean vecto

Re: How to query a function and get a list of expected parameters?

2006-09-29 Thread Nick Vatamaniuc
Matt, In [26]: inspect.getargspec(f) Out[26]: (['x1', 'x2'], None, None, None) For more see the inspect module. -Nick Vatamaniuc Matthew Wilson wrote: > I'm writing a function that accepts a function as an argument, and I > want to know to all the parameters t

Re: DAT file compilation

2006-09-29 Thread Nick Vatamaniuc
ou can use cPickle for a much faster pickle (but check out the constraints imposed by cPickle in the Python documentation). Hope this helps, -Nick Vatamaniuc Jay wrote: > Is there a way through python that I can take a few graphics and/or > sounds and combine them into a single .dat file?

Re: Block Diagram / digraph Editor

2006-09-29 Thread Nick Vatamaniuc
Tkinter is behind other modern GUI kits out there. Hope this helps, Nick Vatamaniuc MakaMaka wrote: > Hi, > Does anybody know of a good widget for wxpython, gtk, etc. that allows > the editing of block diagrams and make it easy to export the diagram as > a digraph? It has to be a

Re: Generating unique row ID ints.

2006-10-01 Thread Nick Vatamaniuc
mportant to realize that there will be some collision between the keys if the number of all possible digests (as limited by the digest algoritm) is smaller than the number of the possible messages. In practice if you have large enough integers (64) you shouldn't see any collisions occu

Re: switch user

2006-10-03 Thread Nick Vatamaniuc
user and group IDs, not with user and group names. Hope that helps, -Nick Vatamaniuc [EMAIL PROTECTED] wrote: > hi > > due to certain constraints, i will running a python script as root > inside this script, also due to some constraints, i need to switch user > to user1 to run the

Re: Finding skilled pythonistas for micro-jobs?

2006-11-19 Thread Nick Vatamaniuc
If you are agile it means that the developer is in constant communication with the user/client often changing and updating the requirements. The typical work that you specify though is not of that nature because it a list of specifications and then the coder implements it, and when done gets back

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Nick Vatamaniuc
The regular string split does not take a _class_ of characters as the separator, it only takes one separator. Your example suggests that you expect that _any_ of the characters "; ()[]" could be a separator. If you want to use a regular expression as a list of separators, then you need to use the s

Re: Properties on old-style classes actually work?

2007-05-07 Thread Nick Vatamaniuc
ork but as soon as you use the set property it fails and even 'get' won't work after that. It surely is deceiving, I wish it would just give an error or something. See below. -Nick Vatamaniuc >>> class O: : def __init__(self): : self._x=15

  1   2   >