Re: help to code...

2013-05-02 Thread Matteo Boscolo
The error is self expleined .. print str(current_month) + '/' + str(current_day) + '/' + str(current_year) +' *'+ * this line have a + at the end,the interpreter need something to add .. so remove it and it will work regards, Matteo Il 02/05/2013 15:50, leonardo selmi ha scritto: dear pyt

Re: question about try/except blocks

2013-05-02 Thread Steven D'Aprano
On Thu, 02 May 2013 21:54:29 -0400, J wrote: > I have this function in a class: > > def write_file(self, data, dest): > with open(dest, 'wb', 0) as outfile: > try: > print("IN WRITE_FILE") > outfile.write(self.data) > except IOError

Re: question about try/except blocks

2013-05-02 Thread Devin Jeanpierre
On Thu, May 2, 2013 at 9:54 PM, J wrote: > Would it be better to wrap the call and catch the OSError there, or > wrap the whole with open() block in the function itself? > > My thought is to wrap the with open() call in the function so that I'm > not wrapping the function call every time I use the

Re: Red Black Tree implementation?

2013-05-02 Thread Dan Stromberg
On Wed, May 1, 2013 at 7:06 PM, duncan smith wrote: > I have an implementation that you can try out. It's not based on any other > implementation, so my bugs will be independent of any bugs in the code > you're currently using. It looks more like a set - add, remove, discard. > Not tried on Python

question about try/except blocks

2013-05-02 Thread J
I have this function in a class: def write_file(self, data, dest): with open(dest, 'wb', 0) as outfile: try: print("IN WRITE_FILE") outfile.write(self.data) except IOError as exc: logging.error("Unable to write data t

Re: Python teaching book recommendations: 3.3+ and with exercises

2013-05-02 Thread TP
On Thu, May 2, 2013 at 7:36 AM, Chris Angelico wrote: > One of my younger brothers, still school age, is to be studying some > aspect of computing for the next term or two. I strongly recommended > he learn Python (it has a bit more future than studying the internals > of OS/2), and my/his father

Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-02 Thread Steven D'Aprano
On Fri, 03 May 2013 05:34:40 +0600, Mr. Joe wrote: > Is there any way to raise the original exception that made the call to > __getattr__? No. There is some discussion on the Python-Dev mailing list about adding better error reporting to AttributeError, but that may not go anywhere, and even i

Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-02 Thread Mr. Joe
Is there any way to raise the original exception that made the call to __getattr__? I seem to stumble upon a problem where multi-layered attribute failure gets obscured due to use of __getattr__. Here's a dummy code to demonstrate my problems: """ import traceback class BackupAlphabet(object):

Re: query from sqlalchemy returns AttributeError: 'NoneType' object

2013-05-02 Thread Dave Angel
On 05/02/2013 06:14 PM, karthik.sha...@gmail.com wrote: from pox.core import core import pox.openflow.libopenflow_01 as of import re import datetime You're mixing tabs and space, so all bets are off. No promise that the compiler will interpret the indentations the same way yo

Re: query from sqlalchemy returns AttributeError: 'NoneType' object

2013-05-02 Thread MRAB
On 02/05/2013 23:14, karthik.sha...@gmail.com wrote: [snip] class SourcetoPort(Base): "" __tablename__ = 'source_to_port' id = Column(Integer, primary_key=True) port_no

Re: [Python-Help] help to code...

2013-05-02 Thread bob gailer
On 5/2/2013 9:50 AM, leonardo selmi wrote: Please in future post plain text. -- http://mail.python.org/mailman/listinfo/python-list

query from sqlalchemy returns AttributeError: 'NoneType' object

2013-05-02 Thread karthik . sharma
from pox.core import core import pox.openflow.libopenflow_01 as of import re import datetime from sqlalchemy import create_engine, ForeignKey from sqlalchemy import Column, Date, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy

???????? DID MUHAMMAD AUTHOR THE QURAN

2013-05-02 Thread BV BV
DID MUHAMMAD AUTHOR THE QURAN? Did Muhammad Author the Quran? Who authored the Quran? Someone must have produced it! After all, how many desert men have stood up in the history of man and given the world a book like the Quran? The book has amazing details of past nations, prophets, and

Re: Red Black Tree implementation?

2013-05-02 Thread Dan Stromberg
On Thu, May 2, 2013 at 3:46 AM, Christian Heimes wrote: > Am 02.05.2013 01:11, schrieb Dan Stromberg: > No wonder it's getting slow and doesn't stand a change against Python's > dict implementation. The rbtree implementation from > newcenturycomputers.net is written entirely in Python. It's goo

Re: help to code...

2013-05-02 Thread Mark Lawrence
On 02/05/2013 16:37, MRAB wrote: On 02/05/2013 16:26, Mark Lawrence wrote: On 02/05/2013 15:59, Chris Angelico wrote: On Thu, May 2, 2013 at 11:50 PM, leonardo selmi wrote: dear python community, i wrote the following program: print str(current_month) + '/' + str(current_day) + '/' + str(cu

Re: help to code...

2013-05-02 Thread MRAB
On 02/05/2013 16:26, Mark Lawrence wrote: On 02/05/2013 15:59, Chris Angelico wrote: On Thu, May 2, 2013 at 11:50 PM, leonardo selmi wrote: dear python community, i wrote the following program: print str(current_month) + '/' + str(current_day) + '/' + str(current_year) +' '+ print str(curren

Re: help to code...

2013-05-02 Thread Mark Lawrence
On 02/05/2013 15:59, Chris Angelico wrote: On Thu, May 2, 2013 at 11:50 PM, leonardo selmi wrote: dear python community, i wrote the following program: print str(current_month) + '/' + str(current_day) + '/' + str(current_year) +' '+ print str(current_hour) + str(current_minute) + str(current

Re: help..

2013-05-02 Thread leonardo
thanks@all Il giorno 02/mag/2013, alle ore 16:30, Robert Kern ha scritto: > On 2013-05-02 15:20, leonardo wrote: >> on codecademy there is an interactive box where you type your code, it is a >> kind of exercise program to practice. but i don't understand what is wrong. >> this is the websit

Re: help to code...

2013-05-02 Thread MRAB
On 02/05/2013 14:50, leonardo selmi wrote: dear python community, i wrote the following program: from datetime import datetime now = datetime.now() current_month = now.month current_day = now.day current_year = now.year current_hour = now.hour current_minute = now.minute current_second = now.se

Re: help to code...

2013-05-02 Thread Chris Angelico
On Thu, May 2, 2013 at 11:50 PM, leonardo selmi wrote: > dear python community, > > i wrote the following program: > > print str(current_month) + '/' + str(current_day) + '/' + str(current_year) > +' '+ > print str(current_hour) + str(current_minute) + str(current_second) > > SyntaxError: invalid

Re: help..

2013-05-02 Thread Michael Herman
the problem is in your code: http://screencast.com/t/haF1NY5RvpMv On Thu, May 2, 2013 at 7:30 AM, Robert Kern wrote: > > On 2013-05-02 15:20, leonardo wrote: >> >> on codecademy there is an interactive box where you type your code, it is a >> kind of exercise program to practice. but i don't u

help to code...

2013-05-02 Thread leonardo selmi
dear python community, i wrote the following program: from datetime import datetime now = datetime.now() current_month = now.month current_day = now.day current_year = now.year current_hour = now.hour current_minute = now.minute current_second = now.second print str(current_month) + '/' + str(cur

Python teaching book recommendations: 3.3+ and with exercises

2013-05-02 Thread Chris Angelico
One of my younger brothers, still school age, is to be studying some aspect of computing for the next term or two. I strongly recommended he learn Python (it has a bit more future than studying the internals of OS/2), and my/his father then asked me what book I'd recommend him to study through. I k

Re: help..

2013-05-02 Thread Robert Kern
On 2013-05-02 15:20, leonardo wrote: on codecademy there is an interactive box where you type your code, it is a kind of exercise program to practice. but i don't understand what is wrong. this is the website address of that if you want to give a look: http://www.codecademy.com/courses/python-

Re: Efficient way of looging in python

2013-05-02 Thread Maitrey Mishra
Sometimes, I notice the below errors: python call_Test.py Traceback (most recent call last): File "call_Test.py", line 1, in from Test_Task import TestTask File "/cygdrive/d/smoketest/targetflasher/flasher_server/Source/Test_Task.py", line 5, in import Logging.logQueueHandler as logq

Re: help..

2013-05-02 Thread Chris Angelico
On Fri, May 3, 2013 at 12:20 AM, leonardo wrote: > on codecademy there is an interactive box where you type your code, it is a > kind of exercise program to practice. but i don't understand what is wrong. > this is the website address of that if you want to give a look: > > http://www.codecademy

Re: help..

2013-05-02 Thread leonardo
on codecademy there is an interactive box where you type your code, it is a kind of exercise program to practice. but i don't understand what is wrong. this is the website address of that if you want to give a look: http://www.codecademy.com/courses/python-beginner-P5YtY/1/3?curriculum_id=4f89da

Re: Efficient way of looging in python

2013-05-02 Thread Maitrey Mishra
I wrote some tests for logging module. I use python 2.6 and use the example as in cookbook file : Test_Task.py from threading import Thread import Logging.logQueueHandler as logq class TestTask(threading.Thread): def __init__(self): pass def run(self): t = Thread(target=logq.log, args=("ERROR", "

Re: help..

2013-05-02 Thread Chris Angelico
On Thu, May 2, 2013 at 11:56 PM, leonardo selmi wrote: > so i wrote the following code: > def rental_car_cost(days): > cost = 40*days > if days >= 7: > return cost - 50 > elif days >= 3 and days < 7: > return cost - 20 > else: > r

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Wolfgang Maier
Oscar Benjamin gmail.com> writes: > > On 2 May 2013 13:55, Chris Angelico gmail.com> wrote: > > On Thu, May 2, 2013 at 10:52 PM, Oscar Benjamin > > gmail.com> wrote: > >> They are all easy to write as generator functions but to me the point > >> of itertools is that you can do things more effi

help..

2013-05-02 Thread leonardo selmi
i have also this program: write a function called rental_car_costthat takes days as input and returns the cost for renting a car for said number of days. The cost must abide by the following conditions: Every day you rent the car is $40. If you rent the car for 3 or more days, you get $20 off yo

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Oscar Benjamin
On 2 May 2013 13:55, Chris Angelico wrote: > On Thu, May 2, 2013 at 10:52 PM, Oscar Benjamin > wrote: >> They are all easy to write as generator functions but to me the point >> of itertools is that you can do things more efficiently than a >> generator function. Otherwise code that uses a combin

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Fábio Santos
> > Why is not a chunks function in itertools? > It is in more-itertools. It's not the standard library, but it's better than rolling your own every time you need it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Chris Angelico
On Thu, May 2, 2013 at 10:52 PM, Oscar Benjamin wrote: > They are all easy to write as generator functions but to me the point > of itertools is that you can do things more efficiently than a > generator function. Otherwise code that uses a combination of > itertools primitives is usually harder t

Re: "python.exe has stopped working" when os.execl() runs on Windows 7

2013-05-02 Thread Neil Cerutti
On 2013-05-01, F?bio Santos wrote: > Reproduced in Windows 7 Ultimate: > import os os.execl('ping.exe', '') > > At this point the REPL freezes, and windows prompts me to close Python > since it stopped responding. To repeat others and the documentation: In either case, the arguments

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Oscar Benjamin
On 2 May 2013 06:15, Steven D'Aprano wrote: > On Wed, 01 May 2013 10:00:04 +0100, Oscar Benjamin wrote: >> >> I'm not sure that's a valid argument against it since a chunks function >> could just do a different thing depending on the arguments given. > > Yes, but that's a rubbish API. I'd rather h

Re: Red Black Tree implementation?

2013-05-02 Thread Christian Heimes
Am 02.05.2013 01:11, schrieb Dan Stromberg: > > What's the best Red Black Tree implementation for Python with an > opensource license? > > I started out looking at > http://newcenturycomputers.net/projects/rbtree.html > because it was > prett

Re: Sum operation in numpy arrays

2013-05-02 Thread Steven D'Aprano
On Thu, 02 May 2013 02:10:11 -0700, Ana Dionísio wrote: > Hello! I have several numpy arrays in my script and i want to add them. > For example: > > a=[1,2,3,4,5] > b=[1,1,1,1,1] > c=[1,0,1,0,1] These are not numpy arrays, they are lists of ints. Based on the error message you quote: TypeError

Re: Sum operation in numpy arrays

2013-05-02 Thread Jens Thoms Toerring
Ana Dionísio wrote: > Hello! I have several numpy arrays in my script and i want to add them. For > example: > a=[1,2,3,4,5] > b=[1,1,1,1,1] > c=[1,0,1,0,1] > for i in range(5): > d[i]=a[i]+b[i]+c[i] > print d > [3,3,5,5,7] > I did it like that but I get an error: "TypeError: unsupported

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Mark Lawrence
On 02/05/2013 09:53, Wolfgang Maier wrote: What do you think? Wolfgang It ain't gonna happen, unless somebody puts Raymond Hettinger in the Comfy Chair :) -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence -- http://mail.python

Sum operation in numpy arrays

2013-05-02 Thread Ana Dionísio
Hello! I have several numpy arrays in my script and i want to add them. For example: a=[1,2,3,4,5] b=[1,1,1,1,1] c=[1,0,1,0,1] for i in range(5): d[i]=a[i]+b[i]+c[i] print d [3,3,5,5,7] I did it like that but I get an error: "TypeError: unsupported operand type(s) for +: 'float' and 'num

Re: Why chunks is not part of the python standard lib?

2013-05-02 Thread Wolfgang Maier
Steven D'Aprano pearwood.info> writes: > > > 1) Yield a shorter chunk > > 2) Extend the chunk with fill values > > 3) Raise an error > > 4) Ignore the last chunk > > > > Cases 2 and 4 can be achieved with current itertools primitives e.g.: 2) > > izip_longest(fillvalue=fillvalue, *[iter(iterable