Re: Copying a ZipExtFile

2009-10-29 Thread ryles
On Oct 28, 8:33 pm, ryles ryle...@gmail.com wrote: As for why the bytesToRead calculation in ZipExtFile.read() results in a long, I've not yet looked at it closely. Simple, actually: In ZipExtFile.__init__(): self.bytes_read = 0L In ZipExitFile.read(): bytesToRead

Re: Copying a ZipExtFile

2009-10-28 Thread ryles
On Oct 23, 1:15 pm, Moore, Mathew L moor...@battelle.org wrote: Hello all, A newbie here.  I was wondering why the following fails on Python 2.6.2 (r262:71605) on win32.  Am I doing something inappropriate? Interestingly, it works in 3.1, but would like to also get it working in 2.6.

Re: Building Python on Solaris 10?

2009-10-28 Thread ryles
On Oct 28, 3:46 pm, Judy Booth j...@invalid.invalid wrote: Can anyone point me towards some instructions for building Python on Solaris 10? We need this for some of our test scripts and so far we cannot get this to build. We have tried both Python 2.6.4 and 3.1.1 and both fail with messages

Re: Working threads progress

2009-10-28 Thread ryles
On Oct 28, 7:02 pm, mattia ger...@gmail.com wrote: Now, I would like to know the activity done (e.g. every two seconds) so I create another thread that checks the queue size (using .qsize()). Have you any suggestion to improve the code? It's not uncommon to pass each thread a second queue for

Re: Anyone have python 3.1.1 installed on Solaris 10 ? (sparc or x86)

2009-10-20 Thread ryles
On Oct 19, 1:00 pm, Dave Crouse dc...@crouse.us wrote: Anyone have python 3.1.1 installed on Solaris 10 ? (sparc or x86) I've tried several times  on sparc, I keep getting: gcc -lintl -o python \ Modules/python.o \ libpython3.1.a -lsocket -lnsl -lintl -lrt -ldl -lm Undefined first

Re: restriction on sum: intentional bug?

2009-10-19 Thread ryles
On Oct 16, 6:53 pm, ryles ryle...@gmail.com wrote: Then you probably haven't read through these discussions: sum and strings:http://mail.python.org/pipermail/python-list/2006-August/subject.html summing a bunch of numbers:http://mail.python.org/pipermail/python-dev/2003-April/subj You

Re: Installation question 2.5.4

2009-10-17 Thread ryles
On Sat, Oct 17, 2009 at 9:55 PM, JimR kd...@arrl.net wrote: Thanks. As it turned out, I needed /usr/local/python instead of /usr/local as the prefix. After setting that, all worked as it should. -- http://mail.python.org/mailman/listinfo/python-list

Re: restriction on sum: intentional bug?

2009-10-16 Thread ryles
On Oct 16, 11:39 am, Alan G Isaac alan.is...@gmail.com wrote: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last):    File stdin, line 1, in module TypeError: sum() can't sum strings [use ''.join(seq) instead] Then you probably haven't read

Re: How about adding slice notation to iterators/generators?

2009-10-16 Thread ryles
On Oct 16, 5:28 pm, Eloff dan.el...@gmail.com wrote: By giving iterators a default, overridable, __getitem__ that is just syntactic sugar for islice, they would share a slightly larger interface subset with the builtin container types. In a duck-typed language like python, that's almost

Re: strange behaviour when inheriting from tuple

2009-10-12 Thread ryles
On Oct 11, 3:04 am, metal metal...@gmail.com wrote: Environment: PythonWin 2.5.4 (r254:67916, Apr 27 2009, 15:41:14) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. Evil Code: class Foo:      

Re: Script to complete web form fields

2009-10-11 Thread ryles
On Oct 10, 9:39 pm, Feyo dkatkow...@gmail.com wrote: How can I use Python to complete web form fields automatically? My work web-based email time-out is like 15 seconds. Every time I need to access my calendar, address book, or email, I have to type in my username and password. I'm just tired

Re: code in a module is executed twice (cyclic import problems) ?

2009-10-11 Thread ryles
On Oct 10, 7:36 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I always thought code in a module was only executed once, but doesn't seem to be true. I'm using Python 2.5. And this is the example: == A.py == My_List = [] == B.py == from A import * My_List.append ( 3 ) print

Re: How to find number of line that is currently executing?

2009-10-10 Thread ryles
On Oct 9, 11:46 pm, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: I would like to put a statement on line N of my program that prints the line number that is currently executing. inspect.currentframe().f_lineno http://docs.python.org/library/inspect.html --

Re: Need feedback on subprocess-using function

2009-10-05 Thread ryles
On Oct 4, 9:46 pm, Nobody nob...@nowhere.com wrote: On Sat, 03 Oct 2009 13:21:00 +, gb345 wrote: I'm relatively new to Python, and I'm trying to get the hang of using Python's subprocess module.  As an exercise, I wrote the Tac class below, which can prints output to a file in reverse

Re: Python shared lib

2009-10-05 Thread ryles
On Oct 4, 11:04 am, a...@pythoncraft.com (Aahz) wrote: I've got a dim memory that there's a reason for this -- you might try searching the python-dev archives and/or bugs.python.org. Found mention of it in this discussion: http://bugs.python.org/issue771998 I disagree that --enable-shared

Re: weak reference to bound method

2009-10-04 Thread ryles
On Oct 2, 4:54 am, Ole Streicher ole-usenet-s...@gmx.net wrote: Hi group, I am trying to use a weak reference to a bound method: class MyClass(object):     def myfunc(self):         pass o = MyClass() print o.myfunc   bound method MyClass.myfunc of __main__.MyClass object at 0xc675d0

Re: question about the GC implementation

2009-10-03 Thread ryles
On Oct 2, 11:20 am, Francis Moreau francis.m...@gmail.com wrote: Hello, I'm looking at gcmodule.c and in move_unreachable() function, the code assumes that if an object has its gc.gc_refs stuff to 0 then it *may* be unreachable. How can an object tagged as unreachable could suddenly become

Re: Granularity of OSError

2009-09-20 Thread ryles
On Sep 19, 9:22 pm, MRAB pyt...@mrabarnett.plus.com wrote: The point is that it's sometimes a good idea to do a cheap check first before attempting an operation that's 'expensive' even when it fails. Strongly agree. Furthermore, with LBYL it's often easier to give a user clearer error messages

Re: on package import, have it conditionally import a subpackage

2009-09-20 Thread ryles
this. Thank you, Gabriel You might try something like the following: $ export PYTHONPATH=/home/ryles $ cat mybase_test.py import mybase mybase.type = type2 from mybase.mypkg import module0, module1, module2 print module0.__file__ print module1.__file__ print module2.__file__ $ python

Re: Are min() and max() thread-safe?

2009-09-17 Thread ryles
On Sep 17, 7:02 am, Carl Banks pavlovevide...@gmail.com wrote: On Sep 16, 9:33 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: def minmax(seq):     result = [None, None]     t1 = MMThread(seq, min, result, 0)     t2 = MMThread(seq, max, result, 1)     t1.start()    

Re: Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

2009-09-09 Thread ryles
On Sep 9, 1:47 am, The Music Guy music...@alphaios.net wrote: I should also mention--and I should have realized this much sooner--that each of the BaseN classes are themselves each going to have at least one common base which will define method_x, so each BaseN will be calling that if it

Re: Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

2009-09-09 Thread ryles
On Sep 9, 7:48 pm, The Music Guy music...@alphaios.net wrote: Btw, Carl, please forgive me if I frustrate you, because I'm trying my best not to. I'm trying to keep track of what I did and what you did and what Ryles and Scott did, while at the same time trying to keep a firm grasp of exactly

Re: Is #!/usr/bin/env python the better shebang line ?

2009-09-07 Thread ryles
On Sep 6, 10:01 am, Timothy Madden terminato...@gmail.com wrote: Hello Sorry if this has been discussed before, my search did not find it. My questions is if I should use    #!/usr/bin/env python as the shebang line in a portable and open python script and if it does help with portability

Re: simple string question

2009-09-07 Thread ryles
There's probably a more general method covering all the escape sequences, but for just \n: your_string = your_string.replace(\\n, \n) py s = hello\\r\\n py s 'hello\\r\\n' py s.decode(string_escape) 'hello\r\n' py -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

2009-09-05 Thread ryles
On Sep 4, 6:01 am, The Music Guy music...@alphaios.net wrote: I have a peculiar problem that involves multiple inheritance and method calling. I have a bunch of classes, one of which is called MyMixin and doesn't inherit from anything. MyMixin expects that it will be inherited along with

Re: executable path finding

2009-09-01 Thread ryles
On Aug 31, 12:37 pm, koranthala koranth...@gmail.com wrote: On Aug 31, 9:07 pm, Diez B. Roggisch de...@nospam.web.de wrote: koranthala wrote: Hi,     I am creating a python application using py2exe. I am facing a problem which I am not sure how to solve.     The application

Re: Q: multiprocessing.Queue size limitations or bug...

2009-08-27 Thread ryles
On Aug 26, 4:56 am, Michael Riedel mrie...@inova-semiconductors.de wrote: Sorry for being not more specific but I'm not absolutely certain whether I encountered a bug or did anything wrong: The (stupid) code below results in a stall forever or not at 'p0.join()' depending on the value of

Re: Object's nesting scope

2009-08-26 Thread ryles
On Aug 26, 8:51 am, zaur szp...@gmail.com wrote: Hi folk! What do you think about idea of object's nesting scope in python? Let's imaging this feature, for example, in this syntax: obj=expression:      body or expression:    body That's means that result object of expression

Re: Protecting against callbacks queuing up?

2009-08-24 Thread ryles
On Aug 23, 8:14 pm, Esben von Buchwald find@paa.google wrote: I thought that this code would do the trick, but it obviously doesn't help at all, and i can't understand why...      def doCallback(self):          if self.process_busy==False:              self.process_busy=True            

Re: Setuptools - help!

2009-08-19 Thread ryles
On Aug 7, 3:04 pm, Peter Chant rempete...@petezilla.co.uk wrote: Robert Kern wrote: You need to put main.py into the pphoto package. $ mkdir pphoto/ $ mv main.py pphoto/ $ touch pphoto/__init__.py Thanks, it worked.  Any ideas how to run the resulting scripts without installing or

Re: Python 2.6 still not giving memory back to the OS...

2009-08-16 Thread ryles
On Aug 15, 7:55 am, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I thought this was fixed back in Python 2.5, but I guess not? So, I'm playing in an interactive session:   from xlrd import open_workbook   b = open_workbook('some.xls',pickleable=0,formatting_info=1) At this point,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 14, 8:22 pm, candide cand...@free.invalid wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with

Re: Splitting a string into substrings of equal size

2009-08-15 Thread ryles
On Aug 15, 6:28 pm, MRAB pyt...@mrabarnett.plus.com wrote:       for z in [75096042068045, 509, 12024, 7, 2009]:            print re.sub(r(?=.)(?=(?:...)+$), ,, z)     75,096,042,068,045     509     12,024     7     2,009 The call replaces a zero-width match with a comma, ie

Re: Python and behavior

2009-08-14 Thread ryles
On Aug 13, 8:36 pm, goldtech goldt...@worldpost.com wrote: Could you explain or link me to an explanation of this? http://docs.python.org/tutorial/datastructures.html#more-on-conditions Give the whole tutorial a good read. -- http://mail.python.org/mailman/listinfo/python-list

Re: run all scripts in sub-directory as subroutines?

2009-08-12 Thread ryles
On Aug 11, 5:12 pm, guthrie guth...@mum.edu wrote: This works fine, but in the sub-modules the sys.path appropriately returns the same as from the parent, I want them to know their own file names. How?? I can pass it to them, but wondered if there is a more self-sufficient way for a module to

Re: How to do relpath implementation on 2.5

2009-08-09 Thread ryles
On Aug 8, 9:08 pm, Brian Allen Vanderburg II brianvanderbu...@aim.com wrote: I've coded my own 'relpath' implementation for 2.5 (shown below) and I want to make sure it follows as closely as it should to 2.6 and later.   I've got a question regarding that.  When attempting to convert to a

Re: unique-ifying a list

2009-08-08 Thread ryles
On Aug 7, 4:53 pm, kj no.em...@please.post wrote: Suppose that x is some list.  To produce a version of the list with duplicate elements removed one could, I suppose, do this:     x = list(set(x)) but I expect that this will not preserve the original order of elements. OrderedSet is most

Re: Web page data and urllib2.urlopen

2009-08-06 Thread ryles
On Aug 5, 4:30 pm, Massi massi_...@msn.com wrote: Hi everyone, I'm using the urllib2 library to get the html source code of web pages. In general it works great, but I'm having to do with a financial web site which does not provide the souce code I expect. As a matter of fact if you try:

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread ryles
On Aug 4, 10:37 pm, erikcw erikwickst...@gmail.com wrote: Traceback (most recent call last):   File scraper.py, line 144, in module     print pool.map(scrape, range(10))   File /usr/lib/python2.6/multiprocessing/pool.py, line 148, in map     return self.map_async(func, iterable,

Re: Wrapping prstat on Solaris

2009-07-28 Thread ryles
On Jul 27, 10:26 am, s...@pobox.com wrote: At work we currently use top to monitor ongoing system utilization on our Solaris systems.  As time has moved on though, use of top has become problematic.  Our admins want us to switch to prstat, Sun's top-like command.  It works fine however doesn't

Re: The longest word

2009-07-28 Thread ryles
On Jul 28, 7:55 am, NiklasRTZ nikla...@gmail.com wrote: Sincere thanks for strengthening python's superior flexibility. Same function also works around an exploding index problem returning results for longest word where otherwise a word with whitespace crashes the index: Babelfish? --

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-25 Thread ryles
On Jul 25, 8:57 am, Piet van Oostrum p...@cs.uu.nl wrote: ryles ryle...@gmail.com (r) wrote: r According tohttp://www.python.org/doc/essays/packages.html: r The import statement first tests whether the item is defined in the r package; if not, it assumes it is a module and attempts to load

Re: difference in printing to screen Mac / Windows

2009-07-24 Thread ryles
On Jul 18, 7:03 am, Tim Chase python.l...@tim.thechases.com wrote: Lastly, you can force all standard-output in your program to be unbuffered without the -u parameter: And if you're using -u a lot, the PYTHONUNBUFFERED environment variable can also be set (but not empty), so that python adds

Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-24 Thread ryles
According to http://www.python.org/doc/essays/packages.html: The import statement first tests whether the item is defined in the package; if not, it assumes it is a module and attempts to load it. However, I've noticed that once a module is imported using the `from pkg import mod' syntax, if its

Re: Python Equivalent for dd fold

2009-07-16 Thread ryles
On Jul 15, 1:14 pm, seldan24 selda...@gmail.com wrote: On Jul 15, 12:47 pm, Michiel Overtoom mot...@xs4all.nl wrote: seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len):      while s:          print s[:len]          s=s[len:] s=A very

Re: how to set timeout while colling a soap method?

2009-07-14 Thread ryles
On Jul 13, 9:07 am, dzizes dzizes...@gmail.com wrote: Hello! I wrote some some python code for executing a soap method: import SOAPpy from SOAPpy import WSDL _server = WSDL.Proxy(some wsdl) r=_server.generuj(some parameters...) print r.encode('cp1250') It works fine. However, the

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread ryles
You can go ahead and implement a __del__() method. It will often work in CPython, but you get no guarantees, especially when you have reference cycles and with other Python implementations that don't use refcounting. And for resources whose lifetime is greater than your process (e.g. a file),

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 6:10 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 01 Jul 2009 12:49:31 -0300, Scott David Daniels   scott.dani...@acm.org escribió: These loops work well with the two-argument version of iter, which is easy to forget, but quite useful to have in your bag of tricks:

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread ryles
This reminds me. Would anyone object to adding a sentence to http://docs.python.org/library/stringio.html#module-cStringIO just to mention that attributes cannot be added to a cStringIO, like such: % import cStringIO, StringIO % StringIO.StringIO().value = 1 % cStringIO.StringIO().value = 1

Re: Adding an object to the global namespace through f_globals is that allowed ?

2009-07-02 Thread ryles
On Jul 2, 1:25 am, Terry Reedy tjre...@udel.edu wrote: The next statement works, but I'm not sure if it will have any dramatical side effects, other than overruling a possible object with the name A def some_function ( ...) : A = object ( ...) sys._getframe(1).f_globals [

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 10:20 pm, Paul Rubin http://phr...@nospam.invalid wrote: ryles ryle...@gmail.com writes: # Oh... yeah. I really *did* want 'is None' and not '== None' which iter() will do. Sorry guys! Please don't let this happen to you too ;) None is a perfectly good value to put onto

Re: multiprocessing: pool with blocking queue

2009-07-02 Thread ryles
On Jul 2, 11:09 am, masher vertesp...@gmail.com wrote: My questions, then, is: Is there a more elegant/pythonic way of doing what I am trying to do with the current Pool class? Another thing you might try is to subclass Pool and add an apply_async () wrapper which would wait for

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 11:55 pm, Paul Rubin http://phr...@nospam.invalid wrote: Yeah, it should allow supplying a predicate instead of using == on a value.  How about (untested):    from itertools import *    ...    for row in takewhile(lambda x: x is sentinel,                          

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-01 Thread ryles
On Jun 29, 5:43 pm, Scott David Daniels scott.dani...@acm.org wrote:  and I personally wouldn't have it any other way. Simulating a shell with hooks on its I/O should be so complicated that a script kiddie has trouble writing a Trojan. +1 QOTW --

Re: Making code run in both source tree and installation path

2009-06-30 Thread ryles
On Jun 29, 12:20 pm, Javier Collado javier.coll...@gmail.com wrote: Hello, I would like to be able to run the main script in a python project from both the source tree and the path in which it's installed on Ubuntu. The script, among other things, imports a package which in turns makes use

Re: generator expression works in shell, NameError in script

2009-06-19 Thread ryles
Does the generator expression have its own little namespace or so ? Yes, generators create a new scope: http://docs.python.org/reference/expressions.html#grammar-token-generator_expression -- http://mail.python.org/mailman/listinfo/python-list

Re: generator expression works in shell, NameError in script

2009-06-18 Thread ryles
On Jun 18, 9:56 am, nn prueba...@latinmail.com wrote: On Jun 18, 8:38 am, guthrie grguth...@gmail.com wrote: On Jun 17, 6:38 pm, Steven Samuel Cole steven.samuel.c...@gmail.com wrote: Still don't really understand why my initial code didn't work, though... Your code certainly looks

Re: Unhandled exception in thread

2009-06-12 Thread ryles
On Jun 11, 3:52 pm, Mads Michelsen madsmaill...@gmail.com wrote: Here's the deal. The script in question is a screen scraping thing which downloads and parses the html in the background using a separate thread (the 'thread' module), while the main program serves up the data to the user,

Re: unpickling a stream

2009-05-27 Thread ryles
On May 26, 3:25 pm, mso...@linuxmail.org wrote: Hello, I want to send a stream of pickled objects over a socket.  Is there a standard way of ensuring that only complete objects are unpickled on the receiving side. client pseudo code:   loop forever:     receive some bytes on the socket  

Re: slice iterator?

2009-05-09 Thread ryles
On May 8, 11:17 pm, Ross ross.j...@gmail.com wrote: I have a really long list that I would like segmented into smaller lists. Let's say I had a list a = [1,2,3,4,5,6,7,8,9,10,11,12] and I wanted to split it into groups of 2 or groups of 3 or 4, etc. Is there a way to do this without explicitly