Re: for loop without variable

2008-01-09 Thread Hrvoje Niksic
Mike Meyer <[EMAIL PROTECTED]> writes: > It sounds to me like your counter variable actually has meaning, It depends how the code is written. In the example such as: for meaningless_variable in xrange(number_of_attempts): ... the loop variable really has no meaning. Rewriting this code on

Re: docstrings style question

2008-01-09 Thread Fredrik Lundh
Steve Brown wrote: > I've got a series of modules which look like this: > > # > # > # Temperature Sense Test > # > # > class Test3(ar_test.AR_TEST): > """Temperature Sense Test""" > > > I don't like the duplicated information: But the comment is attractive, and > th

Re: for loop without variable

2008-01-09 Thread Sam
> Unfortunately, I don't *think* I can shut the > warning for that line or function off, only for the entire file. > Pylint gives you a rating of your quality of code which I think is wrong :) # pylint: disable-msg=X will only impact the current line! $ cat -n dummy.py 1 for i in range(2):

Re: docstrings style question

2008-01-09 Thread Russ P.
On Jan 9, 9:47 pm, "Steve Brown" <[EMAIL PROTECTED]> wrote: > I've got a series of modules which look like this: > > # > # > # Temperature Sense Test > # > # > class Test3(ar_test.AR_TEST): > """Temperature Sense Test""" > > I don't like the duplicated information: But t

Re: Update of Gnuplot.py

2008-01-09 Thread Wayne Brehaut
On Wed, 9 Jan 2008 03:43:38 -0800 (PST), Tom La Bone <[EMAIL PROTECTED]> wrote: > >Can someone suggest where to get a version of Gnuplot.py (for Windows) that >has been updated to use numpy? Or, is there another interface available to >use GnuPlot from Python? > >Thanks. > >Tom Gnuplot 1.7 uses

Re: Tracking colors

2008-01-09 Thread Tim Roberts
[EMAIL PROTECTED] wrote: > >I'm just getting started with Python, and I want to do a bit of color >tracking using VideoCapture. However, I've never worked with video or >images, so I'm a little at a loss. How would I use VideoCapture to >track a specified color, and its coordinates? There's real

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Paddy
On Jan 9, 11:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jan 9, 8:15 am, Paddy <[EMAIL PROTECTED]> wrote: > > > > > On Jan 9, 6:52 am, Paddy <[EMAIL PROTECTED]> wrote: > > > > On Jan 9, 2:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > > wrote: > > > > > Greetings Pythoneers -- >

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Some of us over on edu-sig, one of the community actives, > have been brainstorming around this Rich Data Structures > idea, by which we mean Python data structures already > populated with non-trivial data about various topics such > as: periodic table (proton, neutron

Re: printing dots in simple program while waiting

2008-01-09 Thread Alex VanderWoude
John wrote: > what i want to do is print a 'waiting' statement while a script is > working-- the multithreading aspect isn't an issue, the printing on > the same line is. i want to print something like: > > (1sec) working... > (2sec) working > (3sec) working. > > > where the 'working' l

docstrings style question

2008-01-09 Thread Steve Brown
I've got a series of modules which look like this: # # # Temperature Sense Test # # class Test3(ar_test.AR_TEST): """Temperature Sense Test""" I don't like the duplicated information: But the comment is attractive, and the docstring self.__doc__ is already in use in

Re: for loop without variable

2008-01-09 Thread Mike Meyer
On Wed, 9 Jan 2008 18:49:36 -0800 (PST) erik gartz <[EMAIL PROTECTED]> wrote: > The loop performs some actions with web services. The particular > iteration I'm on isn't important to me. It is only important that I > attempt the web services that number of times. If I succeed I > obviously break ou

Re: Structure of packages

2008-01-09 Thread Scott David Daniels
Ben Fisher wrote: > I am trying to learn the best way to do intra-package references. My > package looks like this: ... > I had thought that "from PackageName.b import *" would work In an attempt to hand oyu a net, rather than an answer: Try using command line: python -v whatever.py You

Re: Converting a bidimensional list in a bidimensional array

2008-01-09 Thread Scott David Daniels
Santiago Romero wrote: >... [I wrote] >>def __init__( self, bw, bh, tiles ): >> self.width, self.height = bw, bh >> self.tilemap = array.array('b', [0]) * bw * bh >> Gives a pure linearization (you do the math for lines). > Do you mean : tilemap[(width*y)+x] ? Yup, exac

Re: for loop without variable

2008-01-09 Thread Ben Finney
erik gartz <[EMAIL PROTECTED]> writes: > The loop performs some actions with web services. The particular > iteration I'm on isn't important to me. It is only important that I > attempt the web services that number of times. If I succeed I > obviously break out of the loop and the containing funct

Re: Pygame w/ GUI

2008-01-09 Thread Carl Banks
On Wed, 09 Jan 2008 18:10:03 -0800, PatrickMinnesota wrote: > I know this isn't strictly a Python question, but I'm betting some here > might be able to give me a hint. > > I have a few graphical programs doing some 2D data visualization using > simple Pygame code for pseudo real-time animation.

Re: for loop without variable

2008-01-09 Thread Carl Banks
On Wed, 09 Jan 2008 14:25:36 -0800, erik gartz wrote: > Hi. I'd like to be able to write a loop such as: for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint and > it complains about the unused variable i. I can achieve the above with > more lines of

Re: ISO books of official Python docs

2008-01-09 Thread Terry Reedy
"Doug Morse" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hi Fredrik, | | I'm terribly confused. You want me to apologize for recommending that someone | buy your books? To apologize for noting that they are a quality reference | sources for Python? As a past and future tech

Re: Pygame w/ GUI

2008-01-09 Thread Adonis Vargas
PatrickMinnesota wrote: > I know this isn't strictly a Python question, but I'm betting some > here might be able to give me a hint. > > I have a few graphical programs doing some 2D data visualization using > simple Pygame code for pseudo real-time animation. It's running > under windows XP rig

Re: for loop without variable

2008-01-09 Thread Basilisk96
On Jan 9, 9:49 pm, erik gartz <[EMAIL PROTECTED]> wrote: > The loop performs some actions with web services. The particular > iteration I'm on isn't important to me. It is only important that I > attempt the web services that number of times. If I succeed I > obviously break out of the loop and the

help with a problem from school??

2008-01-09 Thread Josh
Hello all I did a Google search and found this site and was hoping someone could help me with what I am sure is a simple question that I cannot figure out. Here goes: Given a simple straight through switch (SPST) with a supply of 14V, and the need to simulate its intended load of 1

Re: using super

2008-01-09 Thread Basilisk96
On Jan 1, 12:11 am, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > On Mon, 31 Dec 2007 16:19:11 -0800, Scott David Daniels wrote: > > >> Steven D'Aprano wrote: > >>> On Mon, 31 Dec 2007 08:03:22 -0800, Scott David Daniels wrote: > Steven D'Aprano wrote: ... > >

Re: for loop without variable

2008-01-09 Thread erik gartz
On Jan 9, 8:35 pm, Dan Sommers <[EMAIL PROTECTED]> wrote: > On Wed, 09 Jan 2008 14:25:36 -0800, erik gartz wrote: > > Hi. I'd like to be able to write a loop such as: > > for i in range(10): > > pass > > but without the i variable. The reason for this is I'm using pylint and > > it complains ab

Re: alternating string replace

2008-01-09 Thread bearophileHUGS
Gordon C: > This is very cool stuff but I suspect that the code is unreadable > to many readers, including me. Just for fun here is a complete program, > written in Turbo Pascal, circa 1982, that does the job. Readable > n'est pas? I think it's quite readable, especially if you indent it more cor

Re: using super

2008-01-09 Thread Basilisk96
On Jan 2, iu2 <[EMAIL PROTECTED]> wrote: > I missed new style classes though... Now I know how to use them (not > fully), but I must say it has been difficult. I'll appreciate some > good documentation about them. > > Thanks > iu2 This is a decent start: http://www.python.org/doc/newstyle/ Cheers

Re: Natural-language datetime parsing and display

2008-01-09 Thread Daniel Fetchinson
> > > The OP was looking for presentation though. I know roundup has > > > code for this if an independent library can't be found. > > > > Thanks for all the responses! > > Indeed I was looking for presentation and not parsing, I'll take a > > look at roundup. > > Yes, that's why I indicated that C

Pygame w/ GUI

2008-01-09 Thread PatrickMinnesota
I know this isn't strictly a Python question, but I'm betting some here might be able to give me a hint. I have a few graphical programs doing some 2D data visualization using simple Pygame code for pseudo real-time animation. It's running under windows XP right now, but eventually it'll need to

Re: Python too slow?

2008-01-09 Thread Steven D'Aprano
On Wed, 09 Jan 2008 21:26:05 +0100, Bruno Desthuilliers wrote: > hint: how can a compiler safely optimize anything in a language so > dynamic that even the class of an object can be changed at runtime ? Is that a trick question? By finding things to optimize that *can't* change at runtime. E.g.

Re: Conventions for dummy name (was: for loop without variable)

2008-01-09 Thread MRAB
On Jan 9, 11:17 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > > > The underscore is used as "discarded" identifier. So maybe > > > for _ in xrange(10): > > ... > > The problem with the '_' name is that it is already well-known and > long-used exist

Re: for loop without variable

2008-01-09 Thread Dan Sommers
On Wed, 09 Jan 2008 14:25:36 -0800, erik gartz wrote: > Hi. I'd like to be able to write a loop such as: > for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint and > it complains about the unused variable i ... What does that loop do? (Not the loop

Re: Python too slow?

2008-01-09 Thread Ed Jensen
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > And the reference implementation of Python (CPython) is not > interpreted, it's compiled to byte-code, which is then executed by a VM > (just like Java). Wow, this is pretty misleading. Java is, indeed, compiled to bytecode; however, modern JVMs

Re: alternating string replace

2008-01-09 Thread Gordon C
This is very cool stuff but I suspect that the code is unreadable to many readers, including me. Just for fun here is a complete program, written in Turbo Pascal, circa 1982, that does the job. Readable n'est pas? Program dash; var str: string[80]; n: integer; odd: boolean; begin

Re: Python too slow?

2008-01-09 Thread Mike Meyer
On Wed, 9 Jan 2008 15:45:41 -0800 (PST) "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Okay I profiled the code and here is the output: > > http://heightened.files.wordpress.com/2008/01/output.txt > > It seems that the function it spends the longest on is the red_points > function that he use

Re: for loop without variable

2008-01-09 Thread John Machin
On Jan 10, 10:00 am, Tim Chase <[EMAIL PROTECTED]> wrote: > >> Hi. I'd like to be able to write a loop such as: > >> for i in range(10): > >> pass > >> but without the i variable. The reason for this is I'm using pylint > >> and it complains about the unused variable i. > > > if a computer tell

Re: Learning Python via a little word frequency program

2008-01-09 Thread Paul Hankin
On Jan 9, 12:19 pm, Bruno Desthuilliers wrote: > Andrew Savige a écrit : > > and the -x hack above to > > achieve a descending sort feels a bit odd to me, though I couldn't think > > of a better way to do it. > > The "other" way would be to pass a custom comparison callback to sort, > which would

Re: Learning Python via a little word frequency program

2008-01-09 Thread MRAB
On Jan 9, 12:19 pm, Bruno Desthuilliers wrote: > Andrew Savige a écrit : > > > > > I'm learning Python by reading David Beazley's "Python Essential Reference" > > book and writing a few toy programs. To get a feel for hashes and sorting, > > I set myself this little problem today (not homework, BT

Re: Python too slow?

2008-01-09 Thread [EMAIL PROTECTED]
Okay I profiled the code and here is the output: http://heightened.files.wordpress.com/2008/01/output.txt It seems that the function it spends the longest on is the red_points function that he uses to find the points. -- http://mail.python.org/mailman/listinfo/python-list

Conventions for dummy name (was: for loop without variable)

2008-01-09 Thread Ben Finney
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > The underscore is used as "discarded" identifier. So maybe > > for _ in xrange(10): > ... The problem with the '_' name is that it is already well-known and long-used existing convention for an entirely unrelated purpose: in the 'gettext' i18n

Re: Python too slow?

2008-01-09 Thread [EMAIL PROTECTED]
On 10 jan, 00:02, "[EMAIL PROTECTED]" > (sorry, hit the wrong key - time to bed I guess...) > If none of the two above answers fits your needs, and no Python Guru > comes with a better answer, then I'm afraid you'll have to go for a > language with a faster implementation. Python is quite faster

Python in work/study context (futuristic, fw: from physics list)

2008-01-09 Thread [EMAIL PROTECTED]
This archival (yet recent) posting to an obscure physics list might be of some interest to those taking a longer view. The work/study projects described below come from an Oregon think tank working in private-public partnerships on education policy. I'm one of the principals. Kirby = Dat

Re: Collecting Rich Data Structures for students

2008-01-09 Thread [EMAIL PROTECTED]
On Jan 9, 8:15 am, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 9, 6:52 am, Paddy <[EMAIL PROTECTED]> wrote: > > > > > On Jan 9, 2:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > Greetings Pythoneers -- > > > > Some of us over on edu-sig, one of the community actives, > > > have been

Re: for loop without variable

2008-01-09 Thread Thomas Heller
erik gartz schrieb: > Hi. I'd like to be able to write a loop such as: > for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint > and it complains about the unused variable i. Pychecker won't complain if you rename 'i' to '_', IIRC: for _ in range(10)

Re: Python too slow?

2008-01-09 Thread [EMAIL PROTECTED]
On 9 jan, 21:46, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Thanks for the clarification. > > Though I was hoping someone could give me a definitive answer. Sorry - but I'm definitively not the right person on this... > I was > quite excited about this project initially, but seeing the act

Re: for loop without variable

2008-01-09 Thread Tim Chase
>> Hi. I'd like to be able to write a loop such as: >> for i in range(10): >> pass >> but without the i variable. The reason for this is I'm using pylint >> and it complains about the unused variable i. > > if a computer tells you to do something stupid, it's often better to > find a way to t

Re: for loop without variable

2008-01-09 Thread Diez B. Roggisch
erik gartz schrieb: > Hi. I'd like to be able to write a loop such as: > for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint > and it complains about the unused variable i. I can achieve the above > with more lines of code like: > i = 0 > while (i !=

Re: Another dumb scope question for a closure.

2008-01-09 Thread Waldemar Osuch
On Jan 9, 3:52 pm, Waldemar Osuch <[EMAIL PROTECTED]> wrote: > On Jan 9, 11:47 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > > > > > So sorry because I know I'm doing something wrong. > > > 574 > cat c2.py > > #! /usr/local/bin/python2.4 > > > def inc(jj): > > def dummy(): > > jj =

Re: Natural-language datetime parsing and display

2008-01-09 Thread Ben Finney
"Daniel Fetchinson" <[EMAIL PROTECTED]> writes: > > The OP was looking for presentation though. I know roundup has > > code for this if an independent library can't be found. > > Thanks for all the responses! > Indeed I was looking for presentation and not parsing, I'll take a > look at roundup.

Re: Python too slow?

2008-01-09 Thread Ben Finney
Christian Heimes <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: > > [...] after running the code with the included sample input file, > > it seems quite slow (1-2 seconds from start to finish to do the > > 800 by 600 gif image). > > Have you profiled your application? Do you know the bott

Re: Another dumb scope question for a closure.

2008-01-09 Thread Waldemar Osuch
On Jan 9, 11:47 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > So sorry because I know I'm doing something wrong. > > 574 > cat c2.py > #! /usr/local/bin/python2.4 > > def inc(jj): > def dummy(): > jj = jj + 1 > return jj > return dummy > > h = inc(33) > print 'h() = '

Re: problem of converting a list to dict

2008-01-09 Thread Matt Nordhoff
bsneddon wrote: > This seemed to work for me if you are using 2.4 or greater and > like list comprehension. dict([ tuple(a.split("=")) for a in mylist[1:-1]]) > {'mike': 'manager', 'paul': 'employee', 'tom': 'boss'} > > should be faster than looping That's what he's doing (well, a generator

Re: mysqldb SELECT COUNT reurns 1

2008-01-09 Thread mike
On Dec 27 2007, 5:25 pm, Ian Clark <[EMAIL PROTECTED]> wrote: > On 2007-12-27, SMALLp <[EMAIL PROTECTED]> wrote: > > > connectionString = {"host":"localhost", "user":"root", > > "passwd":"pofuck", "db":"fileshare"} > > dataTable = "files" > > conn = mysql.connect(host=connectionString["host"], > >

Re: for loop without variable

2008-01-09 Thread Fredrik Lundh
erik gartz wrote: > Hi. I'd like to be able to write a loop such as: > for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint > and it complains about the unused variable i. if a computer tells you to do something stupid, it's often better to find a

for loop without variable

2008-01-09 Thread erik gartz
Hi. I'd like to be able to write a loop such as: for i in range(10): pass but without the i variable. The reason for this is I'm using pylint and it complains about the unused variable i. I can achieve the above with more lines of code like: i = 0 while (i != 10): i += 1 Is there a concise

Re: problem of converting a list to dict

2008-01-09 Thread John Machin
On Jan 10, 7:34 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of John Machin > > Sent: Wednesday, January 09, 2008 3:02 PM > > To: [EMAIL PROTECTED] > > Subject: Re: problem of converting a

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Paddy
On Jan 9, 9:39 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Paddy wrote: > > To see how they act against 'corner cases' and > > an exercise for me in trying to create corner cases. (I'm in to > > functional testing at the mo'). > > sounds more like "pulling requirements out of thin air". not sur

Re: getting absolute path ?

2008-01-09 Thread kyosohma
On Jan 9, 3:22 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I'm trying to convert the links in html pages to absolute links, > these pages can either be webpages or files on local harddisk (winXP). > Now I've struggling for a while, and this code works a lilttle: > > i = line.find

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Paddy
On Jan 9, 9:29 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 9, 8:56 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > Donald 'Paddy' McCarthy wrote: > > > I created some more test strings and ran posters solutions against them. > > > the point being? > > > > > To see how they act against 'corner

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Fredrik Lundh
Paddy wrote: > To see how they act against 'corner cases' and > an exercise for me in trying to create corner cases. (I'm in to > functional testing at the mo'). sounds more like "pulling requirements out of thin air". not sure that helps the OP get a better understanding of Python, really.

getting absolute path ?

2008-01-09 Thread Stef Mientki
hello, I'm trying to convert the links in html pages to absolute links, these pages can either be webpages or files on local harddisk (winXP). Now I've struggling for a while, and this code works a lilttle: i = line.find ( 'href=' ) if i < 0 : i = line.find ( ' src='

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Paddy
On Jan 9, 8:56 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Donald 'Paddy' McCarthy wrote: > > I created some more test strings and ran posters solutions against them. > > the point being? > > To see how they act against 'corner cases' and an exercise for me in trying to create corner cases. (I

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Paddy
On Jan 9, 8:47 pm, [EMAIL PROTECTED] wrote: > Donald 'Paddy' McCarthy: > > [... lots and lots and lots of tests...] > > C'mon Paddy, where are the timings too? Are you becoming lazy > lately? ;-) > > Bear bugs, > bearophile Get it right before you get it fast. But what is 'right'. -- http://mail.

Re: ISO books of official Python docs

2008-01-09 Thread Fredrik Lundh
Doug Morse wrote: > I'm terribly confused. You want me to apologize for recommending that someone > buy your books? To apologize for noting that they are a quality reference > sources for Python? for implying that the material in them is copied from the python.org handbooks. at least that's w

Re: Python too slow?

2008-01-09 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > I'm pretty new to Python, and even newer to Image/Video processing, > and trying to get started on a project similar to GRL Vienna's laser > marker. I found some sample code here > http://janto.blogspot.com/2006/01/motion-capture-in-python.html, > but after running the c

Re: ISO books of official Python docs

2008-01-09 Thread Doug Morse
Hi Fredrik, I'm terribly confused. You want me to apologize for recommending that someone buy your books? To apologize for noting that they are a quality reference sources for Python? Doug On Wed, 09 Jan 2008 21:59:34 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Doug Morse wrote: > > >

Re: Natural-language datetime parsing and display (was: user friendly datetime features)

2008-01-09 Thread Daniel Fetchinson
> For PARSING see http://code-bear.com/code/parsedatetime/ > > The OP was looking for presentation though. I know roundup has code for > this if an independent library can't be found. Thanks for all the responses! Indeed I was looking for presentation and not parsing, I'll take a look at roundup

Re: problem of converting a list to dict

2008-01-09 Thread Mike Meyer
On Wed, 9 Jan 2008 14:34:26 -0600 "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of John Machin > > Sent: Wednesday, January 09, 2008 3:02 PM > > To: python-list@python.org > > Subject: Re: pro

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Fredrik Lundh
Donald 'Paddy' McCarthy wrote: > I created some more test strings and ran posters solutions against them. the point being? -- http://mail.python.org/mailman/listinfo/python-list

Re: ISO books of official Python docs

2008-01-09 Thread Fredrik Lundh
Doug Morse wrote: > Several of the O'Reilly & Assoc. books -- such as Python in a Nutshell, The > Python Standard Library, etc -- are in large part reproductions of the > official docs and references. if you're using "reproduction" to mean "copy", I think you owe both me and Alex a big apology.

Re: Structure of packages

2008-01-09 Thread Raymond Hettinger
[Ben Fisher] > I am trying to learn the best way to do intra-package references. IMO, the email package is a stellar example of best practices using packages. > I have layered the dependencies so that a depends on b, >b depends on c, and c depends on d. For the most part, I think packages tend

Re: Another dumb scope question for a closure.

2008-01-09 Thread Fredrik Lundh
Ben Fisher wrote: > One way to get this to work is: > > def inc(jj): > def dummy(jj = jj): > jj = jj + 1 > return jj > return dummy > > h = inc(33) > print h() > > It's not very pretty though, especially when you have many variables > you want to have in

Re: Another dumb scope question for a closure.

2008-01-09 Thread Arnaud Delobelle
On Jan 9, 8:24 pm, Mike Meyer <[EMAIL PROTECTED]> wrote: > On Wed, 9 Jan 2008 13:47:30 -0500 (EST) "Steven W. Orr" <[EMAIL PROTECTED]> > wrote: > > > > > So sorry because I know I'm doing something wrong. > > > 574 > cat c2.py > > #! /usr/local/bin/python2.4 > > > def inc(jj): > >      def dummy()

Re: ISO books of official Python docs

2008-01-09 Thread Doug Morse
Several of the O'Reilly & Assoc. books -- such as Python in a Nutshell, The Python Standard Library, etc -- are in large part reproductions of the official docs and references. So, while not exactly what you asked for, the ORA books might be a viable alternative if what you want isn't available.

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread bearophileHUGS
Donald 'Paddy' McCarthy: [... lots and lots and lots of tests...] C'mon Paddy, where are the timings too? Are you becoming lazy lately? ;-) Bear bugs, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Python too slow?

2008-01-09 Thread [EMAIL PROTECTED]
Thanks for the clarification. Though I was hoping someone could give me a definitive answer. I was quite excited about this project initially, but seeing the actual execute times was a big downer. Seeing that the original laser marker by GRL Vienna is done in Processing which from what I know is

Re: ISO books of official Python docs

2008-01-09 Thread gordyt
Howdy kynnjo, > Is it possible to buy the official Python docs in book form? If > so, I'd very much appreciate the name(s) and author(s) of the > book(s). I haven't seen them in print form, but you can download PDF's from here: http://docs.python.org/download.html --gordy -- http://mail.pytho

Re: Another dumb scope question for a closure.

2008-01-09 Thread Ben Fisher
One way to get this to work is: def inc(jj): def dummy(jj = jj): jj = jj + 1 return jj return dummy h = inc(33) print h() It's not very pretty though, especially when you have many variables you want to have in the inner scope. -Ben On 1/9/08, Mi

Re: Structure of packages

2008-01-09 Thread Jean-Paul Calderone
On Wed, 9 Jan 2008 15:07:16 -0500, Ben Fisher <[EMAIL PROTECTED]> wrote: >I am trying to learn the best way to do intra-package references. My >package looks like this: > >PackageName >__init__.py >/a >__init__.py > a.py >... >/b >__init__.py >... >

Re: alternating string replace

2008-01-09 Thread Paul McGuire
On Jan 9, 7:41 am, "Neil Cerutti" <[EMAIL PROTECTED]> wrote: > On Jan 9, 2008 5:34 AM, cesco <[EMAIL PROTECTED]> wrote: > > > Hi, > > > say I have a string like the following: > > s1 = 'hi_cat_bye_dog' > > and I want to replace the even '_' with ':' and the odd '_' with ',' > > so that I get a new

RE: problem of converting a list to dict

2008-01-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of John Machin > Sent: Wednesday, January 09, 2008 3:02 PM > To: python-list@python.org > Subject: Re: problem of converting a list to dict > > On Jan 10, 6:52 am, "Reedick, Andrew" <[EMAIL PROTECT

Re: Another dumb scope question for a closure.

2008-01-09 Thread Mike Meyer
On Wed, 9 Jan 2008 13:47:30 -0500 (EST) "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > So sorry because I know I'm doing something wrong. > > 574 > cat c2.py > #! /usr/local/bin/python2.4 > > def inc(jj): > def dummy(): > jj = jj + 1 > return jj > return dummy > > h =

Re: problem of converting a list to dict

2008-01-09 Thread bsneddon
On Jan 9, 3:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > > I'd like to remove the first and the last item as they are irrevalent, > > and convert it to the dict: > > {'tom':'boss','mike':'manager','paul':'employee'} > > > I

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Donald 'Paddy' McCarthy
cesco wrote: I created some more test strings and ran posters solutions against them. results attached. - Paddy. # alternating_replacements.py tests = " 1 2_ 3_4 5_6_ 7_8_9 10_11_12_ 13_14_15_16 17_18_19_20_" \ " _ _21 _22_ _23_24 _25_26_ _27_28_29 _30_31_32_ _33_34_35_36" \ " __ _

Re: problem of converting a list to dict

2008-01-09 Thread John Machin
On Jan 10, 7:12 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > > I'd like to remove the first and the last item as they are irrevalent, > > and convert it to the dict: > > {'tom':'boss','mike':'manager','paul':'employee'} > > > I

Re: Python too slow?

2008-01-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I'm pretty new to Python, and even newer to Image/Video processing, > and trying to get started on a project similar to GRL Vienna's laser > marker. I found some sample code here > http://janto.blogspot.com/2006/01/motion-capture-in-python.html, > but after running th

Re: executing newgrp from python in current shell possible?

2008-01-09 Thread Zentrader
On Jan 9, 5:56 am, Svenn Are Bjerkem <[EMAIL PROTECTED]> wrote: >I have been looking for a way to execute this command > as a part of a script, but it seems that the changes are only valid in > the context of the script and when the script exits, the current shell > still have the original "users"

Re: problem of converting a list to dict

2008-01-09 Thread Tim Chase
> mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > I'd like to remove the first and the last item as they are irrevalent, > and convert it to the dict: > {'tom':'boss','mike':'manager','paul':'employee'} > > I tried this but it didn't work: > > mydict={} > for i in mylist[

Re: "Canonical" way of deleting elements from lists

2008-01-09 Thread Robert Latest
Sion Arrowsmith wrote: > Robert Latest <[EMAIL PROTECTED]> wrote: >> BTW, where can I find all methods of the built-in types? >>Section 3.6 only talks about strings and mentions the list append() method >>only in an example. Am I too stupid to read the manual, or is this an >>omission? > > 3.6

Structure of packages

2008-01-09 Thread Ben Fisher
I am trying to learn the best way to do intra-package references. My package looks like this: PackageName __init__.py /a __init__.py a.py ... /b __init__.py ... /c __init__.py ... /d __init__.py ... I have l

Re: How does unicode() work?

2008-01-09 Thread Robert Latest
John Machin wrote: > When mixing unicode strings with byte strings, Python attempts to > decode the str object to unicode, not encode the unicode object to > str. Thanks for the explanation. Of course I didn't want to mix Unicode and Latin in one string, my snippet just tried to illustrate the p

Re: problem of converting a list to dict

2008-01-09 Thread John Machin
On Jan 10, 6:52 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Fredrik Lundh > > Sent: Wednesday, January 09, 2008 2:39 PM > > To: [EMAIL PROTECTED] > > Subject: Re: problem of converting

Re: problem of converting a list to dict

2008-01-09 Thread Louis . Soninhu
oops, it seems there are other 'meaningless' item, which actually caused the problem Thanks for helps -- http://mail.python.org/mailman/listinfo/python-list

ISO books of official Python docs

2008-01-09 Thread kj
Is it possible to buy the official Python docs in book form? If so, I'd very much appreciate the name(s) and author(s) of the book(s). TIA! kynnjo -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- ht

Re: Converting a bidimensional list in a bidimensional array

2008-01-09 Thread bearophileHUGS
Santiago Romero: > - Speed Performance: Do you think that changing from list to Array() > would improve speed? I'm going to do lots of tilemap[y][x] checks (I > mean, player jumping around the screen, checking if it's falling over > a non-zero tile, and so). First of all: if you have enough memory

Re: printing dots in simple program while waiting

2008-01-09 Thread John Machin
On Jan 10, 6:30 am, John <[EMAIL PROTECTED]> wrote: > On Jan 9, 12:14 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > > > > > -Original Message- > > > From: [EMAIL PROTECTED] [mailto:python- > > > [EMAIL PROTECTED] On Behalf Of Martin Marcher > > > Sent: Wednesday, January 09, 2008 11:

RE: problem of converting a list to dict

2008-01-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Fredrik Lundh > Sent: Wednesday, January 09, 2008 2:39 PM > To: python-list@python.org > Subject: Re: problem of converting a list to dict > > [EMAIL PROTECTED] wrote: > > >> to see what's goin

Re: problem of converting a list to dict

2008-01-09 Thread John Machin
On Jan 10, 5:56 am, [EMAIL PROTECTED] wrote: > Hi pals > > I have a list like this > > mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > I'd like to remove the first and the last item as they are irrevalent, > and convert it to the dict: > {'tom':'boss','mike':'manager','paul'

Re: problem of converting a list to dict

2008-01-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: >> to see what's going on on your machine, try printing "a" after the >> split, but before you use it to populate the dictionary. > > 'print a' works so what does it tell you? -- http://mail.python.org/mailman/listinfo/python-list

Re: printing dots in simple program while waiting

2008-01-09 Thread John
On Jan 9, 12:14 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Martin Marcher > > Sent: Wednesday, January 09, 2008 11:57 AM > > To: [EMAIL PROTECTED] > > Subject: Re: printing dots in si

Re: problem of converting a list to dict

2008-01-09 Thread Louis . Soninhu
On Jan 9, 3:05 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I have a list like this > > > mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > > I'd like to remove the first and the last item as they are irrevalent, > > and convert it to the dict: >

Re: problem of converting a list to dict

2008-01-09 Thread Louis . Soninhu
that's very strange... the list I give here is almost same as the real list, except for the length. Thanks Marc, I'll go check what's wrong elsewhere -- http://mail.python.org/mailman/listinfo/python-list

Python too slow?

2008-01-09 Thread [EMAIL PROTECTED]
I'm pretty new to Python, and even newer to Image/Video processing, and trying to get started on a project similar to GRL Vienna's laser marker. I found some sample code here http://janto.blogspot.com/2006/01/motion-capture-in-python.html, but after running the code with the included sample input

  1   2   3   >