Vancouver Python Day (Nov 16)
The Vancouver Python User Group and the Vancouver Django Meetup Group are pleased to announce: Vancouver Python Day Saturday, November 16, 2013 SFU Harbour Centre Part of Vancouver Developer Week 2013, Vancouver Python Day is a one-day mini conference celebrating the Python Developer Community in Vancouver. We hope to have talks covering a wide variety of Python development, from web development to gaming to performance and optimization. To that end, we're currently seeking talk proposals. Please visit https://github.com/andymckay/vancouver-python-day and submit your proposal today. Tickets will be offered for a nominal fee; we'll be sending another announcement before tickets go on sale. In the meantime, please mark your calendars! More information on Vancouver Python Day: http://www.vanpyday.com/ More information on Vancouver Developer Week: http://vancouver.devweek.org/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Released: Python 2.6.9 release candidate 1
Hello Pythoneers and Pythonistas, I'm happy to announce the availability of Python 2.6.9 release candidate 1. Python 2.6.9rc1 is a security-fix source-only release for Python 2.6. This means that general bug maintenance has ended, and only critical security issues are being fixed. It also means that no installers for Windows or Mac OS X will be provided. The last binary release of Python 2.6 was 2.6.6. Python 2.6.9 final is currently scheduled for Monday, October 28, 2013. Five years after the original release of Python 2.6, the 2.6.9 final release will be the last release of the Python 2.6 series. After this, all official maintenance of any kind for Python 2.6 will cease and the series will be retired. For ongoing maintenance, please see Python 2.7. Since 2.6.9 will be the last Python 2.6 release ever, I ask that you please download Python 2.6.9rc1, build it on your favorite platforms, and test it with your favorite code. You can report bugs to the Python bug tracker: http://bugs.python.org The source can be download from: http://www.python.org/download/releases/2.6.9/ You can also see what's changed since Python 2.6.8: http://www.python.org/download/releases/2.6.9/NEWS.txt Many thanks go out to the entire Python community for their contributions and help in making Python 2.6.9 available, especially Jyrki Pulliainen for his patch contributions. Enjoy, -Barry (on behalf of the Python development community) -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Python Unit Tests
On 9/30/2013 12:19 AM, melw...@gmail.com wrote: Hi Dave, Yeah I found the silly mistake lol thanks for that. making progress. Guess a number: 5 That's too high. Guess a number: 4 That's too high. Guess a number: 3 Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 29, in main print(responseCorrect + '! You guessed my number in ' + tries + 'guesses!') TypeError: cannot concatenate 'str' and 'int' objects This is what 'untested' means ;-) [code]import random intro = 'I have chosen a number from 1-10' request = 'Guess a number: ' responseHigh = That's too high. responseLow = That's too low. responseCorrect = That's correct! responseWrong = Wrong, The correct number is guessTaken = Your number of guesses were goodbye = ' Goodbye and thanks for playing!' allowed = 5 def getguess(target, allowed): tries = 0 while tries allowed: tries += 1 guess = int(input(request)) if guess target: print(responseLow) elif guess target: print(responseHigh) else: return guess, tries def main(target): guess, tries = getguess(target, allowed) if guess == target: print(responseCorrect + '! You guessed my number in ' + tries + 'guesses!') Either change 'tries' to 'str(tries)' or replace the statement with print(responseCorrect, 'You guessed my number in', tries, 'guesses!') There is no need to create a single string before the print. else: print(goodbye + ' The number I was thinking of was ' + number) ditto if __name__ == '__main__': main(random.randint(1, 10)) [/code] -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
How to read a particular cell by using wb = load_workbook('path', True) in openpyxl
Hi..there I have written code for reading the large excel files but my requirement is to read a particular cell in a excel file when i kept True in wb = load_workbook('Path', True) any body please help me... CODE: from openpyxl import load_workbook wb = load_workbook('Path', True) sheet_ranges = wb.get_sheet_by_name(name = 'Global') for row in sheet_ranges.iter_rows(): for cell in row: print cell.internal_value Regards, G.Someswara Rao -- https://mail.python.org/mailman/listinfo/python-list
Re: [ANN] ftputil 3.0a1 released
Glad to hear there's someone else other than me who still cares about the almost forgotten FTP protocol! =) --- Giampaolo https://code.google.com/p/pyftpdlib/ https://code.google.com/p/psutil/ https://code.google.com/p/pysendfile/ On Sun, Sep 29, 2013 at 8:00 PM, Stefan Schwarzer sschwar...@sschwarzer.net wrote: ftputil 3.0a1 is now available from http://ftputil.sschwarzer.net/download . Changes since version 2.8 - Note: This version of ftputil is _not_ backward-compatible with earlier versions.See the links below for information on adapting existing client code. - This version adds Python 3 compatibility! :-) The same source is used for Python 2.x and Python 3.x. I had to change the API to find a good compromise for both Python versions. - ftputil now requires at least Python 2.6. - Remote file-like objects use the same semantics as Python's `io` module. (This is the same as for the built-in `open` function in Python 3.) - `ftputil.ftp_error` was renamed to `ftputil.error`. - For custom parsers, import `ftputil.parser` instead of `ftputil.stat`. For more information please read http://ftputil.sschwarzer.net/trac/wiki/WhatsNewInFtputil3.0 http://ftputil.sschwarzer.net/trac/wiki/PreReleaseDocumentation What is ftputil? ftputil is a high-level FTP client library for the Python programming language. ftputil implements a virtual file system for accessing FTP servers, that is, it can generate file-like objects for remote files. The library supports many functions similar to those in the os, os.path and shutil modules. ftputil has convenience functions for conditional uploads and downloads, and handles FTP clients and servers in different timezones. License --- ftputil is Open Source software, released under the revised BSD license (see http://opensource.org/licenses/BSD-3-Clause ). Stefan -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
class implementation
Is there a way to give a class extra functions whidout editing the .py file where the class is located? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tab completion in Python3.4
Steven D'Aprano steve at pearwood.info writes: I don't consider either of these solutions to be satisfactory. If you agree, I urge you to try it out for yourself, and then leave a comment on the bug tracker asking for tab completion to still insert tabs at the beginning of the line: Such a change is much more likely to happen if someone actually proposes a patch for it, rather than merely ask for it. I don't think anyone is ideologically opposed to it. Regards Antoine. -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
markot...@gmail.com wrote: Is there a way to give a class extra functions whidout editing the .py file where the class is located? A clean way is subclassing: import vehicles class FlyingCar(vehicles.Car): def lift_off(self): pass flying_car = FlyingCar() flying_car.lift_off() -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
esmaspäev, 30. september 2013 11:43.19 UTC+3 kirjutas mark...@gmail.com: Is there a way to give a class extra functions whidout editing the .py file where the class is located? But does it have all the variables that the main class have? -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
markot...@gmail.com wrote: esmaspäev, 30. september 2013 11:43.19 UTC+3 kirjutas mark...@gmail.com: Is there a way to give a class extra functions whidout editing the .py file where the class is located? But does it have all the variables that the main class have? Yes. You can invoke all methods of Car on a FlyingCar instance. If you don't define an __init__() method in FlyingCar the initializer of the parent class will be invoked which typically sets a few attributes (I think this is what you mean by variables; if not: please clarify). So just try it out. If you don't get your code to work you can post it here and ask for help on an actual piece of Python. -- https://mail.python.org/mailman/listinfo/python-list
CRUD library
Hi, Do you know any library or framework that unifies CRUD somehow. Maybe I'll describe my problem: I have a application that uses many external services and processes them together. This are things like web services and DB and so on. In the REST era we usually operate on object and collections of objects (like in django's ORM) but have different source behind them. My idea was that there might be somewhere a unified abstraction layer that would require from programmers to write the CRUD methods and handle object creation and management (maybe even relations?) by itself. I've started to work on my own library for that but I wouldn't like to do something that someone has done already. Do you know any such library/framework? Do you think that it makes any sense at all? regards, Adam -- https://mail.python.org/mailman/listinfo/python-list
Re: Handling 3 operands in an expression without raising an exception
On 2013-09-28, Zero Piraeus z...@etiol.net wrote: : On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: You actually need the tool that was used on King Edward II. To be clear, Mark, you are calling for ?? to be tortured to death with a red hot poker, yes? I'm going to go out on a limb and suggest that such a suggestion is outside what people generally consider acceptable on this list. It's reassuring that even a guy like Nikos has his White Knights. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
DNS query against a specific server.
Hi, ``socket.gethostbyname`` sends the DNS resolution query to the DNS server specified by the OS. Is there an easy way to send a query to a *different* server? I see that twisted.names allows you to do this, but, having all of twisted as dependency to my project when all I need to do is a simple DNS query seems a bit extreme. I also found pydns, but that looks fairly outdated and unmaintained. Is there not an actively maintained lightweight solution? If not, I will go with twisted. Cheers, Mich. -- https://mail.python.org/mailman/listinfo/python-list
Re: Handling 3 operands in an expression without raising an exception
On Mon, Sep 30, 2013 at 9:32 PM, Neil Cerutti ne...@norwich.edu wrote: On 2013-09-28, Zero Piraeus z...@etiol.net wrote: : On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: You actually need the tool that was used on King Edward II. To be clear, Mark, you are calling for ?? to be tortured to death with a red hot poker, yes? I'm going to go out on a limb and suggest that such a suggestion is outside what people generally consider acceptable on this list. It's reassuring that even a guy like Nikos has his White Knights. Ahoy! Ahoy! Check! Actually, it's more that even those of us who will put him down verbally don't actually want to see him tortured to death. I've strongly recommended that he either shape up or ship out (learn to code or get out of programming as a business), but that doesn't in any way mean I would rejoice at his death. But he is annoying. Very annoying. And I completely understand the frustration that leads people to want him to suffer great pain. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: CRUD library
On 09/30/2013 03:14 AM, AdamKal wrote: Hi, Do you know any library or framework that unifies CRUD somehow. Sounds kind of like the DAL (Data Abstaction Layer/Language) from web2py, perhaps? I think I've heard of it being able to be used outside a regular web2py install... not sure, haven't tried it myself. HTH, Monte -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
On Sep 30, 2013, at 7:42 AM, Michel Albert exh...@gmail.com wrote: Hi, ``socket.gethostbyname`` sends the DNS resolution query to the DNS server specified by the OS. Is there an easy way to send a query to a *different* server? I see that twisted.names allows you to do this, but, having all of twisted as dependency to my project when all I need to do is a simple DNS query seems a bit extreme. I also found pydns, but that looks fairly outdated and unmaintained. Is there not an actively maintained lightweight solution? If not, I will go with twisted. Cheers, Mich. -- https://mail.python.org/mailman/listinfo/python-list It isn't pure python, but you would be pretty much guaranteed a maintained solution if you use the name server lookup in your OS. Something like: import subprocess nsl_reslt = subprocess.Popen(['nslookup', 'insert name nere' ],stderr = subprocess.PIPE, stdout = subprocess.PIPE).communicate()[0] Hope this helps, Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
On Monday, 30 September 2013 14:36:34 UTC+2, William Ray Wing wrote: On Sep 30, 2013, at 7:42 AM, Michel Albert *** wrote: Hi, ``socket.gethostbyname`` sends the DNS resolution query to the DNS server specified by the OS. Is there an easy way to send a query to a *different* server? I see that twisted.names allows you to do this, but, having all of twisted as dependency to my project when all I need to do is a simple DNS query seems a bit extreme. I also found pydns, but that looks fairly outdated and unmaintained. Is there not an actively maintained lightweight solution? If not, I will go with twisted. Cheers, Mich. -- https://mail.python.org/mailman/listinfo/python-list It isn't pure python, but you would be pretty much guaranteed a maintained solution if you use the name server lookup in your OS. Something like: import subprocess nsl_reslt = subprocess.Popen(['nslookup', 'insert name nere' ],stderr = subprocess.PIPE, stdout = subprocess.PIPE).communicate()[0] Hope this helps, Bill Hmm... I had this option in mind, but opening a subprocess for something as small as this seemed a bit error-prone. If something on the system changes, nslookup replaced by dig or nslookup output changes for example your application will bug out. Granted, the chance of this happening is slim, but using a fixed-version dependency in your setup script gives you a much safer solution IMO. I know I may be splitting hairs. Any of the mentioned solutions are fine. But I am curious to see if something like this is not yet implemented in a more standard way. I was surprised to see that ``gethostbyname`` does not take an optional parameter for this task. -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
Hello, On Mon, Sep 30, 2013 at 04:42:29AM -0700, Michel Albert wrote: Hi, ``socket.gethostbyname`` sends the DNS resolution query to the DNS server specified by the OS. Is there an easy way to send a query to a *different* server? I see that twisted.names allows you to do this, but, having all of twisted as dependency to my project when all I need to do is a simple DNS query seems a bit extreme. I also found pydns, but that looks fairly outdated and unmaintained. Is there not an actively maintained lightweight solution? If not, I will go with twisted. there is a dns modul for Python (I don't know is it part of standard Python library or not), on most Linux distribution you can find it, eg. in Debian it's called python-dnspython. It can handle different nameserver, than OS knows - here is a sample code: import dns.resolver r = dns.resolver.Resolver() r.namerservers = ['127.0.0.1'] # or any other IP, in my case I'm using PDNS, which have two # parts: a recursor and a resolver; recursor allows requests only # on localhost mxservers = r.query(python.org, 'MX').response hth, a. -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
On Mon, Sep 30, 2013 at 10:45 PM, Michel Albert exh...@gmail.com wrote: I know I may be splitting hairs. Any of the mentioned solutions are fine. But I am curious to see if something like this is not yet implemented in a more standard way. I was surprised to see that ``gethostbyname`` does not take an optional parameter for this task. gethostbyname is a simple function with not much flexibility. (You can't, for instance, look up a TXT record.) For anything more complex, you want a proper DNS implementation. There are a few Python DNS modules. It means adding another dependency, but perhaps not as large as twisted. And of course, you could always manually send UDP packets and listen for responses, but that seems a little unnecessary :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Handling 3 operands in an expression without raising an exception
On 2013-09-30, Chris Angelico ros...@gmail.com wrote: You actually need the tool that was used on King Edward II. To be clear, Mark, you are calling for ?? to be tortured to death with a red hot poker, yes? I'm going to go out on a limb and suggest that such a suggestion is outside what people generally consider acceptable on this list. It's reassuring that even a guy like Nikos has his White Knights. Ahoy! Ahoy! Check! Actually, it's more that even those of us who will put him down verbally don't actually want to see him tortured to death. I've strongly recommended that he either shape up or ship out (learn to code or get out of programming as a business), but that doesn't in any way mean I would rejoice at his death. This makes perfect sense. It's be sort of like being one of the police in Dallas protecting Oswald; it's from a sense of duty, rather than a generally sincere love. But he is annoying. Very annoying. And I completely understand the frustration that leads people to want him to suffer great pain. I don't want him to suffer great pain, but it would please me if it were possible to annoy him in some way. Like maybe with the sound of a mosquito. B! BzZ! -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
markot...@gmail.com wrote: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Please show us some code. Thankyou. -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
On Monday, 30 September 2013 14:54:41 UTC+2, Ervin Hegedüs wrote: Hello, On Mon, Sep 30, 2013 at 04:42:29AM -0700, Michel Albert wrote: Hi, ``socket.gethostbyname`` sends the DNS resolution query to the DNS server specified by the OS. Is there an easy way to send a query to a *different* server? I see that twisted.names allows you to do this, but, having all of twisted as dependency to my project when all I need to do is a simple DNS query seems a bit extreme. I also found pydns, but that looks fairly outdated and unmaintained. Is there not an actively maintained lightweight solution? If not, I will go with twisted. there is a dns modul for Python (I don't know is it part of standard Python library or not), on most Linux distribution you can find it, eg. in Debian it's called python-dnspython. It can handle different nameserver, than OS knows - here is a sample code: import dns.resolver r = dns.resolver.Resolver() r.namerservers = ['127.0.0.1'] # or any other IP, in my case I'm using PDNS, which have two # parts: a recursor and a resolver; recursor allows requests only # on localhost mxservers = r.query(python.org, 'MX').response hth, a. Indeed, this looks much nicer than both twisted or pydns. I think I'll go with that one. Thanks a lot! -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On Mon, Sep 30, 2013 at 9:02 AM, Peter Otten __pete...@web.de wrote: markot...@gmail.com wrote: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Please show us some code. Thankyou. -- https://mail.python.org/mailman/listinfo/python-list You should start by learning about classes -- perhaps here: http://docs.python.org/2/tutorial/classes.html#classes Then, try writing some code using classes or extending a class. Then come back when something doesn't work as expected -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: DNS query against a specific server.
Chris Angelico ros...@gmail.com wrote: There are a few Python DNS modules. It means adding another dependency, but perhaps not as large as twisted. And of course, you could always manually send UDP packets and listen for responses, but that seems a little unnecessary :) Then there is pycares; a Python module which provides an interface to c-ares c-ares is a C library that performs DNS requests and name resolves asynchronously.. I have good experience wih C-ares and it can set specific nameservers. Ref: https://pypi.python.org/pypi/pycares/0.3.0 --gv -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 2013-09-29, ?? nikos.gr...@gmail.com wrote: 29/9/2013 10:53 , ??/?? Chris Angelico : You fail to understand that these code i now use was written with the help of regulars here and yes its correct. If you're code is correct, then use it and be happy. There's no need to bother us if your code is correct. -- Grant Edwards grant.b.edwardsYow! Can I have an IMPULSE at ITEM instead? gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: what is wrong in my code?? (python 3.3)
On Friday, September 27, 2013 7:19:45 PM UTC+3, Denis McMahon wrote: On Fri, 27 Sep 2013 06:54:48 -0700, dream4soul wrote: #!c:/Python33/python.exe -u import os, sys print(Content-type: text/html; charset=utf-8\n\n) print ('Hello, world!hr') print('ранее предусматривалась смертная казнь.') I see only first print, second it just question marks in my browser(code edited in notepad++ with UTF-8 encode). what is wrong?? Sounds like your browser is ignoring the charset. Can you force the browser to utf-8? What happens if you create a plain html file with the same content and send it to your browser? eg: test.html: - Hello, world!hr ранее предусматривалась смертная казнь. - This really doesn't look like a python issue (again). -- Denis McMahon, denismfmcma...@gmail.com I rename file from test.py in test.txt and all works fine. So clearly problem it is not in file coding or browser. ANY IDEAS?? -- https://mail.python.org/mailman/listinfo/python-list
Using GNU libc mtrace/muntrace via ctypes?
I'm getting an error in certain situations which leads to this message: *** glibc detected *** /opt/TWWfsw/bin/python: corrupted double-linked list: 0x07952420 *** Valgrind hasn't been any help. I'd really like to avoid recompiling Python, as that might just move or obscure the error. Might it be possible to enable the GNU libc malloc tracing via ctypes? Thanks, Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 29/09/2013 17:19, Νίκος wrote: Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε: asked and answered. Move on shut up. you are nothign but annoyance here. Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
RE: Barcode printing
If that's a bit heavyweight (and confusing; it's not all free software, since some of it is under non-free license terms), there are other options. pyBarcode URL:http://pythonhosted.org/pyBarcode/ says it's a pure-Python library that takes a barcode type and the value, and generates an SVG of the barcode. Actually, The canvas concept is exactly what I need and this is perfect! Thanks Gary and Ben, jlc -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 14:51, Grant Edwards wrote: On 2013-09-29, ?? nikos.gr...@gmail.com wrote: 29/9/2013 10:53 , ??/?? Chris Angelico : You fail to understand that these code i now use was written with the help of regulars here and yes its correct. If you're code is correct, then use it and be happy. There's no need to bother us if your code is correct. Could this be an extremely rare case whereby the original code is 100% correct but the problems have been exacerbated by the many suggested patches given here being 100% incorrect? -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
fetchall to python lists
Hi - I have some basic programming experience and new to Python. I have connected to SQL Server as follows: import pyodbc conn = pyodbc.connect('DSN=DBC') cursor = conn.cursor() cursor.execute(select measure,fin_year_no,fin_week_no,location_no,value from actual) result=cursor.fetchall() result looks like this: result[0] - ('2013', 2014, 7, 242, 96064.35) result[1] - ('2013', 2014, 7, 502, 18444.2) approximately 2m records Is there a way to assign the values of result to 5 lists without doing 5 select statments one for each of the colums and then assigning it to a list so that: list1[0] = '2013' list1[1] = 2014 list1[2] = 7 list1[3] = 242 list1[4] = 96064.35 list2[0] = '2013' list2[1] = 2014 list2[2] = 7 list2[3] = 502 list2[4] = 18444.2 and so on ... Hope someone can help. Regards Jerome -- https://mail.python.org/mailman/listinfo/python-list
Re: Handling 3 operands in an expression without raising an exception
On 29/09/2013 18:44, MRAB wrote: On 29/09/2013 18:24, Piet van Oostrum wrote: Antoon Pardon antoon.par...@rece.vub.ac.be writes: Why? What is so important about this particular way, that you are willing to spend/waste so much time on it? You act like someone who want to get from Brussels to London and when asked how to do that gets advise on how to take the boat or plane at which point you react that you want to get to Londen without boat or plane but just by bicycle. And in further exchange make it clear that using a bike is more important than arriving in London. And then the easiests would be to put your bicycle in the train. But what if you don't want to use the train, but cycle all the way? There _must_ be a way of cycling through the tunnel... There is but all the illegal immigrants who use it won't tell us about it :) -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Tue, Oct 1, 2013 at 12:51 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 30/09/2013 14:51, Grant Edwards wrote: On 2013-09-29, ?? nikos.gr...@gmail.com wrote: 29/9/2013 10:53 , ??/?? Chris Angelico : You fail to understand that these code i now use was written with the help of regulars here and yes its correct. If you're code is correct, then use it and be happy. There's no need to bother us if your code is correct. Could this be an extremely rare case whereby the original code is 100% correct but the problems have been exacerbated by the many suggested patches given here being 100% incorrect? Jests and barbs left aside, I believe his definition of correct is wasn't crashing. Earlier in this thread there was a hint that he'd tightened a bare except to one specific exception. My guess is his code wasn't correct, but one bug (overly-broad try/except) masked another. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Handling 3 operands in an expression without raising an exception
On 29/09/2013 22:15, Denis McMahon wrote: Nick, you have now spent 4 days arguing over a minor coding problem that you were given solutions to on the first day, primarily because you feel that the solutions you are being offend some programming aesthetic you have. I suggest that it's time for you to re-evaluate what you want from this ng, and indeed what language you want to code in if your perl minimal code possible aesthetic is so important to you. If you want good python code, then stop telling everyone here that their working solutions are wrong and should be more like your dysfunctional code, and use the solutions you are given. If you want to write minimalist perl code, then stop using python and use perl. In either case, you need to stop arguing with people who are offering you solutions to your problems solely based on the fact that you don't like their coding styles. You are the one who comes here asking for solutions. Either accept the solutions you are offered, or stop asking for them. +googol -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: fetchall to python lists
On Mon, Sep 30, 2013 at 10:58 AM, christensen.jer...@gmail.com wrote: Hi - I have some basic programming experience and new to Python. I have connected to SQL Server as follows: import pyodbc conn = pyodbc.connect('DSN=DBC') cursor = conn.cursor() cursor.execute(select measure,fin_year_no,fin_week_no,location_no,value from actual) result=cursor.fetchall() result looks like this: result[0] - ('2013', 2014, 7, 242, 96064.35) result[1] - ('2013', 2014, 7, 502, 18444.2) approximately 2m records Is there a way to assign the values of result to 5 lists without doing 5 select statments one for each of the colums and then assigning it to a list so that: What you have below is just result[0][0], result[0][1], etc. list1[0] = '2013' list1[1] = 2014 list1[2] = 7 list1[3] = 242 list1[4] = 96064.35 list2[0] = '2013' list2[1] = 2014 list2[2] = 7 list2[3] = 502 list2[4] = 18444.2 and so on ... Hope someone can help. Regards Jerome So what I'm trying to say is that you already have what you want. each tuple is contained in the out list of all of the tuples. For brevity sake, I am acting as if the data set contained only a single row: result = (('2013', 2014, 7, 242, 96064.35),) result (('2013', 2014, 7, 242, 96064.35),) result[0] ('2013', 2014, 7, 242, 96064.35) result[0][0] '2013' result[0][1] 2014 -- https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: fetchall to python lists
On Monday, September 30, 2013 4:58:25 PM UTC+2, christens...@gmail.com wrote: Hi - I have some basic programming experience and new to Python. I have connected to SQL Server as follows: import pyodbc conn = pyodbc.connect('DSN=DBC') cursor = conn.cursor() cursor.execute(select measure,fin_year_no,fin_week_no,location_no,value from actual) result=cursor.fetchall() result looks like this: result[0] - ('2013', 2014, 7, 242, 96064.35) result[1] - ('2013', 2014, 7, 502, 18444.2) approximately 2m records Is there a way to assign the values of result to 5 lists without doing 5 select statments one for each of the colums and then assigning it to a list so that: list1[0] = '2013' list1[1] = 2014 list1[2] = 7 list1[3] = 242 list1[4] = 96064.35 list2[0] = '2013' list2[1] = 2014 list2[2] = 7 list2[3] = 502 list2[4] = 18444.2 and so on ... Hope someone can help. Regards Jerome Thanks Joel did not think it could be so simple!!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Restart the interactive python shell like in IDLE
On Thursday, June 11, 2009 1:48:42 AM UTC+2, Chris Rebert wrote: On Wed, Jun 10, 2009 at 12:01 PM, Matt Bursonmsbur...@gmail.com wrote: Is there a way to reproduce the behavior of IDLE's restart shell ability by using a function? I thought there would be since you can exit python by executing the simple quit() function I thought there would be an equally simple function name something like restart(). I'd prefer something like this as opposed to having to exit the shell and then start it up again to refresh it. I believe IDLE itself implements the restart capability by killing and re-launching its Python interpreter subprocess, so it's not like it's using some hidden capability of Python to accomplish this. Is doing Ctrl+D, up-arrow, Enter really that hard? It's even fewer keystrokes than restart()... Cheers, Chris -- http://blog.rebertia.com You might be launching python from something else other than a shell and it might be harder to re-launch it from there -- https://mail.python.org/mailman/listinfo/python-list
VERY BASIC HELP
c=int(raw_input(How many numbers do you want to work? (Min. 2 Max. 3))) if c==2: x=int(raw_input(Enter the first number to be worked)) y=int(raw_input(Enter the second number to be worked)) elif c==3: x=int(raw_input(Enter the first number to be worked)) y=int(raw_input(Enter the second number to be worked)) z=int(raw_input(Enter the third number to be worked)) else: print Invalid input.;raw_input(Press enter to close this window);exit p=int(raw_input(Do you want to divide, subtract, add or multiply these numbers? (1=divide, 2=subtract, 3=add, 4=multiply))) if p==1 and c==2: print The result is : ;x/y elif p==1 and c==3: print The result is :;x/y/z elif p==2 and c==2: print The result is :;x-y elif p==2 and c==3: print The result is :;x-y-z elif p==3 and c==2: print The result is :;x+y elif p==3 and c==3: print The result is :;x+y+z elif p==4 and c==2: print The result is :;x*y elif p==4 and c==3: print The result is :;x*y*z else: print Invalid Input.;raw_input(Press enter to close this window) That is my program. These are the problems I am having : 1. Even if c is not 2 or 3, the program continues, as if it received a valid input, it does not exit as I have tried to code it to. 2. If all values are entered correctly, the result does not display. It shows up as The result is : and just blank. PLEASE HELP -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
In article ba94102b-18b6-4850-ac85-032b0fe2f...@googlegroups.com, rusi rustompm...@gmail.com wrote: Combining your two questions -- Recently: What minimum should a person know before saying I know Python And earlier this On Sunday, August 4, 2013 10:00:35 PM UTC+5:30, Aseem Bansal wrote: If there is an issue in place for improving the lambda forms then that's good. I wanted a link about functional programming because it is mentioned as if it were a household word. Python is not a functional programming language; however it supports most of FP better than traditional languages like C/Java. eg with iterators/generators + itertools + functools you can do most of what lazy lists give in haskell Some discussion here: http://stackoverflow.com/questions/1017621/why-isnt-python-very-good-for-functional-programming [Not everything said there is correct; eg python supports currying better than haskell which is surprising considering that Haskell's surname is Curry!] So if I may break your question into two: 1. Why should a programmer of a non-FP language know FP? 2. What in FP should a (any|all) programmer know? I touched upon these in two blog-posts: 1. http://blog.languager.org/2013/06/functional-programming-invades.html 2. http://blog.languager.org/2012/10/functional-programming-lost-booty.html Also most programmers without an FP background have a poor appreciation of the centrality of recursion in CS; see http://blog.languager.org/2012/05/recursion-pervasive-in-cs.html Good approach of FP in Python, but two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. 2. Lambda-expression body is limited to one expression. Why ? Why the hell those limitations ? In this aspect, Javascript has a cooler approach. franck -- https://mail.python.org/mailman/listinfo/python-list
Re: VERY BASIC HELP
On Tue, Oct 1, 2013 at 2:55 AM, vignesh.harikris...@gmail.com wrote: print Invalid input.;raw_input(Press enter to close this window);exit 1. Even if c is not 2 or 3, the program continues, as if it received a valid input, it does not exit as I have tried to code it to. In Python, exit isn't a statement, it's a function. So you need to write: exit() to actually terminate. elif p==3 and c==3: print The result is :;x+y+z 2. If all values are entered correctly, the result does not display. It shows up as The result is : and just blank. The semicolon ends the print statement, and then you simply evaluate and do nothing with the sum. Try a comma instead - that'll make it a second argument to print, so it'll be printed out as you expect. Thank you for making your problem so clear. You've given your code, and you've said exactly what it's doing that you don't expect. I really appreciate that! But one thing I would ask: Next time, please consider your subject line. That's the first chance you have to grab someone's attention - VERY BASIC HELP doesn't say _what_ you need help with. :) Your post makes a nice change from some I've seen, though... Have fun, happy Pythoning! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
On Tue, Oct 1, 2013 at 3:04 AM, Franck Ditter nob...@nowhere.org wrote: 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. I've yet to see any value in having the compiler/interpreter optimize tail recursion that can't be achieved just as well, and usually more clearly, with simple iteration. Recursion's important; tail recursion's important; tail recursion optimization isn't. (But I do sometimes yearn for a goto.) 2. Lambda-expression body is limited to one expression. Why ? Why the hell those limitations ? In this aspect, Javascript has a cooler approach. Since you can just use def in the middle of another function, the difference between def and lambda isn't all that huge. Yes, def isn't an expression - but Python's lambda gives an incredibly compact notation for the common case. Compare these two snippets: # Python odd_numbers = filter(lambda x: x%2, numbers) //Pike odd_numbers = filter(numbers, lambda(int x) {return x%2;}) Aside from the type declaration and the argument order, these two snippets are doing exactly the same thing in exactly the same way. Python's version is way more compact. Pike's version lets you put multiple statements into the expression... but most of the time you don't need that. Both approaches have their value. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: VERY BASIC HELP
In 380132bc-bc9c-4d57-95d8-dc01f26f4...@googlegroups.com vignesh.harikris...@gmail.com writes: c=int(raw_input(How many numbers do you want to work? (Min. 2 Max. 3))) if c==2: x=int(raw_input(Enter the first number to be worked)) y=int(raw_input(Enter the second number to be worked)) elif c==3: x=int(raw_input(Enter the first number to be worked)) y=int(raw_input(Enter the second number to be worked)) z=int(raw_input(Enter the third number to be worked)) else: print Invalid input.;raw_input(Press enter to close this window);exit p=int(raw_input(Do you want to divide, subtract, add or multiply these numbers? (1=divide, 2=subtract, 3=add, 4=multiply))) if p==1 and c==2: print The result is : ;x/y elif p==1 and c==3: print The result is :;x/y/z elif p==2 and c==2: print The result is :;x-y elif p==2 and c==3: print The result is :;x-y-z elif p==3 and c==2: print The result is :;x+y elif p==3 and c==3: print The result is :;x+y+z elif p==4 and c==2: print The result is :;x*y elif p==4 and c==3: print The result is :;x*y*z else: print Invalid Input.;raw_input(Press enter to close this window) That is my program. These are the problems I am having : 1. Even if c is not 2 or 3, the program continues, as if it received a valid input, it does not exit as I have tried to code it to. That's because your code is this: exit instead of this: exit() In other words, you're referring to the exit function, but not actually calling it. 2. If all values are entered correctly, the result does not display. It shows up as The result is : and just blank. That's because you're using a semicolon after the print statement. This code is really two completely separate statements: print The result is : ;x/y It prints the message and then, as a separate action, it calculates the value of x/y (and then throws that value away, because it isn't assigned anywhere.) Use a comma instead of a semicolon, like this: print The result is : , x/y -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
markot...@gmail.com writes: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Do you mean class variables or instance variables? -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: VERY BASIC HELP
Thank you both so much! I'll be sure to make more pertinent subject lines now :) Thanks for the detailed explanations! Clearly, I've just started learning this language ~20 minutes before I made this post, and am still learning the basics. Do you guys know of any guides for a beginner? I am definitely willing to take the time to learn in depth :) -- https://mail.python.org/mailman/listinfo/python-list
Re: what is wrong in my code?? (python 3.3)
dream4s...@gmail.com writes: I rename file from test.py in test.txt and all works fine. So clearly problem it is not in file coding or browser. ANY IDEAS?? It looks like the encoding of stdout is not utf-8 in the CGI script. Check it with import sys print(sys.stdout.encoding) If it's not utf-8, you must force your output to be utf-8, as that is what the browser expects, because of your Content-type. You could use: sys.stdout.buffer.write('ранее предусматривалась смертная казнь.'.encode('utf-8')) Or to change stdout into utf-8 encoding: import codecs sys.stdout = codecs.getwriter(utf-8)(sys.stdout.detach()) [Note: I haven't tested this] -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: On 29/09/2013 17:19, Νίκος wrote: Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε: asked and answered. Move on shut up. you are nothign but annoyance here. Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. Perhaps it would be even better if you quit spamming my thread with your funny quotes. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Op 30-09-13 20:03, Νίκος schreef: Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: On 29/09/2013 17:19, Νίκος wrote: Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε: asked and answered. Move on shut up. you are nothign but annoyance here. Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. You may like porgramming, but it is rather obvious you don't like the python style of programming. So maybe you should chose a laguage whose style is more to your liking. Perhaps it would be even better if you quit spamming my thread with your funny quotes. You have no authority over what people contribute in your thread. Since you don't seem very considerate about the effect your contributions have on others, you can hardly expect others to be considerate of you. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
On 2013-09-30, Franck Ditter nob...@nowhere.org wrote: In article ba94102b-18b6-4850-ac85-032b0fe2f...@googlegroups.com, rusi rustompm...@gmail.com wrote: I touched upon these in two blog-posts: 1. http://blog.languager.org/2013/06/functional-programming-invades.html 2. http://blog.languager.org/2012/10/functional-programming-lost-booty.html Also most programmers without an FP background have a poor appreciation of the centrality of recursion in CS; see http://blog.languager.org/2012/05/recursion-pervasive-in-cs.html Good approach of FP in Python, but two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. If you've got a set of recursive functions with recursive calls in tail-call position it's pretty easy to convert to a solution that doesn't blow the stack. Converting to a while loop is usually straightforward, or you try trampolining. If the calls aren't in tail-call position then you wouldn't get tail-call optimization from a language like scheme, either. Getting calls in tail position is often the sticking point, and tail-call optimization doesn't help with that. I think the Python rationale also discusses how it would make tracebacks harder to understand if stackframes could clobber each other. Personally I think that's more a theoretical than a practical problem. Languages with tail-call optimization aren't impossible to debug. 2. Lambda-expression body is limited to one expression. Why ? Why the hell those limitations ? In this aspect, Javascript has a cooler approach. It's in the Design and History FAQ. http://docs.python.org/3/faq/design.html Why cant lambda forms contain statements? Python lambda forms cannot contain statements because Pythons syntactic framework cant handle statements nested inside expressions. However, in Python, this is not a serious problem. Unlike lambda forms in other languages, where they add functionality, Python lambdas are only a shorthand notation if youre too lazy to define a function. Functions are already first class objects in Python, and can be declared in a local scope. Therefore the only advantage of using a lambda form instead of a locally-defined function is that you dont need to invent a name for the function but thats just a local variable to which the function object (which is exactly the same type of object that a lambda form yields) is assigned! What I usually end up with is a dictionary of callbacks, with the simple functions defined in-line and the more complex functions defined just before that and referenced instead. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 19:03, Νίκος wrote: Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: On 29/09/2013 17:19, Νίκος wrote: Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε: asked and answered. Move on shut up. you are nothign but annoyance here. Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. Perhaps it would be even better if you quit spamming my thread with your funny quotes. Your approach as given in the pseudocode given below is taking up what, 50% of the bandwidth here? What a waste of a resource. while answer_isn't_what_I_want: keep_asking_question() You are to this mailing list what King Herod was to baby sitting. Please drop dead and the sooner the better. Your arrogant attitide to the numerous people who've tried so hard to help you is disgraceful. -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 9/30/13 2:42 PM, Mark Lawrence wrote: Please drop dead and the sooner the better. Your arrogant attitide to the numerous people who've tried so hard to help you is disgraceful. Mark, I'm as frustrated as anyone by Nikos' threads, but there's really no call for Please drop dead. We can do better than that. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
Franck Ditter nob...@nowhere.org writes: Good approach of FP in Python, but two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. Tail recursion optimization throws away valuable stack trace information in case of an error. 2. Lambda-expression body is limited to one expression. Why ? Allowing general statements in a lambda body makes indentation more difficult, I think. -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: VERY BASIC HELP
On Mon, Sep 30, 2013 at 1:50 PM, vignesh.harikris...@gmail.com wrote: Thank you both so much! I'll be sure to make more pertinent subject lines now :) Thanks for the detailed explanations! Clearly, I've just started learning this language ~20 minutes before I made this post, and am still learning the basics. Do you guys know of any guides for a beginner? I am definitely willing to take the time to learn in depth :) check out the documentation links on python.org to start -- https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
Op 30-09-13 19:04, Franck Ditter schreef: Good approach of FP in Python, but two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. Guido doesn't like it. 2. Lambda-expression body is limited to one expression. Why ? Why the hell those limitations ? In this aspect, Javascript has a cooler approach. Guido prefers it that way. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Which Python Framework for REST API and Facebook Wrapper?
On Saturday, September 28, 2013 11:20:21 AM UTC-5, harry@gmail.com wrote: I will be designing a REST based API for a cross-platform back end that will serve both desktop Facebook users as well as mobile users. It will handle operations such as user creation, retrieval of user and other data, payment verification and in the case of the desktop side, handle the html/css template customization. The database back end is MySQL and I do need a cache system. Currently we were using Codeigniter (PHP) for our codebase but as CI seems on the way out, I do not wish to start a new project based on it. I was looking at Laravel for PHP, but, Python is very attractive to me as a language and since the introduction of WSGI, I am confident it can make a difference in performance and code maintainability over PHP while being able to plug in to our dedicated server infrastructure. Since I am not experienced with Python frameworks (though learning curve is not much of an issue for me) I look to the community to understand which Python framework can rival or surpass Codeigniter in terms of performance in heavy traffic backend solutions (over 1M requests per day, with up to 100 req/sec at peak). I really want to make the switch from PHP to Python as I believe that Python can solve more problems with less code and faster execution time, not to mention freedom from brackets and semicolons. If you're looking for something simple, there are solutions like Flask (my favourite), CherryPy, Bottle, and web2py. (I only know the names of the last 3) I recommend taking a look into the likes of Flask, if only to familiarize yourself with some of the techniques of Python frameworks. Here's a basic Flask app: from flask import Flask app = Flask(__name__) @app.route('/') def main(): return Hey, I'm in a Flask! if __name__ == __main__: app.run('0.0.0.0', port=5000, debug=True) If you're looking for performance, Tornado (http://www.tornadoweb.org/en/stable/) I've heard is pretty awesome - though I've not put it through the paces myself. HTH, -W -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On 30/9/2013 08:41, markot...@gmail.com wrote: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. But perhaps you mean attributes. There are both class attributes and instance attributes, and the behavior is quite different. Roughly speaking a class attribute occurs only once per class, and all code can read its value with either Class.my_attrib or instance.my_attrib. It can be written with Class.my_attrib. On the other hand, instance attributes are usable by instance.my_attrib, regardless of whether the instance is a base class or a child class. Each instance of the class gets a separate copy of such an attribute. They are normally defined in the __init__() method. If you don't happen to know the difference between a class an an instance of that class, then all the above will look like gibberish, and you need to do some studying first. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: CRUD library
On Monday, September 30, 2013 5:14:28 AM UTC-5, AdamKal wrote: Hi, Do you know any library or framework that unifies CRUD somehow. Maybe I'll describe my problem: I have a application that uses many external services and processes them together. This are things like web services and DB and so on. In the REST era we usually operate on object and collections of objects (like in django's ORM) but have different source behind them. My idea was that there might be somewhere a unified abstraction layer that would require from programmers to write the CRUD methods and handle object creation and management (maybe even relations?) by itself. I've started to work on my own library for that but I wouldn't like to do something that someone has done already. Do you know any such library/framework? Do you think that it makes any sense at all? Does http://python-eve.org/ look anything like what you mean? Or perhaps http://www.sqlalchemy.org/ ? HTH, W -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Unit Tests
Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none? Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 27, in main guess, tries = getguess(target, allowed) TypeError: 'NoneType' object is not iterable On Saturday, September 28, 2013 12:52:26 AM UTC-4, mel...@gmail.com wrote: Hey, How do i go about coming up/coding tests for this program below. Not sure how to even approach writing about 5 tests for it. Initially I had this for the test but its not working well. Test was name test_guess.py (Code Below) [code] from unittest import TestCase import pexpect as pe import guess as g import random random_number = random.randrange(1, 10) correct = False class GuessTest(TestCase): def setUp(self): self.intro = 'I have chosen a number from 1-10' self.request = 'Guess a number: ' self.responseHigh = That's too high. self.responseLow = That's too low. self.responseCorrect = That's right! self.goodbye = 'Goodbye and thanks for playing!' def test_main(self): #cannot execute main now because it will #require user input from guess import main def test_guessing_hi_low_4(self): # Conversation assuming number is 4 child = pe.spawn('python guess.py') child.expect(self.intro,timeout=5) child.expect(self.request,timeout=5) child.sendline('5') child.expect(self.responseHigh,timeout=5) child.sendline('3') child.expect(self.responseLow,timeout=5) child.sendline('4') child.expect(self.responseCorrect,timeout=5) child.expect(self.goodbye,timeout=5) def __init__(self): self.number = random.randint(0,10) HIGH = 1 LOW = 2 OK = 3 def guess(self, number): if number self.number: return self.HIGH if number self.number: return self.LOW return self.OK def test_guesstoolow(self): while not correct: guess = input(What could it be?) if guess == random_number: print Congrats You Got It correct = True elif guess random_number: print To High elif guess random_number: print To Low else: print Try Again [/code] Python code for game below [code] import random intro = 'I have chosen a number from 1-10' request = 'Guess a number: ' responseHigh = That's too high. responseLow = That's too low. responseCorrect = That's right! goodbye = 'Goodbye and thanks for playing!' print(intro) def main(): guessesTaken = 0 number = random.randint(1, 10) while guessesTaken 5: print(request) guess = input() guess = int(guess) guessesTaken = guessesTaken + 1 if guess number: print(responseLow) if guess number: print(responseHigh) if guess == number: break if guess == number: guessesTaken = str(guessesTaken) print(responseCorrect + '! You guessed my number in ' + guessesTaken + ' guesses!') if guess != number: number = str(number) print(goodbye + ' The number I was thinking of was ' + number) ##def main(): #print(intro) # user_input = raw_input(request) # print(responseHigh) # print(request) # user_input = raw_input(request) # print(responseLow) # user_input = raw_input(request) # print(responseCorrect) # print(goodbye) if __name__ == '__main__': main()[/code] -- https://mail.python.org/mailman/listinfo/python-list
Do I really need a web framework?
I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user. I know that this is exactly the purpose of web frameworks, and that they work fine. However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct? What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Unit Tests
On 30/09/2013 20:54, melw...@gmail.com wrote: Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none? Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 27, in main guess, tries = getguess(target, allowed) TypeError: 'NoneType' object is not iterable [snip] Look at 'getguess'. If the user guess correctly within the number of allowed attempts, the function returns (guess, tries), but what if the user runs out of attempts? -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 30/9/2013 9:42 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 19:03, Νίκος wrote: Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: On 29/09/2013 17:19, Νίκος wrote: Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε: asked and answered. Move on shut up. you are nothign but annoyance here. Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. Perhaps it would be even better if you quit spamming my thread with your funny quotes. Your approach as given in the pseudocode given below is taking up what, 50% of the bandwidth here? What a waste of a resource. while answer_isn't_what_I_want: keep_asking_question() I was thankfull to the people that tried to help me(excluding you) Several method have been given to solve the problem. Other newbies reading this will help them better understand why its written the way it is if they compare all the solutions. And yes, i won't rest until i have it working as i think its clearer and more compact. You are to this mailing list what King Herod was to baby sitting. And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Please drop dead and the sooner the better. After you please. Your arrogant attitide to the numerous people who've tried so hard to help you is disgraceful. Your ironic attitude on the other hand is what characterizes you. Triing out various solutions and picking the one that better meets one's style and needs, is hardly considered as arrogance. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Unit Tests
On 30/9/2013 15:54, melw...@gmail.com wrote: Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none? Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 27, in main guess, tries = getguess(target, allowed) TypeError: 'NoneType' object is not iterable Please don't top-post. Further, if you insist on using a buggy app like googlegroups, at least remove all the stupid double-spacing. Do you know how to interpret this error message? The line that fails is guess, tries = getguess(target, allowed) So can you tell what the None data is? You're doing a tuple-unpack on the left side of the equals, so the right side needs to be a tuple, list, or equivalent. In specific, an iterable. Now you reread the error, and realize that the getguess() function is returning None. If I were a novice, I'd start by splitting up the line with the error: temp = getguess(target, allowed) guess, tries = temp Then when the error complains about the second line, I'd add a print statement: temp = getguess(target, allowed) print(repr(temp)) guess, tries = temp Lacking the source code, I'm going to guess that some path through your code is missing a return expression. For example, you might have def getguess(a, b): if a b: return a, a*b So it'll return a tuple of two items in the if body, but without an else clause, it simply falls off the end, and returns None. (All functions return something, so if you don't provide a value, None is used) -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
Op 30-09-13 20:55, Piet van Oostrum schreef: Franck Ditter nob...@nowhere.org writes: Good approach of FP in Python, but two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, this is bullshit. Tail recursion optimization throws away valuable stack trace information in case of an error. This is hardly relevant. Because what are we told to use instead of tail calls? We are told to use loops. But when you use a loop the stack trace doesn't contain the values of previous runs through the loop. So how valuable is that stack frame information when the proposed alternative doesn't produces it either. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Do I really need a web framework?
On 1 October 2013 05:57, duf...@gmail.com wrote: I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user. I know that this is exactly the purpose of web frameworks, and that they work fine. However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct? What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small? There is no *need* to use a web framework. But a web framework can make things a lot easier for you. Have a look at webapp2: http://webapp-improved.appspot.com/ Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list
[ANN] MATLAB fmincon now available in Python
Hi all, current state of Python - MATLAB connection soft doesn't allow passing of function handlers, however, a walkaround has been implemented via some tricks, so now MATLAB function fmincon is available in Python-written OpenOpt and FuncDesigner frameworks (with possibility of automatic differentiation, example ). Future plans include MATLAB fsolve, ode23, ode45 (unlike scipy fsolve and ode they can handle sparse matrices), fgoalattain, maybe global optimization toolbox solvers. I intend to post the message to several forums, so to keep discussion in a single place use OpenOpt forum thread http://forum.openopt.org/viewtopic.php?id=769 Regards, D. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/lists/python-list/651611/ -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Op 30-09-13 20:54, Ned Batchelder schreef: On 9/30/13 2:42 PM, Mark Lawrence wrote: Please drop dead and the sooner the better. Your arrogant attitide to the numerous people who've tried so hard to help you is disgraceful. Mark, I'm as frustrated as anyone by Nikos' threads, but there's really no call for Please drop dead. We can do better than that. I disagree. The Please drop dead seems well deserved to me. You may think it better if people could put themselves above it, but that doesn't make the remark less deserved. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
On 2013-09-30 19:04, Franck Ditter wrote: two points make me crazy : 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). And don't answer with good programmers don't use recursion, I seem to recall hearing that the primary reason it hadn't been implemented is because of Python's super-dynamism (to make up a word). That a function could be a tail recursion in one call, but the calling the same name could then become rebound. I'm making up the example, but I think it was something like this: def kablooie(*args): if not args: def kablooie(*args): woah() do_something(args) kablooie(args[1:]) where tail recursion optimization would do weird things. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like to know the details: http://nedbatchelder.com/text/names.html --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Mon, Sep 30, 2013 at 5:34 PM, Νίκος nikos.gr...@gmail.com wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/**lists/python-list/651611/http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/**mailman/listinfo/python-listhttps://mail.python.org/mailman/listinfo/python-list well, actually no. one positive comment (and I'm sorry your reference didn't reveal one!) is 10^2-1 times as 10^2 negative comments. Look in a mirror dude. You are lazy, you charge people for code that you don't even have under source control, you have no interest in understanding and studying how your servers work, how python works. You bitch and whine at people who come along to help you. You are to slothful to look at a traceback. Your hosting company ignores you apparently because you are such an sob they don't even want your business. You pick a nickname that is the defininition of an asshole: http://www.politicsforum.org/images/flame_warriors/flame_62.php and yet you return again and again to be rude to all who first try to help you out, then realize you are such a total jerk that they even wish you an awful demise without even having met you.. Take a look in the mirror dude. I don't care if you want to tell me to shut up. It seemed amusing to others here. -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 22:34, Νίκος wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. Yet more sheer unadulterated rubbish from an imbecile who clearly hasn't got the faintest idea what he's talking about. Would you please be kind enough to stand up, your voice is rather muffled. That is after you've done a proper statistical analysis of the number of positive posts I've made over the years. You are actually one of the very few people who has managed to get quite so far up my nose, that's quite an achievement as by nature I'm actually extremely tolerant. -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On Mon, Sep 30, 2013, at 17:28, Ned Batchelder wrote: On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like to know the details: http://nedbatchelder.com/text/names.html Wait a minute, how exactly are C variables supposed to be different from this? -- https://mail.python.org/mailman/listinfo/python-list
Re: Do I really need a web framework?
In f4a6d31f-cffe-4c03-9586-4f00f9037...@googlegroups.com duf...@gmail.com writes: I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user. No, it's not necessary. But depending on how large your website is, using a framework can end up being a lot less work than doing it from scratch. What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small? That depends on how you define very simple and very small. For example, how many different pages will your website have? A login page? A search entry page? A search results page? A help page? An error page? A logout page? Any other pages? I worked on a project that did its own web handling from scratch, and frankly it was a nightmare. But it wasn't a small project, so yours might be doable. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 12:44 πμ, ο/η Joel Goldstick έγραψε: On Mon, Sep 30, 2013 at 5:34 PM, Νίκος nikos.gr...@gmail.com mailto:nikos.gr...@gmail.com wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/__lists/python-list/651611/ http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/__mailman/listinfo/python-list https://mail.python.org/mailman/listinfo/python-list well, actually no. one positive comment (and I'm sorry your reference didn't reveal one!) is 10^2-1 times as 10^2 negative comments. Look in a mirror dude. You are lazy, you charge people for code that you don't even have under source control, you have no interest in understanding and studying how your servers work, how python works. You bitch and whine at people who come along to help you. You are to slothful to look at a traceback. Your hosting company ignores you apparently because you are such an sob they don't even want your business. You pick a nickname that is the defininition of an asshole: http://www.politicsforum.org/images/flame_warriors/flame_62.php and yet you return again and again to be rude to all who first try to help you out, then realize you are such a total jerk that they even wish you an awful demise without even having met you.. Take a look in the mirror dude. I don't care if you want to tell me to shut up. It seemed amusing to others here. -- Joel Goldstick http://joelgoldstick.com stfu dickhead. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Mon, 30 Sep 2013 15:51:39 +0100, Mark Lawrence wrote: On 30/09/2013 14:51, Grant Edwards wrote: On 2013-09-29, ?? nikos.gr...@gmail.com wrote: 29/9/2013 10:53 , ??/?? Chris Angelico : You fail to understand that these code i now use was written with the help of regulars here and yes its correct. If you're code is correct, then use it and be happy. There's no need to bother us if your code is correct. Could this be an extremely rare case whereby the original code is 100% correct but the problems have been exacerbated by the many suggested patches given here being 100% incorrect? I'm sending you the bill for hospital admission. I laughed so hard I fell off of my chair and banged my head! -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Mon, Sep 30, 2013 at 6:08 PM, Νίκος nikos.gr...@gmail.com wrote: Στις 1/10/2013 12:44 πμ, ο/η Joel Goldstick έγραψε: On Mon, Sep 30, 2013 at 5:34 PM, Νίκος nikos.gr...@gmail.com mailto:nikos.gr...@gmail.com** wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/__**lists/python-list/651611/http://code.activestate.com/__lists/python-list/651611/ http://code.activestate.com/**lists/python-list/651611/http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/__**mailman/listinfo/python-listhttps://mail.python.org/__mailman/listinfo/python-list https://mail.python.org/**mailman/listinfo/python-listhttps://mail.python.org/mailman/listinfo/python-list well, actually no. one positive comment (and I'm sorry your reference didn't reveal one!) is 10^2-1 times as 10^2 negative comments. Look in a mirror dude. You are lazy, you charge people for code that you don't even have under source control, you have no interest in understanding and studying how your servers work, how python works. You bitch and whine at people who come along to help you. You are to slothful to look at a traceback. Your hosting company ignores you apparently because you are such an sob they don't even want your business. You pick a nickname that is the defininition of an asshole: http://www.politicsforum.org/**images/flame_warriors/flame_**62.phphttp://www.politicsforum.org/images/flame_warriors/flame_62.php and yet you return again and again to be rude to all who first try to help you out, then realize you are such a total jerk that they even wish you an awful demise without even having met you.. Take a look in the mirror dude. I don't care if you want to tell me to shut up. It seemed amusing to others here. -- Joel Goldstick http://joelgoldstick.com stfu dickhead. -- https://mail.python.org/**mailman/listinfo/python-listhttps://mail.python.org/mailman/listinfo/python-list that was responsive! You should join your local debating club! anyway, out! -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 23:08, Νίκος wrote: Στις 1/10/2013 12:44 πμ, ο/η Joel Goldstick έγραψε: On Mon, Sep 30, 2013 at 5:34 PM, Νίκος nikos.gr...@gmail.com mailto:nikos.gr...@gmail.com wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/__lists/python-list/651611/ http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/__mailman/listinfo/python-list https://mail.python.org/mailman/listinfo/python-list well, actually no. one positive comment (and I'm sorry your reference didn't reveal one!) is 10^2-1 times as 10^2 negative comments. Look in a mirror dude. You are lazy, you charge people for code that you don't even have under source control, you have no interest in understanding and studying how your servers work, how python works. You bitch and whine at people who come along to help you. You are to slothful to look at a traceback. Your hosting company ignores you apparently because you are such an sob they don't even want your business. You pick a nickname that is the defininition of an asshole: http://www.politicsforum.org/images/flame_warriors/flame_62.php and yet you return again and again to be rude to all who first try to help you out, then realize you are such a total jerk that they even wish you an awful demise without even having met you.. Take a look in the mirror dude. I don't care if you want to tell me to shut up. It seemed amusing to others here. -- Joel Goldstick http://joelgoldstick.com stfu dickhead. To quote from The A-Team, I love it when a plan comes together. -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Do I really need a web framework?
On Monday, September 30, 2013 2:57:08 PM UTC-5, duf...@gmail.com wrote: I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user. I know that this is exactly the purpose of web frameworks, and that they work fine. However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct? What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small? If it's small you want, Flask has worked quite well for me. Here's an example: from flask import Flask, render_template, redirect, request from yourstuff import save_data, get_data app = Flask(__name__) @app.route('/') def main(): return render_template('index.html') @app.route('/data', methods=['GET', 'POST']) def data(): if request.method == 'POST': save_data(request.form.get('data')) else: return render_template('data.html', data=get_data()) It doesn't take much to tack SQLAlchemy on top of that for data access, and a couple hundred lines will give you quite a lot of power. HTH, W -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 1:14 πμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 23:08, Νίκος wrote: Στις 1/10/2013 12:44 πμ, ο/η Joel Goldstick έγραψε: On Mon, Sep 30, 2013 at 5:34 PM, Νίκος nikos.gr...@gmail.com mailto:nikos.gr...@gmail.com wrote: Στις 30/9/2013 11:44 μμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 21:13, Νίκος wrote: And you are a major asshole leading this list, who is doing nothing else than critizizing others people's posts, spamming all he way along while contributing negatively only. Really? http://code.activestate.com/__lists/python-list/651611/ http://code.activestate.com/lists/python-list/651611/ One positive comment in the history opposes 10^2 negative ones. -- https://mail.python.org/__mailman/listinfo/python-list https://mail.python.org/mailman/listinfo/python-list well, actually no. one positive comment (and I'm sorry your reference didn't reveal one!) is 10^2-1 times as 10^2 negative comments. Look in a mirror dude. You are lazy, you charge people for code that you don't even have under source control, you have no interest in understanding and studying how your servers work, how python works. You bitch and whine at people who come along to help you. You are to slothful to look at a traceback. Your hosting company ignores you apparently because you are such an sob they don't even want your business. You pick a nickname that is the defininition of an asshole: http://www.politicsforum.org/images/flame_warriors/flame_62.php and yet you return again and again to be rude to all who first try to help you out, then realize you are such a total jerk that they even wish you an awful demise without even having met you.. Take a look in the mirror dude. I don't care if you want to tell me to shut up. It seemed amusing to others here. -- Joel Goldstick http://joelgoldstick.com stfu dickhead. To quote from The A-Team, I love it when a plan comes together. 2 dickheads names Joe Mark work together to achieve total bullshit! Well done Beavis Butthead! rofl... -- https://mail.python.org/mailman/listinfo/python-list
Python variables? [was Re: class implementation]
On 09/30/2013 02:28 PM, Ned Batchelder wrote: On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like to know the details: http://nedbatchelder.com/text/names.html Because Python's model is different enough that it usually makes thinking about it simpler to stay away from the word 'variable'; in every other language I have used a variable is a box, but in Python it's a label for a box. From your blog: Names are Python's variables: they refer to values, and those values can change (vary) over the course of your program. This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you meant to say that which object the name points to can vary over time? -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On 30/09/2013 23:19, Νίκος wrote: 2 dickheads names Joe Mark work together to achieve total bullshit! Well done Beavis Butthead! rofl... Well aside from the fact that you've maintained your record by being inaccurate with 50% of the names that you've quoted, it appears that we've something that has very much in common with your website. Which reminds me, is it still possible to access your users' names and passwords in plain text or is that something that you've actually bothered to fix? -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Tue, Oct 1, 2013 at 4:03 AM, Νίκος nikos.gr...@gmail.com wrote: Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. Perhaps it would be even better if you quit spamming my thread with your funny quotes. Then maybe you should keep to programming for personal pleasure and stop trying to make it part of your business. Most of your problems stem from a perceived urgency - you panic, because you have stupidly edited your live code again, and come to this list begging for help. If you were coding purely for pleasure, your problems would not lose you customers, and you could deal with issues calmly. To be quite frank, I think you SHOULD lose customers. Suppose you buy a piece of furniture from some small-time carpenter, and the moving parts are stuck, it wobbles on its legs, and if anyone uses it who isn't American, it crashes to the floor (which is how your Unicode issues make you look). You go and complain, loudly, in front of people who were looking at his wares and considering buying. He might lose customers because of your complaint - but if he's selling a dodgy product, he *should* lose customers. Carpentry for pleasure, or programming for pleasure, is a fine thing to do, but it should not be considered business. Nikos, I sincerely hope that all these problems cause you to go out of business. Preferably right now, with just enough maintenance to last till the end of your contracts with people. Then start programming purely as a hobby, until you actually master the craft. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 1:28 πμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 23:19, Νίκος wrote: 2 dickheads names Joe Mark work together to achieve total bullshit! Well done Beavis Butthead! rofl... Well aside from the fact that you've maintained your record by being inaccurate with 50% of the names that you've quoted, it appears that we've something that has very much in common with your website. Which reminds me, is it still possible to access your users' names and passwords in plain text or is that something that you've actually bothered to fix? Nope, it isn't. I have fixed it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python variables?
Ethan Furman et...@stoneleaf.us writes: From [Ned Batchelder]'s blog: Names are Python's variables: they refer to values, and those values can change (vary) over the course of your program. This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you meant to say that which object the name points to can vary over time? I agree. Names are not Python's variables. If anything in Python is a “variable” as generally understood, it is not a name. It is a *binding*, from a reference (a name, or some other reference like a list item) to a value. It is the binding which can change over the course of the program, so that is the variable. -- \“Good judgement comes from experience. Experience comes from | `\ bad judgement.” —Frederick P. Brooks | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 1:29 πμ, ο/η Chris Angelico έγραψε: On Tue, Oct 1, 2013 at 4:03 AM, Νίκος nikos.gr...@gmail.com wrote: Στις 30/9/2013 5:45 μμ, ο/η Mark Lawrence έγραψε: Absolutely hilarious. Please give up your web work and Python and get a job writing scripts for comedians, you'd make a large fortune. I learn Python for personal pleasure because i like programming. Perhaps it would be even better if you quit spamming my thread with your funny quotes. Then maybe you should keep to programming for personal pleasure and stop trying to make it part of your business. Most of your problems stem from a perceived urgency - you panic, because you have stupidly edited your live code again, and come to this list begging for help. If you were coding purely for pleasure, your problems would not lose you customers, and you could deal with issues calmly. To be quite frank, I think you SHOULD lose customers. Suppose you buy a piece of furniture from some small-time carpenter, and the moving parts are stuck, it wobbles on its legs, and if anyone uses it who isn't American, it crashes to the floor (which is how your Unicode issues make you look). You go and complain, loudly, in front of people who were looking at his wares and considering buying. He might lose customers because of your complaint - but if he's selling a dodgy product, he *should* lose customers. Carpentry for pleasure, or programming for pleasure, is a fine thing to do, but it should not be considered business. Nikos, I sincerely hope that all these problems cause you to go out of business. Preferably right now, with just enough maintenance to last till the end of your contracts with people. Then start programming purely as a hobby, until you actually master the craft. I learn during the process. That's how i deal with the situation. I challedge my self and then try to confront the given situation _live_. It's not wise to do so, but that how i operate. Apart form that my customer's webistes have no problems, everyhting i do its domain specific, my domain, DNS and Mail issues for my domain, i don't play with customer's settings and data. I have a good sense _not_ to fiddle with their accounts(except from the time that i have taken the risk to give you root access to helo me with a python issue, and you've helped me appropiately). -- https://mail.python.org/mailman/listinfo/python-list
Mutual respect, tolerance, encouragement (was: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte)
Chris Angelico ros...@gmail.com writes: Nikos, I sincerely hope that all these problems cause you to go out of business. Preferably right now, with just enough maintenance to last till the end of your contracts with people. Then start programming purely as a hobby, until you actually master the craft. This is a sentiment I can heartily endorse. Far better than puerile jeers and hostile desires for violence. Please, everyone in this thread needs to keep in mind our host's Diversity Statement: The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to be more diverse: whoever you are, and whatever your background, we welcome you. Let's keep all discussions here close to those principles. -- \ “The trouble with the rat race is that even if you win, you're | `\ still a rat.” —Jane Wagner, via Lily Tomlin | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Tue, Oct 1, 2013 at 8:30 AM, Νίκος nikos.gr...@gmail.com wrote: Στις 1/10/2013 1:28 πμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 23:19, Νίκος wrote: 2 dickheads names Joe Mark work together to achieve total bullshit! Well done Beavis Butthead! rofl... Well aside from the fact that you've maintained your record by being inaccurate with 50% of the names that you've quoted, it appears that we've something that has very much in common with your website. Which reminds me, is it still possible to access your users' names and passwords in plain text or is that something that you've actually bothered to fix? Nope, it isn't. I have fixed it. And this doesn't bother you???!? Nikos, industry best practice is to make sure people can't steal all your users' passwords *even if they get access to your hard drive*. Passwords should be stored like this: 92e25cf5beefd4982cedd2f28b430e0e9d23e0966ee3f20c74f825eb9842 That's the password qwer, on an account named asdf, on a mythical system. Even knowing that, you can't work out what another password means. Storing people's passwords in plain text is a HORRIBLE HORRIBLE idea - and having them accessible to the world is a sign of a complete and utter lack of any semblance of security. I understand that bugs happen. But bugs of this criticality should be your very highest priority... unless you're not actually in business here, and you're just scamming a bunch of people by pretending you run a legit enterprise. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 1:43 πμ, ο/η Chris Angelico έγραψε: On Tue, Oct 1, 2013 at 8:30 AM, Νίκος nikos.gr...@gmail.com wrote: Στις 1/10/2013 1:28 πμ, ο/η Mark Lawrence έγραψε: On 30/09/2013 23:19, Νίκος wrote: 2 dickheads names Joe Mark work together to achieve total bullshit! Well done Beavis Butthead! rofl... Well aside from the fact that you've maintained your record by being inaccurate with 50% of the names that you've quoted, it appears that we've something that has very much in common with your website. Which reminds me, is it still possible to access your users' names and passwords in plain text or is that something that you've actually bothered to fix? Nope, it isn't. I have fixed it. And this doesn't bother you???!? Nikos, industry best practice is to make sure people can't steal all your users' passwords *even if they get access to your hard drive*. Passwords should be stored like this: 92e25cf5beefd4982cedd2f28b430e0e9d23e0966ee3f20c74f825eb9842 That's the password qwer, on an account named asdf, on a mythical system. Even knowing that, you can't work out what another password means. Storing people's passwords in plain text is a HORRIBLE HORRIBLE idea - and having them accessible to the world is a sign of a complete and utter lack of any semblance of security. I understand that bugs happen. But bugs of this criticality should be your very highest priority... unless you're not actually in business here, and you're just scamming a bunch of people by pretending you run a legit enterprise. ChrisA I don't have the security awareness you have, but i'am learnign at the process. What maked you think i store peoples password in plain text? All the user account passwords i set i do it via cPanel or via WHM. How those services store the password in the linux server its up to them. -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Tue, Oct 1, 2013 at 8:36 AM, Νίκος nikos.gr...@gmail.com wrote: I learn during the process. That's how i deal with the situation. I challedge my self and then try to confront the given situation _live_. It's not wise to do so, but that how i operate. Everyone's learning on the job. (I learned this week that it's possible to play fast and loose with ARP and routing, to make one computer look like two and two look like one. That was fun. When I came up with the concept, I gave my boss a 95% confidence that it'd work; and so far it's not caused any trouble.) But what you're doing is charging your customers while you learn the very basics. You can't sell Hello, world. Most people expect to go to university to learn a trade; some spend two decades playing with something before earning a single dollar (or Euro, or yen). Learn to code, THEN try to make money at it. Or even leave off the 'then' clause - plenty of people never earn anything from code, and stay as happy amateurs. There's nothing wrong with that. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Στις 1/10/2013 1:56 πμ, ο/η Chris Angelico έγραψε: But what you're doing is charging your customers while you learn the very basics. I designed their websites and they are up and running. Yes i have charged some money, but they gain what they paid for, a running website, all of them. So, its not like i'm ripping off someone here. You can't sell Hello, world. I hope i was in the position to sell python code but i'am not. I learn Python because i like programming. My reseller site should have been made probably in wordpress or joomla cms but i decided to code it in Python instead because i like the language and want it to learn it better and better. It has secret functions as well. When i problem occurs i just ask and thats how i progress. Sometimes i do a little reading too :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python variables? [was Re: class implementation]
On 9/30/13 6:02 PM, Ethan Furman wrote: On 09/30/2013 02:28 PM, Ned Batchelder wrote: On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like to know the details: http://nedbatchelder.com/text/names.html Because Python's model is different enough that it usually makes thinking about it simpler to stay away from the word 'variable'; in every other language I have used a variable is a box, but in Python it's a label for a box. It might help C programmers to stay away from variable, but some people claim we should avoid the word so as not to confuse beginners. That's just silly. Beginners have no holdover concepts from C. Lots of languages use the same names and values model that Python does: Javascript, Java, Ruby, Lisp, etc. From your blog: Names are Python's variables: they refer to values, and those values can change (vary) over the course of your program. This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you meant to say that which object the name points to can vary over time? Yes, I meant that 1) names refer to values, and 2) a name can refer to different values over the course of a program. Hence, the value varies, hence, a variable. In fact, it's more accurate to say that Python has no constants! :) --Ned. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python variables?
On 9/30/13 6:37 PM, Ben Finney wrote: Ethan Furman et...@stoneleaf.us writes: From [Ned Batchelder]'s blog: Names are Python's variables: they refer to values, and those values can change (vary) over the course of your program. This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you meant to say that which object the name points to can vary over time? I agree. Names are not Python's variables. If anything in Python is a “variable” as generally understood, it is not a name. It is a *binding*, from a reference (a name, or some other reference like a list item) to a value. It is the binding which can change over the course of the program, so that is the variable. True, but no one calls the binding the variable. Here is a program: x = 4 Every one of us is perfectly comfortable talking about the variable x. Don't get hung up on implementation pedantry. The name x here refers to 4. Later it could refer to four. The value associated with the name x changed. x is a variable. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On Mon, 30 Sep 2013 17:28:30 -0400, Ned Batchelder wrote: On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like to know the details: http://nedbatchelder.com/text/names.html I'm not convinced that Python variables are different from C variables is a better way to get through to people than Python doesn't have variables, it has name bindings. Of course, *technically* the first statement is accurate, and the second relies on a definition of variable that is not universal. The question is which is more effective at getting the differences between the two programming models through to the reader. I can't speak for others, but in my own experience, I never *quite* understood the semantic differences between Python name bindings and Pascal variables until I came across the meme Python has no variables. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
On Tue, 01 Oct 2013 01:08:41 +0300, Νίκος wrote: stfu dickhead. And you're back in the kill-file. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Unit Tests
On 9/30/2013 3:54 PM, melw...@gmail.com wrote: Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none? Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 27, in main guess, tries = getguess(target, allowed) TypeError: 'NoneType' object is not iterable If you have not figured it out yet, add a copy of the return within the while loop, return guess, tries after the while loop also, so it does not return the default of None. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
On Mon, 30 Sep 2013 18:36:28 +, Neil Cerutti quoted: Why cant lambda forms contain statements? Gah! Please fix your news client! (I see you're using slrn.) The \x92 bytes found in your message are apostrophes (technically: right single quotation marks), encoded using the legacy Windows-1252 codec, but your news client is falsely advertising it as US-ASCII: Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit It's almost 2014, it is unspeakably poor form that an application is still making this mistake. Is there an updated version of slrn that fixes this? Can you manually force it to use UTF-8? Can you report this as a bug? In case you aren't too clear on the concepts, here are two Must Read links: http://www.joelonsoftware.com/articles/Unicode.html http://nedbatchelder.com/text/unipain.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Tab completion in Python3.4
On Mon, 30 Sep 2013 08:50:01 +, Antoine Pitrou wrote: Steven D'Aprano steve at pearwood.info writes: I don't consider either of these solutions to be satisfactory. If you agree, I urge you to try it out for yourself, and then leave a comment on the bug tracker asking for tab completion to still insert tabs at the beginning of the line: Such a change is much more likely to happen if someone actually proposes a patch for it, rather than merely ask for it. I don't think anyone is ideologically opposed to it. I thought you were and am glad to hear you aren't :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: class implementation
On Mon, 30 Sep 2013 05:41:16 -0700, markotaht wrote: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Firstly, in Python circles we prefer to call them attributes rather than variables. Since this is Python, it is trivially easy to test this for yourself. Start an interactive Python interpreter, and then in under a dozen lines you can test it: py class Test: ... attr = Hello World! # Shared class attribute. ... py class MyTest(Test): ... pass ... py x = MyTest() py x.attr 'Hello World!' Works perfectly! (It would be a funny programming language where it didn't, since this is one of the most fundamental parts of inheritance. A language that didn't do something equivalent to this couldn't really claim to be object-oriented.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python variables? [was Re: class implementation]
On Tue, 01 Oct 2013 00:45:06 +0100, Ned Batchelder n...@nedbatchelder.com wrote: On 9/30/13 6:02 PM, Ethan Furman wrote: From your blog: Names are Python's variables: they refer to values, and those values can change (vary) over the course of your program. This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you meant to say that which object the name points to can vary over time? Yes, I meant that 1) names refer to values, and 2) a name can refer to different values over the course of a program. Hence, the value varies, hence, a variable. Yes, except no. The problem is that word value, which I can practically see morphing its meaning through that paragraph. Names refer to objects, which have values or interpretations or however you choose to say it. Some (mutable) objects can change their value, some (immutable) can't. Independently, names can refer to different objects, which may or may not have different values (or indeed concepts of value). When you say The value varies, it begs the question Which 'the value'? In fact, it's more accurate to say that Python has no constants! :) Or, alternatively, that Python has many constants, such as all those immutable integers cached around the place :-) What it doesn't have is fixed bindings. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list