Hello All,
I am getting the "Invalid Syntax" error. I am on Python 2.6.
Thanks In Advance
Nitin
import sys,os, fileinput
FileA = raw_input('Enter CSV file with lists of Files:')
try:
fp6 = open(FileA,'r')
except IOError:
## I am get
Hi guys,
I'm using Python 2.7 and the ElementTree standard-lib to write some xml.
My output xml has no line breaks! So, it looks like that:
instead of something like this:
I'm aware of lxml which seems to have a pretty print option, but I would
prefer to use the standard-lib Element
On Fri, 20 Aug 2010 05:28:42 pm nitin chandra wrote:
> try:
>fp6 = open(FileA,'r')
>except IOError:
You need to outdent the except line:
try:
fp6 = open(FileA,'r')
except IOError:
sys.exit('Could not open file: %s' % FileA)
--
Steven D'Aprano
"nitin chandra" wrote
FileA = raw_input('Enter CSV file with lists of Files:')
try:
fp6 = open(FileA,'r')
except IOError:
## I am getting the following error at this line:-
##
##File "mer5Pr2.py", line 7
##except IOError:
##^
##SyntaxError: invalid syntax
The
"Steven D'Aprano" wrote
the purpose). No matter how fast you can perform a loop, it's always
faster to avoid it altogether, so this:
seq = xrange(1000)
result = []
for i in seq:
if i >= 10: break
result.append(i%2)
will be much faster than this:
seq = xrange(1000)
result = [i%
"Roelof Wobben" wrote
Others have pointed out the lack of indentation.
I'll point out some shortcuts you can use...
def is_even(argument):
remainder= argument%2
if remainder == 0 :
return True
else :
return False
You can abbreviate this to just
def is_even(arg):
r
Thank you, Alan and Steven.
Now i am facing some thing 'different'
This is even when i have not done a carriage return to create line "66".
This is after i have done
fp1.close()
fp2.close()
fp3.close()
**
File "mer5Pr2.py", line 66
Hi guys,
just found "hidden" in the "Schema change in Etree"-Thread the answer to
my formatting question:
Quotation:
"
ElementTree doesn't have a way of formatting (pretty printing) XML
files, so there can't be that many newline characters in the structure
(they may be in the occur, though!)
On Fri, 20 Aug 2010 06:10:59 pm Alan Gauld wrote:
> "Steven D'Aprano" wrote
>
> > the purpose). No matter how fast you can perform a loop, it's
> > always faster to avoid it altogether, so this:
> >
> > seq = xrange(1000)
> > result = []
> > for i in seq:
> >if i >= 10: break
> >result
On Fri, 20 Aug 2010 06:27:01 pm nitin chandra wrote:
> Thank you, Alan and Steven.
>
> Now i am facing some thing 'different'
>
> This is even when i have not done a carriage return to create line
> "66". This is after i have done
> fp1.close()
> fp2.close()
> fp3.close()
>
import sys,os, fileinput
FileA = raw_input('Enter CSV file with lists of Files:')
try:
fp6 = open(FileA,'r')
except IOError:
sys.exit('Could not open file: %s' % FileA)
while True:
lines = fp6.readline().split(",")
file11 = lines[0]
file12 = lines[1]
file3 = lines[2]
#file11 =
Hi all,
I often struggle with object design and inheritance. I'd like opinions on how
best to design a Point class to be used in multiple circumstances.
I typically deal with geographic (either 2D or 3D) data, yet there are
occasions when I need n-dimensional points as well. My thought was to
On 8/20/2010 5:44 AM, Steven D'Aprano wrote:
On Fri, 20 Aug 2010 06:10:59 pm Alan Gauld wrote:
"Steven D'Aprano" wrote
the purpose). No matter how fast you can perform a loop, it's
always faster to avoid it altogether, so this:
seq = xrange(1000)
result = []
for i in seq:
if i>= 10:
On 8/20/10, Gregory, Matthew wrote:
> Hi all,
>
> I often struggle with object design and inheritance. I'd like opinions on
> how best to design a Point class to be used in multiple circumstances.
>
> I typically deal with geographic (either 2D or 3D) data, yet there are
> occasions when I need n
On 8/20/2010 11:45 AM, Gregory, Matthew wrote:
Hi all,
I often struggle with object design and inheritance. I'd like opinions on how
best to design a Point class to be used in multiple circumstances.
I typically deal with geographic (either 2D or 3D) data, yet there are
occasions when I nee
On Fri, Aug 20, 2010 at 10:45 AM, Gregory, Matthew <
matt.greg...@oregonstate.edu> wrote:
> Hi all,
>
> I often struggle with object design and inheritance. I'd like opinions on
> how best to design a Point class to be used in multiple circumstances.
>
> I typically deal with geographic (either 2
result = [i%2 for i in itertools.takewhile(lamda x:i< 10, seq)]
is a good approach but it is taking little more time than the for loop over
iterator.
def takewhile(predicate, iterable):
# takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4
for x in iterable:
if predicate(x):
Wayne Werner wrote:
> class Point2D(PointND):
> def __init__(self, x = 0, y = 0):
> super(Point2D, self).__init__([x,y])
> self.x = 0
> self.y = 0
>
> though you wouldn't be able to directly modify the values, or you'll
> lose the distance function. You'd have to creat
Oke,
I don''t understand it complety.
return not arg%2
Why use not here ?
I think that arg%2 is True not makes it false.
Another question.
How can I round outcome of a calculation.
round ( ( t-32)/1.8) does not work because I get a message that there are two
arguments.
Outcome
On Fri, Aug 20, 2010 at 2:48 PM, Roelof Wobben wrote:
> Oke,
>
> I don''t understand it complety.
>
> return not arg%2
>
> Why use not here ?
>
> I think that arg%2 is True not makes it false.
>
What happens when you replace arg with a value? % is modulo division, so it
just returns the remaind
Hello Nitin,
On 20/08/10 16:21, nitin chandra wrote:
import sys,os, fileinput
[...]
while True:
try:
line1 = fp1.readline().split(",")
line2 = fp2.readline().split(",")
[...]
fp3.write(str3)
You're missing the completion for the try/finally block. Tr
On Fri, Aug 20, 2010 at 12:55 PM, Gregory, Matthew
wrote:
> Wayne Werner wrote:
>> class Point2D(PointND):
>> def __init__(self, x = 0, y = 0):
>> super(Point2D, self).__init__([x,y])
>> self.x = 0
>> self.y = 0
>>
>> though you wouldn't be able to directly modify the v
Please use ReplyAll when responding to posts from the tutor list.
> I don''t understand it complety.
> return not arg%2
>>
>> Why use not here ?
>>
>> I think that arg%2 is True not makes it false.
>
>For an even number arg % 2 will be 0 which Python considers to be False.
So for a True res
Hi All,
I just had reason the write the following:
itemCodes = [UPCxref['0'+xx[:10]][0] for xx in itemUPCs]
... and it occurred to me exactly how overloaded square brackets are.
This is certainly not something you want to see as a beginning python
programmer, but I thought it might be an inte
On 8/20/2010 1:55 PM, Gregory, Matthew wrote:
Wayne Werner wrote:
class Point2D(PointND):
def __init__(self, x = 0, y = 0):
super(Point2D, self).__init__([x,y])
self.x = 0
self.y = 0
though you wouldn't be able to directly modify the values, or you'll
lose the d
On 8/20/2010 1:55 PM, Gregory, Matthew wrote:
Wayne Werner wrote:
class Point2D(PointND):
def __init__(self, x = 0, y = 0):
super(Point2D, self).__init__([x,y])
self.x = 0
self.y = 0
though you wouldn't be able to directly modify the values, or you'll
lose the d
"Gregory, Matthew" wrote
I typically deal with geographic (either 2D or 3D) data, yet
there are occasions when I need n-dimensional points as well.
Thats OK.
The rub to this is that in the n-dimensional case, it probably
makes most sense to store the actual coordinates as a list
whereas wi
On Sat, 21 Aug 2010 01:45:18 am Gregory, Matthew wrote:
> Hi all,
>
> I often struggle with object design and inheritance. I'd like
> opinions on how best to design a Point class to be used in multiple
> circumstances.
>
> I typically deal with geographic (either 2D or 3D) data, yet there
> are oc
On Sat, 21 Aug 2010 08:08:56 am Alan Gauld wrote:
> Every time you change the interface of inherited methods you
> create for yourself extra work in converting types to match the
> superclass. But that is often easier than rewriting the methods
> from scratch.
Every time you change the interface o
On Sat, 21 Aug 2010 01:47:12 am bob gailer wrote:
> > Well yes, but I pointed out that you *can* bail out early of
> > for-loops, but not list comprehensions. The whole point is with a
> > list comp, you're forced to iterate over the entire sequence, even
> > if you know that you're done and would
On Sat, 21 Aug 2010 11:50:40 am Steven D'Aprano wrote:
> On Sat, 21 Aug 2010 08:08:56 am Alan Gauld wrote:
> > Every time you change the interface of inherited methods you
> > create for yourself extra work in converting types to match the
> > superclass. But that is often easier than rewriting the
Thank You Very Much :) Walter. It WOrked I did the "except" closing.
Thanks
Nitin
On Sat, Aug 21, 2010 at 2:17 AM, Walter Prins wrote:
>
> Hello Nitin,
>
> On 20/08/10 16:21, nitin chandra wrote:
>>
>> import sys,os, fileinput
>>
>
> [...]
>>
>> while True:
>> try:
>> line1 =
32 matches
Mail list logo