Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread Diez B. Roggisch
Yes, I need to make sure my requests are properly written so that the generic XPath engine does not need all the structure in memory. There are quite a few cases where you really don't need to load everything at all. /a/b/*/c/d is an example. But even with an example like /x/z[last()]/t, you don

Re: print problem

2008-06-17 Thread Rich Healey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gabriel Genellina wrote: > En Tue, 17 Jun 2008 03:15:11 -0300, pirata <[EMAIL PROTECTED]> escribió: > >> I was trying to print a dot on console every second to indicates >> running process, so I wrote, for example: >> >> for i in xrange(10): >> pr

Re: String Concatenation O(n^2)

2008-06-17 Thread Hrvoje Niksic
"Ian Kelly" <[EMAIL PROTECTED]> writes: > On Mon, Jun 16, 2008 at 11:09 AM, Jean-Paul Calderone > <[EMAIL PROTECTED]> wrote: >> It will depend what version of Python you're using and the *exact* details >> of the code in question. An optimization was introduced where, if the >> string being conca

Re: UnicodeDecodeError: 'ascii' codec can't decode byte

2008-06-17 Thread Peter Otten
Gilles Ganault wrote: > It seems like I have Unicode data in a CSV file but Python is using > a different code page, so isn't happy when I'm trying to read and put > this data into an SQLite database with APSW: My guess is that you have non-ascii characters in a bytestring. > What should I do s

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Gabriel Genellina
En Tue, 17 Jun 2008 02:25:42 -0300, Lie <[EMAIL PROTECTED]> escribió: > On Jun 17, 11:07 am, "Leo Jay" <[EMAIL PROTECTED]> wrote: >> On Tue, Jun 17, 2008 at 11:29 AM, pirata <[EMAIL PROTECTED]> wrote: >> > What's the difference between "is not" and "!=" or they are the same thing? >> >> The 'is' i

Re: newbie question: for loop within for loop confusion

2008-06-17 Thread Gabriel Genellina
En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <[EMAIL PROTECTED]> escribió: > takayuki wrote: > >> I'm early on in my python adventure so I'm not there yet on the strip >> command nuances.I'm reading "How to think like a python >> programmer" first. It's great. >> >> Then "Learning python"

Re: Removing inheritance (decorator pattern ?)

2008-06-17 Thread Gerard flanagan
Maric Michaud wrote: Le Monday 16 June 2008 20:35:22 George Sakkis, vous avez écrit : On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: [...] variation of your toy code. I was thinking the Strategy pattern, different classes have different initialisation strategies? But then you c

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Peter Otten
Terry Reedy wrote: > Cédric Lucantis wrote: > >> I don't see any string method to do that > > >>> 'abcde'.translate(str.maketrans('','','bcd')) > 'ae' > > I do not claim this to be better than all the other methods, > but this pair can also translate while deleting, which others cannot. You s

Re: print problem

2008-06-17 Thread Gabriel Genellina
En Tue, 17 Jun 2008 04:10:41 -0300, Rich Healey <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: >> En Tue, 17 Jun 2008 03:15:11 -0300, pirata <[EMAIL PROTECTED]> escribió: >> >>> I was trying to print a dot on console every second to indicates >>> running process, so I wrote, for example:

Re: print problem

2008-06-17 Thread Chris
On Jun 17, 8:15 am, pirata <[EMAIL PROTECTED]> wrote: > I was trying to print a dot on console every second to indicates > running process, so I wrote, for example: > > for i in xrange(10): >     print ".", >     time.sleep(1) > > Idealy, a dot will be printed out each second. But there is nothing

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Duncan Booth
"Leo Jay" <[EMAIL PROTECTED]> wrote: > same objects are equal, but equal don't have to be the same object. same objects are often equal, but not always: >>> inf = 2e200*2e200 >>> ind = inf/inf >>> ind==ind False >>> ind is ind True -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.pyt

Re: get keys with the same values

2008-06-17 Thread Wolfgang Grafen
You could use my mseqdict implementation of a sorted dict. http://home.arcor.de/wolfgang.grafen/Python/Modules/Modules.html swap: This method can only be applied when all values of the dictionary are immutable. The Python dictionary cannot hold mutable keys! So swap doesn't work if only one of

Re: Showing a point in Gnuploy.py

2008-06-17 Thread A.T.Hofkamp
On 2008-06-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello. Could some1 tell me how i could "display" a specific point in > gnuplot.py. Supposingly if i have a point of intersection (2,3). How > can i show this on the graph? As in how can i write near the point of > intersection the value

gtk.gdk.Pixbuf.scale() unexpected behavior when offset != 0

2008-06-17 Thread Joel Hedlund
Hi! I'm developing a pygtk application where I need to show images zoomed in so that the user can see individual pixels. gtk.gdk.Pixbuf.scale() seemed ideal for this, but if I set offset_x and offset_y to anything other than 0, the resulting image is heavily distorted and the offset is wrong.

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Sion Arrowsmith
In article <[EMAIL PROTECTED]>, Peter Otten <[EMAIL PROTECTED]> wrote: >Terry Reedy wrote: >> >>> 'abcde'.translate(str.maketrans('','','bcd')) >> 'ae' >You should mention that you are using Python 3.0 ;) >The 2.5 equivalent would be > u"abcde".translate(dict.fromkeys(map(ord, u"bcd"))) >u'

go to specific line in text file

2008-06-17 Thread Patrick David
Hello NG, I am searching for a way to jump to a specific line in a text file, let's say to line no. 9000. Is there any method like file.seek() which leads me to a given line instead of a given byte? Hope for help Patrick -- http://mail.python.org/mailman/listinfo/python-list

Re: pyinotify issue

2008-06-17 Thread AndreH
On Jun 13, 3:39 pm, AndreH <[EMAIL PROTECTED]> wrote: > Good day, > > I just installed pyinotify on my gentoo box. > > When I test the library through "pyinotify.pv -v /tmp" under root, > everything works great, but when I try the same thing under my local > user account, I receive the following er

New widget

2008-06-17 Thread Petertos
Hello, here's a new casual game that looks interesting. It's called Smilies Invasion and you have to eat as much green smilies as you can: http://www.dolmenent.com/smiliesinvasion/ Greetings from a newbie developer. -- http://mail.python.org/mailman/listinfo/python-list

Re: go to specific line in text file

2008-06-17 Thread John Machin
On Jun 17, 8:10 pm, Patrick David <[EMAIL PROTECTED]> wrote: > Hello NG, > > I am searching for a way to jump to a specific line in a text file, let's > say to line no. 9000. > Is there any method like file.seek() which leads me to a given line instead > of a given byte? If by "jump" you mean with

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Peter Otten
Sion Arrowsmith wrote: > In article <[EMAIL PROTECTED]>, > Peter Otten <[EMAIL PROTECTED]> wrote: >>Terry Reedy wrote: >>> >>> 'abcde'.translate(str.maketrans('','','bcd')) >>> 'ae' >>You should mention that you are using Python 3.0 ;) >>The 2.5 equivalent would be >> > u"abcde".translate(di

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-17 Thread bearophileHUGS
Martin v. L.: > http://wiki.python.org/moin/TimeComplexity Thank you, I think that's not a list of guarantees, while a list of how things are now in CPython. > If so, what's the advantage of using that method over d.items[n]? I think I have lost the thread here, sorry. So I explain again what I

Numeric type conversions

2008-06-17 Thread John Dann
I'm new to Python and can't readily find the appropriate function for the following situation: I'm reading in a byte stream from a serial port (which I've got working OK with pyserial) and which contains numeric data in a packed binary format. Much of the data content occurs as integers encoded as

Re: Numeric type conversions

2008-06-17 Thread Diez B. Roggisch
John Dann wrote: > I'm new to Python and can't readily find the appropriate function for > the following situation: > > I'm reading in a byte stream from a serial port (which I've got > working OK with pyserial) and which contains numeric data in a packed > binary format. Much of the data content

Re: Numeric type conversions

2008-06-17 Thread ershov . a_n
try struct.pack -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric type conversions

2008-06-17 Thread A.T.Hofkamp
On 2008-06-17, John Dann <[EMAIL PROTECTED]> wrote: > I'm reading in a byte stream from a serial port (which I've got > working OK with pyserial) and which contains numeric data in a packed > binary format. Much of the data content occurs as integers encoded as > 2 consecutive bytes, ie a 2-byte in

Re: Numeric type conversions

2008-06-17 Thread Gerhard Häring
John Dann wrote: I'm new to Python and can't readily find the appropriate function for the following situation: I'm reading in a byte stream from a serial port (which I've got working OK with pyserial) and which contains numeric data in a packed binary format. Much of the data content occurs as

Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread méchoui
On Jun 17, 9:08 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Yes, I need to make sure my requests are properly written so that the > > generic XPath engine does not need all the structure in memory. > > > There are quite a few cases where you really don't need to load > > everything at all

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Derek Martin
On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote: > > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)' > > and 'not(id(a) == id(b))' > > No. Sure it is... he said "similar"... not identical. They are not the same, but they are similar. Saying a flat "no" al

Re: Numeric type conversions

2008-06-17 Thread John Machin
On Jun 17, 9:28 pm, John Dann <[EMAIL PROTECTED]> wrote: > I'm new to Python and can't readily find the appropriate function for > the following situation: > > I'm reading in a byte stream from a serial port (which I've got > working OK with pyserial) and which contains numeric data in a packed > b

Re: 32 bit or 64 bit?

2008-06-17 Thread Phil Hobbs
[EMAIL PROTECTED] wrote: On Jun 15, 7:43 pm, Peter Otten <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: On Jun 15, 6:58 pm, Christian Meesters <[EMAIL PROTECTED]> wrote: I do need speed. Is there an option? Mind telling us what you *actually* want to achieve? (What do you want to calcula

Mapping a series of Dates to an array of Numbers

2008-06-17 Thread J-Burns
Hello. Got a problem here. Ive got a set of points tht id be plotting. Those points would contain the date on which the work was done against its frequency. Supposedly if i did something on the 28th of March one of the points would be (28, respective freq). The next time i did my work on the 1st o

Re: Mapping a series of Dates to an array of Numbers

2008-06-17 Thread J-Burns
Btw dnt forget the solution should also cater to this problem: Supposedly there is a day on which i did not do anything. Than that particular spot in my graph should be left empty. Meaning that if i did something on the 1st March and after it i did something on the 7th March. Then essentially 1st m

Re: Mapping a series of Dates to an array of Numbers

2008-06-17 Thread Chris
On Jun 17, 2:15 pm, J-Burns <[EMAIL PROTECTED]> wrote: > Hello. Got a problem here. > > Ive got a set of points tht id be plotting. Those points would contain > the date on which the work was done against its frequency. Supposedly > if i did something on the 28th of March one of the points would be

Re: go to specific line in text file

2008-06-17 Thread Hrvoje Niksic
Patrick David <[EMAIL PROTECTED]> writes: > I am searching for a way to jump to a specific line in a text file, > let's say to line no. 9000. Is there any method like file.seek() > which leads me to a given line instead of a given byte? You can simulate it fairly easily, but it will internally r

How do I avoid using HTTPRedirectHandler with urllib2?

2008-06-17 Thread Mukherjee, Pratip
Hi, I am new to Python, trying it as an alternative to Perl. I am having problem with python HTTP handling library, urllib2. How do I avoid using the HTTPRedirectHandler while making a HTTP request? For those familiar to Perl-LWP, this is done by using simple_request() on the UserAgent object. Than

Re: Buffer size when receiving data through a socket?

2008-06-17 Thread John Salerno
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Both programs say recv(buffer_size) - buffer_size is the maximum number of > bytes to be RECEIVED, that is, READ. recv will return at most buffer_size > bytes. It may return less than that, even if the other side s

Re: Buffer size when receiving data through a socket?

2008-06-17 Thread John Salerno
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > from socket import * > > host = 'localhost' > port = 51567 > address = (host, port) > buffer_size = 1024 > > client_socket = socket(AF_INET, SOCK_STREAM) > client_socket.connect(address) > > while True: >data = raw_in

Re: 32 bit or 64 bit?

2008-06-17 Thread [EMAIL PROTECTED]
On Jun 17, 3:13 pm, Phil Hobbs <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Jun 15, 7:43 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] wrote: > >>> On Jun 15, 6:58 pm, Christian Meesters <[EMAIL PROTECTED]> wrote: > > I do need speed. Is there an option? > >>

Re: go to specific line in text file

2008-06-17 Thread John Machin
On Jun 17, 10:46 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Patrick David <[EMAIL PROTECTED]> writes: > > I am searching for a way to jump to a specific line in a text file, > > let's say to line no. 9000. Is there any method like file.seek() > > which leads me to a given line instead of a giv

Re: 32 bit or 64 bit?

2008-06-17 Thread Richard Brodie
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >That was suggested. Problem is, that sometimes the velocities are near >zero. So this solution, by itself, is not general enough. Maybe working in p, and delta-p would be more stable. -- http://mail.python.org/mailman/listinfo/pyth

Re: The best way to package a Python module?

2008-06-17 Thread js
Thanks everyone for details. I'll try stealing some of the good bits of python-central of debian for my purpose. On Mon, Jun 16, 2008 at 10:43 AM, Ben Finney <[EMAIL PROTECTED]> wrote: > Jean-Paul Calderone <[EMAIL PROTECTED]> writes: > >> >What has changed is that the tools in common use for Debi

Authentic Designer Handbags at www. yoyobag.com

2008-06-17 Thread kalra . shrut
Authentic Designer Handbags at www. yoyobag.com -- http://mail.python.org/mailman/listinfo/python-list

Annoying message when interrupting python scripts

2008-06-17 Thread geoffbache
Hi all, I find that I semi-frequently get the cryptic message import site failed; use -v for traceback printed on standard error when an arbitrary python script receives SIGINT while the python interpreter is still firing up. If I use -v for traceback I get something along the lines of 'import

Re: Annoying message when interrupting python scripts

2008-06-17 Thread geoffbache
To clarify: this is more serious than an incorrect error message, as the intended interrupt gets swallowed and script execution proceeds. Sometimes I seem to get half-imported modules as well, the script failing later with something like AttributeError: 'module' object has no attribute 'getenv'

Re: Pattern Matching Over Python Lists

2008-06-17 Thread Kirk Strauser
At 2008-06-17T05:55:52Z, Chris <[EMAIL PROTECTED]> writes: > Is anyone aware of any prior work done with searching or matching a > pattern over nested Python lists? I have this problem where I have a > list like: > > [1, 2, [1, 2, [1, 7], 9, 9], 10] > > and I'd like to search for the pattern [1, 2

Re: How to catch StopIteration?

2008-06-17 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm writing to see calcuration process. > And so, I can't catch StopIteration... > > What is mistake? > > def collatz(n): >r=[] >while n>1: > r.append(n) > n = 3*n+1 if n%2 else n/2 > yield r > > for i, x in enumerate(col

Re: 2Q's: How to autocreate instance of class;How to check for membership in a class

2008-06-17 Thread Mark Wooding
asdf <[EMAIL PROTECTED]> wrote: (Presumably nothing to do with the Common Lisp system-definition utility.) > So for example if I know that var1=jsmith. Can I somehow do > var1=User(). Something like this might work. class User (object): def __init__(me, name): me.name = name class Users

Re: Numeric type conversions

2008-06-17 Thread MRAB
On Jun 17, 12:28 pm, John Dann <[EMAIL PROTECTED]> wrote: > I'm new to Python and can't readily find the appropriate function for > the following situation: > > I'm reading in a byte stream from a serial port (which I've got > working OK with pyserial) and which contains numeric data in a packed >

Re: Debuggers

2008-06-17 Thread R. Bernstein
TheSaint <[EMAIL PROTECTED]> writes: > On 19:21, venerdì 13 giugno 2008 R. Bernstein wrote: > >> I'm not completely sure what you mean, but I gather that in >> post-mortem debugging you'd like to inspect local variables defined at the >> place of error. > > Yes, exactly. This can be seen with pdb,

text alignment

2008-06-17 Thread Gandalf
Hi every one. What is the similar python WX style property for CSS text-align? I need this item text to start from the right direction: aaa= html.HtmlWindow(self, -1, style=wx.SIMPLE_BORDER, size=(250, 60)) aaa.LoadPage('../../aa.html') Thanks! -- http://mail.python.org/mailman/listinfo

Trying to get pcap working

2008-06-17 Thread Michael Matthews
Hello, I'm fairly new to Python, and have run into dead ends in trying to figure out what is going on. The basic thing I am trying to do is get pylibpcap working on a Python installation. More precisely, I want to get it working on an ActiveState Python installation. I have it working on cygwin

Re: text alignment

2008-06-17 Thread Gandalf
On Jun 17, 6:43 pm, Gandalf <[EMAIL PROTECTED]> wrote: > Hi every one. What is the similar python WX style property for CSS > text-align? > > I need this item text to start from the right direction: > > aaa= html.HtmlWindow(self, -1, style=wx.SIMPLE_BORDER, size=(250, 60)) >         aaa.LoadPage('.

Re: Pattern Matching Over Python Lists

2008-06-17 Thread bearophileHUGS
Kirk Strauser: > Hint: recursion. Your general algorithm will be something like: Another solution is to use a better (different) language, that has built-in pattern matching, or allows to create one. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Context manager for files vs garbage collection

2008-06-17 Thread Sebastian "lunar" Wiesner
Floris Bruynooghe <[EMAIL PROTECTED]>: > I was wondering when it was worthwil to use context managers for > file. Consider this example: > > def foo(): > t = False > for line in file('/tmp/foo'): > if line.startswith('bar'): > t = True > break > return

Re: Numeric type conversions

2008-06-17 Thread John Dann
On Tue, 17 Jun 2008 08:58:11 -0700 (PDT), MRAB <[EMAIL PROTECTED]> wrote: >[snip] >Please note that in slicing the start position is included and the end >position is excluded, so that should be ByteStream[12:14]. Yes, I just tripped over that, in fact, hence the error in my original post. I supp

Re: Buffer size when receiving data through a socket?

2008-06-17 Thread John Salerno
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Note that most of the time you want to use the sendall() method, because > send() doesn't guarantee that all the data was actually sent. > If I use sendall(), am I

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Terry Reedy
pirata wrote: I'm a bit confusing about whether "is not" equivelent to "!=" >>> 0 is not 0.0 True >>> 0 != 0.0 False -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric type conversions

2008-06-17 Thread Peter Otten
John Dann wrote: > On Tue, 17 Jun 2008 08:58:11 -0700 (PDT), MRAB > <[EMAIL PROTECTED]> wrote: > >>[snip] >>Please note that in slicing the start position is included and the end >>position is excluded, so that should be ByteStream[12:14]. > > Yes, I just tripped over that, in fact, hence the er

Re: Making wxPython a standard module?

2008-06-17 Thread TYR
>" b = wx.Button(label="Click Me", action=myCallable) >Instead you used to have to create a button and then call >some utility function in some other object to bind that >button to a callable (IIRC this was one place where Window >IDs could be used). Now, the button actually

Re: text alignment

2008-06-17 Thread Mike Driscoll
On Jun 17, 11:45 am, Gandalf <[EMAIL PROTECTED]> wrote: > On Jun 17, 6:43 pm, Gandalf <[EMAIL PROTECTED]> wrote: > > > Hi every one. What is the similar python WX style property for CSS > > text-align? > > > I need this item text to start from the right direction: > > > aaa= html.HtmlWindow(self, -

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: Cédric Lucantis wrote: I don't see any string method to do that >>> 'abcde'.translate(str.maketrans('','','bcd')) 'ae' I do not claim this to be better than all the other methods, but this pair can also translate while deleting, which others cannot.

Re: text alignment

2008-06-17 Thread Gandalf
On Jun 17, 7:49 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Jun 17, 11:45 am, Gandalf <[EMAIL PROTECTED]> wrote: > > > On Jun 17, 6:43 pm, Gandalf <[EMAIL PROTECTED]> wrote: > > > > Hi every one. What is the similar python WX style property for CSS > > >text-align? > > > > I need this item te

Re: text alignment

2008-06-17 Thread Gandalf
since you brought up this issue, please tell me where can I fine menual for this library? can i generate dynamic GUI from it? If not, Is there any way to generate dynamic GUI (one that can change according to the user input) with HTML-CSS- javascript similar environment? -- http://mail.python.org/m

Static memory allocation in Python

2008-06-17 Thread Eduardo Henrique Tessarioli
Hi, I am running a very simple python application and I noted that the memory allocation is something like 4,5M. This is a problem in my case, because I have to run 2 thousand process at the same time. The memory I need is 100k or less. Is there any way to set this for the python process? Regards

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Ethan Furman
Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --> 'www.example.com'.strip('cmowz.') 'example'

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Roel Schroeven
Peter Otten schreef: Ethan Furman wrote: The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) identity = "".join(map(chr, range(256))) Or identity

Re: text alignment

2008-06-17 Thread Mike Driscoll
On Jun 17, 12:59 pm, Gandalf <[EMAIL PROTECTED]> wrote: > On Jun 17, 7:49 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > > > On Jun 17, 11:45 am, Gandalf <[EMAIL PROTECTED]> wrote: > > > > On Jun 17, 6:43 pm, Gandalf <[EMAIL PROTECTED]> wrote: > > > > > Hi every one. What is the similar python

Re: text alignment

2008-06-17 Thread Mike Driscoll
On Jun 17, 1:20 pm, Gandalf <[EMAIL PROTECTED]> wrote: > since you brought up this issue, please tell me where can I fine > menual for this library? You want the manual for wxPython? Go to the download page on the Official wxPython page and get the Docs & Demos package: http://wxpython.org/downloa

Re: Removing inheritance (decorator pattern ?)

2008-06-17 Thread George Sakkis
On Jun 16, 11:10 pm, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Monday 16 June 2008 20:35:22 George Sakkis, vous avez écrit : > > > > > On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > > > George Sakkis wrote: > > > > I have a situation where one class can be customized with sev

Re: Static memory allocation in Python

2008-06-17 Thread Calvin Spealman
On Jun 17, 2008, at 2:34 PM, Eduardo Henrique Tessarioli wrote: Hi, I am running a very simple python application and I noted that the memory allocation is something like 4,5M. This is a problem in my case, because I have to run 2 thousand process at the same time. The memory I need is 100k

2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Terrence Brannon
Hello, I have written a program to draw a vescica piscis from turtle import * def main(): setup(width=400, height=400) r = 50 color("black") circle(r) color("white") forward(r) color("black") circle(r) x = raw_input('please enter a string:') if __name__ == '

Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Mensanator
On Jun 17, 2:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote: > Hello, I have written a program to draw a vescica piscis en.wikipedia.org/wiki/Vesica_piscis> > > from turtle import * > > def main(): >     setup(width=400, height=400) > >     r = 50 >     color("black") >     circle(r) >     colo

Is there a standard binary search with overridable comparisons?

2008-06-17 Thread markscottwright
I've got an ordered list of MyClasses that I want to be able to do binary searches on, but against a tuple. MyClass has valid __lt__(self, rhs) and __eq__(self, rhs) member functions that work when rhs is a tuple. This works: l = [MyClass(..), MyClass(..), ...] l.find((a,b)) But this doesn't: bi

Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Matimus
On Jun 17, 12:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote: > Hello, I have written a program to draw a vescica piscis en.wikipedia.org/wiki/Vesica_piscis> > > from turtle import * > > def main(): >     setup(width=400, height=400) > >     r = 50 >     color("black") >     circle(r) >     col

Re: UnicodeDecodeError: 'ascii' codec can't decode byte

2008-06-17 Thread Gilles Ganault
On Tue, 17 Jun 2008 09:23:28 +0200, Peter Otten <[EMAIL PROTECTED]> wrote: > Assuming that encoding is UTF-8 and that apsw can cope > with unicode, try to convert your data to unicode before > feeding it to the database api: > >> sql = "INSERT INTO mytable (col1,col2) VALUES (?,?)" > > rows = ([co

using the string functions (ex. find()) on a multi-symbol string

2008-06-17 Thread korean_dave
How can i use the find() function on a string that is composed of tons of symbols that cause errors... THis is my string: find("p, li { white-space: pre-wrap; }Connected!","margin") The tough part about this is that the string is dynamically produced. So I can't manually go into the string and e

Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Lie
On Jun 18, 2:45 am, Terrence Brannon <[EMAIL PROTECTED]> wrote: > Hello, I have written a program to draw a vescica piscis en.wikipedia.org/wiki/Vesica_piscis> > > from turtle import * > > def main(): >     setup(width=400, height=400) > >     r = 50 >     color("black") >     circle(r) >     colo

Re: text alignment

2008-06-17 Thread Gandalf
On Jun 17, 8:43 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Jun 17, 1:20 pm, Gandalf <[EMAIL PROTECTED]> wrote: > > > since you brought up this issue, please tell me where can I fine > > menual for this library? > > You want the manual for wxPython? Go to the download page on the > Official w

Re: newbie question: for loop within for loop confusion

2008-06-17 Thread John Salerno
Gabriel Genellina wrote: En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <[EMAIL PROTECTED]> escribió: takayuki wrote: I'm early on in my python adventure so I'm not there yet on the strip command nuances.I'm reading "How to think like a python programmer" first. It's great. Then "Lear

Re: using the string functions (ex. find()) on a multi-symbol string

2008-06-17 Thread John Machin
On Jun 18, 7:12 am, korean_dave <[EMAIL PROTECTED]> wrote: > How can i use the find() function on a string that is composed of tons > of symbols that cause errors... > > THis is my string: > > find(" type="text/css">p, li { white-space: pre-wrap; } style=" font-family:'MS Shell Dlg 2'; font-size:8.

Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread Diez B. Roggisch
Do you know if there is such XPath engine that can be applied to a DOM- like structure ? No. But I toyed with the idea to write one :) One way would be to take an XPath engine from an existing XML engine (ElementTree, or any other), and see what APIs it calls... and see if we cannot create a

Re: [Twisted-Python] Re-working a synchronous iterator to use Twisted

2008-06-17 Thread Jean-Paul Calderone
On Tue, 17 Jun 2008 23:10:48 +0200, Terry Jones <[EMAIL PROTECTED]> wrote: For the record, here's a followup to my own posting, with working code. The earlier untested code was a bit of a mess. The below runs fine. In case it wasn't clear before, you're pulling "results" (e.g., from a search eng

Re: using the string functions (ex. find()) on a multi-symbol string

2008-06-17 Thread John Machin
On Jun 18, 7:12 am, korean_dave <[EMAIL PROTECTED]> wrote: > How can i use the find() function on a string that is composed of tons > of symbols that cause errors... > > THis is my string: > > find(" type="text/css">p, li { white-space: pre-wrap; } style=" font-family:'MS Shell Dlg 2'; font-size:8.

Calling pcre with ctypes

2008-06-17 Thread moreati
Recently I discovered the re module doesn't support POSIX character classes: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> r = re.compile('[:alnum:]+') >>> prin

Execfile issue

2008-06-17 Thread Dan Yamins
I'm having (what I assume is) a simple problem regarding the way import and execfile interact. I apologize in advance for my naivete. Lets say I have the function: def Func1(): print dir() execfile('testfile') print dir() X and the file #file: testfile X

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-17 Thread Martin v. Löwis
> I think I have lost the thread here, sorry. So I explain again what I > mean. I think for this data structure it's important to keep all the > normal dict operations at the same speed. If you use a C > implementation vaguely similar to my pure python recipe you can > perform the del in O(1) too,

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-17 Thread Martin v. Löwis
> Well, this has become something of a rant, Indeed - and I was only asking about .byindex(n) :-) I don't know why that method is included in the PEP. Speculating myself, I assume that the PEP author wants it to be O(1). As bearophile explains, that's not possible/not a good idea. As for releas

Re: Is there a standard binary search with overridable comparisons?

2008-06-17 Thread John Machin
On Jun 18, 6:55 am, markscottwright <[EMAIL PROTECTED]> wrote: > I've got an ordered list of MyClasses that I want to be able to do > binary searches on, but against a tuple. MyClass has valid > __lt__(self, rhs) and __eq__(self, rhs) member functions that work > when rhs is a tuple. > > This work

Re: Annoying message when interrupting python scripts

2008-06-17 Thread John Machin
On Jun 18, 12:51 am, geoffbache <[EMAIL PROTECTED]> wrote: [snip] > Is this a bug? I couldn't find any code, but I imagine something like > try: > import site > except: > sys.stderr.write("import site failed; use -v for traceback\n") > > which should surely allow a KeyboardInterrupt excep

Re: 32 bit or 64 bit?

2008-06-17 Thread Phil Hobbs
[EMAIL PROTECTED] wrote: That was suggested. Problem is, that sometimes the velocities are near zero. So this solution, by itself, is not general enough. Are you sure? I sort of doubt that you're spending zillions of iterations getting closer and closer to zero. It would be worth actually

Multiprecision arithmetic library question.

2008-06-17 Thread Michael Press
I already compiled and installed the GNU multiprecision library on Mac OS X, and link to it in C programs. How do I link to the library from Python? I do not want to download and install redundant material. (I am new to Python) -- Michael Press -- http://mail.python.org/mailman/listinfo/python-

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Gabriel Genellina
En Tue, 17 Jun 2008 09:09:41 -0300, Derek Martin <[EMAIL PROTECTED]> escribió: On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote: > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)' > and 'not(id(a) == id(b))' No. Sure it is... he said "similar"... not ide

How do I create user-defined warnings?

2008-06-17 Thread Clay Hobbs
I already know how to make user-defined exceptions, like this one: class MyException(Exception): pass But for a module I'm making, I would like to make a warning (so it just prints the warning to stderr and doesn't crash the program). I have tried this: class MyWarni

Re: Decimals in python

2008-06-17 Thread Ethan Furman
[EMAIL PROTECTED] wrote: Hello. New to using Python. Python automatically round off watver i calculate using the floor function. How wud i make the exact value appear? Tried out fabs() in the math library but still confused. Cud some1 elaborate on it. [python] ---help(math.floor): Help on buil

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Asun Friere
On Jun 17, 5:33 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 17 Jun 2008 02:25:42 -0300, Lie <[EMAIL PROTECTED]> escribió: > > > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)' > > and 'not(id(a) == id(b))' > > No. ... > ... The above statement is not. A counter

Re: Annoying message when interrupting python scripts

2008-06-17 Thread Ben Finney
John Machin <[EMAIL PROTECTED]> writes: > On Jun 18, 12:51 am, geoffbache <[EMAIL PROTECTED]> wrote: > [snip] > > Is this a bug? I couldn't find any code, but I imagine something like > > try: > > import site > > except: > > sys.stderr.write("import site failed; use -v for traceback\n")

Re: How do I create user-defined warnings?

2008-06-17 Thread Hans Nowak
Clay Hobbs wrote: I already know how to make user-defined exceptions, like this one: class MyException(Exception): pass But for a module I'm making, I would like to make a warning (so it just prints the warning to stderr and doesn't crash the program). I have tried this:

One more socket programming question

2008-06-17 Thread John Salerno
I'm now experimenting with the SocketServer class. Originally I subclassed the StreamRequestHandler to make my own custom handler, but a result of this seems to be that the client socket closes after it has been used, instead of staying open. Just as a test, I decided to use BaseRequestHandler

Re: Annoying message when interrupting python scripts

2008-06-17 Thread John Machin
On Jun 18, 12:26 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > John Machin <[EMAIL PROTECTED]> writes: > > On Jun 18, 12:51 am, geoffbache <[EMAIL PROTECTED]> wrote: > > [snip] > > > Is this a bug? I couldn't find any code, but I imagine something like > > > try: > > > import site > > > except:

Re: Multiprecision arithmetic library question.

2008-06-17 Thread casevh
On Jun 17, 5:13 pm, Michael Press <[EMAIL PROTECTED]> wrote: > I already compiled and installed the GNU multiprecision library > on Mac OS X, and link to it in C programs. > How do I link to the library from Python? > I do not want to download and install redundant material. > (I am new to Python)

  1   2   >