Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Gregory Ewing
alex23 wrote: But on the gripping hand, it is a clear triumph of "Explicit is better than implicit." ;) I think we may have found the long-lost 20th principle of the Zen: "If it results in eye-bleedingly horrible code, it might be a bad idea." -- Greg -- http://mail.python.org/mailman/listinf

Re: Is exec() also not used in python 2.7.1 anymore?

2011-10-04 Thread Gabriel Genellina
En Tue, 04 Oct 2011 07:32:41 -0300, Wong Wah Meng-R32813 escribió: Haha... yeah I reviewed the code, it is supposed to exposed some remote methods locally (RMI proxy usage). However, I am not sure why what it does is merely a pass. I commented out this code and haven't seen any negative

Re: BaseHTTPServer ThreadMixIn not working

2011-10-04 Thread Gabriel Genellina
En Mon, 03 Oct 2011 12:03:18 -0300, amit escribió: I am really stuck in a very simple problem and wanted to know if you could take some time to check it out - My code is simple. Using BaseHTTPServer and ThreadInMix I want to run a python script (Script1.py) for every request made simultaneousl

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Steven D'Aprano
On Tue, 04 Oct 2011 20:20:34 -0700, alex23 wrote: > Steven D'Aprano wrote: >> Imported modules are variables like any other, and as they usually >> exist in the global scope, so they will all need to be explicitly >> referenced as global. This will get tiresome very quickly, and is a >> cure far

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread alex23
Steven D'Aprano wrote: > Imported modules are variables like any other, and as they usually exist > in the global scope, so they will all need to be explicitly referenced as > global. This will get tiresome very quickly, and is a cure far worse than > the disease, and alone is enough to disqualify

Re: how to call java methods in python

2011-10-04 Thread Alan Meyer
On 10/4/2011 2:39 AM, masood shaik wrote: Hi I am trying to import java method in python. But i am getting the following error. error: ImportError: No module named Calculator Calculator is the name of the class written in java. I am trying to access the methods of that class. Plea

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Steven D'Aprano
On Mon, 03 Oct 2011 21:27:12 -0700, alex23 wrote: > rantingrick wrote: >> Why? Well because many times i find myself wondering if this or that >> variable is local or global -- and when i say "global" i am speaking of >> module scope! The "global" cures the ill. > > Given your stated propensity

Re: syntax enhancement

2011-10-04 Thread Terry Reedy
On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like itertools.islice). What do you think a

Re: how to call java methods in python

2011-10-04 Thread Steven D'Aprano
On Tue, 04 Oct 2011 00:14:49 -0700, masood shaik wrote: > Hi > I am trying out my hand on accessing java methods in python. here is > my piece of code.. [...] > Now i am trying to access the calculateTip() and its showing import > error. > It works fine when i am running it with jython but why i

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Steven D'Aprano
On Tue, 04 Oct 2011 21:07:10 -0400, Alan Meyer wrote: > Incidentally, all of these exercises involve maintaining or re-writing > existing code written by other people. Students don't usually do much > of that, but when they get a real job, they find that maintenance is > most of what they actuall

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Alan Meyer
On 10/4/2011 9:07 PM, Alan Meyer wrote: ... and to write up a comparison of the pros and cons of the global and no-global approaches. ... Of course you'll need to be fair in evaluating the students comparisons. Some bright students are likely to come up with good reasons for using globals

Re: Need A script to open a excel file and extract the data using autofilter

2011-10-04 Thread Alan Meyer
On 10/4/2011 5:12 PM, David Monaghan wrote: On Tue, 04 Oct 2011 19:42:06 +0100, Chris Withers wrote: On 01/10/2011 23:00, David Monaghan wrote: after opening the text.xls file i need to filter all the rows in which the status column is passed and copy the whole sheet to another sheet I don't

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Alan Meyer
On 10/3/2011 12:26 PM, Alec Taylor wrote: ... On Tue, Oct 4, 2011 at 3:21 AM, Aivar Annamaa wrote: ... I'm looking for a trick or hidden feature to make Python 3 automatically call a "main" function but without programmers writing `if __name__ == "__main__": ...` ... Here's why I want such a

GOZERBOT 0.99.0 RELEASED

2011-10-04 Thread Bart Thate
Hello world and everybody ! i'm pleased to announce the release of GOZERBOT 0.99.0, the first in a series of releases that are supposed to lead to a proper 1.0 release for GOZERBOT. The intention is to get a 1.0 version of GOZERBOT available for users that still use this bot, got almost 2000 downl

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Ben Finney
Westley Martínez writes: > Boiler plate is silly. Let the students figure out stuff themselves. That argues directly against the Primacy effect mentioned earlier https://secure.wikimedia.org/wikipedia/en/wiki/Principles_of_learning#Primacy> https://secure.wikimedia.org/wikipedia/en/wiki/Serial_

Re: Need A script to open a excel file and extract the data using autofilter

2011-10-04 Thread David Monaghan
On Tue, 04 Oct 2011 19:42:06 +0100, Chris Withers wrote: >On 01/10/2011 23:00, David Monaghan wrote: >>> after opening the text.xls file i need to filter all the rows in which >>> the status column is passed and copy the whole sheet to another sheet >> >> I don't do this often enough to have it t

Re: eggbasket

2011-10-04 Thread Andrea Crotti
On 10/04/2011 08:34 PM, Miki Tebeka wrote: Do you have a local file/directory that is called sqlalchemy? Funny thing, I have the same problem with another machine, with sqlalchemy installed system-wide instead of locally. Strange issue, maybe a problem with python 2.7/Linux? -- http://mail.p

Re: HTTP ResponseNotReady

2011-10-04 Thread pedr0
Mumble mumble... I described bad my question I think, yes I read that, but maybe is not a correct way of working. The http request I did retrieve (every time) an empty response, when I print the read() result call the result is the same of the sample you are talking about. http://docs.python.

Re: HTTP ResponseNotReady

2011-10-04 Thread MRAB
On 04/10/2011 21:29, pedr0 wrote: Hi solved this problem, I have to add: #connection http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60) #first request http_connection.request("POST", "/",params,headers=headers_) r1 = http_connection.getresponse() r1.read() // THIS ONE #

Re: HTTP ResponseNotReady

2011-10-04 Thread pedr0
Hi solved this problem, I have to add: #connection http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60) #first request http_connection.request("POST", "/",params,headers=headers_) r1 = http_connection.getresponse() r1.read() // THIS ONE #second request http_connection.reque

HTTP ResponseNotReady

2011-10-04 Thread pedr0
Hi at all, I don't understand why, in this piece of code, i catch the raise ResponseNotReady(self.__state) http.client.ResponseNotReady: Request-sent EVERY time I run this piece of code: #connection http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60) #first request http_

Re: eggbasket

2011-10-04 Thread Miki Tebeka
> How is it possible that the module exists and it's actually imported, > and not found when I actually try to import something from it? Do you have a local file/directory that is called sqlalchemy? -- http://mail.python.org/mailman/listinfo/python-list

Re: recommend a graphics library for plotting by the pixel?

2011-10-04 Thread Derek Simkowiak
If this is strictly for 2D pixel graphics, I recommend using PyGame (aka SDL). Why do you not think it's the way to go? It was built for this type of thing. You may also want to use PIL (Python Imaging Library) for various image manipulation tasks, but PIL doesn't handle mouse clicks

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread galyle
On Oct 4, 11:05 am, galyle wrote: > On Oct 4, 9:45 am, woooee wrote: > > > > > > > > > > > Sorry, I did not understand the question correctly, and so have added > > another focus_set for the entry after the menu's creation.  You can > > still enter after the menu comes up, even though you can't s

Re: Need A script to open a excel file and extract the data using autofilter

2011-10-04 Thread Chris Withers
On 01/10/2011 23:00, David Monaghan wrote: after opening the text.xls file i need to filter all the rows in which the status column is passed and copy the whole sheet to another sheet I don't do this often enough to have it to mind, so what I normally do is record a Macro, convert it to VBS and

TestFixtures 2.2.0 Released!

2011-10-04 Thread Chris Withers
Hi All, The TestFixtures releases keep coming, I hope someone other than me is finding these useful ;-) This release features a change to test_datetime and test_date so that they return instances of the real datetime.datetime and datetime.date classes by default. I'm hoping this will makin

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread galyle
On Oct 4, 9:45 am, woooee wrote: > Sorry, I did not understand the question correctly, and so have added > another focus_set for the entry after the menu's creation.  You can > still enter after the menu comes up, even though you can't see where > you are entering. > > import Tkinter > > class dem

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Westley Martínez
On Mon, Oct 03, 2011 at 09:35:16PM -0700, alex23 wrote: > Sorry for hijacking Alec's response but I didn't see the OP. > > > Aivar Annamaa wrote: > > > I'm looking for a trick or hidden feature to make Python 3 automatically > > > call a "main" function but without programmers writing `if __name_

Re: syntax enhancement

2011-10-04 Thread Calvin Spealman
On Tue, Oct 4, 2011 at 9:50 AM, Valiev Sergey wrote: > Hi, > you may found this idea stupid, but nevertheless... > - `[]` - used for list comprehension, > - `()` - used for generators, > - `[start:stop]` / `[start:stop:step]` - used for slices. > The idea is to use `(start:stop)` / `(start:stop:s

Re: recommend a graphics library for plotting by the pixel?

2011-10-04 Thread Ian Kelly
On Tue, Oct 4, 2011 at 3:56 AM, Adam Funk wrote: > I'd like to create a window with a "pause" button and a large plotting > area, in which I'd like to draw a polygon, detect the pixel > coördinates of a mouse click, and then start setting the colors of > pixels by (x,y) coördinates.  (This is just

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread woooee
Sorry, I did not understand the question correctly, and so have added another focus_set for the entry after the menu's creation. You can still enter after the menu comes up, even though you can't see where you are entering. import Tkinter class demo: def __init__(self, parent): self.

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread woooee
Adding focus_set seems to work for me. What do want to do differently? import Tkinter class demo: def __init__(self, parent): self._entry = Tkinter.Entry(width = 60) self._suggestions = Tkinter.Menu(parent, tearoff = 0, takefocus = 0) self._entry.pack(padx = 20, pady

Re: recommend a graphics library for plotting by the pixel?

2011-10-04 Thread Alec Taylor
Sounds like a job for Processing... On Tue, Oct 4, 2011 at 8:56 PM, Adam Funk wrote: > I'd like to create a window with a "pause" button and a large plotting > area, in which I'd like to draw a polygon, detect the pixel > coördinates of a mouse click, and then start setting the colors of > pixels

eggbasket

2011-10-04 Thread andrea . crotti . 0
I'm struggling trying to get a working local pypi server. Now eggbasket apparently also supports upload, which should be nice. So I: - created a virtualenv - installed all the necessary and trying to initializing the server I get: --8<---cut here---start->8--

syntax enhancement

2011-10-04 Thread Valiev Sergey
Hi, you may found this idea stupid, but nevertheless... - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like itertools.islice). What do y

Re: how to call java methods in python

2011-10-04 Thread Laszlo Nagy
Please help me Regarding how to create java bridge as how to call a java function from python If you want to call a Java *method* from the C python implementation, then there are many possibilities. For example, you can write your Java program as a service. The Python program can talk to it t

RE: Is exec() also not used in python 2.7.1 anymore?

2011-10-04 Thread Wong Wah Meng-R32813
Haha... yeah I reviewed the code, it is supposed to exposed some remote methods locally (RMI proxy usage). However, I am not sure why what it does is merely a pass. I commented out this code and haven't seen any negative implication. I will look into this again if I am convinced the next error

recommend a graphics library for plotting by the pixel?

2011-10-04 Thread Adam Funk
I'd like to create a window with a "pause" button and a large plotting area, in which I'd like to draw a polygon, detect the pixel coördinates of a mouse click, and then start setting the colors of pixels by (x,y) coördinates. (This is just for my own amusement, to play with some formulas for gene

Re: how to call java methods in python

2011-10-04 Thread masood shaik
On Oct 4, 1:16 pm, Chris Rebert wrote: > On Tue, Oct 4, 2011 at 12:14 AM, masood shaik wrote: > > Hi > >  I am trying out my hand on accessing java methods in python. here is > > my piece of code.. > > > Calculator.java > > --- > > public class Calculator { > > >    public Calculator(

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-04 Thread Aivar Annamaa
Thanks for all the comments! It seems that the best way is still just to teach students self discipline. And hope that they (for now) believe some things (eg. dangers of global variables) without seeing. Aivar -- http://mail.python.org/mailman/listinfo/python-list

Re: Is exec() also not used in python 2.7.1 anymore?

2011-10-04 Thread Peter Otten
Wong Wah Meng-R32813 wrote: > In migrating my application from python 1.5.2 to 2.7.1, one of my modules > breaks when I import it. Here is the line where it breaks. Can I have a > quick check if this built-in function still supported in python 2.7.1 and > if so, what ought to be changed here? Than

Re: Is exec() also not used in python 2.7.1 anymore?

2011-10-04 Thread Chris Rebert
On Tue, Oct 4, 2011 at 12:51 AM, Wong Wah Meng-R32813 wrote: > In migrating my application from python 1.5.2 to 2.7.1, one of my modules > breaks when I import it. Here is the line where it breaks. Can I have a > quick check if this built-in function still supported in python 2.7.1 Er, `exec` is

Re: how to call java methods in python

2011-10-04 Thread Chris Rebert
On Tue, Oct 4, 2011 at 12:14 AM, masood shaik wrote: > Hi >  I am trying out my hand on accessing java methods in python. here is > my piece of code.. > > Calculator.java > --- > public class Calculator { > >    public Calculator(){ > >    } > >    public double calculateTip(double cos

Is exec() also not used in python 2.7.1 anymore?

2011-10-04 Thread Wong Wah Meng-R32813
In migrating my application from python 1.5.2 to 2.7.1, one of my modules breaks when I import it. Here is the line where it breaks. Can I have a quick check if this built-in function still supported in python 2.7.1 and if so, what ought to be changed here? Thanks in advance for replying. exe

Re: how to call java methods in python

2011-10-04 Thread masood shaik
Hi I am trying out my hand on accessing java methods in python. here is my piece of code.. Calculator.java --- public class Calculator { public Calculator(){ } public double calculateTip(double cost, double tipPercentage){ return cost * tipPercentage; }