Re: Profiler for long-running application

2015-02-09 Thread Ryan Stuart
Hi Asad, Is there any reason why you can't just use profile/cProfile? In particular, you could use the api of that module to save out the profile stats to an external file with a unique name and then inspect them later with a tool like snakeviz . The code to

Re: Profiler for long-running application

2015-02-09 Thread Asad Dhamani
On Monday, February 9, 2015 at 1:50:58 PM UTC+5:30, Ryan Stuart wrote: > Hi Asad, > > Is there any reason why you can't just use profile/cProfile? In particular, > you could use the api of that module to save out the profile stats to an > external file with a unique name and then inspect them la

doc buglets?

2015-02-09 Thread Rustom Mody
Poking around in help() (python 3.4.2) I find * PACKAGES does not seem to have anything on packages * DYNAMICFEATURES seems to be some kind of footnote * SPECIALATTRIBUTES has 'bases' and 'subclasses'. It seems to me a more consistent naming for OOP would be in order. These are the OOP-metaphors

Re: How to Mock a mongodb

2015-02-09 Thread Jean-Michel Pichavant
- Original Message - > From: "Xavier Pegenaute" > To: python-list@python.org > Sent: Saturday, 7 February, 2015 11:09:10 PM > Subject: How to Mock a mongodb > > Dear, > > I am trying to mock the use of a mongo db and I am having some > trouble. > Appears that I am not able to return a de

locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?

2015-02-09 Thread Albert-Jan Roskam
Hi, In the locale module we have: * setlocale, the setter that also returns something * getlocale, the getter that returns the OS-specific locale tuple (supposedly!) * getdefaultlocale, the getter that always returns a unix locale tuple Why are the getlocale() results below sometimes windows-lik

Re: doc buglets?

2015-02-09 Thread Mark Lawrence
On 09/02/2015 11:28, Rustom Mody wrote: Poking around in help() (python 3.4.2) I find * PACKAGES does not seem to have anything on packages * DYNAMICFEATURES seems to be some kind of footnote * SPECIALATTRIBUTES has 'bases' and 'subclasses'. It seems to me a more consistent naming for OOP would

Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?

2015-02-09 Thread Mark Lawrence
On 09/02/2015 15:43, Albert-Jan Roskam wrote: Hi, In the locale module we have: * setlocale, the setter that also returns something * getlocale, the getter that returns the OS-specific locale tuple (supposedly!) * getdefaultlocale, the getter that always returns a unix locale tuple Why are the

ANN: Wing IDE 5.1.1 released

2015-02-09 Thread Wingware
Hi, Wingware has released version 5.1.1 of Wing IDE, our cross-platform integrated development environment for the Python programming language. Wing IDE features a professional code editor with vi, emacs, visual studio, and other key bindings, auto-completion, call tips, context-sensitive au

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Skip Montanaro
On Sun, Feb 8, 2015 at 9:58 PM, Chris Angelico wrote: > Those three characters are the CP-1252 decode of the bytes for U+2019 > in UTF-8 (E2 80 99). Not sure if that helps any, but given that it was > an XLSX file, Windows codepages are reasonably likely to show up. Thanks, Chris. Are you telling

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Skip Montanaro
On Sun, Feb 8, 2015 at 10:51 PM, Steven D'Aprano wrote: > The second question is, are you > using Windows? No, I'm on a Mac (as, I think I indicated in my original note). All transformations occurred on a Mac. LibreOffice spit out a CSV file (with those three odd bytes). My script sucked in the C

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 4:30 AM, Skip Montanaro wrote: > On Sun, Feb 8, 2015 at 9:58 PM, Chris Angelico wrote: >> Those three characters are the CP-1252 decode of the bytes for U+2019 >> in UTF-8 (E2 80 99). Not sure if that helps any, but given that it was >> an XLSX file, Windows codepages are

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 4:32 AM, Skip Montanaro wrote: > On Sun, Feb 8, 2015 at 10:51 PM, Steven D'Aprano > wrote: >> The second question is, are you >> using Windows? > > No, I'm on a Mac (as, I think I indicated in my original note). All > transformations occurred on a Mac. LibreOffice spit out

Please help.

2015-02-09 Thread chimex60
‎Hello. Am trying to change the key words to my tribal language. Eg change English language: print() to igbo language: de(). I have been stuck for months I need a mentor or someone that can guide me and answer some of my questions when I get stuck. Thanks..I will really appreciate it if someone at

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Matthew Ruffalo
On 02/09/2015 12:30 PM, Skip Montanaro wrote: > Thanks, Chris. Are you telling me I should have defined the input file > encoding for my CSV file as CP-1252, or that something got hosed on > the export from XLSX to CSV? Or something else? > > Skip Hi Skip- I think it's most likely that the encodi

Re: Please help.

2015-02-09 Thread John Ladasky
On Monday, February 9, 2015 at 9:44:16 AM UTC-8, chim...@gmail.com wrote: > Hello. Am trying to change the key words to my tribal language. Eg change > English language: print() to igbo language: de(). I have been stuck for > months I need a mentor or someone that can guide me and answer some of

Python 3 and the requests library

2015-02-09 Thread Brian
On the Mac running Mavericks, I have successfully managed to install and use the requests library for HTTP and HTTPS requests using Python 2. But I'd like to move to Python 3. I downloaded the most recent stable version of Python 3 for Mac. All is well. I did a pip3 install requests command and

Re: How to extract a movie title out of a text file

2015-02-09 Thread sohcahtoa82
On Saturday, February 7, 2015 at 8:54:26 AM UTC-8, Seymore4Head wrote: > What I would like to be able to do is download and save to a folder > all the srr files in this Usenet group. alt.binaries.moovee > > I would then like to be able to search for a title in the text file. > > Anyone care to c

Re: Please help.

2015-02-09 Thread Dave Angel
On 02/09/2015 01:08 PM, John Ladasky wrote: On Monday, February 9, 2015 at 9:44:16 AM UTC-8, chim...@gmail.com wrote: Hello. Am trying to change the key words to my tribal language. Eg change English language: print() to igbo language: de(). I have been stuck for months I need a mentor or some

Re: Please help.

2015-02-09 Thread John Ladasky
On Monday, February 9, 2015 at 10:26:47 AM UTC-8, Dave Angel wrote: > That will help him with the functions. But not with the keywords. The > OP didn't specify Python version, but in 3.x, print() is a function, and > can be rebound. Since he said keyword, he's either mistaken, or he's > runn

WHO IS PROPHET MUHAMMAD, MAY PEACE AND BLESSINGS BE UPON HIM?

2015-02-09 Thread BV BV
WHO IS PROPHET MUHAMMAD, MAY PEACE AND BLESSINGS BE UPON HIM? He is the one who defended the rights of all humanity 1400 years ago He defended men's, women's and children rights He commanded and fostered the love between relatives and neighbors He established a coexistence relationship between Mu

__next__ and StopIteration

2015-02-09 Thread Charles Hixson
I'm trying to write a correct iteration over a doubly indexed container, and what I've got so far is:def __next__ (self): for rowinrange(self._rows): for col in range(self._cols): if self._grid[row][col]: yieldself._grid[row]

Re: __next__ and StopIteration

2015-02-09 Thread Ned Batchelder
On 2/9/15 2:14 PM, Charles Hixson wrote: I'm trying to write a correct iteration over a doubly indexed container, and what I've got so far is:def __next__ (self): for rowinrange(self._rows): for col in range(self._cols): if self._grid[row][col]:

Re: Python 3 and the requests library

2015-02-09 Thread Brian
I am also seeing this in my Mac Mavericks Python 3 installation when I use just the built-in logging library. Again, a tiny example executable script and the results: $ cat test2.py #!/usr/bin/env python3 import logging logging.info("TEST2 starting") $ ./test2.py Traceback (most recent call las

Re: __next__ and StopIteration

2015-02-09 Thread Rob Gaddi
On Mon, 09 Feb 2015 11:14:55 -0800, Charles Hixson wrote: > I'm trying to write a correct iteration over a doubly indexed container, > and what I've got so far is:def __next__ (self): > for rowinrange(self._rows): > for col in range(self._cols): >

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread mm0fmf
On 09/02/2015 03:44, Skip Montanaro wrote: I am trying to process a CSV file using Python 3.5 (CPython tip as of a week or so ago). According to chardet[1], the file is encoded as utf-8: >>> s = open("data/meets-usms.csv", "rb").read() >>> len(s) 562272 >>> import chardet >>> chardet.detect(

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Zachary Ware
On Mon, Feb 9, 2015 at 11:32 AM, Skip Montanaro wrote: > LibreOffice spit out a CSV file > (with those three odd bytes). My script sucked in the CSV file and > inserted data into my SQLite db. If all else fails, you can try ftfy to fix things: http://ftfy.readthedocs.org/en/latest/ >>> import

Re: Python 3 and the requests library

2015-02-09 Thread Zachary Ware
On Mon, Feb 9, 2015 at 1:20 PM, Brian wrote: > I am also seeing this in my Mac Mavericks Python 3 installation when I use > just the built-in logging library. Again, a tiny example executable script > and the results: > > $ cat test2.py > #!/usr/bin/env python3 > import logging > logging.info("T

Re: Python 3 and the requests library

2015-02-09 Thread Brian
Zach, Here is what I get on the Mac: $ python3 -c "import token;print(token.__file__)" /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py Just for grins, I also ran it against the built-in Python 2.7.5 version: $ python -c "import token;print(token.__file__)" /System/Lib

Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?

2015-02-09 Thread Albert-Jan Roskam
- Original Message - > From: Mark Lawrence > To: python-list@python.org > Cc: > Sent: Monday, February 9, 2015 5:02 PM > Subject: Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)? > > On 09/02/2015 15:43, Albert-Jan Roskam wrote: >> Hi, >> >> In the locale module we have: >> * set

Re: Python 3 and the requests library

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 1:37 PM, Brian wrote: > Zach, > > Here is what I get on the Mac: > > $ python3 -c "import token;print(token.__file__)" > /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py Are you running this from the same directory where you have your test scripts (i

Re: Python 3 and the requests library

2015-02-09 Thread Zachary Ware
On Mon, Feb 9, 2015 at 2:37 PM, Brian wrote: > Zach, > > Here is what I get on the Mac: > > $ python3 -c "import token;print(token.__file__)" > /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py That looks correct. > Just for grins, I also ran it against the built-in Python

Re: What killed Smalltalk could kill Python

2015-02-09 Thread Ethan Furman
On 01/21/2015 03:37 PM, Tim Daneliuk wrote: > > I wrote some rambling disquisition on these matters some years ago ... > > http://www.tundraware.com/TechnicalNotes/Python-Is-Middleware > > http://www.tundraware.com/TechnicalNotes/How-To-Pick-A-Programming-Language Very enjoyable, thank you!

Re: Python 3 and the requests library

2015-02-09 Thread Brian
Thank you, Ian and Zack! That was exactly the issue. Apparently, having a token.py script (one of my first Python 2 scripts to get an authorization token from a billing server) is OK for Python 2 but breaks Python 3. *face palm* Thank you again so very much! Brian On Monday, February 9, 2015

Re: Monte Carlo probability calculation in Python

2015-02-09 Thread Paul Moore
On Friday, 6 February 2015 23:49:51 UTC, Steven D'Aprano wrote: > > Just a quick status update, in case you're interested. With relatively > > little work (considering I started not knowing much about numpy) I managed > > to put together solutions for a couple of my friend's problems which ran > >

Re: Python 3 and the requests library

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 2:37 PM, Brian wrote: > Thank you, Ian and Zack! That was exactly the issue. Apparently, having a > token.py script (one of my first Python 2 scripts to get an authorization > token from a billing server) is OK for Python 2 but breaks Python 3. Local modules that have the

Re: __next__ and StopIteration

2015-02-09 Thread Steven D'Aprano
Charles Hixson wrote: > I'm trying to write a correct iteration over a doubly indexed container, > and what I've got so far is:def __next__ (self): > for rowinrange(self._rows): > for col in range(self._cols): > if self._grid[row][col]: >

TypeError: list indices must be integers, not tuple

2015-02-09 Thread james8booker
import random RandomNum = random.randint(0,7) restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or Indian?") if restraunt == ("Pizza"): fav = ("1") elif restraunt == ("Chinease"): fav = ("2") elif restraunt == ("Indian"): fav = ("3") else: print("Try us

Re: __next__ and StopIteration

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 4:30 PM, Steven D'Aprano wrote: > The way you write iterators is like this: > > > Method 1 (the hard way): > > - Give your class an __iter__ method which simply returns self: > > def __iter__(self): > return self > > - Give your class a __next__ method (`next` in

Re: Please help.

2015-02-09 Thread Steven D'Aprano
Hello Chimex, and welcome. First, before I answer your question, I have a favour to ask. Please adjust your email program to send Plain Text as well as (or even instead of) so-called "Rich Text". When you send Rich Text, many people here will see your email like this: chime...@gmail.com wrote: >

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Ethan Furman
On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: > import random > RandomNum = random.randint(0,7) > restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or > Indian?") > if restraunt == ("Pizza"): > fav = ("1") > > elif restraunt == ("Chinease"): > fav = ("2") >

Re: Python 3.x stuffing utf-8 into SQLite db

2015-02-09 Thread Skip Montanaro
On Mon, Feb 9, 2015 at 2:38 PM, Skip Montanaro wrote: > On Mon, Feb 9, 2015 at 2:05 PM, Zachary Ware > wrote: > > If all else fails, you can try ftfy to fix things: > > http://ftfy.readthedocs.org/en/latest/ > > Thanks for the pointer. I would prefer to not hand-mangle this stuff > in case I get

Re: __next__ and StopIteration

2015-02-09 Thread Steven D'Aprano
Ian Kelly wrote: > On Mon, Feb 9, 2015 at 4:30 PM, Steven D'Aprano > wrote: [...] >> Your class is itself an iterator. > > This is an anti-pattern, so don't even suggest it. Iterables should > never be their own iterators. Otherwise, your iterable can only be > iterated over once! Hmmm, good po

Re: __next__ and StopIteration

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 11:42 AM, Steven D'Aprano wrote: > Also, *technically* iterators may be re-iterable. The docs say that > iterators which fail to raise StopIteration forever once they are exhausted > are "broken", but the docs do not forbid broken iterators. Consenting > adults and all that

Re: __next__ and StopIteration

2015-02-09 Thread Chris Kaynor
On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano wrote: > so that's an excellent sign that doing so is best practice, but it should > not be seen as *required*. After all, perhaps you have good reason for > wanting your iterable class to only be iterated over once. In fact, there is one in the std

Re: __next__ and StopIteration

2015-02-09 Thread Steven D'Aprano
Chris Angelico wrote: > On Tue, Feb 10, 2015 at 11:42 AM, Steven D'Aprano > wrote: >> Also, *technically* iterators may be re-iterable. The docs say that >> iterators which fail to raise StopIteration forever once they are >> exhausted are "broken", but the docs do not forbid broken iterators. >>

Re: __next__ and StopIteration

2015-02-09 Thread Ned Batchelder
On 2/9/15 2:24 PM, Ned Batchelder wrote: On 2/9/15 2:14 PM, Charles Hixson wrote: I'm trying to write a correct iteration over a doubly indexed container, and what I've got so far is:def __next__ (self): for rowinrange(self._rows): for col in range(self._cols):

Re: __next__ and StopIteration

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 12:11 PM, Steven D'Aprano wrote: >> Yes, it is allowed. But when you write code that's documented as being >> "broken", you should expect annoying, subtle errors, maybe a long way >> down the track. > > Well, that depends, don't it? > > Am I really going to care if the iter

Weird behavior on __dict__ attr

2015-02-09 Thread Shiyao Ma
Hi. My context is a little hard to reproduce. NS3 is a network simulation tool written in C++. I am using its Python binding. So the class I am dealing with is from a .so file. Say, I do the following: % import ns.network.Node as Node # Node is a class # it has a __dict__ attr # Now I insta

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Dave Angel
On 02/09/2015 07:02 PM, Ethan Furman wrote: On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or Indian?") if restraunt == ("Pizza"): fav = ("1") elif restraunt == ("C

Re: Weird behavior on __dict__ attr

2015-02-09 Thread Dave Angel
On 02/09/2015 09:52 PM, Shiyao Ma wrote: Hi. My context is a little hard to reproduce. WHY don't you try? Telling us about a class without showing how it's defined leaves us all guessing. Start by telling us Python version. And if it's 2.x, tell us whether this class is an old style or n

Re: __next__ and StopIteration

2015-02-09 Thread Charles Hixson
On 02/09/2015 03:56 PM, Ian Kelly wrote: On Mon, Feb 9, 2015 at 4:30 PM, Steven D'Aprano wrote: The way you write iterators is like this: Method 1 (the hard way): - Give your class an __iter__ method which simply returns self: def __iter__(self): return self - Give your clas

Re: __next__ and StopIteration

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 3:33 PM, Charles Hixson wrote: >> The proper version of the "hard way" is: >> >> 1) The __iter__ method of the iterable constructs a new iterator >> instance and returns it. >> >> 2) The __iter__ method of the *iterator* simply returns itself. >> >> 3) The __next__ method o

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Dave Angel
On 02/09/2015 10:05 PM, Dave Angel wrote: On 02/09/2015 07:02 PM, Ethan Furman wrote: On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or Indian?") if restraunt == ("Pizza"

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Terry Reedy
On 2/9/2015 6:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or Indian?") if restraunt == ("Pizza"): fav = ("1") As a style note, putting parentheses around strings is worse than us

Re: __next__ and StopIteration

2015-02-09 Thread Steven D'Aprano
Chris Kaynor wrote: > On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano > wrote: >> so that's an excellent sign that doing so is best practice, but it should >> not be seen as *required*. After all, perhaps you have good reason for >> wanting your iterable class to only be iterated over once. > >

Re: __next__ and StopIteration

2015-02-09 Thread Charles Hixson
On 02/09/2015 08:46 PM, Chris Angelico wrote: On Tue, Feb 10, 2015 at 3:33 PM, Charles Hixson wrote: The proper version of the "hard way" is: 1) The __iter__ method of the iterable constructs a new iterator instance and returns it. 2) The __iter__ method of the *iterator* simply returns itse

Re: __next__ and StopIteration

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 5:16 PM, Charles Hixson wrote: > Yes, rows and cols are lists, but I'm going to need to iterate through them > more than once. I'd rather do without a included class, but if a properly > formed iterator can only be cycled through once, and if I understand > properly that m

Varable parsing error with python

2015-02-09 Thread OmPs
In an XML file which contain a tag and then these tags contain properties, which later are being called in anoter tag where these properties are expanded as variables. For eg. 1.0 1.2 Red Hat Enterprise Linux Serv

Re: Varable parsing error with python

2015-02-09 Thread Chris Angelico
On Tue, Feb 10, 2015 at 6:30 PM, OmPs wrote: > def _getPackgeVersion(xmlfile, p): > package = str(p) > if isinstance(fpmdict["application"]["package"], list): > for i in fpmdict["application"]["package"]: > if i["@name"] == p: > _