Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Karen Palen
Yes I see. Based on other feedback I am leaning towards not using any IDE for the moment. Python seems well adapted to that kind of workflow, as well as an impressive portability - every bit as good a Java from my tests so far. Karen --- On Thu, 6/18/09, Lie Ryan wrote: > From: Lie Ryan >

Re: [Tutor] home directory usage script

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 9:48 PM, dave chachi wrote: >     A. Create a script that monitors the /home partition >     B. have it write to a log file in /var/log >     C. have crontab run it daily What do you want it to write? Kent ___ Tutor maillist -

Re: [Tutor] Subclassing list

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 9:48 PM, Luis N wrote: >>> I get an error "TypeError: 'rounding' is an invalid keyword argument >>> for this function" on my list subclass. >>> >>> How might I subclass list without this error? >>> >>> This is the code: >>> >>> class SeriesList(list): >>>    def __new__(cls

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 9:03 PM, Serdar Tumgoren wrote: > When I run this code: > > <<< snip >>> > for line in infile: >    cleanline = translate_code(line) >    newline = strip_html(cleanline) >    outfile.write(newline) > <<< snip >>> > > ...I receive the below traceback: > >   Traceback (most r

[Tutor] home directory usage script

2009-06-18 Thread dave chachi
I was wondering if I can get some incite on how to create a python that will accomplish the following tasks: issue: /home partition is partitioned to 80 or so G of space 24 G's is used         A. What is taking up this amount of space     B. Not alot of packages are installed and shouldnt take

Re: [Tutor] Subclassing list

2009-06-18 Thread Luis N
On Fri, Jun 19, 2009 at 12:56 AM, bob gailer wrote: > > Luis N wrote: >> >> I get an error "TypeError: 'rounding' is an invalid keyword argument >> for this function" on my list subclass. >> >> How might I subclass list without this error? >> >> This is the code: >> >> class SeriesList(list): >>  

Re: [Tutor] list of instance objects, access attribute

2009-06-18 Thread Dave Angel
Vincent Davis wrote: given a class like class B(): def __init__(self, b1, b2): ??? self.fooa = fooa ??? self.foob = foob Ok now I have several instances in a list b1 = B(1, 2) b2 = B(3, 4) b3 = B(9, 10) alist = [b1, b2, b3] Lets say for each instance of the class I want to print the value of fo

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Serdar Tumgoren
Ok, I should say that I managed to "solve" the problem by first reading and translating the data, and then applying Mr. Lundh's strip_html function to the resulting lines. For future reference (and of course any additional feedback), the working code is here: http://pastebin.com/f309bf607 But of

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Kent Johnson
2009/6/18 Serdar Tumgoren : >> In [7]: print x.encode('cp437') >> --> print(x.encode('cp437')) >> abc░ >> > So does this mean that my python install is incapable of encoding the > en/em dash? No, the problem is with the print, not the encoding. Your console, as configured, is incapable of dis

Re: [Tutor] list of instance objects, access attribute

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 7:32 PM, Vincent Davis wrote: > given a class like > class B(): > def __init__(self, b1, b2): >     self.fooa = fooa >     self.foob = foob > > Ok now I have several instances in a list > b1 = B(1, 2) > b2 = B(3, 4) > b3 = B(9, 10) > alist = [b1, b2, b3] > > Lets say for eac

[Tutor] list of instance objects, access attribute

2009-06-18 Thread Vincent Davis
given a class like class B(): def __init__(self, b1, b2):     self.fooa = fooa     self.foob = foob Ok now I have several instances in a list b1 = B(1, 2) b2 = B(3, 4) b3 = B(9, 10) alist = [b1, b2, b3] Lets say for each instance of the class I want to print the value of fooa if it is greater tha

Re: [Tutor] Checking Syntax

2009-06-18 Thread Alan Gauld
"Kevin Pearson" wrote run a check on the sytax (before I try running the program) it places a cursor like so: outFeatureClas|s = outWorkspace + "/" + GP.ValidateTableName(fc,outWorkspace) You should try running it, the error message may be more helpful than the syntax checker... However,

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Serdar Tumgoren
> The example is written assuming the console encoding is utf-8. Yours > seems to be cp437. Try this: > In [1]: import sys > > In [2]: sys.stdout.encoding > Out[2]: 'cp437' That is indeed the result that I get as well. > But there is another problem - \u2013 is an em dash which does not > appea

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 4:37 PM, Serdar Tumgoren wrote: > On the above link, the section on "Encoding Unicode Byte Streams" has > the following example: > u = u"abc\u2013" print u > Traceback (most recent call last): >  File "", line 1, in > UnicodeEncodeError: 'ascii' codec can't encod

Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Luke Paireepinart
Karen Palen wrote: WOW! Thanks for the detailed explanation! Sure thing, putting off doing homework so... This was about what I had expected so it is no surprise. My conclusion (so far) is that there is not much to gain from an IDE in this situation and a lot of complexity to deal with.

Re: [Tutor] Checking Syntax

2009-06-18 Thread Emile van Sebille
On 6/18/2009 12:55 PM Kevin Pearson said... I am teaching myslef Python from a GIS tutorial 'Writing_Geoprocessing_Scripts.pdf'. I have typed everything exactly like it is in the tutorial and when I go to run a check on the sytax (before I try running the program) it places a cursor like so: ou

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Serdar Tumgoren
Hey everyone, I'm trying to get down to basics with this handy intro on Python encodings: http://eric.themoritzfamily.com/2008/11/21/python-encodings-and-unicode/ But I'm running into some VERY strange results. On the above link, the section on "Encoding Unicode Byte Streams" has the following e

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread Elisha Rosensweig
Thanks - just what I needed (and thanks to all the others too) Elisha On Thu, Jun 18, 2009 at 12:48 PM, Dave Angel wrote: > bob gailer wrote: > > Elisha Rosensweig wrote: >> >>> > Hi, >>> > >>> > How can I determine the directory in which a module is located, from > >>> within that module? >>>

[Tutor] Checking Syntax

2009-06-18 Thread Kevin Pearson
I am teaching myslef Python from a GIS tutorial 'Writing_Geoprocessing_Scripts.pdf'. I have typed everything exactly like it is in the tutorial and when I go to run a check on the sytax (before I try running the program) it places a cursor like so: outFeatureClas|s = outWorkspace + "/" + GP.Validat

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 9:15 AM, karma wrote: > I was playing around with eliminating duplicates in a list not using > groupby. From the two solutions below, which is more "pythonic". > Alternative solutions would be welcome. But why not use groupby()? That seems much clearer to me: In [1]: from

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread Strax-Haber, Matthew (LARC-D320)
Whoops. I should read more carefully. I thought he said the path to the module itself. Yes, os.path.dirname(__file__) works. If you want an absolute path (rather than a relative path), use: os.path.abspath(os.path.dirname(__file__)) I would find this more useful if the path will be passed around.

Re: [Tutor] List Splicing

2009-06-18 Thread Lie Ryan
Luke Paireepinart wrote: > Robert Berman wrote: >> Emille, >> >> Thank you for the example of list splicing. Do you know if this is >> faster than a more conventional loop statement as in my code for >> primearray which is in my original post (reprinted here) > As has been mentioned, you will wan

Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Lie Ryan
Luke Paireepinart wrote: > So the problem is that the stdout of the "ls" command is appearing in > some location that you cannot see. > As for ways to remedy this - I don't know. The idea here, though, is > that even though the regular Python version has the side-effect that it > outputs it in the

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread Strax-Haber, Matthew (LARC-D320)
Try the following: import os.path os.path.abspath(__file__) This won't work in an interactive shell since it is not being executed from within a module. -- ~ Matthew Strax-Haber National Aeronautics and Space Administration Langley Research Center (LaRC) Co-op, Safety-Critical Avionics Sys

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread Dave Angel
bob gailer wrote: Elisha Rosensweig wrote: > Hi, > > How can I determine the directory in which a module is located, from > within that module? sys.modules[__name__].__file__ -- Bob Gailer Or more simply, __file__ But the OP wanted the directory, which can be extracted with method d

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Dave Angel
karma wrote: I was playing around with eliminating duplicates in a list not using groupby. From the two solutions below, which is more "pythonic". Alternative solutions would be welcome. Thanks x=[1,1,1,3,2,2,2,2,4,4] [v for i,v in enumerate(x) if x[i]!=x[i-1] or i==0] [x[i] for i in range(l

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread bob gailer
Elisha Rosensweig wrote: Hi, How can I determine the directory in which a module is located, from within that module? sys.modules[__name__].__file__ -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python

[Tutor] reference to directory a module is located at

2009-06-18 Thread Elisha Rosensweig
Hi, How can I determine the directory in which a module is located, from within that module? Elisha ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Subclassing list

2009-06-18 Thread bob gailer
Luis N wrote: I get an error "TypeError: 'rounding' is an invalid keyword argument for this function" on my list subclass. How might I subclass list without this error? This is the code: class SeriesList(list): def __new__(cls, *args, **kwargs): series_list = list.__new__(cls, *arg

Re: [Tutor] Program Slicing / Trace

2009-06-18 Thread Jojo Mwebaze
True both are assignments, L3, does change a value of any variable. Johnson On Thu, Jun 18, 2009 at 4:53 PM, Elisha Rosensweig wrote: > It is not clear to me in what way line 3 is different than line 2 - both > are assignments... Please clarify > > Elisha > > On Thu, Jun 18, 2009 at 10:37 AM,

[Tutor] Subclassing list

2009-06-18 Thread Luis N
I get an error "TypeError: 'rounding' is an invalid keyword argument for this function" on my list subclass. How might I subclass list without this error? This is the code: class SeriesList(list): def __new__(cls, *args, **kwargs): series_list = list.__new__(cls, *args) serie

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Robert Berman
Whoops. That's called assuming what I read is really what I see. A good lesson in reading questions twice. I remember this from a post some time back and I remember having been intrigued by it. I used Google, and since I tend to keep extensive notes, the solution I found is not uniquely mine, but

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Emile van Sebille
On 6/18/2009 7:23 AM karma said... Hi Robert, Thanks for the link. However, I am looking for eliminating consecutive duplicates rather than all duplicates - my example wasn't clear, apologies for that. x=[1,1,1,3,2,2,2,4,4,2,2] [1 ,3 ,2 ,4 ,2 ] Something like [ ii for ii,jj in zip(x,x[1:]+[

Re: [Tutor] Program Slicing / Trace

2009-06-18 Thread Emile van Sebille
On 6/18/2009 7:37 AM Jojo Mwebaze said... Hi Tutor The problem i have is to see which statements modify my data at execution time without referring to the code. Referring to the code is difficult esp because of branching. You can never tell before hand which branch execution will follow. e.

Re: [Tutor] Program Slicing / Trace

2009-06-18 Thread Elisha Rosensweig
It is not clear to me in what way line 3 is different than line 2 - both are assignments... Please clarify Elisha On Thu, Jun 18, 2009 at 10:37 AM, Jojo Mwebaze wrote: > Hi Tutor > > The problem i have is to see which statements modify my data at execution > time without referring to the code. R

Re: [Tutor] please help me

2009-06-18 Thread Emile van Sebille
On 6/18/2009 1:30 AM suzee Eslam said... to every one help me please .. i need the code to do chatting by python in mobiles over bluetooth technology .. i need it please if any one know it send it to me as soon as possible.. thanks for all. Maybe this will get you started... http://www.mobi

[Tutor] Program Slicing / Trace

2009-06-18 Thread Jojo Mwebaze
Hi Tutor The problem i have is to see which statements modify my data at execution time without referring to the code. Referring to the code is difficult esp because of branching. You can never tell before hand which branch execution will follow. e.g in the example below, statements 1, 2, 5,7 and

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread karma
Hi Robert, Thanks for the link. However, I am looking for eliminating consecutive duplicates rather than all duplicates - my example wasn't clear, apologies for that. x=[1,1,1,3,2,2,2,4,4,2,2] [1 ,3 ,2 ,4 ,2 ] 2009/6/18 Robert Berman : > This might help: http://code.activestate.com/recipes/525

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Robert Berman
This might help: http://code.activestate.com/recipes/52560/ Robert On Thu, 2009-06-18 at 15:15 +0200, karma wrote: > I was playing around with eliminating duplicates in a list not using > groupby. From the two solutions below, which is more "pythonic". > Alternative solutions would be welcome. >

[Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread karma
I was playing around with eliminating duplicates in a list not using groupby. From the two solutions below, which is more "pythonic". Alternative solutions would be welcome. Thanks x=[1,1,1,3,2,2,2,2,4,4] [v for i,v in enumerate(x) if x[i]!=x[i-1] or i==0] [x[i] for i in range(len(x)-1) if i==0

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-18 Thread Serdar Tumgoren
> Some further searching reveals this: > (yay archives ;)) > http://mail.python.org/pipermail/python-list/2008-April/658644.html > Aha! I noticed that 150 was missing from the ISO encoding table and the source xml is indeed using windows-1252 encoding. That explains why this appears to be the only

Re: [Tutor] variable within function retains value

2009-06-18 Thread karma
Excellent, thanks for that answer Kent. Also thanks for the link 2009/6/18 Kent Johnson : > On Thu, Jun 18, 2009 at 6:21 AM, karma wrote: >> Hi All, >> >> I'm trying to write a function that flattens a list. However after I >> call the function more than once, it appends the result (a list) from

Re: [Tutor] variable within function retains value

2009-06-18 Thread Kent Johnson
On Thu, Jun 18, 2009 at 6:21 AM, karma wrote: > Hi All, > > I'm trying to write a function that flattens a list. However after I > call the function more than once, it appends the result (a list) from > the second call with the first. I can get around it by either setting > the list to an empty one

[Tutor] please help me

2009-06-18 Thread suzee Eslam
to every one help me please .. i need the code to do chatting by python in mobiles over bluetooth technology .. i need it please if any one know it send it to me as soon as possible.. thanks for all. ___ Tutor maillist - Tutor@python.org http:/

[Tutor] variable within function retains value

2009-06-18 Thread karma
Hi All, I'm trying to write a function that flattens a list. However after I call the function more than once, it appends the result (a list) from the second call with the first. I can get around it by either setting the list to an empty one before calling the function, but I would like to keep it

Re: [Tutor] Fast way to access items in a dictionary

2009-06-18 Thread Alan Gauld
"Elisha Rosensweig" wrote if 'someKey' in dict.keys(): someData = dict['someKey'] is there a faster way to do this? Faster in terms of execution speed? Sure just miss out the test... accessing a key that does not exist will through an exception, which is just as tiresome... Tiresom