Re: Exception Handling in Python 3

2010-10-23 Thread Lawrence D'Oliveiro
In message , Steve Holden wrote: > I was somewhat surprised to discover that Python 3 no longer allows an > exception to be raised in an except clause (or rather that it reports it > as a separate exception that occurred during the handling of the first). So what exactly is the problem? Exceptio

Re: Exception Handling in Python 3

2010-10-23 Thread Steve Holden
On 10/24/2010 1:26 AM, Chris Rebert wrote: >> I was somewhat surprised to discover that Python 3 no longer allows an >> > exception to be raised in an except clause (or rather that it reports it >> > as a separate exception that occurred during the handling of the first). > [snip] >> > What >> > i

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Ned Deily
In article , Steve Howe wrote: > The whole point is, is not supposed to be a set; a set literal would > end with "})". As you can see, there is no such construct in the > string. > It's just a dict inside parentheses. Somehow, the parser seems to > think it's a set. >>> type({'', 1}) >>> type(

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Steve Holden
Geremy and the parser are correct - it *is* a set. It would only be a dict if you changed the comma to a colon. regards Steve On 10/24/2010 1:31 AM, Steve Howe wrote: > Hello Geremy, > > The whole point is, is not supposed to be a set; a set literal would > end with "})". As you can see, there

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Steve Howe
Ok, forget, I found the problem: bad sleeping. Thanks. -- Howe howest...@gmail.com On Sun, Oct 24, 2010 at 3:31 AM, Steve Howe wrote: > Hello Geremy, > > The whole point is, is not supposed to be a set; a set literal would > end with "})". As you can see, there is no such construct in the > st

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Steve Howe
Hello Geremy, The whole point is, is not supposed to be a set; a set literal would end with "})". As you can see, there is no such construct in the string. It's just a dict inside parentheses. Somehow, the parser seems to think it's a set. -- Howe howest...@gmail.com On Sun, Oct 24, 2010 at 2:

Re: Exception Handling in Python 3

2010-10-23 Thread Chris Rebert
On Sat, Oct 23, 2010 at 10:01 PM, Steve Holden wrote: > I was somewhat surprised to discover that Python 3 no longer allows an > exception to be raised in an except clause (or rather that it reports it > as a separate exception that occurred during the handling of the first). > Give the traceback

Re: numpad in idle

2010-10-23 Thread Alex
thanks, but this doesn't solve the problem, because I need to use the numpad as a cursor, not to enter numbers. cheers, Alex On 24 окт, 16:44, rantingrick wrote: > On Oct 23, 7:41 pm, Jah_Alarm wrote: > > > here's my problem: I'm running IDLE in Ubuntu. For some reason numpad > > buttons do no

Exception Handling in Python 3

2010-10-23 Thread Steve Holden
I was somewhat surprised to discover that Python 3 no longer allows an exception to be raised in an except clause (or rather that it reports it as a separate exception that occurred during the handling of the first). So the following code: >>> d = {} >>> try: ... val = d['nosuch'] ... except:

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread geremy condra
On Sat, Oct 23, 2010 at 9:40 PM, Steve Howe wrote: > Hello, > > This looks like a parser bug, but it's so basic I'm in doubt. Can > anyone confirm ? > import sys sys.version > '2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) \n[GCC 4.4.5]' ({'', 1}.items()) > Traceback (most recent call l

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Jerry Hill
On Sun, Oct 24, 2010 at 12:40 AM, Steve Howe wrote: > Hello, > > This looks like a parser bug, but it's so basic I'm in doubt. Can > anyone confirm ? > import sys sys.version > '2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) \n[GCC 4.4.5]' ({'', 1}.items()) > Traceback (most recent call

Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Steve Howe
Hello, This looks like a parser bug, but it's so basic I'm in doubt. Can anyone confirm ? >>> import sys >>> sys.version '2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) \n[GCC 4.4.5]' >>> ({'', 1}.items()) Traceback (most recent call last): File "", line 1, in AttributeError: 'set' object has no at

Get 899$ To Your PAYPAL Account ( There is a FORM )

2010-10-23 Thread baptist
CLICK on the IMAGE below the SEARCH BOX for the FORMhttp://moneymaking.en.st -- http://mail.python.org/mailman/listinfo/python-list

Re: numpad in idle

2010-10-23 Thread Aram Ter-Sarkissov
On 24 окт, 16:44, rantingrick wrote: > On Oct 23, 7:41 pm, Jah_Alarm wrote: > > > here's my problem: I'm running IDLE in Ubuntu. For some reason numpad > > buttons do not work. I'm kinda used to this layout. Doesn anyone have > > an idea on how to switch it on? > > Sure, look directly above the n

Re: A good decorator library

2010-10-23 Thread Tim Roberts
Felipe Bastos Nunes wrote: > >Hi! I was looking for a good decorator library to study and make my >own decorators. I've read the Bruce Eckel's blog at artima dot com. >But I need some more examples. I'm building a WSN simulator like SHOX >is in java, but programming it in python. I'd like to use d

Re: pythagorean triples exercise

2010-10-23 Thread Tim Roberts
Baba wrote: > >i need a hint regarding the following exercise question: > >"Write a program that generates all Pythagorean triples whose small >sides are no larger than n. >Try it with n <= 200." > >what is "n" ? i am guessing that it is a way to give a bound to the >triples to be returned but i c

Re: numpad in idle

2010-10-23 Thread rantingrick
On Oct 23, 7:41 pm, Jah_Alarm wrote: > here's my problem: I'm running IDLE in Ubuntu. For some reason numpad > buttons do not work. I'm kinda used to this layout. Doesn anyone have > an idea on how to switch it on? Sure, look directly above the number pad and you will see a button labeled "NumLoc

Re: A Unique XML Parsing Problem

2010-10-23 Thread Lawrence D'Oliveiro
In message <0af3e9b1-8d3d-4efd-99d6-ca033204e...@n26g2000yqh.googlegroups.com>, Devon wrote: > I have heard about Beautiful Soup but never used it. BeautifulSoup is intended for HTML parsing. It is, or was, particularly good at dealing with badly-formed HTML, as commonly found on lots of websit

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-23 Thread Lawrence D'Oliveiro
In message , Dave Angel wrote: > Presumably the original pythonw.exe was called that because it's marked > as a windows-app. In win-speak, that means it has a gui. Applications > that are not so-marked are console-apps, and get a console created if > they weren't already started from one. That's w

numpad in idle

2010-10-23 Thread Jah_Alarm
hi, here's my problem: I'm running IDLE in Ubuntu. For some reason numpad buttons do not work. I'm kinda used to this layout. Doesn anyone have an idea on how to switch it on? cheers, Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: OO and game design questions

2010-10-23 Thread Gregory Ewing
Jonathan Hartley wrote: One common way to store delayed actions is as a lambda (an anonymous function.) Although note that you don't have to use 'lambda' in particular -- functions defined with 'def' can be used the same way. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: A Unique XML Parsing Problem

2010-10-23 Thread Chris Rebert
On Sat, Oct 23, 2010 at 4:40 PM, Devon wrote: > I must quickly and efficiently parse some data contained in multiple > XML files in order to perform some learning algorithms on the data. > Info: > > I have thousands of files, each file corresponds to a single song. > Each XML file contains informa

A Unique XML Parsing Problem

2010-10-23 Thread Devon
I must quickly and efficiently parse some data contained in multiple XML files in order to perform some learning algorithms on the data. Info: I have thousands of files, each file corresponds to a single song. Each XML file contains information extracted from the song (called features). Examples i

Background image with Tkinter

2010-10-23 Thread Emeka
Hello All, I know this is pretty easy to do, but I was not able to to do it because I am new to GUI and Python. I am using grid to manager my layout and I would like to add background image to one of my cells (say row=1 column=3), I intend to have a label (text ) written on top of the image. For

Re: A question I have...

2010-10-23 Thread Chris Rebert
On Thu, Oct 21, 2010 at 7:25 PM, Joe Shoulak wrote: > I'm trying to make a sports simulation program and so far everything has > worked until I try entering: > > Score1 = (Team1Off + Team2Def)/2 > > I get the error: > > TypeError: unsupported operand type(s) for /: 'str' and 'int' > > Can someone

Re: A question I have...

2010-10-23 Thread Vlastimil Brom
2010/10/22 Joe Shoulak : > I'm trying to make a sports simulation program and so far everything has > worked until I try entering: > > Score1 = (Team1Off + Team2Def)/2 > > I get the error: > > TypeError: unsupported operand type(s) for /: 'str' and 'int' > > Can someone please explain to me what th

Re: A question I have...

2010-10-23 Thread geremy condra
On Thu, Oct 21, 2010 at 7:25 PM, Joe Shoulak wrote: > I'm trying to make a sports simulation program and so far everything has > worked until I try entering: > > Score1 = (Team1Off + Team2Def)/2 > > I get the error: > > TypeError: unsupported operand type(s) for /: 'str' and 'int' > > Can someone

Re: yield all entries of an iterable

2010-10-23 Thread Chris Rebert
On Wed, Oct 20, 2010 at 3:27 PM, Sebastian wrote: > Hi, > Is there a simpler way to yield all elements of a sequence than this? > for x in xs: >    yield x Not presently. There's a related PEP under discussion though: PEP 380: Syntax for Delegating to a Subgenerator http://www.python.org/dev/peps

Re: inline for and if

2010-10-23 Thread Chris Rebert
On Wed, Oct 20, 2010 at 11:28 AM, Guy Doune wrote: > Hello, > I would get : > db.table.field1, db.table.field2, etc. > Inside a python instruction : > db().select(HERE) > It is web2py query actually. > > But I can't do this : > db().select( > for f in db['table'].fields: >     if f not in fieldsBl

A question I have...

2010-10-23 Thread Joe Shoulak
I'm trying to make a sports simulation program and so far everything has worked until I try entering: Score1 = (Team1Off + Team2Def)/2 I get the error: TypeError: unsupported operand type(s) for /: 'str' and 'int' Can someone please explain to me what this means, why it doesn't work and what

Perforce integrate using p4 module

2010-10-23 Thread Eric_NYRelEng
Does anyone have any example with perforce integrate command? Please help —Code Snippet— import P4 ##set p4.port, p4.client p4c = P4.P4() p4c.connect() view = “//depot/meta/project/frombranch/...//depot/meta/project/ tobranch/..." p4c.run(“integ –n”,view) —Getting— return P4API.P4Adapter.run(

yield all entries of an iterable

2010-10-23 Thread Sebastian
Hi, Is there a simpler way to yield all elements of a sequence than this? for x in xs: yield x I tried googling but fond only the other direction (turning a generator into a list with "list(my_generator())". Sebastian -- http://mail.python.org/mailman/listinfo/python-list

inline for and if

2010-10-23 Thread Guy Doune
Hello, I would get : db.table.field1, db.table.field2, etc. Inside a python instruction : db().select(HERE) It is web2py query actually. But I can't do this : db().select(for f in db['table'].fields:    if f not in fieldsBlackList:         db['table'][f],) Any idea? -- http://mail.python.

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread Arnaud Delobelle
Emile van Sebille writes: > On 10/23/2010 11:51 AM Arnaud Delobelle said... >> >> Can you change the value of a.x? >> >> (Hint: my shortest solution is of the form A.*.*[*].*[*].x = 3) > > A.x,a.x = a.x,3 I knew that was going to come next! That'll teach me not to specify the problem precisely

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread Emile van Sebille
On 10/23/2010 11:51 AM Arnaud Delobelle said... Can you change the value of a.x? (Hint: my shortest solution is of the form A.*.*[*].*[*].x = 3) A.x,a.x = a.x,3 -- http://mail.python.org/mailman/listinfo/python-list

Re: pythagorean triples exercise

2010-10-23 Thread Terry Reedy
On 10/23/2010 3:34 AM, Lawrence D'Oliveiro wrote: In message<8idui6f21...@mid.individual.net>, Peter Pearson wrote: Is it important to let "a" range all the way up to b, instead of stopping at b-1? (tongue in cheek) Makes no difference. :) The difference is that before one writes the restri

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread Arnaud Delobelle
Emile van Sebille writes: > On 10/23/2010 11:51 AM Arnaud Delobelle said... >> >> Just to challenge you a bit, here is another (doomed) attempt at having >> private attributes for object instances: [...] > I'm obviously missing something: > > ActivePython 2.6.1.1 (ActiveState Software Inc.) based

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread Emile van Sebille
On 10/23/2010 11:51 AM Arnaud Delobelle said... Just to challenge you a bit, here is another (doomed) attempt at having private attributes for object instances: def private_maker(): class Private: pass privmap = {} def private(f): def wrapper(self, *args, **kwargs):

TRANSFER 300$ To Your EFT Account By Just ONE CLICK From OTHER Account

2010-10-23 Thread hollywood
The FORM is in the IMAGE below the SEARCH BOX...CLICK on the IMAGE for the FORM of TRANSFERhttp://moneymaking.en.st -- http://mail.python.org/mailman/listinfo/python-list

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread Arnaud Delobelle
dmytro starosud writes: > > I think I'm being realized that Python allows to do everything. > Maybe I will not try to find "really hidden encapsulation". :) I think it's a wise decision :) Just to challenge you a bit, here is another (doomed) attempt at having private attributes for object inst

Re: Request for comments on a design

2010-10-23 Thread TomF
On 2010-10-23 01:50:53 -0700, Peter Otten said: TomF wrote: I have a program that manipulates lots of very large indices, which I implement as bit vectors (via the bitarray module). These are too large to keep all of them in memory so I have to come up with a way to cache and load them from

Re: 64 bit offsets?

2010-10-23 Thread Martin v. Loewis
Am 07.10.2010 23:20, schrieb MRAB: > On 07/10/2010 20:12, jay thompson wrote: >> I'm not sure if it is limited to 32 bit addresses or if it's only >> re.start() that is limited to 'em. >> >> jt >> > From what I can tell, Microsoft compilers (I'm assuming you're using > Windows) have a 32-bit 'int'

ANNOUNCE: PYBAG v0.4.0

2010-10-23 Thread Aleksey
This is first PYBAG announce on comp.lang.python. PYBAG implements a portable bag and is intended for fast synchronization and backup. It lets you use a portable digital storage device to carry your electronic documents similar to the way you can use a bag to carry paper documents. You can synchro

Re: How to make a method into a property without using the @property decorator

2010-10-23 Thread Phlip
On Oct 23, 8:01 am, Peter Otten <__pete...@web.de> wrote: > You may be better off with __getattr__(). Ayup, thanks. (Maybe I should have googled for "python equivalent of ruby method_missing", hmm?;) -- http://mail.python.org/mailman/listinfo/python-list

Re: measuring python code efficiency

2010-10-23 Thread n.a.s
Thanks Felipe , sure i will search for that.. Bests, n.a.s On Sat, Oct 23, 2010 at 7:11 PM, Felipe Bastos Nunes < felipe.bast...@gmail.com> wrote: > Theres the time module and the timeit() function to evaluate time to > execute. For memory usage and cpu usage i can't remember exactly. I > read t

MATLAB:matplotlib::Mathematica::???

2010-10-23 Thread kj
Is there anything that does for Mathematica what matplotlib does for MATLAB? matplotlib, even in its underlying so-called "OO mode", follows MATLAB's graphics model, which, in my very subjective opinion, is vastly inferior to Mathematica's. The latter allows for a clean separation between the t

Re: pywebkit - python bindings for webkit DOM (alpha)

2010-10-23 Thread deostroll
Okay found the instruction to build the project on the site http://www.gnu.org/software/pythonwebkit/ Not sure how to apply the patch. I already have an installation of pythonwebkit. Should I uninstall it, download the source from http://code.google.com/p/pywebkitgtk and then apply the patch. I'v

Re: measuring python code efficiency

2010-10-23 Thread Felipe Bastos Nunes
Theres the time module and the timeit() function to evaluate time to execute. For memory usage and cpu usage i can't remember exactly. I read the profile and cprofile documentation, and, in my opinion, help in somethings you wanna do. 2010/10/23, n.a.s : > Hi all, > I use to program in many langua

Re: ftplib - Did the whole file get sent?

2010-10-23 Thread Sean DiZazzo
On Oct 22, 10:48 pm, Steven D'Aprano wrote: > On Fri, 22 Oct 2010 22:03:38 -0700, Sean DiZazzo wrote: > > How can I assure him (and the client) that the transfer completed > > successfully like my log shows? > > "It has worked well for many years, there are no reported bugs in the ftp > code > [..

Re: "Strong typing vs. strong testing" [OT]

2010-10-23 Thread Mark Wooding
Steven D'Aprano writes: > Well, what is the definition of pi? Is it: > > the ratio of the circumference of a circle to twice its radius; > the ratio of the area of a circle to the square of its radius; > 4*arctan(1); > the complex logarithm of -1 divided by the negative of the complex square > r

Re: IDLE debugger questions

2010-10-23 Thread Roger Davis
Thanks for that info, Ned, I can now get the sys.argv[] list I need, that's a big help! However, is there any other way to set a breakpoint in idle that will work on Mac OS X, maybe entering a manual command somewhere with a specified line number? Inability to set a breakpoint is an absolute showst

measuring python code efficiency

2010-10-23 Thread n.a.s
Hi all, I use to program in many languages ,currently i 'm working in python ,i wonder if their is any way-program to measure my code , for example memory usage , cpu speed - because of the ability to write one program in many ways , how i can evaluate my code? Many thanks, n.a.s -- http://mail.p

Re: mro() or __mro__?

2010-10-23 Thread Peter Otten
Hrvoje Niksic wrote: > The documentation of the mro() method on the class object says: > > class.mro() > This method can be overridden by a metaclass to customize the method > resolution order for its instances. It is called at class > instantiation, and its result is stored in __mro_

==Get an Internship in the United States ==

2010-10-23 Thread neha shena
==Get an Internship in the United States == Internships are practical experiences that bridge the gap between the educational world and the real world allowing students to understand what is really like to work in the industry of their choice. International internships offer much more than the usu

Re: How to make a method into a property without using the @property decorator

2010-10-23 Thread Peter Otten
Phlip wrote: > Pythonistas: > > Here's the property decorator: > >@property >def foo(self): return 'bar' > > If I generate foo dynamically, how to I make it a property? > > setattr(self, 'foo', property(lambda: 'bar')) > > Variations of that are apparently not working. You have to

How to make a method into a property without using the @property decorator

2010-10-23 Thread Phlip
Pythonistas: Here's the property decorator: @property def foo(self): return 'bar' If I generate foo dynamically, how to I make it a property? setattr(self, 'foo', property(lambda: 'bar')) Variations of that are apparently not working. (I'm heading for a proxy pattern, where if you ne

Re: A good decorator library

2010-10-23 Thread Michele Simionato
On Oct 22, 10:42 pm, Felipe Bastos Nunes wrote: > Hi! I was looking for a good decorator library to study and make my > own decorators. I've read the Bruce Eckel's blog at artima dot com. > But I need some more examples. I'm building a WSN simulator like SHOX > is in java, but programming it in py

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-23 Thread Dave Angel
On 2:59 PM, Lawrence D'Oliveiro wrote: In message, Tim Golden wrote: If you were to rename the .py to a .pyw it would run without a console window showing up. Presumably the “w” stands for “window”. Wouldn’t it be less confusing if it was the other way round? Presumably the original pythonw

ANN: Shed Skin 0.6

2010-10-23 Thread Mark Dufour
Hi all, I have just released Shed Skin 0.6, an optimizing (restricted-)Python-to-C++ compiler. Most importantly, this release comes with a substantial scalability improvement. It should now be possible to compile programs into several thousands of lines, as shown by the new Commodore 64 emulator e

mro() or __mro__?

2010-10-23 Thread Hrvoje Niksic
The documentation of the mro() method on the class object says: class.mro() This method can be overridden by a metaclass to customize the method resolution order for its instances. It is called at class instantiation, and its result is stored in __mro__. Am I interpreting it correctly

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-23 Thread Lawrence D'Oliveiro
In message , Chris Rebert wrote: > On Sat, Oct 23, 2010 at 12:32 AM, Lawrence D'Oliveiro > wrote: > >> In message , Tim >> Golden wrote: >> >>> If you were to rename the .py to a .pyw it would run without a console >>> window showing up. >> >> Presumably the “w” stands for “window”. > > Why not

Re: Has Next in Python Iterators

2010-10-23 Thread Alexander Gattin
Hello, On Thu, Oct 21, 2010 at 12:26:50PM +, Steven D'Aprano wrote: > I know what you're thinking: "it's easy to cache > the next result, and return it on the next > call". But iterators can also be dependent on > the time that they are called, like in this > example: > > def evening_time():

Re: Python has a "really hidden encapsulation"?

2010-10-23 Thread dmytro starosud
:-0 very interesting! I've tried to run something like this: . class en_property(property): ptr_pget = None ptr_pset = None def pset(self, _class, value): if (self.ptr_pset is None or type(value) == tuple):

Re: Request for comments on a design

2010-10-23 Thread Peter Otten
TomF wrote: > I have a program that manipulates lots of very large indices, which I > implement as bit vectors (via the bitarray module). These are too > large to keep all of them in memory so I have to come up with a way to > cache and load them from disk as necessary. I've been reading about

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-23 Thread Chris Rebert
On Sat, Oct 23, 2010 at 12:32 AM, Lawrence D'Oliveiro wrote: > In message , Tim Golden > wrote: > >> If you were to rename the .py to a .pyw it would run without a console >> window showing up. > > Presumably the “w” stands for “window”. Why not "windowless"? - Chris -- http://mail.python.org/m

Re: pythagorean triples exercise

2010-10-23 Thread Lawrence D'Oliveiro
In message <8idui6f21...@mid.individual.net>, Peter Pearson wrote: > Is it important to let "a" range all the way up to b, instead of > stopping at b-1? (tongue in cheek) Makes no difference. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-23 Thread Lawrence D'Oliveiro
In message , Tim Golden wrote: > If you were to rename the .py to a .pyw it would run without a console > window showing up. Presumably the “w” stands for “window”. Wouldn’t it be less confusing if it was the other way round? -- http://mail.python.org/mailman/listinfo/python-list