Re: cPickle.dumps differs from Pickle.dumps; looks like a bug.

2007-05-16 Thread Nick Vatamaniuc
On May 16, 1:13 pm, Victor Kryukov <[EMAIL PROTECTED]> wrote: > Hello list, > > I've found the following strange behavior of cPickle. Do you think > it's a bug, or is it by design? > > Best regards, > Victor. > > from pickle import dumps > from cPickle import dumps as cdumps > > print dumps('100179

Re: cPickle.dumps differs from Pickle.dumps; looks like a bug.

2007-05-16 Thread Nick Vatamaniuc
ST 2007; root:xnu-792.18.15~1/RELEASE_I386 i386 i386 If you unpickle though will the results be the same? I suspect they will be. That should matter most of all (unless you plan to compare objects' identity based on their pickled version.) Remember, that by default pickle and cPickle will cr

Re: Splitting a string

2007-05-15 Thread Nick Vatamaniuc
selected : employee">''' >>> s '\'D132258\\\',\\\'\\\',\n\\ \'status=no,location=no,width=630,height=550,left=200,top=100\\ \')"\ntarget="_blank" class="dvLink" title="Send an Email to selected \nemp

Re: Sorting troubles

2007-05-14 Thread Nick Vatamaniuc
modified in place, create another wrapper function that calls your qsort and then will copy all data from the result into the original list and you are done. Something like: def qsort_in_place(L): sortedL=qsort(L) for (i,x) in enumerate(sortedL): L[i]=x Cheers, -Nick Vatamaniuc -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: module organisation

2007-05-14 Thread Nick Vatamaniuc
rsMesh(BaseMesh): def __init__(self,...): BaseMesh.__init__(self,...) etc. initializer... def refine(self,...): ...user's refine method would go here... -- So for each different refine() method the user can

Re: Setting thread priorities

2007-05-13 Thread Nick Vatamaniuc
riority value between 0.0 (the lowest) and up. Then look at the run trace and notice that on average the 0.75 priority thread is called more often than the 1.0 priority. Hope this helped, -Nick Vatamaniuc >>> from threading import Thread >>> from time import sleep

Re: PYDOC replacement. (Was:Sorting attributes by catagory)

2007-05-10 Thread Nick Vatamaniuc
On May 10, 1:28 am, Ron Adam <[EMAIL PROTECTED]> wrote: > Nick Vatamaniuc wrote: > > Ron, > > > Consider using epydoc if you can. Epydoc will sort the methods and it > > will also let you use custom CSS style sheets for the final HTML > > output. Check out the

Re: Sorting attributes by catagory

2007-05-09 Thread Nick Vatamaniuc
It seems I can get some of these fairly easy with the inspect module, but > others I need to test in multiple ways. > > Any ideas? > > Cheers, > Ron Ron, Consider using epydoc if you can. Epydoc will sort the methods and it will also let you use custom CSS style sheets for the final HT

Re: Questions about bsddb

2007-05-09 Thread Nick Vatamaniuc
-- and return an __iterator__. The iterator as a the result is excellent because you can iterate over results much larger than your virtual memory. But in the background PyDBTable will retrieve rows from the database in large batches and cache them as to o

Re: Questions about bsddb

2007-05-09 Thread Nick Vatamaniuc
ields. The result was that my disk I/ O was saturated (i.e. the application was running as fast as the hard drive would let it), so it was good enough for me. Hope this helps, -Nick Vatamaniuc -- http://mail.python.org/mailman/listinfo/python-list

Re: view workspace, like in MatLab ?

2007-05-09 Thread Nick Vatamaniuc
try: [var for var in dir() if not (var.startswith('_') or var=='var')] Example: --- >>> a=10 >>> b=20 >>> [var for var in dir() if not (var.startswith('_') or var=='var')] ['a', 'b'] >>> --- Hope that helps, Nick Vatamaniuc -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple regex match idiom

2007-05-09 Thread Nick Vatamaniuc
way to > write the above code? Hrvoje, To make it more elegant I would do this: 1. Put all the ...do somethings... in functions like re1_do_something(), re2_do_something(),... 2. Create a list of pairs of (re,func) in other words: dispatch=[ (re1, re1_do_something), (re2, re2_do_something), .

Re: How to make Python poll a PYTHON METHOD

2007-05-07 Thread Nick Vatamaniuc
On May 7, 10:42 pm, Nick Vatamaniuc <[EMAIL PROTECTED]> wrote: > On May 7, 10:07 pm, johnny <[EMAIL PROTECTED]> wrote: > > > Is there a way to call a function on a specified interval(seconds, > > milliseconds) every time, like polling user defined method? > >

Re: How to make Python poll a PYTHON METHOD

2007-05-07 Thread Nick Vatamaniuc
gt;> from threading import Timer >>> timer=Timer(5.0,baz) >>> timer.start() >>> Baz! >>> Cheers, -Nick Vatamaniuc -- http://mail.python.org/mailman/listinfo/python-list

Re: randomly write to a file

2007-05-07 Thread Nick Vatamaniuc
rest of the lines will have to be shifted to accommodate, the potentially larger new line. -Nick Vatamaniuc On May 7, 3:51 pm, rohit <[EMAIL PROTECTED]> wrote: > hi, > i am developing a desktop search.For the index of the files i have > developed an algorithm with which > i shou

Re: assisging multiple values to a element in dictionary

2007-05-07 Thread Nick Vatamaniuc
On May 7, 7:03 am, [EMAIL PROTECTED] wrote: > Hi, >I have a dictionary which is something like this: > id_lookup={ > 16:'subfunction', > 26:'dataId', > 34:'parameterId', > 39:'subfunction', > 44:'dataPackageId', > 45:'parameterId', > 54:'subfunction', > 59:'dataId', > 165:'subfunction', > 1

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

Re: urllib timeout issues

2007-03-27 Thread Nick Vatamaniuc
erver at a time so you still 'play nice' with each of the servers. If you want to have a max # of server threads running (in case you have way to many servers to deal with) then run batches of server threads. Hope this helps, Nick Vatamaniuc -- http://mail.python.org/mailman/listinfo/python-list

Re: Watching a file another app is writing

2007-03-11 Thread Nick Vatamaniuc
On Mar 11, 3:36 pm, Gordon Airporte <[EMAIL PROTECTED]> wrote: > I'm trying to find a way to take a file that another program has opened > and writes to periodically, open it simultaneously in Python, and > automatically update some of my objects in Python when the file is > written to. > I can ope

Re: Bitpacked Data

2007-03-11 Thread Nick Vatamaniuc
gt;>> #note > means big endian >>> packed '\xca\xfe' >>> #oh, wow it spells cafe! ;-) >>> #now unpack >>> unpacked=unpack('>H',packed) >>> unpacked (51966,) >>> odata=unpacked[0] >>> vars=[] >>> for

Re: Is numeric keys of Python's dictionary automatically sorted?

2007-03-07 Thread Nick Vatamaniuc
On Mar 7, 3:49 pm, "John" <[EMAIL PROTECTED]> wrote: > Then is there anyway to sort the numeric keys and avoid future implemetation > confusion? > > "Ant" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > On Mar 7, 8:18 pm, "John" <[EMAIL PROTECTED]> wrote: > > ... > >> However,

Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-05 Thread Nick Vatamaniuc
On Mar 5, 5:16 pm, "Alex Li" <[EMAIL PROTECTED]> wrote: > Hello, > > I would like to use Python 2.5 on Windows with Graphviz to generate > graphs. I used yapgvb but it only requires Python 2.4 (won't work > with Python 2.5). Other packages like pydot seems to be unmaintained > or requires custom

Re: Can Parallel Python run on a muti-CPU server ?

2007-02-07 Thread Nick Vatamaniuc
>From the www.parallelpython.com , the 'Features' section: Features: *Parallel execution of python code on SMP and clusters --- PP uses processes, and thus it will take advantage of multiple cores for a CPU bound task. -Nick On Feb 6

Re: Repr or Str ?

2007-02-06 Thread Nick Vatamaniuc
On Feb 6, 5:47 am, "Johny" <[EMAIL PROTECTED]> wrote: > Where and when is good/nescessary to use `repr` instead of `str` ? > Can you please explain the differences > Thanks > LL When you want to provide a representation of an object from which you can create another object if you had to. Use 'str

Re: Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Nick Vatamaniuc
-- >>> S=('a','b','d') >>> L=('alpha,'beta','delta') >>> f={} >>> for i in range(3): : f[S[i]]=L[i] : f[L[i]]=S[i] >>> f {'a': 'alpha',

Re: Best way to document Python code...

2007-01-24 Thread Nick Vatamaniuc
Epydoc is the way to go. You can even choose between various formating standards (including javadoc ) and customize the output using CSS. On Jan 22, 7:51 pm, "Stuart D. Gathman" <[EMAIL PROTECTED]> wrote: > On Mon, 22 Jan 2007 17:35:18 -0500, Stuart D. Gathman wrote: > > The HTML generated by py

Re: Tools Designing large/complicated applications

2007-01-12 Thread Nick Vatamaniuc
Carl, Some well known design applications have plugins for UML<->Python translation. For example EnterpriseArchitect (http://www.sparxsystems.com.au/resources/mdg_tech/) has a plugin for Python. ObjectDomain though supports it natively: http://www.objectdomain.com/products/od/overview.do The goo

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: 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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: 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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
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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

  1   2   >