Re: Obtaining the attributes and properties of a folder recursively.

2009-03-21 Thread Tim Golden
venutaurus...@gmail.com wrote: On Mar 20, 6:58 pm, Tim Golden wrote: venutaurus...@gmail.com wrote: Thank you for your suggestion but.. I'll have around 1000 such files in the whole directory and it becomes hard to manage such output because again I've to take this snapshot before backing up t

Re: improve this newbie code/nested functions in Python?

2009-03-21 Thread Paul Hankin
On Mar 20, 3:21 am, Esmail wrote: > Hi, > > I'm new to writing Python code. This is a simple client I wrote, it > works, but I feel it doesn't look as clean as it could. Can anyone > make suggestions how to streamline this code? > > Also, I am using two nested functions, it seems that nested funct

Re: garbage collection / cyclic references

2009-03-21 Thread Aaron Brady
On Mar 20, 8:12 pm, "andrew cooke" wrote: > Aaron Brady wrote: > > [...] > > > caveats and fragilities?  If free software can do it, why isn't it all > > over the industry?  What disqualifies it from solved-problem status? > > the two dominant virtual machines - .net and the jvm both handle circul

Re: garbage collection / cyclic references

2009-03-21 Thread Martin v. Löwis
> The actual backend of CPython requires garbage-collected container > types to implement tp_inquiry and tp_clear methods, but user-defined > types apparently aren't required to conform. tp_inquiry doesn't exist, you probably mean tp_traverse. tp_traverse is completely irrelevant for python-define

Re: file.read() doesn't read the whole file

2009-03-21 Thread Sreejith K
The break and continue problem was actually my own mistake. I wrote no_blks = length/4096 + 1, so the loop actually executes twice. Sorry for my idiotic mistake But the read() problem still persists. Thanks.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining the attributes and properties of a folder recursively.

2009-03-21 Thread Tim Golden
venutaurus...@gmail.com wrote: Thank you Sir for your reply. It is working for me. But is failing if I have Unicode characters in my path. I tried giving a 'u' in front of the path but still it fails at f.createdat. Does it support Unicode Characters? This the traceback which I got while running

Is it possible to create a shortcut ?

2009-03-21 Thread Stef Mientki
I would like to make a shortcut for this: self.Brick.Par [ self.EP[0] ] = something like this: self.P[0] = is that possible, otherwise than by eval / exec ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: precision question

2009-03-21 Thread MRAB
Lada Kugis wrote: [snip] Normal integers are up to 10 digits, after which they become long integers, right ? But if integers can be exactly represented, then why do they need two types of integers (long and ... uhmm, let's say, normal). I mean, their error will always be zero, no matter what kin

Re: Is it possible to create a shortcut ?

2009-03-21 Thread Peter Otten
Stef Mientki wrote: > I would like to make a shortcut for this: > self.Brick.Par [ self.EP[0] ] = > > something like this: >self.P[0] = > > > is that possible, otherwise than by eval / exec ? class Brick(object): def __init__(self): self.Par = [1,2,3] class P(object):

Creating Linked Lists in Python

2009-03-21 Thread J-Burns
Hey thr, I need some help here actually. So i thought i could get it easily from here. I need to make a linked list that can do the following: 1) Point to multiple nodes at one time 2) Should have 2 values: a) The node no. b) The value of that node in reference to the next node that it i

Re: file.read() doesn't read the whole file

2009-03-21 Thread Steve Holden
Sreejith K wrote: > The break and continue problem was actually my own mistake. I wrote > no_blks = length/4096 + 1, so the loop actually executes twice. Sorry > for my idiotic mistake > That's good! > But the read() problem still persists. > Try and write an example that shows the probl

Re: Is it possible to create a shortcut ?

2009-03-21 Thread Steven D'Aprano
On Sat, 21 Mar 2009 11:55:04 +0100, Stef Mientki wrote: > I would like to make a shortcut for this: > self.Brick.Par [ self.EP[0] ] = That's a pretty ugly expression there. (Mind you, I've seen worse.) And a non-standard naming convention. I'm just sayin'. When you walk your dog, do you try

Re: improve this newbie code/nested functions in Python?

2009-03-21 Thread Esmail
Paul Hankin wrote: I would decouple the speaker and the listener from the client, and make the client interface more abstract. Simple and descriptive interfaces can make code dramatically easier to understand. class ClientListener(Thread): def __init__(self, client, ...): ... def ru

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
Paul Rubin wrote: > "andrew cooke" writes: >> the two dominant virtual machines - .net and the jvm both handle >> circular >> references with no problem whatever. > > AFAIK, they also don't guarantee that finalizers ever run, much less > run in deterministic order. i think you're right, but i'm m

Re: Creating Linked Lists in Python

2009-03-21 Thread John Machin
On Mar 21, 10:38 pm, J-Burns wrote: > Hey thr, > > I need some help here actually. So i thought i could get it easily > from here. > > I need to make a linked list that can do the following: > > 1) Point to multiple nodes at one time The term "linked list" is usually restricted to a collection of

Downloading binary files - Python3

2009-03-21 Thread Anders Eriksson
Hello, I have made a short program that given an url will download all referenced files on that url. It works, but I'm thinking it could use some optimization since it's very slow. I create a list of tuples where each tuple consist of the url to the file and the path to where I want to save it.

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
J-Burns wrote: > I need to make a linked list that can do the following: > > 1) Point to multiple nodes at one time > 2) Should have 2 values: > a) The node no. > b) The value of that node in reference to the next node that it is > pointing to > > For example, this means that there can be a

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
andrew cooke wrote: [...] i messed up my example; corrected below (I hope) > in your case you could use ints for the nodes and a dict([int]) for the > graph. so: > {1: [2,3], 2: [1,3], 3: [3]} > > is a graph in which 1 and 2 are connected in each direction, both 1 and 2 > are linked to 3, and 3

Re: Creating Linked Lists in Python

2009-03-21 Thread Aaron Brady
On Mar 21, 8:11 am, "andrew cooke" wrote: > J-Burns wrote: snip > > For example, this means that there can be a start node supposedly. > > Having a value of 0. It is pointing to node 1 with the value of "a" > > and to node 2 with the value of "b". Trying to make something like an > > NFA. Where id

script files with python (instead of tcsh/bash)?

2009-03-21 Thread Esmail
Hello all, I am wondering if anyone is using python to write script files? Right now I have a bigg'ish bash/tcsh script that contain some grep/awk command plus various files are processed and created, renamed and moved to specific directories. I also write out some gnuplot scripts that later get

R6034 -- 0.9.1 -- problems installing under XP

2009-03-21 Thread Esmail
I apologize if this is a duplicate, been having lots of problems posting to this group. --- Hello all, I am having problems trying installing iPython under XP. It works great under Linux and it would be great if I could also use it when I have to be in Windows. XP Professional SP2 + SP3 (tried

Re: Compiling modules in OSX, eg PyUSB?

2009-03-21 Thread Philip Semanchuk
On Mar 21, 2009, at 2:49 AM, Dr Mephesto wrote: On Mar 20, 6:23 pm, Philip Semanchuk wrote: So change line 32 in the PyUSB setup.py from this: extra_compile_args = ['-I/sw/include'] to this: extra_compile_args = ['-I/sw/include', '-I/usr/local/include'] The same assumption is made

Re: Creating Linked Lists in Python

2009-03-21 Thread Tim Chase
For example, this means that there can be a start node supposedly. Having a value of 0. It is pointing to node 1 with the value of "a" and to node 2 with the value of "b". Trying to make something like an NFA. Where id be changing regular expressions to NFAs. John has already pointed out the pre

Re: speech recognition help

2009-03-21 Thread Murali kumar
thanks for the reply.. now working on cmu sphinx project.. do u know which one 1. cmu sphinx 2. natural speaking 3. windows sapi is best ( in accuray and speed ) for predefined vocabulary.. and worth for learning as well.? -- http://mail.python.org/mailman/listinfo/python-list

(SORRY .. )Re: R6034 -- 0.9.1 -- problems installing under XP

2009-03-21 Thread Esmail
Argh .. sorry about this post I was trying to post to gmane.comp.python.ipython.user (but it's not working), this was an accident - I didn't mean to send it here (wrong screen). Sorry about this. Esmail -- http://mail.python.org/mailman/listinfo/python-list

[regex] How to check for non-space character?

2009-03-21 Thread Gilles Ganault
Hello Some of the adresses are missing a space between the streetname and the ZIP code, eg. "123 Main Street01159 Someville" The following regex doesn't seem to work: #Check for any non-space before a five-digit number re_bad_address = re.compile('([^\s].)(\d{5}) ',re.I | re.S | re.M) I also tr

Re: Is python worth learning as a second language?

2009-03-21 Thread Aahz
In article , Tomasz Rola wrote: >On Sat, 20 Mar 2009, Aahz wrote: >> >> Taking C++ and turning it into a VM model does not exactly strike me >> as particularly good use of resources. > >It doesn't strike me either. But resources are not the only dimension of >judging the language, you know. Yo

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Aahz
In article , Esmail wrote: > >I am wondering if anyone is using python to write script files? These days, I always convert any even slightly complicated script to Python. >I've looked around the web w/o much luck for some examples but come >short. Any comments/suggestions? Not sure what you're

Re: [regex] How to check for non-space character?

2009-03-21 Thread Tim Chase
Gilles Ganault wrote: Hello Some of the adresses are missing a space between the streetname and the ZIP code, eg. "123 Main Street01159 Someville" The following regex doesn't seem to work: #Check for any non-space before a five-digit number re_bad_address = re.compile('([^\s].)(\d{5}) ',re.I |

Re: argument problem in optparse

2009-03-21 Thread Neal Becker
Qian Xu wrote: > Hi All, > > I have a problem with OptParse. > I want to define such an arugument. It can accept additional value or no > value. > > "myscript.py --unittest File1,File2" > "myscript.py --unittest" > > Is it possible in OptParse? I have tried several combination. But ... > > >

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Esmail
Aahz wrote: In article , Esmail wrote: I am wondering if anyone is using python to write script files? These days, I always convert any even slightly complicated script to Python. well .. that sounds encouraging ... I've looked around the web w/o much luck for some examples but come shor

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Joe Riopel
On Sat, Mar 21, 2009 at 9:26 AM, Esmail wrote: > In any case, the scripts are starting to look pretty hairy and I was > wondering if it would make sense to re-write them in Python. I am not > sure how suitable it would be for this. Are these scripts run on computers that are guaranteed to have Py

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Esmail
Hi Joe, Joe Riopel wrote: Are these scripts run on computers that are guaranteed to have Python installed? If not, can you install Python on them? I use Python when I can, but sometimes shell scripts just makes sense. T Yes. Currently I am running the bash/tcsh scripts under Ubuntu. The scri

Re: speech recognition help

2009-03-21 Thread Tim Chase
do u know which one 1. cmu sphinx 2. natural speaking 3. windows sapi is best ( in accuray and speed ) for predefined vocabulary.. and worth for learning as well.? For a pre-defined vocabulary, they should all be pretty good. In general (for non-predefined vocabularies), I've heard that NS b

Re: speech recognition help

2009-03-21 Thread Tim Chase
Murali kumar wrote: thanks for the reply.. now working on cmu sphinx project.. do u know which one 1. cmu sphinx 2. natural speaking 3. windows sapi is best ( in accuray and speed ) ^^^ Typo of the week... -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: argument problem in optparse

2009-03-21 Thread Qian Xu
John O'Hagan wrote: > action="callback", > callback=my_callback it works perfect. You made my day and thank you both ^^) -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-21 Thread Aaron Brady
On Mar 21, 7:54 am, "andrew cooke" wrote: > Paul Rubin wrote: > > "andrew cooke" writes: > >> the two dominant virtual machines - .net and the jvm both handle > >> circular > >> references with no problem whatever. > > > AFAIK, they also don't guarantee that finalizers ever run, much less > > run

Re: [regex] How to check for non-space character?

2009-03-21 Thread John Machin
Gilles Ganault nospam.com> writes: > > Hello > > Some of the adresses are missing a space between the streetname and > the ZIP code, eg. "123 Main Street01159 Someville" This problem appears very similar to the one you had in a previous episode, where you were deleting in address contexts whe

Re: Downloading binary files - Python3

2009-03-21 Thread Matteo
> srcdata = urlopen(url).read() > dstfile = open(path,mode='wb') > dstfile.write(srcdata) > dstfile.close() > print("Done!") Have you tried reading all files first, then saving each one on the appropriate directory? It might work if you have enough memory, i

Re: Lambda forms and scoping

2009-03-21 Thread Márcio Faustino
On Mar 20, 12:28 pm, "R. David Murray" wrote: > Hope this helps.  I find that thinking in terms of namespaces helps > me understand how Python works better than any other mental model > I've come across. It does, thanks. On Mar 20, 12:41 pm, Michele Simionato wrote: > This post http://www.artim

Re: Creating Linked Lists in Python

2009-03-21 Thread Giuliano Vilela
I've done something similar on the past week, regarding RE's and NFA's: http://code.google.com/p/yaree/ The significant code is on re_fsa.py, on the svn repository. The implementation is also a dict, of the form: { Node -> { Character -> Set(Node) } }. That is, it is a mapping of Node's to a mappi

python php/html file upload issue

2009-03-21 Thread S.Selvam Siva
Hi all, I want to upload a file from python to php/html form using urllib2,and my code is below PYTHON CODE: import urllib import urllib2,sys,traceback url='http://localhost/index2.php' values={} f=open('addons.xcu','r') values['datafile']=f.read() #is this correct ? values['Submit']='True' data

Re: Downloading binary files - Python3

2009-03-21 Thread Peter Otten
Anders Eriksson wrote: > Hello, > > I have made a short program that given an url will download all referenced > files on that url. > > It works, but I'm thinking it could use some optimization since it's very > slow. > > I create a list of tuples where each tuple consist of the url to the file

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
Aaron Brady wrote: > On Mar 21, 7:54 am, "andrew cooke" wrote: >> they should not be used to do things like flushing and closing >> files, for example. > What is your basis for this claim, if it's not the mere unreliability > of finalization? IOW, are you not merely begging the question? I'm not

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
andrew cooke wrote: > Aaron Brady wrote: >> On Mar 21, 7:54 am, "andrew cooke" wrote: >>> they should not be used to do things like flushing and closing >>> files, for example. >> What is your basis for this claim, if it's not the mere unreliability >> of finalization? IOW, are you not merely beg

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread D'Arcy J.M. Cain
On Sat, 21 Mar 2009 09:26:02 -0400 Esmail wrote: > Hello all, > > I am wondering if anyone is using python to write script files? All the time. > Right now I have a bigg'ish bash/tcsh script that contain some grep/awk > command plus various files are processed and created, renamed and > moved t

How do I call the double() function?

2009-03-21 Thread grocery_stocker
Given the following def double(val): return val.bind(lambda x: val.return_(x*2)) I get "AttributeError: 'int' object has no attribute 'bind' " when I try to do the following double(2) Below is the output... [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.

Re: speech recognition help

2009-03-21 Thread Stef Mientki
Tim Chase wrote: do u know which one 1. cmu sphinx 2. natural speaking 3. windows sapi is best ( in accuray and speed ) for predefined vocabulary.. and worth for learning as well.? For a pre-defined vocabulary, they should all be pretty good. In general (for non-predefined vocabularies), I

Re: Tkinter book on current versions

2009-03-21 Thread W. eWatson
Paul Watson wrote: Has anyone tried the Grayson book, "Python and Tkinter Programming," with a recent version of Python? The first example code (calculator) generates a single row of buttons. Perhaps I have not applied the errata correctly. Has anyone been successful? I am using: Python 2.5.2

Re: How do I call the double() function?

2009-03-21 Thread John Machin
On Mar 22, 1:55 am, grocery_stocker wrote: > Given the following > > def double(val): >     return val.bind(lambda x: val.return_(x*2)) > > I get "AttributeError: 'int' object has no attribute 'bind' " when I > try to do the following > > double(2) > > Below is the output... > > [cdal...@local

Re: Downloading binary files - Python3

2009-03-21 Thread Stefan Behnel
Anders Eriksson wrote: > I have made a short program that given an url will download all referenced > files on that url. > > It works, but I'm thinking it could use some optimization since it's very > slow. What's slow about it? Is downloading each file slow, is it the overhead of connecting to t

Re: How to do this in Python?

2009-03-21 Thread Josh Holland
On Tue, Mar 17, 2009 at 08:00:51PM -0500, Jim Garrison wrote: > There's always some "trollish" behavior in any comp.lang.* > group. Too many people treat languages as religions instead > of tools. They all have strengths and weaknesses :-) If you're referring to my reply (about his pseudocode loo

Re: How do I call the double() function?

2009-03-21 Thread grocery_stocker
On Mar 21, 8:11 am, John Machin wrote: > On Mar 22, 1:55 am, grocery_stocker wrote: > > > > > Given the following > > > def double(val): > > return val.bind(lambda x: val.return_(x*2)) > > > I get "AttributeError: 'int' object has no attribute 'bind' " when I > > try to do the following >

Re: How do I call the double() function?

2009-03-21 Thread Kushal Kumaran
On Mar 21, 7:55 pm, grocery_stocker wrote: > Given the following > > def double(val): >     return val.bind(lambda x: val.return_(x*2)) > > I get "AttributeError: 'int' object has no attribute 'bind' " when I > try to do the following > > double(2) > > See the usage of the double function in

Re: How do I call the double() function?

2009-03-21 Thread grocery_stocker
On Mar 21, 8:21 am, Kushal Kumaran wrote: > On Mar 21, 7:55 pm, grocery_stocker wrote: > > > Given the following > > > def double(val): > > return val.bind(lambda x: val.return_(x*2)) > > > I get "AttributeError: 'int' object has no attribute 'bind' " when I > > try to do the following >

Re: garbage collection / cyclic references

2009-03-21 Thread Aaron Brady
On Mar 21, 9:50 am, "andrew cooke" wrote: > Aaron Brady wrote: > > On Mar 21, 7:54 am, "andrew cooke" wrote: > >> they should not be used to do things like flushing and closing > >> files, for example. > > What is your basis for this claim, if it's not the mere unreliability > > of finalization?

Re: Is it possible to create a shortcut ?

2009-03-21 Thread Stef Mientki
Steven D'Aprano wrote: On Sat, 21 Mar 2009 11:55:04 +0100, Stef Mientki wrote: I would like to make a shortcut for this: self.Brick.Par [ self.EP[0] ] = That's a pretty ugly expression there. (Mind you, I've seen worse.) And a non-standard naming convention. I'm just sayin'.

Re: meta question - how to read comp.lang.python w/o usenet feed/google interface?

2009-03-21 Thread kshitij
On Mar 21, 2:17 am, Esmail wrote: > Terry Reedy wrote: > > > Ditto, with T-bird. Just add a newsgroup account with news.gmane.org or > > snews.gmane.org (for ssl) as the server and set the rest as you please. > > > gmane.comp.python.general is a mirror of python-list, from python.org, > > with its

Re: How do I call the double() function?

2009-03-21 Thread John Machin
On Mar 22, 2:21 am, grocery_stocker wrote: > On Mar 21, 8:11 am, John Machin wrote: > > > > > On Mar 22, 1:55 am, grocery_stocker wrote: > > > > Given the following > > > > def double(val): > > >     return val.bind(lambda x: val.return_(x*2)) > > > > I get "AttributeError: 'int' object has

Re: Downloading binary files - Python3

2009-03-21 Thread MRAB
Matteo wrote: srcdata = urlopen(url).read() dstfile = open(path,mode='wb') dstfile.write(srcdata) dstfile.close() print("Done!") Have you tried reading all files first, then saving each one on the appropriate directory? It might work if you have enough me

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 6:38 am, Tim Chase wrote: > > For example, this means that there can be a start node supposedly. > > Having a value of 0. It is pointing to node 1 with the value of "a" > > and to node 2 with the value of "b". Trying to make something like an > > NFA. Where id be changing regular expres

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 8:47 am, grocery_stocker wrote: > On Mar 21, 6:38 am, Tim Chase wrote: > > > > > > For example, this means that there can be a start node supposedly. > > > Having a value of 0. It is pointing to node 1 with the value of "a" > > > and to node 2 with the value of "b". Trying to make some

Re: How to do this in Python?

2009-03-21 Thread Grant Edwards
On 2009-03-21, Josh Holland wrote: > If you're referring to my reply (about his pseudocode looking > like C), I hope you realise that it was tongue-in-cheek. For > the record, I intend to learn C in the near future and know it > is a very powerful language. > How people would write a kernel in P

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Aahz
In article , Esmail wrote: >Aahz wrote: >> In article , >> Esmail wrote: >>> >>> I've looked around the web w/o much luck for some examples but come >>> short. Any comments/suggestions? >> >> Not sure what you're looking for here -- many things you'd run an >> external program for in scriptin

Re: cross compile Python to Linux-ARM

2009-03-21 Thread David Boddie
On Thursday 19 March 2009 17:54, jefm wrote: > We are looking to use Python on an embedded Linux ARM system. > What I gather from googling the subject is that it is not that > straight forward (a fair amount of patching & hacking). > Nobody out there that has done it claims it is easy, which makes

Re: How to do this in Python?

2009-03-21 Thread Josh Holland
Sorry, I meant to write "How *many* people ..." -- Josh Holland http://joshh.co.uk madmartian on irc.freenode.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Preparing teaching materials

2009-03-21 Thread grkuntzmd
Very nice. I printed out the PDF manual for sphinx. I'll take a look at it. -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-21 Thread Aaron Brady
On Mar 21, 10:28 am, Aaron Brady wrote: > On Mar 21, 9:50 am, "andrew cooke" wrote: > > > > > Aaron Brady wrote: > > > On Mar 21, 7:54 am, "andrew cooke" wrote: > > >> they should not be used to do things like flushing and closing > > >> files, for example. > > > What is your basis for this clai

[ANN] lxml 2.2 released

2009-03-21 Thread Stefan Behnel
Hi all, I'm proud to announce the release of lxml 2.2 final. http://codespeak.net/lxml/ http://pypi.python.org/pypi/lxml/2.2 Changelog: http://codespeak.net/lxml/changes-2.2.html What is lxml? == lxml is the most feature-rich and easy-to-use library for working with XML and HTML in

Re: How to do this in Python?

2009-03-21 Thread JanC
Josh Holland wrote: > How people would write a kernel in Python? Like this: http://code.google.com/p/cleese/wiki/CleeseArchitecturehttp://code.google.com/p/cleese/ ? -- JanC -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
Aaron Brady wrote: > My point is, that garbage collection is able to detect when there are > no program-reachable references to an object. Why not notify the > programmer (the programmer's objects) when that happens? If the > object does still have other unreachable references, s/he should be > i

Re: Creating Linked Lists in Python

2009-03-21 Thread Tim Chase
transitions = { # values are tuples of (newstate, transition_function) STATE_A: [ (STATE_B, lambda x: x > 5), (STATE_C, lambda x: x > 10), (STATE_D, lambda x: x > 100), ], STATE_B: [ (STATE_A, lambda x: x < 5), (STATE_C, lambda x: x > 10)

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Peter Pearson
On Sat, 21 Mar 2009 09:26:02 -0400, Esmail wrote: > > I am wondering if anyone is using python to write script files? If it can be done in a few simple lines of shell script, fine: make it a shell script. But if it's more complex than that, Python is clearer. Just my two cents. -- To email me,

Re: pickle.load() extremely slow performance

2009-03-21 Thread Benjamin Peterson
Terry Reedy udel.edu> writes: > > 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the alpha. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating Linked Lists in Python

2009-03-21 Thread Aaron Brady
On Mar 21, 10:47 am, grocery_stocker wrote: > On Mar 21, 6:38 am, Tim Chase wrote: > > > > > > For example, this means that there can be a start node supposedly. > > > Having a value of 0. It is pointing to node 1 with the value of "a" > > > and to node 2 with the value of "b". Trying to make som

Re: garbage collection / cyclic references

2009-03-21 Thread John Nagle
Aaron Brady wrote: Hello, I was reading and Googling about garbage collection, reference counting, and the problem of cyclic references. Python's garbage collection module claims to be able to detect and break cyclic garbage. Some other languages merely prohibit it. Is this the place to ask a

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 10:03 am, Tim Chase wrote: > >>>transitions = { > >>> # values are tuples of (newstate, transition_function) > >>> STATE_A: [ > >>>(STATE_B, lambda x: x > 5), > >>>(STATE_C, lambda x: x > 10), > >>>(STATE_D, lambda x: x > 100), > >>>], > >>>

Re: Creating Linked Lists in Python

2009-03-21 Thread Roy Smith
In article , Tim Chase wrote: > In the past, I've done NFA with a state machine: What I've done at times is have each state be a function. The function returns an (output, next_state) tuple, and the main loop becomes something like this: state = start for input in whatever: output, stat

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Esmail
Aahz wrote: If you post a sample script you're trying to convert, you may get some responses that show how different people would write it in Python. That's a nice suggestion .. I may end up doing this after I do some readings, just wanted to make sure this is not too outlandish of an idea :-)

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Esmail
Peter Pearson wrote: On Sat, 21 Mar 2009 09:26:02 -0400, Esmail wrote: I am wondering if anyone is using python to write script files? If it can be done in a few simple lines of shell script, fine: make it a shell script. But if it's more complex than that, Python is clearer. Just my two cen

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread Ned Deily
In article , Esmail wrote: > Aahz wrote: > > In article , > > Esmail wrote: > >> I am wondering if anyone is using python to write script files? > > > > These days, I always convert any even slightly complicated script to > > Python. > well .. that sounds encouraging ...> > >> I've looked aro

Re: Preparing teaching materials

2009-03-21 Thread Rhodri James
On Fri, 20 Mar 2009 11:58:18 -, wrote: I am considering teaching a beginning programming course using Python. I would like to prepare my class handouts in such a way that I can import the Python code from real ".py" files directly into the documents. This way I can run real unit tests on th

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread andrew cooke
Esmail wrote: > Peter Pearson wrote: >> On Sat, 21 Mar 2009 09:26:02 -0400, Esmail wrote: >>> I am wondering if anyone is using python to write script files? >> If it can be done in a few simple lines of shell script, >> fine: make it a shell script. But if it's more complex than >> that, Python i

RSS feed issues, or how to read each item exactly once

2009-03-21 Thread John Nagle
I've been using the "feedparser" module, and it turns out that some RSS feeds don't quite do RSS right. For the Reuters RSS feed, about once every fifteen minutes, the "Etag" changes, even if there are no new stories. I've been logging this in a program of mine: WARNING: Feed "http://feed

Re: Another of those "is" issues.

2009-03-21 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Hi everybody, I was unit testing some code today and I eventually stumbled on one of those "is" issues quickly solved replacing the "is" with "==". Still, I don't quite see the sense of why these two cases are different: def aFunction(): ... pass ... f = aFunc

Re: Organize large DNA txt files

2009-03-21 Thread andrew cooke
a faster and simpler solution, assuming you are on unix, is to just use the sort command: spl6 tmp: cat 1- 1740060 1780040 1890002 spl6 tmp: cat 1+ 17301

Re: Is python worth learning as a second language?

2009-03-21 Thread Bruno Desthuilliers
Aahz a écrit : In article <49b5196b$0$3514$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Grant Edwards a écrit : Knowing C++ does tend to be a bit of a handicap, but I think any competent programmer could learn Python. +2 QOTW !-) Ditto! Although I suppose you could just go for the j

Crunchy [Was: Preparing teaching materials]

2009-03-21 Thread andrew cooke
André wrote: > If I may suggest a very different alternative than the ones already > suggested: use Crunchy. (http://code.google.com/p/crunchy) > > You can have you handouts (html or reStructuredText documents) live on > the web with all your code samples executable from within Firefox. > > If you

Re: Another of those "is" issues.

2009-03-21 Thread Martin v. Löwis
m is c.myMethod > False <--- What? Why is that? I think nobody has said this plainly yet (although Terry points it out also): You cannot rely that foo.bar is foo.bar for any object foo and any attribute bar. In some cases, that relation may hold, in other cases, it may not. It depends on

Re: Is python worth learning as a second language?

2009-03-21 Thread Tomasz Rola
On Sat, 21 Mar 2009, Aahz wrote: > In article , > Tomasz Rola wrote: > >On Sat, 20 Mar 2009, Aahz wrote: > >> > >> Taking C++ and turning it into a VM model does not exactly strike me > >> as particularly good use of resources. > > > >It doesn't strike me either. But resources are not the only

Re: [ANN] lxml 2.2 released

2009-03-21 Thread python
Stefan, Is it possible to use the same install of lxml across multiple versions of Python, eg. I have 2.4, 2.5, 2.6, and 3.0 installed on my workstation - can I use a single copy of lmxl for 4 versions of Python? My understanding is that we can replace our use of elmentree and htmlparser with lxm

Re: Is python worth learning as a second language?

2009-03-21 Thread Tomasz Rola
On Fri, 20 Mar 2009, alex goretoy wrote: > I've only read he subject and a few lines from other responses. > > yes, it is worth learning. I came from PHP to Python. It's very powerful and > makes application development easier for me than in PHP and/or C#, but bash, > well that depends on the typ

Async serial communication/threads sharing data

2009-03-21 Thread Nick Timkovich
I've been working on a program that will talk to an embedded device over the serial port, using some basic binary communications with messages 4-10 bytes long or so. Most of the nuts and bolts problems I've been able to solve, and have learned a little about the threading library to avoid blocking

Re: Async serial communication/threads sharing data

2009-03-21 Thread Paul Rubin
Nick Timkovich writes: > My main issue is with how to > exchange data between different threads; can I just do something like > have a global list of messages, appending, modifying, and removing as > needed? Does the threading.Lock object just prevent every other > thread from running, or is it b

Re: Crunchy [Was: Preparing teaching materials]

2009-03-21 Thread Andre Roberge
On Sat, Mar 21, 2009 at 5:06 PM, andrew cooke wrote: > André wrote: > > If I may suggest a very different alternative than the ones already > > suggested: use Crunchy. (http://code.google.com/p/crunchy) > > > > You can have you handouts (html or reStructuredText documents) live on > > the web wi

Re: [ANN] lxml 2.2 released

2009-03-21 Thread Stefan Behnel
pyt...@bdurham.com wrote: > Is it possible to use the same install of lxml across multiple versions > of Python, eg. I have 2.4, 2.5, 2.6, and 3.0 installed on my workstation > - can I use a single copy of lmxl for 4 versions of Python? It would be interesting to have some more information about y

simplejson: alternate encoder not called enought

2009-03-21 Thread Pierre Hanser
hello I'm trying to use simplejson to encode some python objects using simplejson dumps method. The dumps method accept a cls parameter to specify an alternate encoder. But it seems that this alternate encoder is called only as a last resort, if object type is not int, string, and all other basic

Re: Async serial communication/threads sharing data

2009-03-21 Thread Scott David Daniels
Nick Timkovich wrote: I've been working on a program that will talk to an embedded device over the serial port, using some basic binary communications with messages 4-10 bytes long or so... Ultimately, this program ... [send] messages and collecting responses for 10k-100k cycles ... Here's a s

Re: Preparing teaching materials

2009-03-21 Thread R. David Murray
"Rhodri James" wrote: > On Fri, 20 Mar 2009 11:58:18 -, wrote: > > > I am considering teaching a beginning programming course using Python. > > I would like to prepare my class handouts in such a way that I can > > import the Python code from real ".py" files directly into the > > documents.

Re: PEP 3143: Standard daemon process library

2009-03-21 Thread Ben Finney
Floris Bruynooghe writes: > Had a quick look at the PEP and it looks very nice IMHO. Thank you. I hope you can try the implementation and report feedback on that too. > One of the things that might be interesting is keeping file > descriptors from the logging module open by default. Hmm. I see

  1   2   >