I am an experienced C/C++/C# programmer who is just starting out with Python.
My first attempt at IDLE worked great with the tutorial, but seems to have a
problem with my first real app!
I am trying to get the Python subprocess/Popen module working with the example
from the Python 3
Karen Palen wrote:
Which appears to be merely the return code, not the stdout!
It looks like I need to set some variable in IDLE, but I can't figure out
exactly what is needed here.
Can anyone point me to an answer?
Well, Karen, according to my IDLE (admittedly it's 2.6 not 3.0 so it
Elisha Rosensweig bensha...@gmail.com 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
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
On Thu, Jun 18, 2009 at 6:21 AM, karmadorjeta...@googlemail.com 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
Excellent, thanks for that answer Kent. Also thanks for the link
2009/6/18 Kent Johnson ken...@tds.net:
On Thu, Jun 18, 2009 at 6:21 AM, karmadorjeta...@googlemail.com wrote:
Hi All,
I'm trying to write a function that flattens a list. However after I
call the function more than once, it
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
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
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.
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 berma...@cfl.rr.com:
This might help:
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
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...
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 jojo.mweb...@gmail.comwrote:
Hi Tutor
The problem i have is to see which statements modify my data at execution
time without
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.
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
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
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)
True both are assignments, L3, does change a value of any variable.
Johnson
On Thu, Jun 18, 2009 at 4:53 PM, Elisha Rosensweig bensha...@gmail.comwrote:
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
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,
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
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
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
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
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
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
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 want to
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.
On Thu, Jun 18, 2009 at 9:15 AM, karmadorjeta...@googlemail.com 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
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 + / +
Thanks - just what I needed (and thanks to all the others too)
Elisha
On Thu, Jun 18, 2009 at 12:48 PM, Dave Angel da...@ieee.org wrote:
bob gailer wrote:
Elisha Rosensweig wrote:
Hi,
How can I determine the directory in which a module is located, from
within that module?
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
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:
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.
On Thu, Jun 18, 2009 at 4:37 PM, Serdar Tumgorenzstumgo...@gmail.com wrote:
On the above link, the section on Encoding Unicode Byte Streams has
the following example:
u = uabc\u2013
print u
Traceback (most recent call last):
File stdin, line 1, in module
UnicodeEncodeError: 'ascii' codec
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
appear in
Kevin Pearson kevinfpear...@gmail.com 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
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
On Thu, Jun 18, 2009 at 7:32 PM, Vincent Davisvinc...@vincentdavis.net 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
2009/6/18 Serdar Tumgoren zstumgo...@gmail.com:
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
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
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
On Fri, Jun 19, 2009 at 12:56 AM, bob gailer bgai...@gmail.com 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):
def
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
On Thu, Jun 18, 2009 at 9:03 PM, Serdar Tumgorenzstumgo...@gmail.com 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
On Thu, Jun 18, 2009 at 9:48 PM, Luis Ngloboph...@gmail.com 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,
On Thu, Jun 18, 2009 at 9:48 PM, dave chachidjbags...@yahoo.com 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
___
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 lie.1...@gmail.com wrote:
47 matches
Mail list logo