Python Ireland Pub Meetup - Wed, 13th Jan, 2010 @ Trinity Capital Hotel

2010-01-11 Thread Vicky Lee
Hi All, Hope everyone had a nice break? Here's to the new year and our first Python Ireland meetup of the year! When: Wed, 13th Jan, 2010 @ 19:00 Where: Trinity Capital Hotel, Pearse St., D2 More details:- http://www.python.ie/meetup/2010/pub_meetup__trinity_capital_hotel_-_wed_13th_jan/

Re: integer and string compare, is that correct?

2010-01-11 Thread Marco Salden
On Jan 10, 1:26 pm, Hellmut Weber m...@hellmutweber.de wrote: Hi, being a causal python user (who likes the language quite a lot) it took me a while to realize the following: l...@sylvester py_count $ python Python 2.6.3 (r263:75183, Oct 26 2009, 12:34:23) [GCC 4.4.1] on linux2 Type help,

Re: how to duplicate array entries

2010-01-11 Thread Alf P. Steinbach
* Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array x=[1,2,3] In python such an object is called a list. (In cpython it's implemented as an automatically resizable array.) I don't think the OP's terminology needs correction. A Python list is an array

Re: how to duplicate array entries

2010-01-11 Thread Steven D'Aprano
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array x=[1,2,3] In python such an object is called a list. (In cpython it's implemented as an automatically resizable array.) I don't think the OP's

Re: how to duplicate array entries

2010-01-11 Thread Sebastian
Thank you for your answers! I actually implemented it using for loops before I posted here, but I was curious if there is a more elegant solution (judging from the post, Alf will probably say, that for loops are already elegant). Sebastian -- http://mail.python.org/mailman/listinfo/python-list

TypeError: __name__ must be set to a string object

2010-01-11 Thread Frank Millman
Hi all This problem is similar to one I posted recently regarding the multiprocessing module and unicode. However, although this one manifests itself while using the multiprocessing module, is caused by Python itself (2.6.2). At the top of my program I have 'from __future__ import

Re: how to duplicate array entries

2010-01-11 Thread Peter Otten
Alf P. Steinbach wrote: Re the thing I don't understand: it's the same in C++, people using hours on figuring out how to do something very simple in an ungrokkable indirect and compiled way using template metaprogramming stuff, when they could just write a simple 'for' loop and be done with

Re: how to duplicate array entries

2010-01-11 Thread Alf P. Steinbach
* Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array x=[1,2,3] In python such an object is called a list. (In cpython it's implemented as an automatically resizable array.) I don't think

Re: Advanced Python programming book?

2010-01-11 Thread flow
Cheers guys - I'll check the books out :) Thanks very much. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Martin v. Loewis
In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? No. Were they different at some earlier point in Python's evolution? That depends on the operating system. These used to be whatever the C library set up as stdout and stderr.

Re: how to duplicate array entries

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array  x=[1,2,3] In python such an object is called a list. (In

Re: integer and string compare, is that correct?

2010-01-11 Thread Hellmut Weber
Hi, thanks to all who answered. I'm using Python 2.6.5 on my machine and consulted the corresponding documentation. I do appreciate the modified definition of python 3, that seems much more reasonable. Thanks for indicating. Greetings from Munich in Winter Hellmut Am 10.01.2010 17:34,

Re: lightweight encryption of text file

2010-01-11 Thread Paul Rubin
geremy condra debat...@gmail.com writes: And having no dependencies frees you from the burden of testing where your software will be deployed? I don't think so. If you just use the stdlib and are a bit careful about OS dependent features, your code can run pretty much everywhere. More to the

Re: how to duplicate array entries

2010-01-11 Thread Alf P. Steinbach
* Chris Rebert: On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array x=[1,2,3] In python such an object is called a

Re: how to duplicate array entries

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 2:20 AM, Alf P. Steinbach al...@start.no wrote: * Chris Rebert: On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de

Re: how to duplicate array entries

2010-01-11 Thread Munir
I have an array  x=[1,2,3] Is there an operator which I can use to get the result [1,1,1,2,2,2,3,3,3] ? I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3] Have you tried: y = x*3 y.sort() Munir -- http://mail.python.org/mailman/listinfo/python-list

easy_install fails on python-magic

2010-01-11 Thread Daniel Fetchinson
I'm not sure whose fault this is, the author of python-magic or easy_install (I'm guessing easy_install) but in any case easy_install python-magic (as root) fails with Searching for python-magic Reading http://pypi.python.org/simple/python-magic/ Reading http://hupp.org/adam/hg/python-magic No

Re: how to duplicate array entries

2010-01-11 Thread Alf P. Steinbach
* Chris Rebert: On Mon, Jan 11, 2010 at 2:20 AM, Alf P. Steinbach al...@start.no wrote: * Chris Rebert: On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian

Re: Fractional Hours from datetime?

2010-01-11 Thread M.-A. Lemburg
W. eWatson wrote: Maybe there's a more elegant way to do this. I want to express the result of datetime.datetime.now() in fractional hours. Here's one way. dt=datetime.datetime.now() xtup = dt.timetuple() h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6 # now is in fractions of

TONIGHT Join 5-6P Mon 11th - 1st Evening Meeting test IRC VOIP online Python at BerkeleyTIP-Global - for forwarding

2010-01-11 Thread giovanni_re
You're invited to the first test of the Global Python bimonthly evening meetings at BerkeleyTIP-Global. :) Join in tonight, Monday Jan 11, 5-6P Pacific, 8-9P Eastern, = Tues Jan 12 1A-2A UTC. http://sites.google.com/site/berkeleytip/schedule On #berkeleytip on irc.freenode.net, on voip -

Re: Fractional Hours from datetime?

2010-01-11 Thread Martin P. Hellwig
W. eWatson wrote: Maybe there's a more elegant way to do this. I want to express the result of datetime.datetime.now() in fractional hours. Here's one way. dt=datetime.datetime.now() xtup = dt.timetuple() h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6 # now is in fractions of an hour

Re: Fractional Hours from datetime?

2010-01-11 Thread Martin P. Hellwig
Martin P. Hellwig wrote: W. eWatson wrote: Maybe there's a more elegant way to do this. I want to express the result of datetime.datetime.now() in fractional hours. Here's one way. dt=datetime.datetime.now() xtup = dt.timetuple() h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6 # now

Re: How to validate the __init__ parameters

2010-01-11 Thread Jean-Michel Pichavant
Aahz wrote: In article mailman.2244.1261418090.2873.python-l...@python.org, Jean-Michel Pichavant jeanmic...@sequans.com wrote: class A: def __init__(self, foo = None, bar = None): if len(foo) 5: raise ValueError('foo cannot exceed 5 characters') Bad Idea

Re: Academic Question

2010-01-11 Thread Victor Subervi
On Sun, Jan 10, 2010 at 3:09 PM, MRAB pyt...@mrabarnett.plus.com wrote: browser = form.getfirst('browser', 'all') except: browser = headers() try: A bare except, and if an exception _does_ occur, they'll be a NameError because 'headers' isn't defined. slap with large halibut/ Oh, not

Re: Easy Q

2010-01-11 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron gher...@islandtraining.com mailto:gher...@islandtraining.com wrote: Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable

force URLencoding script

2010-01-11 Thread João
Hi. I'm trying to figure out how to force URLencoding in my Python 2.4.3 environment receiving data an input argument but I'm really at a loss here. What am I doing wrong? #!/usr/bin/env python import sys from urllib import urlencode, urlopen from urllib2 import Request import urlparse

Re: Easy Q

2010-01-11 Thread Victor Subervi
On Mon, Jan 11, 2010 at 10:00 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron gher...@islandtraining.commailto: gher...@islandtraining.com wrote: Victor Subervi wrote: Hi; I have a string.join

Re: Computer Music Toolkit (CMT) ?

2010-01-11 Thread Michele Petrazzo
Terry Reedy wrote: On 1/10/2010 4:15 AM, Peter Billam wrote: Greetings. Is there a way to get at the Computer Music Toolkit (CMT) http://www.ladspa.org/cmt/ functionality from Python (Python3 in my case) ? You can access compiled C shared libraries most easily via the ctypes module. so if

does anyone know a way to package a static or portable version of a python module?

2010-01-11 Thread Jaime Huerta Cepas
does anyone know a way to package a static version of a python module? This is, the same that pyinstaller does with single scripts, but with a complete module directory. I'm specially interested in packaging all pyqt4, sip and qt4 dependencies within the module itself. thanks, Jaime. --

Re: Academic Question

2010-01-11 Thread Dave Angel
Victor Subervi wrote: On Sun, Jan 10, 2010 at 3:09 PM, MRAB pyt...@mrabarnett.plus.com wrote: browser = form.getfirst('browser', 'all') except: browser = headers() try: A bare except, and if an exception _does_ occur, they'll be a NameError because 'headers' isn't defined.

Re: Academic Question

2010-01-11 Thread Victor Subervi
On Mon, Jan 11, 2010 at 11:26 AM, Dave Angel da...@ieee.org wrote: Victor Subervi wrote: On Sun, Jan 10, 2010 at 3:09 PM, MRAB pyt...@mrabarnett.plus.com wrote: browser = form.getfirst('browser', 'all') except: browser = headers() try: A bare except, and if an exception _does_

pyserial: Unexpected Local Echo

2010-01-11 Thread Steven Woody
Hi, I am using pyserial. But I always get the local echo after I write some characters onto serial port and I find no way to disable this behavior. When I say 'local echo', I mean the next read operation will get characters that was just write to the same port. I run my program on cygwin

Re: pyserial: Unexpected Local Echo

2010-01-11 Thread Steve Holden
Steven Woody wrote: Hi, I am using pyserial. But I always get the local echo after I write some characters onto serial port and I find no way to disable this behavior. When I say 'local echo', I mean the next read operation will get characters that was just write to the same port. I run

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Iain King
On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found = re.findall('^ 1', line, re.MULTILINE) len(found)    6439

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Jeremy
On Jan 11, 8:44 am, Iain King iaink...@gmail.com wrote: On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found =

Re: how to duplicate array entries

2010-01-11 Thread Steven Howe
try --- #!/usr/bin/env python from types import ListType, IntType def array_expander( ar=None, ex=None ): if type( ex ) != IntType: return [] if ex = 0: return [] if type( ar ) != ListType: return [] # working code starts

Procedural API inside class--scoping questions

2010-01-11 Thread Kevin Walzer
I'm trying to make use of a Python library, aemreceive, that provides a procedural API. (aemreceive is a library for Python on the Mac that allows the application to receive and respond to Apple Events.) My Python apps basically run in a single fooApp class, and everything runs inside the

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Arnaud Delobelle
On 11 Jan, 15:35, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found = re.findall('^ 1', line, re.MULTILINE) len(found)    6439 tables

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread MRAB
Jeremy wrote: On Jan 11, 8:44 am, Iain King iaink...@gmail.com wrote: On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found

Re: Procedural API inside class--scoping questions

2010-01-11 Thread Arnaud Delobelle
On 11 Jan, 15:54, Kevin Walzer k...@codebykevin.com wrote: I'm trying to make use of a Python library, aemreceive, that provides a procedural API. (aemreceive is a library for Python on the Mac that allows the application to receive and respond to Apple Events.) My Python apps basically run

Python POS/cash register projects?

2010-01-11 Thread ethan
Anybody have any experience with creating a basic POS register system in Python? Any existing projects out there you are aware of? This would be a GUI app, standalone with some basic export and print functions. I see this as a great opportunity to deepen my Python experience but dont want to

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Peter Otten
Jeremy wrote: On Jan 11, 8:44 am, Iain King iaink...@gmail.com wrote: On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does;

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Duncan Booth
MRAB pyt...@mrabarnett.plus.com wrote: Yep. Thanks for pointing that out. I guess I just assumed that re.split was similar to re.search/match/findall in what it accepted as function parameters. I guess I'll have to use a \n instead of a ^ for split. You could use the .split method of a

Re: lightweight encryption of text file

2010-01-11 Thread Robert Kern
On 2010-01-09 03:52 AM, Anthra Norell wrote: Daniel Fetchinson wrote: I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of a password allows

Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson
Austyn wrote: Here's an improvement in case you want your code to work outside of Arizona: from time import time, timezone h = ((time() - timezone) / 3600) % 24 On Jan 10, 9:04 pm, Austyn aus...@gmail.com wrote: How about: import time arizona_utc_offset = -7.00 h = (time.time() / 3600 +

Re: Procedural API inside class--scoping questions

2010-01-11 Thread Bruno Desthuilliers
Kevin Walzer a écrit : I'm trying to make use of a Python library, aemreceive, that provides a procedural API. (aemreceive is a library for Python on the Mac that allows the application to receive and respond to Apple Events.) My Python apps basically run in a single fooApp class, and

Interesting (?) problem

2010-01-11 Thread mk
Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. (Obviously, hostips can contain any valid ip addresses as strings, they are sorted alphabetically here just

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: Incidentally, it *seems* that list comprehension preserves order: hostips_limited = [ h for h in hostips if h in thread_results ] Empirically speaking it seems to work (I tested it on real ips), but please correct me if that's wrong. Regards, mk Sounds good to me. List are

Re: Interesting (?) problem

2010-01-11 Thread mk
mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated (thread_result is a list of

Re: Interesting (?) problem

2010-01-11 Thread Arnaud Delobelle
mk mrk...@gmail.com writes: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. [...solution:] hostips_limited = [] for h in hostips: if h in

RE: C Module's '1.#INF' changes to 'inf' at Python

2010-01-11 Thread CELEN Erman
Numeric.log10() will check to see if the errno was set to ERANGE. It does not check if a floating point exception flag was set, which is tricky to do across platforms. The newer numpy can do it because we've finally managed to implement all of that platform-specific code, but the

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated (thread_result is a

Fundamental Function Question (beginner)

2010-01-11 Thread Scott
When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it matter at all that

Re: Interesting (?) problem

2010-01-11 Thread Peter Otten
mk wrote: mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated

Re: integer and string compare, is that correct?

2010-01-11 Thread Nobody
On Sun, 10 Jan 2010 23:13:55 -0800, Dan Bishop wrote: If you actually need to perform comparisons across types, you can rely upon the fact that tuple comparisons are non-strict and use e.g.:         a = 5         b = '5'         (type(a).__name__, a) (type(b).__name__, b)         True

Re: Interesting (?) problem

2010-01-11 Thread Paul Rubin
mk mrk...@gmail.com writes: I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. Assuming each address in hostips appears just once: from itertools import izip,count d

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? No. Were they different at some earlier point in Python's evolution? That depends on the operating system. These

Re: C Module's '1.#INF' changes to 'inf' at Python

2010-01-11 Thread Robert Kern
On 2010-01-11 12:27 PM, CELEN Erman wrote: Numeric.log10() will check to see if the errno was set to ERANGE. It does not check if a floating point exception flag was set, which is tricky to do across platforms. The newer numpy can do it because we've finally managed to implement all of that

Re: Fundamental Function Question (beginner)

2010-01-11 Thread MRAB
Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it

Re: pyserial: Unexpected Local Echo

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 23:27:03 +0800, Steven Woody wrote: I am using pyserial. But I always get the local echo after I write some characters onto serial port and I find no way to disable this behavior. When I say 'local echo', I mean the next read operation will get characters that was just

Re: Fundamental Function Question (beginner)

2010-01-11 Thread r0g
Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Steve Holden
Jeremy wrote: On Jan 11, 8:44 am, Iain King iaink...@gmail.com wrote: On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.:

Re: Interesting (?) problem

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 18:57:24 +0100, mk wrote: I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated

Re: integer and string compare, is that correct?

2010-01-11 Thread Arnaud Delobelle
Nobody nob...@nowhere.com writes: On Sun, 10 Jan 2010 23:13:55 -0800, Dan Bishop wrote: If you actually need to perform comparisons across types, you can rely upon the fact that tuple comparisons are non-strict and use e.g.:         a = 5         b = '5'         (type(a).__name__, a)

xml.sax parsing elements with the same name

2010-01-11 Thread amadain
I have an event log with 100s of thousands of entries with logs of the form: event eventTimestamp=2009-12-18T08:22:49.035 uniqueId=1261124569.35725_PFS_1_1340035961 result value=Blocked/ filters filter code=338 type=Filter_Name diagnostic result

Re: Fundamental Function Question (beginner)

2010-01-11 Thread r0g
r0g wrote: Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Jeremy
On Jan 11, 9:28 am, Duncan Booth duncan.bo...@invalid.invalid wrote: MRAB pyt...@mrabarnett.plus.com wrote: Yep.  Thanks for pointing that out.  I guess I just assumed that re.split was similar to re.search/match/findall in what it accepted as function parameters.  I guess I'll have to use

What is built-in method sub

2010-01-11 Thread Jeremy
I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it? Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.sax parsing elements with the same name

2010-01-11 Thread John Bokma
amadain mfmdev...@gmail.com writes: I have an event log with 100s of thousands of entries with logs of the form: event eventTimestamp=2009-12-18T08:22:49.035 uniqueId=1261124569.35725_PFS_1_1340035961 result value=Blocked/ filters filter code=338 type=Filter_Name

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Phlip
MRAB wrote: Scott wrote: for prtnmS in open(portfpth): prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. However, please consider writing complete,

Re: Python Goldmine has been updated: http://preciseinfo.org/Convert/index_Convert_Python.html

2010-01-11 Thread tanix
In article mailman.757.1263177422.28905.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: On 1/8/2010 11:50 AM, tanix wrote: Python Goldmine collection contains the extensive collection of articles going back several years. It includes thousands of code examples and expert

Re: Python Goldmine has been updated: http://preciseinfo.org/Convert/index_Convert_Python.html

2010-01-11 Thread tanix
In article mailman.758.1263178849.28905.python-l...@python.org, Steve Holden st...@holdenweb.com wrote: Terry Reedy wrote: On 1/8/2010 11:50 AM, tanix wrote: Python Goldmine collection contains the extensive collection of articles going back several years. It includes thousands of code

Re: Python Goldmine has been updated: http://preciseinfo.org/Convert/index_Convert_Python.html

2010-01-11 Thread tanix
In article mailman.759.1263180916.28905.python-l...@python.org, Steve Holden st...@holdenweb.com wrote: Steve Holden wrote: [...] Because I habitually run the NoScript extension to Firefox the popups didn't appear, but there didn't seem to be any original content on this site. Google continues

Re: What is built-in method sub

2010-01-11 Thread Carl Banks
On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it? I'm guessing this is re.sub (or, more likely, a method sub of an

Re: What is built-in method sub

2010-01-11 Thread Matthew Barnett
Jeremy wrote: I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it? Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: What is built-in method sub

2010-01-11 Thread MRAB
Jeremy wrote: I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it? I think it's the subtraction operator. The only way to optimise it is to reduce the number of subtractions

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Philip Semanchuk
On Jan 11, 2010, at 2:50 PM, Phlip wrote: MRAB wrote: Scott wrote: for prtnmS in open(portfpth): prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called.

Re: What is built-in method sub

2010-01-11 Thread Jeremy
On Jan 11, 12:54 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it?

Re: pyserial: Unexpected Local Echo

2010-01-11 Thread Grant Edwards
On 2010-01-11, Steven Woody narkewo...@gmail.com wrote: I am using pyserial. But I always get the local echo after I write some characters onto serial port I really doubt you're getting a local echo. Is the data coming out the serial port? Do you get the echo if you disconnect the serial

Re: lightweight encryption of text file

2010-01-11 Thread Anthra Norell
Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: Daniel Fetchinson wrote: I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of

Re: xml.sax parsing elements with the same name

2010-01-11 Thread amadain
On Jan 11, 7:26 pm, John Bokma j...@castleamber.com wrote: amadain mfmdev...@gmail.com writes: I have an event log with 100s of thousands of entries with logs of the form: event eventTimestamp=2009-12-18T08:22:49.035 uniqueId=1261124569.35725_PFS_1_1340035961    result value=Blocked/

Re: What is built-in method sub

2010-01-11 Thread Diez B. Roggisch
Jeremy schrieb: On Jan 11, 12:54 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one of my Python scripts and discovered that 99% of the time was spent in {built-in method sub} What is this function and is there a way to

Re: PIL how to display multiple images side by side

2010-01-11 Thread suresh.amritapuri
On Jan 9, 9:51 pm, Alf P. Steinbach al...@start.no wrote: * Lie Ryan: On 1/9/2010 8:43 AM, suresh.amritapuri wrote: Hi, In PIL, how to display multiple images in say m rows and n colums when I have m*n images. suresh Tkinter has PhotoImage widget and PIL has support for this

Re: What is built-in method sub

2010-01-11 Thread Stephen Hansen
On Mon, Jan 11, 2010 at 12:02 PM, Jeremy jlcon...@gmail.com wrote: Your guess is correct. I had forgotten that I was using that function. I am using the re.sub command to remove trailing whitespace from lines in a text file. The commands I use are copied below. If you have any

Re: What is built-in method sub

2010-01-11 Thread Jeremy
On Jan 11, 1:15 pm, Diez B. Roggisch de...@nospam.web.de wrote: Jeremy schrieb: On Jan 11, 12:54 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one of my Python scripts and discovered that 99% of the time was

Re: lightweight encryption of text file

2010-01-11 Thread Paul Rubin
Anthra Norell anthra.nor...@bluewin.ch writes: Why EVER make anything yourself when you can buy it? http://en.wikipedia.org/wiki/Dunning-Kruger_effect -- http://mail.python.org/mailman/listinfo/python-list

Re: What is built-in method sub

2010-01-11 Thread Steven D'Aprano
On Mon, 11 Jan 2010 11:20:34 -0800, Jeremy wrote: I just profiled one of my Python scripts Well done! I'm not being sarcastic, or condescending, but you'd be AMAZED (or possibly not...) at how many people try to optimize their scripts *without* profiling, and end up trying to speed up parts

os.system function

2010-01-11 Thread Zabin
Hey everyone! I am a new python programmer. I am trying to get the general file functionality with options of save and save as working. These save functions save a folder with multiple files. Upon using the os.system copy function- if my destination directory has files with similar names- i am

Re: What is built-in method sub

2010-01-11 Thread J
On Mon, Jan 11, 2010 at 15:02, Jeremy jlcon...@gmail.com wrote: I am using the re.sub command to remove trailing whitespace from lines in a text file.  The commands I use are copied below.  If you have any suggestions on how they could be improved, I would love to know. Just curious, but if

Re: What is built-in method sub

2010-01-11 Thread Terry Reedy
On 1/11/2010 3:02 PM, Jeremy wrote: I am using the re.sub command to remove trailing whitespace from lines in a text file. help(str.rstrip) Help on method_descriptor: rstrip(...) S.rstrip([chars]) - str Return a copy of the string S with trailing whitespace removed. If chars is

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Scott
On Jan 11, 1:50 pm, Phlip phlip2...@gmail.com wrote: MRAB wrote: Scott wrote: for prtnmS in open(portfpth):     prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Steven D'Aprano
On Mon, 11 Jan 2010 18:57:09 +, MRAB wrote: There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. Actually there is, but the benefit (avoiding the re-creation of the table) may be worth

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Scott
There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. Brilliant! I didn't think of that. I guess I accidentally did it right this time as I query that dictionary quite a few times from the

Re: What is built-in method sub

2010-01-11 Thread Philip Semanchuk
On Jan 11, 2010, at 3:30 PM, Jeremy wrote: On Jan 11, 1:15 pm, Diez B. Roggisch de...@nospam.web.de wrote: Jeremy schrieb: On Jan 11, 12:54 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one of my Python scripts and

Re: What is built-in method sub

2010-01-11 Thread Grant Edwards
On 2010-01-11, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: [regarding profiling results] I think you'll find that Python's regex engine is pretty much optimised as well as it can be, short of a major re-write. But to quote Jamie Zawinski: Some people, when confronted

shell access

2010-01-11 Thread monkeys paw
How do you access the command line from the python interpreter? on unix: type python print 'hey' 'hey' # I want to access the shell here, how do i do that? -- http://mail.python.org/mailman/listinfo/python-list

Re: What is built-in method sub

2010-01-11 Thread Diez B. Roggisch
Philip Semanchuk schrieb: On Jan 11, 2010, at 3:30 PM, Jeremy wrote: On Jan 11, 1:15 pm, Diez B. Roggisch de...@nospam.web.de wrote: Jeremy schrieb: On Jan 11, 12:54 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 11:20 am, Jeremy jlcon...@gmail.com wrote: I just profiled one

Re: xml.sax parsing elements with the same name

2010-01-11 Thread John Bokma
amadain mfmdev...@gmail.com writes: On Jan 11, 7:26 pm, John Bokma j...@castleamber.com wrote: amadain mfmdev...@gmail.com writes: event eventTimestamp=2009-12-18T08:22:49.035 uniqueId=1261124569.35725_PFS_1_1340035961    result value=Blocked/       filters           filter code=338

Re: Python Goldmine has been updated: http://preciseinfo.org/Convert/index_Convert_Python.html

2010-01-11 Thread Terry Reedy
On 1/11/2010 2:50 PM, tanix wrote: In articlemailman.757.1263177422.28905.python-l...@python.org, Terry Reedytjre...@udel.edu wrote: This site pops up spam windowns. One was blocked, one managed to bypass the popup blocker. Tnis is not friendly behaviour. I am sorry. But this is a known

RE: C Module's '1.#INF' changes to 'inf' at Python

2010-01-11 Thread CELEN Erman
(I also noticed that this behavior is same under standard NumPy 1.4 with standard Python 2.6 on Windows. If you call numpy.log10(0.0) you will get an -inf and no exceptions will be raised. Which is not the case with Python's standard math.log10(0.0) which will raise a ValueError)

  1   2   3   >