Re: Getting module path string from a class instance

2012-11-12 Thread Some Developer
On 13/11/2012 07:19, Steven D'Aprano wrote: On Tue, 13 Nov 2012 06:38:31 +, Some Developer wrote: I'm trying to find a way to get a string of the module path of a class. So for instance say I have class Foo and it is in a module called my.module. I want to be able to get a string that is e

Re: Getting module path string from a class instance

2012-11-12 Thread Steven D'Aprano
On Tue, 13 Nov 2012 06:38:31 +, Some Developer wrote: > I'm trying to find a way to get a string of the module path of a class. > > So for instance say I have class Foo and it is in a module called > my.module. I want to be able to get a string that is equal to this: > "my.module.Foo". I'm aw

Re: Strange object identity problem

2012-11-12 Thread F.R.
On 11/12/2012 06:02 PM, duncan smith wrote: On 12/11/12 13:40, F.R. wrote: On 11/12/2012 02:27 PM, Robert Franke wrote: Hi Frederic, [...] bas = {} for year in range (2010, 2013): ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year) ba.run () print year, id (ba) bas [yea

Getting module path string from a class instance

2012-11-12 Thread Some Developer
I'm trying to find a way to get a string of the module path of a class. So for instance say I have class Foo and it is in a module called my.module. I want to be able to get a string that is equal to this: "my.module.Foo". I'm aware of the __repr__ method but it does not do what I want it to d

Re: Simple Question regarding running .py program

2012-11-12 Thread Terry Reedy
On 11/12/2012 9:45 PM, Caroline Hou wrote: Also, how could I edit my script? I have sth called "IDLE" installed along with python. Is it the right place to write/edit my script? IDLE is one way to edit; I use it. When you want to run, hit F5 and stdout and stderr output goes to the shell wind

Re: stackoverflow quote on Python

2012-11-12 Thread Steven D'Aprano
On Tue, 13 Nov 2012 03:08:54 +, Mark Lawrence wrote: > http://stackoverflow.com/questions/tagged/python > > "Python has two major versions (2 and 3) in use which have significant > differences." > > I believe that this is incorrect. The warts have been removed, but > significant differences

Re: stackoverflow quote on Python

2012-11-12 Thread Ian Kelly
On Mon, Nov 12, 2012 at 8:08 PM, Mark Lawrence wrote: > http://stackoverflow.com/questions/tagged/python > > "Python has two major versions (2 and 3) in use which have significant > differences." > > I believe that this is incorrect. The warts have been removed, but > significant differences, not

Re: A gnarly little python loop

2012-11-12 Thread rusi
On Nov 12, 9:09 pm, Steve Howell wrote: > On Nov 12, 7:21 am, rusi wrote: > > > On Nov 12, 12:09 pm, rusi wrote:> This is a classic > > problem -- structure clash of parallel loops > > > > > > Sorry wrong solution :D > > > The fidgetiness is entirely due to python not allowing C-style loops >

Re: stackoverflow quote on Python

2012-11-12 Thread Rodrick Brown
I believe this statement is correct given key differences do exist in underlying implementations even though such differences may be highly transparent to end users (developers). On Mon, Nov 12, 2012 at 10:08 PM, Mark Lawrence wrote: > http://stackoverflow.com/**questions/tagged/python

stackoverflow quote on Python

2012-11-12 Thread Mark Lawrence
http://stackoverflow.com/questions/tagged/python "Python has two major versions (2 and 3) in use which have significant differences." I believe that this is incorrect. The warts have been removed, but significant differences, not in my book. If there is agreement about there not being sign

Re: Simple Question regarding running .py program

2012-11-12 Thread Caroline Hou
On Monday, 12 November 2012 21:25:08 UTC-5, Dave Angel wrote: > On 11/12/2012 09:02 PM, Caroline Hou wrote: > > > Hi all! > > > > > > I just started learning Python by myself and I have an extremely simple > > question now! > > > I am in my Python interpreter now and I want to open/edit a pro

Re: Simple Question regarding running .py program

2012-11-12 Thread Dave Angel
On 11/12/2012 09:02 PM, Caroline Hou wrote: > Hi all! > > I just started learning Python by myself and I have an extremely simple > question now! > I am in my Python interpreter now and I want to open/edit a program called > nobel.py. But when I typed >>> python nobel.py, it gave me a > "SyntaxE

Simple Question regarding running .py program

2012-11-12 Thread Caroline Hou
Hi all! I just started learning Python by myself and I have an extremely simple question now! I am in my Python interpreter now and I want to open/edit a program called nobel.py. But when I typed >>> python nobel.py, it gave me a "SyntaxError:invalid syntax”( I've changed to the correct directo

Re: Division matrix

2012-11-12 Thread Joshua Landau
On 13 November 2012 01:00, Cleuson Alves wrote: > Hello, I need to solve an exercise follows, first calculate the inverse > matrix and then multiply the first matrix. > This list isn't to give answers for homeworks, and this sounds like one. We *do* give help to those who have a specific problem

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
On 11/12/2012 4:35 PM, Terry Reedy wrote: import urllib.request opener = urllib.request.build_opener() request = urllib.request.Request("http://example.com/";, headers = {"Content-Type": "application/x-www-form-urlencoded"}) opener.open(request, "1".encode("us-ascii")) print(request.da

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
On 11/12/2012 5:59 PM, Cameron Simpson wrote: On 12Nov2012 16:35, Terry Reedy wrote: | On 11/12/2012 10:52 AM, Johannes Kleese wrote: | > While at it, I noticed that urllib.request.Request.has_header() and | > .get_header() are case-sensitive, | | Python is case sensitive. To be more precise,

Re: Division matrix

2012-11-12 Thread Ian Kelly
On Mon, Nov 12, 2012 at 6:00 PM, Cleuson Alves wrote: > Hello, I need to solve an exercise follows, first calculate the inverse > matrix and then multiply the first matrix. > I await help. > Thank you. > follows the code below incomplete. So what is the specific problem with the code that you're

Division matrix

2012-11-12 Thread Cleuson Alves
Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix. I await help. Thank you. follows the code below incomplete. m = [[1,2,3],[4,5,6],[7,8,9]] x = [] for i in [0,1,2]: y = [] for linha in m: y.append(linha[i]) x.app

Re: Help building a dictionary of lists

2012-11-12 Thread Joshua Landau
On 12 November 2012 22:26, NJ1706 wrote: > # List of tests > TestList = ( > 'Test_1', > 'Test_2' > ) Note that TestList is a *tuple*, not a list. You normally would want to write "test_names" instead of "TestList" for several reasons: * Unless it's a class, Python prefers lowercase_na

Re: Help building a dictionary of lists

2012-11-12 Thread Joshua Landau
On 12 November 2012 22:26, NJ1706 wrote: > Chaps, > > I am new to Python & have inherited a test harness written in the language > that I am trying to extend. > > The following code shows how dictionaries holding lists of commands are > handled in the script... > > >>> Start of Code_1 <<< > >>

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Cameron Simpson
On 12Nov2012 16:35, Terry Reedy wrote: | On 11/12/2012 10:52 AM, Johannes Kleese wrote: | > While at it, I noticed that urllib.request.Request.has_header() and | > .get_header() are case-sensitive, | | Python is case sensitive. But headers are not. I'd be very inclined to consider case sensitivi

Re: f python?

2012-11-12 Thread Steven D'Aprano
On Mon, 12 Nov 2012 17:37:50 -0500, Dave Angel wrote: > On 11/12/2012 05:07 PM, Beekeeper2020 wrote: [...] >> Python eventually will die once troll troll troll troll troll... > In case anybody is tempted to respond to this troll message, Like you did? Without trimming? :-P -- Steven -- h

Re: f python?

2012-11-12 Thread Dave Angel
On 11/12/2012 05:07 PM, Beekeeper2020 wrote: > I totally agreed about the Python syntax. Why do I need to worry about the > syntax which wasted hours to get it to work? > Brain dead python designer! Maybe Guido need to learn it from the Master, > "Go to Ruby, and see how elegant the language is d

Help building a dictionary of lists

2012-11-12 Thread NJ1706
Chaps, I am new to Python & have inherited a test harness written in the language that I am trying to extend. The following code shows how dictionaries holding lists of commands are handled in the script... >>> Start of Code_1 <<< #! /usr/bin/python # List of tests TestList = ( 'Test_1',

Re: List comprehension for testing **params

2012-11-12 Thread Cantabile
Wow, lots of things I had never heard of in your posts. I guess I need to do some homework... Cantabile -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing Donald E. Knuth based code in Python, cont'd

2012-11-12 Thread Vincent Vande Vyvre
Le 12/11/12 22:02, Juhani Ylikoski a écrit : > Following comes a working, debugged Python program which computes the > permutations of the integers 1, 2, 3 - n after Donald E. Knuth. I > present it as an example of writing straightforward, easy Knuth-based > code in a language with no GOTO stateme

Re: f python?

2012-11-12 Thread Beekeeper2020
I totally agreed about the Python syntax. Why do I need to worry about the syntax which wasted hours to get it to work? Brain dead python designer! Maybe Guido need to learn it from the Master, "Go to Ruby, and see how elegant the language is done. Also, it is stupid of google to hire Guido to

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread jkn
Hi Hans [...] > > >         xargsproc.append("test -f %s/{} && md5sum %s/{}" % (mydir, > > mydir)) > > This will break if there are spaces in the file name, or other > characters meaningful to the shell.  If you change if to > >         xargsproc.append("test -f '%s/{}' && md5sum '%s/{}'" >      

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
On 11/12/2012 10:52 AM, Johannes Kleese wrote: Hi! (Yes, I did take a look at the issue tracker but couldn't find any corresponding bug, and no, I don't want to open a new account just for this one.) You only have to open a tracker account just once. I am reluctant to report this myself as I

Writing Donald E. Knuth based code in Python, cont'd

2012-11-12 Thread Juhani Ylikoski
Following comes a working, debugged Python program which computes the permutations of the integers 1, 2, 3 - n after Donald E. Knuth. I present it as an example of writing straightforward, easy Knuth-based code in a language with no GOTO statement. The Python program has been written after the D

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Terry Reedy
On 11/12/2012 7:25 AM, Joel Goldstick wrote: Chris gave you the same help that you got yesterday. ... go to ://python.org> and read the tutorials, specifically about functions. It is hard to see what is working and not with an empty database. But to drive the point home, running import sq

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread Hans Mulder
On 12/11/12 18:22:44, jkn wrote: > Hi Hans > > On Nov 12, 4:36 pm, Hans Mulder wrote: >> On 12/11/12 16:36:58, jkn wrote: >> >> >> >> >> >> >> >> >> >>> slight followup ... >> >>> I have made some progress; for now I'm using subprocess.communicate to >>> read the output from the first subprocess,

Re: Read number of CSV files

2012-11-12 Thread Smaran Harihar
Oh that is great. [apology on sending the mail directly] Thanks, Smaran On Mon, Nov 12, 2012 at 10:50 AM, Peter Otten <__pete...@web.de> wrote: > Peter Otten wrote: > > [please don't email me directly] > > > How is using glob different from os.listdir() Peter? > > glob retains the path and allo

Re: Read number of CSV files

2012-11-12 Thread Peter Otten
Peter Otten wrote: [please don't email me directly] > How is using glob different from os.listdir() Peter? glob retains the path and allows you to filter the files. Compare: >>> import os, glob >>> os.listdir("alpha") ['one.py', 'two.py', 'one.txt', 'three.py', 'three.txt', 'two.txt'] >>> glob.

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread jkn
Hi Hans On Nov 12, 4:36 pm, Hans Mulder wrote: > On 12/11/12 16:36:58, jkn wrote: > > > > > > > > > > > slight followup ... > > > I have made some progress; for now I'm using subprocess.communicate to > > read the output from the first subprocess, then writing it into the > > secodn subprocess. T

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread jkn
On Nov 12, 4:58 pm, Rebelo wrote: > Dana četvrtak, 8. studenoga 2012. 19:05:12 UTC+1, korisnik jkn napisao je: > > > Hi All > > >     i am trying to build up a set of subprocess.Ponen calls to > > > replicate the effect of a horribly long shell command. I'm not clear > > > how I can do one part of

Re: Strange object identity problem

2012-11-12 Thread duncan smith
On 12/11/12 13:40, F.R. wrote: On 11/12/2012 02:27 PM, Robert Franke wrote: Hi Frederic, [...] bas = {} for year in range (2010, 2013): ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year) ba.run () print year, id (ba) bas [year] = ba 2010 150289932 2011 150835852 2012 1

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread Rebelo
Dana četvrtak, 8. studenoga 2012. 19:05:12 UTC+1, korisnik jkn napisao je: > Hi All > > i am trying to build up a set of subprocess.Ponen calls to > > replicate the effect of a horribly long shell command. I'm not clear > > how I can do one part of this and wonder if anyone can advise. I'm o

Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Johannes Kleese
Hi! (Yes, I did take a look at the issue tracker but couldn't find any corresponding bug, and no, I don't want to open a new account just for this one.) I'm reusing a single urllib.request.Request object to HTTP-POST data to th

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread Hans Mulder
On 12/11/12 16:36:58, jkn wrote: > slight followup ... > > I have made some progress; for now I'm using subprocess.communicate to > read the output from the first subprocess, then writing it into the > secodn subprocess. This way I at least get to see what is > happening ... > > The reason 'we' w

Re: A gnarly little python loop

2012-11-12 Thread Steve Howell
On Nov 12, 7:21 am, rusi wrote: > On Nov 12, 12:09 pm, rusi wrote:> This is a classic > problem -- structure clash of parallel loops > > > > Sorry wrong solution :D > > The fidgetiness is entirely due to python not allowing C-style loops > like these: > > >> while ((c=getchar()!= EOF) { ... } >

Re: A gnarly little python loop

2012-11-12 Thread Peter Otten
rusi wrote: > The fidgetiness is entirely due to python not allowing C-style loops > like these: > >>> while ((c=getchar()!= EOF) { ... } for c in iter(getchar, EOF): ... > Clearly the fidgetiness is there as before and now with extra coroutine > plumbing Hmm, very funny... -- http://mai

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread jkn
slight followup ... I have made some progress; for now I'm using subprocess.communicate to read the output from the first subprocess, then writing it into the secodn subprocess. This way I at least get to see what is happening ... The reason 'we' weren't seeing any output from the second call (th

Re: A gnarly little python loop

2012-11-12 Thread rusi
On Nov 12, 12:09 pm, rusi wrote: > This is a classic problem -- structure clash of parallel loops Sorry wrong solution :D The fidgetiness is entirely due to python not allowing C-style loops like these: >> while ((c=getchar()!= EOF) { ... } Putting it into coroutine form, it becomes something

Re: error

2012-11-12 Thread Dave Angel
On 11/09/2012 09:08 AM, inshu chauhan wrote: > Actually this one.. and its the last.. > > > The only extra libary i am using is Opencv , downloaded from http://sourceforge.net/projects/opencvlibrary/ and numpy. > 3) what import statement did you use ? >

Re: int.__init__ incompatible in Python 3.3

2012-11-12 Thread Ulrich Eckhardt
Am 09.11.2012 12:37, schrieb Steven D'Aprano: In Python 3.3: py> class X(int): ... def __init__(self, *args): ... super().__init__(*args) # does nothing, call it anyway ... py> x = X(22) Traceback (most recent call last): File "", line 1, in File "", line 3, in __init__ TypeE

Re: Strange object identity problem

2012-11-12 Thread Ulrich Eckhardt
Am 12.11.2012 14:12, schrieb F.R.: Once in a while I write simple routine stuff and spend the next few hours trying to understand why it doesn't behave as I expect. Here is an example holding me up: [...snip incomplete code...] Trying something similar with a simpler class works as expected: [

Re: Strange object identity problem

2012-11-12 Thread F.R.
On 11/12/2012 02:27 PM, Robert Franke wrote: Hi Frederic, [...] bas = {} for year in range (2010, 2013): ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year) ba.run () print year, id (ba) bas [year] = ba 2010 150289932 2011 150835852 2012 149727788 for y in sorted (bas.

Re: List comprehension for testing **params

2012-11-12 Thread Joshua Landau
On 12 November 2012 13:23, Joshua Landau wrote: > Just a few tricks you may have missed: > > On 12 November 2012 10:48, Ulrich Eckhardt < > ulrich.eckha...@dominolaser.com> wrote: > >> Am 11.11.2012 23:24, schrieb Cantabile: > > if required.intersection(params.**keys()) != required: >> > > i

Re: Strange object identity problem

2012-11-12 Thread Robert Franke
Hi Frederic, [...] bas = {} for year in range (2010, 2013): > ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year) > ba.run () > print year, id (ba) > bas [year] = ba > > 2010 150289932 > 2011 150835852 > 2012 149727788 > for y in sorted (bas.keys ()): > b = ba

Re: List comprehension for testing **params

2012-11-12 Thread Joshua Landau
Just a few tricks you may have missed: On 12 November 2012 10:48, Ulrich Eckhardt wrote: > Am 11.11.2012 23:24, schrieb Cantabile: if required.intersection(params.**keys()) != required: > if required.issubset(params): >missing = required - set(params.keys()) > missing = required.

Strange object identity problem

2012-11-12 Thread F.R.
Hi all, Once in a while I write simple routine stuff and spend the next few hours trying to understand why it doesn't behave as I expect. Here is an example holding me up: I have a module "st" with a class "runs". In a loop I repeatedly create an object "ba" and call the method "ba.run ()" whic

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread jkn
Hi Hans thanks a lot for your reply: > That's what 'xargs' will do for you.  All you need to do, is invoke > xargs with arguments containing '{}'.  I.e., something like: > > cmd1 = ['tar', '-czvf', 'myfile.tgz', '-c', mydir, 'mysubdir'] > first_process = subprocess.Popen(cmd1, stdout=subproces

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Joel Goldstick
On Mon, Nov 12, 2012 at 6:01 AM, Chris Angelico wrote: > On Mon, Nov 12, 2012 at 9:45 PM, Khalid Al-Ghamdi > wrote: > > Is there a way to create a func that returns a cursor that can be used > to execute sql statements? > > Yes, and you're almost there! > > > I tried this (after importing sqlite

Re: logging, can one get it to email messages over a certain level?

2012-11-12 Thread tinnews
Peter Otten <__pete...@web.de> wrote: > tinn...@isbd.co.uk wrote: > > > Steve Howell wrote: > >> On Nov 11, 9:48 am, tinn...@isbd.co.uk wrote: > >> > I'm sure this must be possible but at the moment I can't see how to do > >> > it. > >> > > >> > I want to send an E-Mail when the logging module lo

Re: List comprehension for testing **params

2012-11-12 Thread Ulrich Eckhardt
Am 11.11.2012 23:24, schrieb Cantabile: I'm writing a small mail library for my own use, and at the time I'm testing parameters like this: Let's ignore the facts that there is an existing mail library, that you should use real parameters if they are required and that exit() is completely inap

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Chris Angelico
On Mon, Nov 12, 2012 at 9:45 PM, Khalid Al-Ghamdi wrote: > Is there a way to create a func that returns a cursor that can be used to > execute sql statements? Yes, and you're almost there! > I tried this (after importing sqlite3), but it gave me the error below: > def connect(): > retu

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Peter Otten
Khalid Al-Ghamdi wrote: > Is there a way to create a func that returns a cursor that can be used to > execute sql statements? You should read an introductory text on Python, this is not specific to sqlite3. > I tried this (after importing sqlite3), but it gave me the error below: > def c

Re: logging, can one get it to email messages over a certain level?

2012-11-12 Thread Peter Otten
tinn...@isbd.co.uk wrote: > Steve Howell wrote: >> On Nov 11, 9:48 am, tinn...@isbd.co.uk wrote: >> > I'm sure this must be possible but at the moment I can't see how to do >> > it. >> > >> > I want to send an E-Mail when the logging module logs a message above >> > a certain level (probably for

Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Khalid Al-Ghamdi
Is there a way to create a func that returns a cursor that can be used to execute sql statements? I tried this (after importing sqlite3), but it gave me the error below: >>> def connect(): conn = sqlite3.connect(':memory:')#use sch3.db or sch4.db etc. cur = conn.cursor() cur.e

Re: skip Trackback error for ftp checking

2012-11-12 Thread Chris Angelico
On Mon, Nov 12, 2012 at 8:25 PM, moonhkt wrote: > On Nov 10, 2:50 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> >> The same way you would skip any other error when you do something wrong: >> catch the exception. > > Thank. Added below. > try: >ftp = FTP(options.remote_host_ad

Re: logging, can one get it to email messages over a certain level?

2012-11-12 Thread tinnews
Steve Howell wrote: > On Nov 11, 9:48 am, tinn...@isbd.co.uk wrote: > > I'm sure this must be possible but at the moment I can't see how to do it. > > > > I want to send an E-Mail when the logging module logs a message above > > a certain level (probably for ERROR and CRITICAL messages only). > >

Fwd: error

2012-11-12 Thread inshu chauhan
No answers for my question ?? :O -- http://mail.python.org/mailman/listinfo/python-list

Re: skip Trackback error for ftp checking

2012-11-12 Thread moonhkt
On Nov 10, 2:50 pm, Steven D'Aprano wrote: > On Fri, 09 Nov 2012 20:51:47 -0800, moonhkt wrote: > > HI All > > > How to skip Trackback warning/error when input ftp address is not > > correct or reject ? > > The same way you would skip any other error when you do something wrong: > catch the except

Re: duck typing assert

2012-11-12 Thread Ian Kelly
On Fri, Nov 9, 2012 at 6:36 AM, Steven D'Aprano wrote: > (I think... I really don't actually know if Zooey Deschanel can sing or > not. Just go along with the example.) Not only does she sing, she's in a band. http://en.wikipedia.org/wiki/She_%26_Him I take your point about the "looks like" ter