Re: Dictionary from a list

2009-08-19 Thread Peter Otten
Jan Kaliszewski wrote: > 20-08-2009 o 02:05:57 Jan Kaliszewski wrote: > >> Or probably better: >> >> from itertools import islice, izip >> dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2))) > > Or similarly, perhaps more readable: > > iterator = iter(li) > dict((ite

Re: Setuptools - help!

2009-08-19 Thread ryles
On Aug 7, 3:04 pm, Peter Chant wrote: > Robert Kern wrote: > > You need to put main.py into the pphoto package. > > > $ mkdir pphoto/ > > $ mv main.py pphoto/ > > $ touch pphoto/__init__.py > > Thanks, it worked.  Any ideas how to run the resulting scripts without > installing or running as root?

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
On Aug 19, 11:34 pm, John Machin wrote: > On Aug 20, 12:12 pm, Simon Forman wrote: > > > On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > > > If you mean: to count non overlaping occurences of string A in B > > > -- simply: > > > >    B.count(A) > > > You don't want to use count() in a case like t

Re: starting selenium rc server from python code

2009-08-19 Thread Steven D'Aprano
On Wed, 19 Aug 2009 21:34:22 -0700, jo wrote: > Hi, > Is there anyway to start the selenium rc server within python code? How would you start the selenium rc server outside of Python code? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting DD MM YYYY into YYYY-MM-DD?

2009-08-19 Thread Mark Tolonen
"Gilles Ganault" wrote in message news:rtqk859vm3rkdfor0gd2u2pq5sftl8m...@4ax.com... I find it odd that the regex library can't handle European characters It can. Read the documentation about the re.LOCALE flag. -Mark -- http://mail.python.org/mailman/listinfo/python-list

starting selenium rc server from python code

2009-08-19 Thread jo
Hi, Is there anyway to start the selenium rc server within python code? Thank you Jo -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I convert an iterator over bytes into a str?

2009-08-19 Thread Steven D'Aprano
On Wed, 19 Aug 2009 20:04:12 -0700, alex23 wrote: > markscottwright wrote: >> Thanks Jan (and all other responders).  I suppose I shouldn't be >> surprised - it's a known wart (http://wiki.python.org/moin/ >> PythonWarts), but it just looks so darn wrong. > > Don't forget that it's exceptionally

Re: How to create functors?

2009-08-19 Thread Steven D'Aprano
On Wed, 19 Aug 2009 18:42:32 -0700, Paul Rubin wrote: > Robert Dailey writes: >> I want to simply wrap a function up into an object so it can be called >> with no parameters. > > Nitpick: what you are asking for is called a closure. "Functor" means > something completely different. I'm glad s

Re: Read C++ enum in python

2009-08-19 Thread Brian
pygccxml http://www.language-binding.net/pygccxml/pygccxml.html It uses gccxml to compile your source code into xml, and then makes all of your source code available to you via a high level and convenient query interface in python. On Tue, Aug 18, 2009 at 5:03 PM, Ludo < olivier.anospamrnospamnno

Re: basic thread question

2009-08-19 Thread Sean DiZazzo
On Aug 18, 4:58 pm, birdsong wrote: > On Aug 18, 3:18 pm, Derek Martin wrote: > > > > > On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote: > > > I have some simple threaded code...  If I run this > > > with an arg of 1 (start one thread), it pegs one cpu, as I would > > > expect.  If I

Re: Read C++ enum in python

2009-08-19 Thread Mark Tolonen
"Mark Tolonen" wrote in message news:h6g9ig$vh...@ger.gmane.org... [snip] This is what 3rd party library pyparsing is great for: begin code-- from pyparsing import * # sample string with enums and other stuff sample = ''' stuff before enum hello { Zero,

Re: #elements of seq A in seq B

2009-08-19 Thread John Machin
On Aug 20, 12:12 pm, Simon Forman wrote: > On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > > If you mean: to count non overlaping occurences of string A in B > > -- simply: > > >    B.count(A) > > You don't want to use count() in a case like this because it iterates > through B len(A) times, i.e.

IDLE is not as interactive as Maple

2009-08-19 Thread laser
In the future, will Python provide programe enviroment like Maple does? In Maple, you can remove anything unneeded in the editor. And the code execution order are not necessary in one direction. You can run any command line on the screen by push Enter key. These functions gave a lot of flaxibility

Re: #elements of seq A in seq B

2009-08-19 Thread Tomasz Rola
On Wed, 19 Aug 2009, Neal Becker wrote: > What would be a time efficient way to count the number of occurrences of > elements of sequence A in sequence B? (in this particular case, these > sequences are strings, if that matters). If A and B are rather lengthy, then maybe build a tree from elem

Re: How do I convert an iterator over bytes into a str?

2009-08-19 Thread alex23
markscottwright wrote: > Thanks Jan (and all other responders).  I suppose I shouldn't be > surprised - it's a known wart (http://wiki.python.org/moin/ > PythonWarts), but it just looks so darn wrong. Don't forget that it's exceptionally easy to create your own mechanism for doing this: def jo

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > 20-08-2009 o 01:19:24 Neal Becker wrote: > > > What would be a time efficient way to count the number of occurrences of > > elements of sequence A in sequence B?  (in this particular case, these > > sequences are strings, if that matters). > > If you

Re: Python and PHP encryption/decryption

2009-08-19 Thread Paul Rubin
Jean-Claude Neveu writes: > I'm working on a project that will require me to store some values in > a database in encrypted format. I'll be storing them from a PHP script > and retrieving them (decrypting them) using Python. I'm currently > using PHP's mcrypt package to encrypt the values, and I'm

Re: How to create functors?

2009-08-19 Thread Paul Rubin
Robert Dailey writes: > I want to simply wrap a function up into an object so it can be called > with no parameters. Nitpick: what you are asking for is called a closure. "Functor" means something completely different. As a few other people have explained, "print" in python 2.x is a statement

Re: python doc available in emacs info format?

2009-08-19 Thread Nathan Keel
A.Politz wrote: > On Aug 17, 6:43 am, Xah Lee wrote: >> btw, is there still [no] info format for python doc? >> >> i feel kinda sad [...] >> Part of this is due to [other peoples fault] > > Someone started a rst2info project (google it), maybe you want to help > this guy out. > > Though, he mig

Re: Identifying a class type - bad practice?

2009-08-19 Thread greg
James Harris wrote: I don't know yet whether it will be easier to modify the tree or to create a new one for each phase. You can create a new tree using this style as well. Just have each method create and return a new node instead of modifying the existing one. -- Greg -- http://mail.python.o

Re: Dictionary from a list

2009-08-19 Thread Jan Kaliszewski
20-08-2009 o 02:05:57 Jan Kaliszewski wrote: Or probably better: from itertools import islice, izip dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2))) Or similarly, perhaps more readable: iterator = iter(li) dict((iterator.next(), iterator.next()) for i in xrange(l

Re: #elements of seq A in seq B

2009-08-19 Thread Jan Kaliszewski
20-08-2009 o 01:19:24 Neal Becker wrote: What would be a time efficient way to count the number of occurrences of elements of sequence A in sequence B? (in this particular case, these sequences are strings, if that matters). If you mean: to count occurences of each element of A (separately)

Re: Dictionary from a list

2009-08-19 Thread Jan Kaliszewski
19-08-2009 o 22:52:54 iu2 wrote: On Aug 19, 11:39 pm, "Diez B. Roggisch" wrote: iu2 schrieb: > Hi all, > I need to create a dictionary out of a list. > Given the list [1, 2, 3, 4, 5, 6] > I need the dictionary: {1:2, 3:4, 5:6} dict(zip(l[::2], l[1::2])) Or (for long lists, when memory

Re: Barcodes

2009-08-19 Thread Ronn Ross
On Wed, Aug 19, 2009 at 9:19 AM, Ronn Ross wrote: > I was hoping that python would have a library to help me print my own bar > codes? We will need labels in all sizes and most label printer just work > with 1 or 2 sizes. I would like to just print a grid of different sizes on > standard paper. D

Re: What file is foo in package bar in ?

2009-08-19 Thread northof40
On Aug 20, 11:06 am, Christian Heimes wrote: > northof40 wrote: > > Given an arbitary package is there some programmatic way to 'ask' what > > file the method/function is implemented in ? > > Indeed, the inspect module contains several useful functions for the > job, for examplehttp://docs.python.

Re: difference between 2 arrays

2009-08-19 Thread Jan Kaliszewski
19-08-2009 o 10:56:20 <""Michel Claveau - MVP"> wrote: (envoyé via news:\\news.wanadoo.fr\comp.lang.python) Hi! See the module "sets" No, see the builtin set type. Module sets is deprecated (removed in Py 3.x) -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

#elements of seq A in seq B

2009-08-19 Thread Neal Becker
What would be a time efficient way to count the number of occurrences of elements of sequence A in sequence B? (in this particular case, these sequences are strings, if that matters). -- http://mail.python.org/mailman/listinfo/python-list

Re: What file is foo in package bar in ?

2009-08-19 Thread Christian Heimes
northof40 wrote: Given an arbitary package is there some programmatic way to 'ask' what file the method/function is implemented in ? Indeed, the inspect module contains several useful functions for the job, for example http://docs.python.org/library/inspect.html#inspect.getfile Christian --

Re: How to create functors?

2009-08-19 Thread J. Cliff Dyer
On Wed, 2009-08-19 at 15:56 +0200, Bruno Desthuilliers wrote: > Terry Reedy a écrit : > > Robert Dailey wrote: > > > >> I'm using Python 2.6. And using the legacy syntax in the lambda does > >> not work either. I want to avoid using a def if possible. Thanks. > > > > In Python, writing > > > > n

What file is foo in package bar in ?

2009-08-19 Thread northof40
Hi - I think this is a pretty basic question but it's never worried me before. To improve my skills I'm reading the source code of a library written by someone else. I've come across a problem doing that. Commonly a function is called like this: thepackage.theclass.foo The problem is that 'the

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: Simon Forman schrieb: On Aug 18, 7:33 pm, Allan wrote: Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it in a text fil

Re: Dictionary from a list

2009-08-19 Thread iu2
On Aug 19, 11:39 pm, "Diez B. Roggisch" wrote: > iu2 schrieb: > > > Hi all, > > > I need to create a dictionary out of a list. > > > Given the list [1, 2, 3, 4, 5, 6] > > > I need the dictionary: {1:2, 3:4, 5:6} > > dict(zip(l[::2], l[1::2])) > > Diez Wow, this is cool! thanks iu2 -- http://mai

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Simon Forman schrieb: On Aug 18, 7:33 pm, Allan wrote: Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it in a text file and I am so lost. Can an

Re: Python and PHP encryption/decryption

2009-08-19 Thread Diez B. Roggisch
Jean-Claude Neveu schrieb: I'm looking for a recommendation about encryption/decryption packages for Python. I'm working on a project that will require me to store some values in a database in encrypted format. I'll be storing them from a PHP script and retrieving them (decrypting them) using

Re: Dictionary from a list

2009-08-19 Thread Diez B. Roggisch
iu2 schrieb: Hi all, I need to create a dictionary out of a list. Given the list [1, 2, 3, 4, 5, 6] I need the dictionary: {1:2, 3:4, 5:6} dict(zip(l[::2], l[1::2])) Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Code formatting question: conditional expression

2009-08-19 Thread John Posner
Diez wrote: No. I love them. But not if they are so large that they stretch over several lines (or to many columns). foo = bar if cond else baz is more than fine for me. But foo = I_need_to_do_something_really_complicated_here() if cond else baz isn't, because one doesn't grasp as easily in

Dictionary from a list

2009-08-19 Thread iu2
Hi all, I need to create a dictionary out of a list. Given the list [1, 2, 3, 4, 5, 6] I need the dictionary: {1:2, 3:4, 5:6} I'll appreciate your help Thanks iu2 -- http://mail.python.org/mailman/listinfo/python-list

Re: python doc available in emacs info format?

2009-08-19 Thread A.Politz
On Aug 17, 6:43 am, Xah Lee wrote: > btw, is there still [no] info format for python doc? > > i feel kinda sad [...] > Part of this is due to [other peoples fault] Someone started a rst2info project (google it), maybe you want to help this guy out. Though, he might be a techgeeker, so watch out

Re: Any way to adjust difflib algorithm?

2009-08-19 Thread Grant Edwards
On 2009-08-19, Aahz wrote: > In article , > Grant Edwards wrote: >>On 2009-08-14, Grant Edwards wrote: >>> >>> In my particular usage, no lines have ever been >>> inserted/deleted, so perhaps I should be running diffs on >>> individual lines instead? If I do that, I can't figure out >>> how to

Re: NOOB: Developing using python on two different computers

2009-08-19 Thread Jonathan Gardner
On Aug 19, 6:50 am, Smeagol wrote: > Hi there, > > Occasionally I have to develop on two different computers, and I was > wondering if there was a way to copy the python "environment" from one > to the other? > > Access to the data is trivial (networked database) but various > packages etc exist o

Re: Any way to adjust difflib algorithm?

2009-08-19 Thread Aahz
In article , Grant Edwards wrote: >On 2009-08-14, Grant Edwards wrote: >> >> In my particular usage, no lines have ever been >> inserted/deleted, so perhaps I should be running diffs on >> individual lines instead? If I do that, I can't figure out >> how to generate HTML output. > >I ended up u

Python and PHP encryption/decryption

2009-08-19 Thread Jean-Claude Neveu
I'm looking for a recommendation about encryption/decryption packages for Python. I'm working on a project that will require me to store some values in a database in encrypted format. I'll be storing them from a PHP script and retrieving them (decrypting them) using Python. I'm currently usin

Re: generate keyboard/mouse event under windows

2009-08-19 Thread Ray
On Aug 19, 2:07 pm, yaka wrote: > Read this and see if it helps: > > http://kvance.livejournal.com/985732.html is there a way to generate a 'true' keyboard event? (works like user pressed a key on keyboard) not send the 'send keyboard event to application' ? -- http://mail.python.org/mailman/lis

Re: httplib incredibly slow :-(

2009-08-19 Thread Aahz
In article , Chris Withers wrote: >Aahz wrote: >> >> What do you need to know for a decent example? > >Simple download of a file from a url with some auth headers added would >do me. Well, I've hacked up some sample code from my company's codebase: # !!! UNTESTED !!! c = pycurl.Curl() c.setopt

Re: Need cleanup advice for multiline string

2009-08-19 Thread Simon Forman
On Aug 19, 12:05 am, Ben Finney wrote: > Simon Forman writes: > > On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney > > wrote: > > > We're all unified by our humanity. Bringing any god into the picture > > > is surely counter to any goals of unity. > > > Unity "in humanity" is, to my way of thinking,

Re: Database query execution times in Python?

2009-08-19 Thread Aahz
In article , pwnedd wrote: > >> Look up EXPLAIN > >Thanks for the suggestion. I don't see any option to have EXPLAIN display >the query time though? My suggestion was partly a gentle push toward a database forum to get more information -- this isn't really a Python question. Unless all you want

Re: recording input from USB port and write to text file

2009-08-19 Thread Simon Forman
On Aug 18, 7:33 pm, Allan wrote: > Hi! I'm fairly new to Python.  I understand the basics basics but I'm > been trying to write a simple python code that will let me read input > data (such as mouse movement) from my USB port and write it in a text > file and I am so lost.  Can anyone help or dire

Re: difference between 2 arrays

2009-08-19 Thread sturlamolden
On 19 Aug, 01:48, Pierre wrote: > Well, the equivalence of setdiff in matlab... That would be numpy.setdiff1d. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-19 Thread Aahz
In article , Jean-Michel Pichavant wrote: >MRAB wrote: >> Carl Banks wrote: >>> On Aug 17, 10:03 am, Jean-Michel Pichavant >>> wrote: I'm no English native, but I already heard women/men referring to a group as "guys", no matter that group gender configuration. It's even used

Re: How do I convert an iterator over bytes into a str?

2009-08-19 Thread markscottwright
On Aug 18, 6:52 pm, "Jan Kaliszewski" wrote: > 19-08-2009 o 00:24:20 markscottwright wrote: > > > What's the correct way to turn an iterator over bytes into a string? > > This works, but, ewww: > >     In [8]: "".join(iter("four score and seven years ago")) > >     Out[8]: 'four score and seven y

Re: difference between 2 arrays

2009-08-19 Thread Robert Kern
On 2009-08-19 01:48 AM, Pierre wrote: Hello, I would like to know how to find the difference (set operation) between 2 arrays : a = array([1,2, 3,2,5,2]) b = array([1,2]) I want a - b = [3,5] Well, the equivalence of setdiff in matlab... You will want to ask numpy questions on the numpy mail

Re: difference between 2 arrays

2009-08-19 Thread Diez B. Roggisch
baalu aanand wrote: > On Aug 19, 1:48 pm, Pierre wrote: >> Hello, >> >> I would like to know how to find the difference (set operation) >> between 2 arrays : >> >> a = array([1,2, 3,2,5,2]) >> b = array([1,2]) >> I want a - b = [3,5] >> >> Well, the equivalence of setdiff in matlab... >> >> I tho

Re: Read C++ enum in python

2009-08-19 Thread Ludo
Neil Hodgson a écrit : For some headers I tried it didn't work until the .* was changed to a non-greedy .*? to avoid removing from the start of the first comment to the end of the last comment. file_data = ' '.join(re.split(r'\/\*.*?\*\/', file_data)) Thank you ! I adopt it ! Cheers. -- h

Re: difference between 2 arrays

2009-08-19 Thread David Robinow
On Wed, Aug 19, 2009 at 4:48 AM, Pierre wrote: > Hello, > > I would like to know how to find the difference (set operation) > between 2 arrays : > > a = array([1,2, 3,2,5,2]) > b = array([1,2]) > I want a - b = [3,5] > > Well, the equivalence of setdiff in matlab... > > I thought a.difference(b) co

New message

2009-08-19 Thread La Vie Spirituelle
Test -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between 2 arrays

2009-08-19 Thread Matthias Huening
Pierre (19.08.2009 10:48): Hello, I would like to know how to find the difference (set operation) between 2 arrays : a = array([1,2, 3,2,5,2]) b = array([1,2]) I want a - b = [3,5] What about set()? >>> a = set([1,2, 3,2,5,2]) >>> b = set([1,2]) >>> a.difference(b) set([3, 5]) Matthias --

Re: difference between 2 arrays

2009-08-19 Thread baalu aanand
On Aug 19, 1:48 pm, Pierre wrote: > Hello, > > I would like to know how to find the difference (set operation) > between 2 arrays : > > a = array([1,2, 3,2,5,2]) > b = array([1,2]) > I want a - b = [3,5] > > Well, the equivalence of setdiff in matlab... > > I thought a.difference(b) could work, bu

Re: difference between 2 arrays

2009-08-19 Thread baalu aanand
On Aug 19, 1:48 pm, Pierre wrote: > Hello, > > I would like to know how to find the difference (set operation) > between 2 arrays : > > a = array([1,2, 3,2,5,2]) > b = array([1,2]) > I want a - b = [3,5] > > Well, the equivalence of setdiff in matlab... > > I thought a.difference(b) could work, bu

Re: Parallelization in Python 2.6

2009-08-19 Thread Grant Edwards
On 2009-08-19, Stefan Behnel wrote: > Dennis Lee Bieber wrote: >> If they are number crunchers (CPU-bound) and don't make use of >> binary extension libraries that release the GIL (for the most common >> Python implementation), they'll run faster being called in sequence >> since you won't h

Re: Help with libxml2dom

2009-08-19 Thread Paul Boddie
On 19 Aug, 13:55, Nuno Santos wrote: > I have just started using libxml2dom to read html files and I have some > questions I hope you guys can answer me. [...] >  >>> table = body.firstChild >  >>> table.nodeName > u'text' #?! Why!? Shouldn't it be a table? (1) You answer this yourself just bel

Re: difference between 2 arrays

2009-08-19 Thread John Machin
On Aug 19, 6:56 pm, "Michel Claveau - MVP" wrote: > See the module "sets" See especially the notice at the front of the current sets doc which says "deprecated since 2.6" and the comparison down the end which explains why the built-in set() and frozenset() are better than the sets module. Startin

Re: How to create functors?

2009-08-19 Thread Bruno Desthuilliers
Terry Reedy a écrit : Robert Dailey wrote: I'm using Python 2.6. And using the legacy syntax in the lambda does not work either. I want to avoid using a def if possible. Thanks. In Python, writing name = lambda arg: expr instead of def name(arg): return expr is all negative and no positiv

NOOB: Developing using python on two different computers

2009-08-19 Thread Smeagol
Hi there, Occasionally I have to develop on two different computers, and I was wondering if there was a way to copy the python "environment" from one to the other? Access to the data is trivial (networked database) but various packages etc exist on one computer, and I want to ensure I have everyt

Re: Code formatting question: conditional expression

2009-08-19 Thread Bruno Desthuilliers
Richard Brodie a écrit : "John Posner" wrote in message news:mailman.26.1250604346.2854.python-l...@python.org... if total > P.BASE: excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True) else: excessblk = None I wonder if it is appropriate to replace the None sen

Re: Subclass dynamically

2009-08-19 Thread Bruno Desthuilliers
Robert Dailey a écrit : Hey, I have a class that I want to have a different base class depending on a parameter that I pass to its __init__method. For example (pseudocode): class MyDerived( self.base ): def __init__( self, base ): self.base = base Something like that... and then I would

Re: Parallelization in Python 2.6

2009-08-19 Thread Neal Becker
sturlamolden wrote: > On 18 Aug, 11:41, Stefan Behnel wrote: > >> I think the canonical answer is to use the threading module or >> (preferably) the multiprocessing module, which is new in Py2.6. >> >> http://docs.python.org/library/threading.htmlhttp://docs.python.org/library/multiprocessing.h

Re: Converting DD MM YYYY into YYYY-MM-DD?

2009-08-19 Thread Gilles Ganault
I find it odd that the regex library can't handle European characters :-/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-19 Thread Grant Edwards
On 2009-08-19, Ben Finney wrote: > Simon Forman writes: >> We are one family. > > Agreed. That's not much comfort if you've seen the way many families get along with each other. -- Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-19 Thread Ben Finney
Simon Forman writes: > On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney wrote: > > We're all unified by our humanity. Bringing any god into the picture > > is surely counter to any goals of unity. > > Unity "in humanity" is, to my way of thinking, the same as Unity "in > God". Then you're playing Hum

Re: Need cleanup advice for multiline string

2009-08-19 Thread Ben Finney
Grant Edwards writes: > On 2009-08-19, Ben Finney wrote: > > Simon Forman writes: > >> We are one family. > > > > Agreed. > > That's not much comfort if you've seen the way many families get along > with each other. Demonstrable facts, by nature of being independently verifiable, are a better

Re: Scope and classes

2009-08-19 Thread Ben Finney
David writes: > Out of 'Abc.message' and 'self.message', which is the favoured > convention? It's not a matter of convention. They mean different things, so you use each depending on what you mean. > It would be very easy to accidentally override 'self.messages' with an > instance attribute! R

Re: Need cleanup advice for multiline string

2009-08-19 Thread Ben Finney
Jean-Michel Pichavant writes: > Anyway the hysteria that is surrounding this thread is just amazing. If the calm reproach that has been the maximum response so far seems like “hysteria” to you, I can only conclude you have only been using the internet for a few hours. -- \ “The fact

Re: Code formatting question: conditional expression

2009-08-19 Thread Diez B. Roggisch
> BTW, from the (admittedly few) responses to my original post, it seems > there's some sentiment that "conditional expressions" are a non-Pythonic > misfeature. Interesting ... No. I love them. But not if they are so large that they stretch over several lines (or to many columns). foo = bar if

Re: can't retrieve data from pyxml

2009-08-19 Thread Diez B. Roggisch
Sakib schrieb: well, i need to retrive data from the following line of xml. i need the Caption and the type data. is any one out there help me doing that? That's not XML. It lacks namespace-declarations. So no XML-parser will (or should) grok it. Also, to get help here it's better t

Re: Using a Callback Function - ftplib

2009-08-19 Thread seldan24
On Aug 18, 6:02 am, Nitebirdz wrote: > On Mon, Aug 17, 2009 at 11:10:25AM -0700, seldan24 wrote: > > > I didn't even notice the higher level methods.  I changed the > > retrieval line to: > > > ftp.nlst("testfile*.txt") > > > This works great.  The result is even captured in an array.  I really >

can't retrieve data from pyxml

2009-08-19 Thread Sakib
well, i need to retrive data from the following line of xml. i need the Caption and the type data. is any one out there help me doing that? thanks, Sakib -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between 2 arrays

2009-08-19 Thread Michel Claveau - MVP
Re ! Juste pour signaler qu'il existe un newsgroup en français sur Python, qui permet de recevoir des réponses en français (donc plus complètes/détaillées). @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing Python Opcodes

2009-08-19 Thread Peter Otten
Diez B. Roggisch wrote: > Sreejith K wrote: >> So I compiled Python from source changing some opcode values > Nobody > can be helping you there, because it's *your* code, not Python anymore. > And giving others access to it defies somewhat the purpose of the whole > exercise ...and everyon

Re: Need cleanup advice for multiline string

2009-08-19 Thread Carl Banks
On Aug 18, 8:49 pm, Ben Finney wrote: > Grant Edwards writes: > > On 2009-08-19, Ben Finney wrote: > > > Simon Forman writes: > > >> We are one family. > > > > Agreed. > > > That's not much comfort if you've seen the way many families get along > > with each other. > > Demonstrable facts, by na

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:27, Dave Angel wrote: > But if you do it that way, it's slower than sequential.  And if you have > a multi-core processor, or two processors, or ...   then it gets much > slower yet, and slows down other tasks as well. > > With the current GIL implementation, for two CPU-bound tasks

Re: Using a Callback Function - ftplib

2009-08-19 Thread nitebirdz
On Mon, Aug 17, 2009 at 11:10:25AM -0700, seldan24 wrote: > > I didn't even notice the higher level methods. I changed the > retrieval line to: > > ftp.nlst("testfile*.txt") > > This works great. The result is even captured in an array. I really > have no idea what the difference between a LI

listen and receive the stock price from a VPN

2009-08-19 Thread John Liu
Hi, My friends   I am trying a Pyhton script to connect a VPN with (IP address, user ID, and passwrod).   suppose I need to use Socket to connect the VPN and compare to a list of stock tickers I want to receive.   Is there any wasy way and fast way to do that?   Thanks so much in advance.   Kind

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 11:41, Stefan Behnel wrote: > I think the canonical answer is to use the threading module or (preferably) > the multiprocessing module, which is new in Py2.6. > > http://docs.python.org/library/threading.htmlhttp://docs.python.org/library/multiprocessing.html > > Both share a (mostly)

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:34, Hendrik van Rooyen wrote: > The GIL does apply - I was talking nonsense again.  Misread the OP's > intention. It depends on what the OP's functions "doStuff1" and "doStuff2" actually do. If they release the GIL (e.g. make I/O calls) it does not apply. The GIL only serialize acc

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:27, Dave Angel wrote: > With the current GIL implementation, for two CPU-bound tasks, you either > do them sequentially, or make a separate process. I'd also like to add that most compute-bound code should be delegated to specialized C libraries, many of which are prewritten. For e

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Piet van Oostrum wrote: >> Allan (A) wrote: > >>A> Hi! I'm fairly new to Python. I understand the basics basics but I'm >>A> been trying to write a simple python code that will let me read input >>A> data (such as mouse movement) from my USB port and write it in a text >>A> file and I am so

Re: Parallelization in Python 2.6

2009-08-19 Thread Hendrik van Rooyen
On Wednesday 19 August 2009 10:13:41 Paul Rubin wrote: > Hendrik van Rooyen writes: > > Just use thread then and thread.start_new_thread. > > It just works. > > The GIL doesn't apply to threads made like that?! The GIL does apply - I was talking nonsense again. Misread the OP's intention. - He

Re: Subclass dynamically

2009-08-19 Thread Piet van Oostrum
> Robert Dailey (RD) wrote: >RD> Hey, >RD> I have a class that I want to have a different base class depending on >RD> a parameter that I pass to its __init__method. For example >RD> (pseudocode): >RD> class MyDerived( self.base ): >RD> def __init__( self, base ): >RD> self.base = base

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:16, sturlamolden wrote: > You should know about the GIL. It prevents multiple threads form using > the Python interpreter simultaneously. For parallel computing, this is > a blessing and a curse. Only C extensions can release the GIL; this > includes I/0 routines in Python's standar

Re: recording input from USB port and write to text file

2009-08-19 Thread Piet van Oostrum
> Allan (A) wrote: >A> Hi! I'm fairly new to Python. I understand the basics basics but I'm >A> been trying to write a simple python code that will let me read input >A> data (such as mouse movement) from my USB port and write it in a text >A> file and I am so lost. Can anyone help or direc

Re: Help with libxml2dom

2009-08-19 Thread Diez B. Roggisch
Nuno Santos wrote: > I have just started using libxml2dom to read html files and I have some > questions I hope you guys can answer me. > > The page I am working on (teste.htm): > > > > Title > > > > > > > > > > >

Re: Parallelization in Python 2.6

2009-08-19 Thread Martin P. Hellwig
sturlamolden wrote: The human brain is bad at detecting computational bottlenecks though. So it almost always pays off to write everything in Python first, and use the profiler to locate the worst offenders. +1 QOTW -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoni

Re: Excel edit using python

2009-08-19 Thread Tim Wintle
On Wed, 2009-08-19 at 05:25 -0700, suman wrote: > > Is there any package to edit the existing excel cell data using python > or > to create excel charts using python Chris, Chris, where are you? http://www.python-excel.org/ Site provided by Chris Withers: http://mail.python.org/pipermail/py

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 13:45, Robert Dailey wrote: > Really, all I'm trying to do is the most trivial type of > parallelization. Take two functions, execute them in parallel. This > type of parallelization is called "embarrassingly parallel", and is > the simplest form. There are no dependencies between the

Excel edit using python

2009-08-19 Thread suman
Hi, Is there any package to edit the existing excel cell data using python or to create excel charts using python please help. Thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Parallelization in Python 2.6

2009-08-19 Thread Dave Angel
Hendrik van Rooyen wrote: On Tuesday 18 August 2009 22:45:38 Robert Dailey wrote: Really, all I'm trying to do is the most trivial type of parallelization. Take two functions, execute them in parallel. This type of parallelization is called "embarrassingly parallel", and is the simplest form

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 11:19, Robert Dailey wrote: > I'm looking for a way to parallelize my python script without using > typical threading primitives. For example, C++ has pthreads and TBB to > break things into "tasks". In C++, parallelization without "typical threading primitives" usually means one of t

About Python Symbian 60

2009-08-19 Thread Kannan
Hi friends I want a Python SDK like Netbeans to work with the Symbian 60 python. I don't have the Symbian 60 mobile.I create some Apps for S60 Platform.To execute that i want this Help me.. With regards, Kannan. R. P, -- http://mail.python.org/mailman/listinfo/python-list

Help with libxml2dom

2009-08-19 Thread Nuno Santos
I have just started using libxml2dom to read html files and I have some questions I hope you guys can answer me. The page I am working on (teste.htm): Title 8/15/2009 >>> import libxml2dom >>> foo

Re: reading a text file

2009-08-19 Thread Tino Wildenhain
superpollo wrote: hi clp what's the difference between: while True: input_line = sys.stdin.readline() if input_line: sys.stdout.write(input_line.upper()) else: break and: while True: try: sys.stdout.write(sys.stdin.next().upper()) e

  1   2   >