RE: How to automatically get the indent level from code?

2013-03-16 Thread Mark Shroyer
I realize this isn't yet precisely what you're asking for, but look at the inspect and ast modules: import ast, inspect def indent_level(): lineno = inspect.currentframe().f_back.f_lineno with open(__file__) as source_file: tree = ast.parse(source_file.read()

Re: How to automatically get the indent level from code?

2013-03-16 Thread Rodrick Brown
No On Sun, Mar 17, 2013 at 12:52 AM, Peng Yu wrote: > Hi, > > I want to get the indent level within the code. For example, I want to > print 1 within the while loop as the line is indented 1 level. Is it > possible to get it within python? > > while 1: >#print the level of indent, which is

How to automatically get the indent level from code?

2013-03-16 Thread Peng Yu
Hi, I want to get the indent level within the code. For example, I want to print 1 within the while loop as the line is indented 1 level. Is it possible to get it within python? while 1: #print the level of indent, which is 1 here. -- Regards, Peng -- http://mail.python.org/mailman/listinfo

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Benjamin Kaplan
On Sat, Mar 16, 2013 at 8:14 PM, Steven D'Aprano wrote: > On Sat, 16 Mar 2013 19:58:41 -0600, Michael Torrie wrote: > >> On 03/16/2013 06:11 PM, Rick Johnson wrote: >>> No, the "ACTUAL PROBLEM" is in the author. >> >> Surely any NameException can also be blamed on the author then, by your >> logic

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 2:14 PM, Steven D'Aprano wrote: > On Sat, 16 Mar 2013 19:58:41 -0600, Michael Torrie wrote: > >> On 03/16/2013 06:11 PM, Rick Johnson wrote: >>> No, the "ACTUAL PROBLEM" is in the author. >> >> Surely any NameException can also be blamed on the author then, by your >> logic

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Steven D'Aprano
On Sat, 16 Mar 2013 19:58:41 -0600, Michael Torrie wrote: > On 03/16/2013 06:11 PM, Rick Johnson wrote: >> No, the "ACTUAL PROBLEM" is in the author. > > Surely any NameException can also be blamed on the author then, by your > logic? Any exception at all is obviously the author's fault. I propo

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Michael Torrie
On 03/16/2013 06:11 PM, Rick Johnson wrote: > No, the "ACTUAL PROBLEM" is in the author. Surely any NameException can also be blamed on the author then, by your logic? -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Rick Johnson
On Saturday, March 16, 2013 6:48:01 PM UTC-5, Steven D'Aprano wrote: > On Sat, 16 Mar 2013 21:19:34 +, Oscar Benjamin wrote: > > [...] > > NameErrors can occur conditionally depending on e.g. the > > arguments to a function. Consider the following script: > [...] > > Correct, although in your e

[ANNC] pynguin-0.13 python turtle graphics application now uses python 3

2013-03-16 Thread Lee Harr
Pynguin is a python-based turtle graphics application.     It combines an editor, interactive interpreter, and     graphics display area. It is meant to be an easy environment for introducing     some programming concepts to beginning programmers. http://pynguin.googlecode.com/ This release p

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 10:50 AM, Rick Johnson wrote: > * Superfluous trackbacks are not only ugly, they damage >productivity. Extraordinary claims require extraordinary evidence. Start evidencing. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 10:48 AM, Steven D'Aprano wrote: > Here's a truly trivial case where code will succeed or fail depending on > the order of function calls. > (chop code) > It's not enough to know that the print line in display() fails, because > that's merely the side-effect. The actual pro

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Rick Johnson
On Saturday, March 16, 2013 6:29:52 PM UTC-5, Oscar Benjamin wrote: > I wasn't looking to convince *you*, just to set the record > straight that this behaviour is sometimes useful. And you claim to "set the record strait" by posting code that *purposely* raises a NameError when some function para

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Steven D'Aprano
On Sat, 16 Mar 2013 21:19:34 +, Oscar Benjamin wrote: > On 16 March 2013 18:27, Rick Johnson > wrote: >> >> Sometimes many levels of trace messages can be helpful when detecting >> bugs, however, in the case of NameErrors, these "nuggets" ejected from >> deep within the bowls of the Python i

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 10:36 AM, Tim Chase wrote: > Because, in the real world, that example looks something like > > def broken(intelligence_level): > if intelligence_level < 100: > return dumb_down(intellegence_level) > else: > return make_harder(intelligence_level) > br

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Tim Chase
On 2013-03-16 15:39, Rick Johnson wrote: > On Saturday, March 16, 2013 4:19:34 PM UTC-5, Oscar Benjamin wrote: > > # tmp.py > > def broken(x): > > if x > 2: > > print(x) > > else: > > print(undefined_name) > > > > broken(1) > > Why would anyone write code lik

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Oscar Benjamin
On 16 March 2013 22:39, Rick Johnson wrote: > On Saturday, March 16, 2013 4:19:34 PM UTC-5, Oscar Benjamin wrote: > >> The traceback shows the arguments passed to the broken >> function that caused the NameError to be generated. >> Different arguments would not have generated the >> NameError. Thi

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Rick Johnson
On Saturday, March 16, 2013 4:19:34 PM UTC-5, Oscar Benjamin wrote: > > NameErrors can occur conditionally depending on e.g. the > arguments to a function. Consider the following script: > > # tmp.py > def broken(x): > if x > 2: > print(x) > else: > print(undefi

Having a hard time installing pygame on Win7.

2013-03-16 Thread Yves S. Garret
Hi all, got a small problem. As I'm going through "Python Programming for the Absolute Beginner", I got to chapter 11 and as I'm working through it, I can't seem to get pygame/livewires installed... I don't even know how to go about installing it (the book is skimpy on details). I'm using Pyt

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread Roy Smith
In article , Neil Hodgson wrote: > Low-level string manipulation often deals with blocks larger than > an individual character for speed. Generally 32 or 64-bits at a time > using the CPU or 128 or 256 using the vector unit. Then there may be > entry/exit code to handle initial alignmen

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread Neil Hodgson
Steven D'Aprano: So while you might save memory by using "UTF-24" instead of UTF-32, it would probably be slower because you would have to grab three bytes at a time instead of four, and the hardware probably does not directly support that. Low-level string manipulation often deals with bl

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Oscar Benjamin
On 16 March 2013 18:27, Rick Johnson wrote: > > Sometimes many levels of trace messages can be helpful when detecting bugs, > however, in the case of NameErrors, these "nuggets" ejected from deep within > the bowls of the Python interpreter are nothing more than steaming piles of > incomprehen

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread jmfauth
-- utf-32 is already here. You are all most probably [*] using it without noticing it. How? By using OpenType fonts, without counting the text processing applications using them. Why? Because there is no other way to do it. [*] depending of the font, the internal table(s), eg "cmap" table, ar

Re: What's the easiest Python datagrid GUI (preferably with easy database hooks as well)?

2013-03-16 Thread Wolfgang Keller
> Very helpful collection, only one open question: which of them work > with Python 3? No clue, sorry. Given how many other modules are not yet compatible with Python 3, I haven't investigated that yet. wxwidgets/wxPython already has *just* made the switch to Cocoa (with 2.9) when Carbon support

Re: Im fetching data from excel using python code.. i could see some junk value also with it.

2013-03-16 Thread Joel Goldstick
On Sat, Mar 16, 2013 at 2:50 AM, dieter wrote: > s.arun...@gmail.com writes: > > > Hi im fetching data from excel using python code.. i could see some junk > value also with it. like [text:u > I used the xlrd module some time back. I think if you google for tutorial on it you will find your ans

PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Rick Johnson
Sometimes many levels of trace messages can be helpful when detecting bugs, however, in the case of NameErrors, these "nuggets" ejected from deep within the bowls of the Python interpreter are nothing more than steaming piles of incomprehensible crap! We don't need multiple layers of traces f

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread Roy Smith
In article <70844d17-22bd-4394-86e2-d7ef3efc6...@ps9g2000pbb.googlegroups.com>, rusi wrote: > I believe that there are many things about unicode that are less than > satisfactory. Some are downright asinine like the 'prime-real-estate' > devoted to the control characters and never used. Ah, bu

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread rusi
On Mar 16, 6:29 pm, Roy Smith wrote: > In article <51440235$0$29965$c3e8da3$54964...@news.astraweb.com>, >  Steven D'Aprano wrote: > > > UTF-32 is a *fixed width* storage mechanism where every code point takes > > exactly four bytes. Since the entire Unicode range will fit in four > > bytes, that

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Mitya Sirenef
On 03/16/2013 11:16 AM, Yves S. Garret wrote: On Saturday, March 16, 2013 11:10:07 AM UTC-4, Mitya Sirenef wrote: On 03/16/2013 10:53 AM, Yves S. Garret wrote: Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to > become more acquainted with the language. Howe

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Yves S. Garret
On Saturday, March 16, 2013 11:23:07 AM UTC-4, Chris Angelico wrote: > On Sun, Mar 17, 2013 at 2:16 AM, Yves S. Garret > > wrote: > > > In the example that I have posted from the book it works just fine. > > > > Yep, I just checked the book's version again and the difference is > > clear. Ch

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Christian Gollwitzer
Am 16.03.13 16:14, schrieb Yves S. Garret: On Saturday, March 16, 2013 11:08:24 AM UTC-4, Chris Angelico wrote: self.secret_txt.delete(0.0, END) self.secret_txt.delete(0.0, message) Is the second one supposed to be adding text? I'm not familiar with tkinter but that's the line with t

New Python book, "Learn Python Quickly"

2013-03-16 Thread John Rowland
Hi All, You may be interested in my latest book "Learn Python Quickly". It's a Kindle book but is specifically designed to be used with any of the free-to-download Kindle Reading Apps. What's special about the book is its comprehensive glossary and the numerous in-text internal hyperlinks to to

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 2:16 AM, Yves S. Garret wrote: > In the example that I have posted from the book it works just fine. Yep, I just checked the book's version again and the difference is clear. Check out the two lines I quoted in my previous post, and look at the corresponding two lines in t

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Yves S. Garret
On Saturday, March 16, 2013 11:08:24 AM UTC-4, Chris Angelico wrote: > On Sun, Mar 17, 2013 at 1:53 AM, Yves S. Garret > > wrote: > > > Hi all, I'm well into "Python Programming for the Absolute Beginner" in > > order to > > > become more acquainted with the language. However, when I got to p

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Yves S. Garret
On Saturday, March 16, 2013 11:10:07 AM UTC-4, Mitya Sirenef wrote: > On 03/16/2013 10:53 AM, Yves S. Garret wrote: > > > Hi all, I'm well into "Python Programming for the Absolute Beginner" in > > order to > > > become more acquainted with the language. However, when I got to page > > 304 a

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Mitya Sirenef
On 03/16/2013 10:53 AM, Yves S. Garret wrote: Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to > become more acquainted with the language. However, when I got to page 304 and > did my first example: > > http://bin.cakephp.org/view/1107093008 > > And this is the

Re: What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Chris Angelico
On Sun, Mar 17, 2013 at 1:53 AM, Yves S. Garret wrote: > Hi all, I'm well into "Python Programming for the Absolute Beginner" in order > to > become more acquainted with the language. However, when I got to page 304 and > did my first example: > > http://bin.cakephp.org/view/1107093008 > > And t

What am I doing wrong in this simple tkinter example?

2013-03-16 Thread Yves S. Garret
Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to become more acquainted with the language. However, when I got to page 304 and did my first example: http://bin.cakephp.org/view/1107093008 And this is the error that I'm getting: http://bin.cakephp.org/view/3997

Re: Simple Plot in Python

2013-03-16 Thread subhabangalore
On Saturday, March 16, 2013 5:12:41 PM UTC+5:30, subhaba...@gmail.com wrote: > Dear Group, > > > > I have two sets of values in probability, like, > > > > x=[0.1,0.2,0.3,0.4] > > and > > y=[0.2,0.4,0.6,0.8] > > > > And I am trying to draw a simple graph with Python. > > > > I was tryi

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread Roy Smith
In article <51440235$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > UTF-32 is a *fixed width* storage mechanism where every code point takes > exactly four bytes. Since the entire Unicode range will fit in four > bytes, that ensures that every code point is covered, and

Re: Simple Plot in Python

2013-03-16 Thread Andreas Perstinger
subhabangal...@gmail.com wrote: >I was trying to draw in Matplotlib but did not find much help. Have you looked already at the homepape for "maptlotlib"?: http://matplotlib.org/index.html There you'll find a tutorial: http://matplotlib.org/users/pyplot_tutorial.html Bye, Andreas -- http://mail.

Simple Plot in Python

2013-03-16 Thread subhabangalore
Dear Group, I have two sets of values in probability, like, x=[0.1,0.2,0.3,0.4] and y=[0.2,0.4,0.6,0.8] And I am trying to draw a simple graph with Python. I was trying to draw in Matplotlib but did not find much help. If any one in the room can kindly suggest. Thanking You in Advance, Regard

Re: String performance regression from python 3.2 to 3.3

2013-03-16 Thread Steven D'Aprano
On Fri, 15 Mar 2013 21:26:28 -0700, rusi wrote: > The unicode standard is language-agnostic. Unicode implementations exist > withing a language x implementation x C- compiler implementation x … -- > Notice the gccs in Andriy's comparison. Do they signify? They should not. Ideally, the behaviour

sqlite3 - a create of table x fails after dropping table x (only on Windows)

2013-03-16 Thread ppotrebic
Interested to understand this problem. It only happens in Windows, not MacOS. Running python 2.7.3. sqlite3 3.7.12. The following script: import sqlite3 table_name = 'table_name' conn = sqlite3.connect('data2.db') c = conn.cursor() sql = 'create table if not exists ' + ta

2nd RFD: comp.sys.raspberry-pi - LAST CALL FOR COMMENTS

2013-03-16 Thread Big 8 Management Board
SECOND REQUEST FOR DISCUSSION (RFD) unmoderated group comp.sys.raspberry-pi LAST CALL FOR COMMENTS This is a formal Request for Discussion (RFD) for the creation of the unmoderated newsgroup comp.sys.raspberry-pi. NEWSGROUPS LINE: comp.sys.raspberr