Re: python proxy checker ,change to threaded version

2009-12-07 Thread r0g
elca wrote: > Hello ALL, > > i have some python proxy checker . > > and to speed up check, i was decided change to mutlthreaded version, > > and thread module is first for me, i was tried several times to convert to > thread version > > and look for many info, but it not so much easy for novic

Re: What is the significance of after() in this code?

2009-12-07 Thread Martin P. Hellwig
W. eWatson wrote: See Subject. def StackImages(self): self.Upload("P") self.after_id = self.master.after(1,self.GetFrameOne) If you are talking tkinter here, it is an alarm callback. See http://effbot.org/tkinterbook/widget.htm -- MPH http://blog.dcuktec.com 'If consume

Re: python proxy checker ,change to threaded version

2009-12-07 Thread elca
r0g wrote: > > elca wrote: >> Hello ALL, >> >> i have some python proxy checker . >> >> and to speed up check, i was decided change to mutlthreaded version, >> >> and thread module is first for me, i was tried several times to convert >> to >> thread version >> >> and look for many info, b

Re: Float precision and float equality

2009-12-07 Thread Steven D'Aprano
On Sun, 06 Dec 2009 14:54:37 -0800, Carl Banks wrote: > (I remember once struggling in a homework assignment over seemingly > large discrepancies in a calculation I was doing, until i realized that > the actual numbers were on the scale of 10**11, and the difference was > around 10**1, so it reall

Re: how to convert string function to string method?

2009-12-07 Thread Peter Otten
Dr. Phillip M. Feldman wrote: > I wrote a handy-dandy function (see below) called "strip_pairs" for > stripping > matching pairs of characters from the beginning and end of a string. This > function works, but I would like to be able to invoke it as a string > method > rather than as a function.

Re: how to convert string function to string method?

2009-12-07 Thread r0g
Dr. Phillip M. Feldman wrote: > I wrote a handy-dandy function (see below) called "strip_pairs" for stripping > matching pairs of characters from the beginning and end of a string. This > function works, but I would like to be able to invoke it as a string method > rather than as a function. Is t

dict.fromkeys strange behavior

2009-12-07 Thread Tsviki Hirsh
Dear list, I'm trying to create a dictionary from set of keys and values using dict.fromkeys When I type: >>>dict.fromkeys('a',50) the output is: {'a': 50} This is fine, but when I try to set the same value to a different name key: >>>dict.fromkeys('at',50) the output now is: {'a': 50, 't':

Re: how to convert string function to string method?

2009-12-07 Thread Bruno Desthuilliers
Dr. Phillip M. Feldman a écrit : I wrote a handy-dandy function (see below) called "strip_pairs" for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it as a string method rather than as a function. Is this

Re: how to convert string function to string method?

2009-12-07 Thread Steven D'Aprano
On Sun, 06 Dec 2009 22:47:48 -0800, Dr. Phillip M. Feldman wrote: > I wrote a handy-dandy function (see below) called "strip_pairs" for > stripping matching pairs of characters from the beginning and end of a > string. This function works, but I would like to be able to invoke it > as a string me

Re: dict.fromkeys strange behavior

2009-12-07 Thread Chris Rebert
On Mon, Dec 7, 2009 at 12:42 AM, Tsviki Hirsh wrote: > Dear list, > I'm trying to create a dictionary from set of keys and values using > dict.fromkeys > When I type: dict.fromkeys('a',50) > the output is: > {'a': 50} > This is fine, but when I try to set the same value to a different name key

Re: Exception classes don't follow pickle protocol, problems unpickling

2009-12-07 Thread Peter Otten
Irmen de Jong wrote: > I am puzzled why Python's exception classes don't seem to follow the > pickle protocol. To be more specific: an instance of a user defined > exception, subclassed from Exception, cannot be pickled/unpickled > correctly in the expected way. > > The pickle protocol says that:

Re: subprocess kill

2009-12-07 Thread Jean-Michel Pichavant
luca72 wrote: On 5 Dic, 03:06, Carl Banks wrote: On Dec 4, 3:44 pm, luca72 wrote: On 5 Dic, 00:14, luca72 wrote: On 5 Dic, 00:03, luca72 wrote: On 4 Dic, 23:23, Mike Driscoll wrote: On Dec 4, 3:50 pm, luca72 wrote: Hello i'm using sub

unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
Hi; I get the following error: /var/www/html/angrynates.com/cart/createCats2.py 111 112 113 ''' 114 115 createCats2() createCats2 = /var/www/html/angrynates.com/cart/createCats2.py in createCats2() 85 for standAloneStore in storePrimaryStandAlone: 86 allStores.append(stan

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Xavier Ho
Hi Victor, the .append function doesn't return anything, so it's a None. And you should have it inside the parentheses. >>> tree.append("%s%s" % ("\t" * level, name)) is probably what you're after. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: how to convert string function to string method?

2009-12-07 Thread Bruno Desthuilliers
r0g a écrit : (snip) > I've never tried it but I think it is possible to inject new methods into existing classes, see... Doesn't work for most builtin types - for both performances and sanity reasons. -- http://mail.python.org/mailman/listinfo/python-list

Two questions ( Oracle and modules )

2009-12-07 Thread Gabor Urban
Hi guys, I have two questions. 1. I have choice to introduce Python to my new employee. We are to write and application that uses databases stored partially in Oracle 10 and partially in Oracle 11. We have to execute standard SQL commands and stored procedures as well. Which is best conection / m

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: global printTree = , allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, 'presCat2': {}}] /var/www/html/angrynates.com/cart/catTree.py in printTree(allTrees=[{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, 'presCat2

Re: What is the significance of after() in this code?

2009-12-07 Thread W. eWatson
Martin P. Hellwig wrote: W. eWatson wrote: See Subject. def StackImages(self): self.Upload("P") self.after_id = self.master.after(1,self.GetFrameOne) If you are talking tkinter here, it is an alarm callback. See http://effbot.org/tkinterbook/widget.htm Very good. I rec

Re: High-performance Python websites

2009-12-07 Thread Dr. Marco
On Wed, 25 Nov 2009 21:21:25 -0800 (PST), Nick Mellor wrote : Hi, > I wasn't aware that Google used Python for running their Google groups > servers. Can you confirm that? The only place > I've seen Google explicitly use Python on their web front end is in > the Google Ads tests. > > I am impre

Re: hola

2009-12-07 Thread Chris Rebert
2009/12/6 franki fuentes cueto : > hola soy un pequeño programador y quiesiera pedirles ayuda para programar en > python, no se si me podrian mandar ejemplos para poder empezar, y como > terminarlo para que se ejecute, me entiendes , aver sime ayudan gracias Esta lista de discusión es en Inglés.

Re: Why Doesn't XP Pro Show Size, Time and Date Mod of a Created File?

2009-12-07 Thread Mensanator
On Dec 5, 11:38�pm, "W. eWatson" wrote: > I created a folder, and wrote a file to it. When I look at what files > are in it, they are correct. However, The Size, Type, and Date Mod are > not shown. Why am I missing those columns? I'm writing files with a > suffix of dat, which seem only to match u

Re: semantics of ** (unexpected/inconsistent?)

2009-12-07 Thread Albert van der Horst
In article <87eingrbh9@benfinney.id.au>, Ben Finney wrote: >Lie Ryan writes: > >> I generally do not expect operator precedence to be reliable at all > >Have another read of the thread. The OP's confusion was not over >operator precedence, but over how names resolve to values in >expressions

postgresql_autodoc in Python?

2009-12-07 Thread Wolfgang Keller
Hello, has anyone ever implemented something similar to postgresql_autodoc in Python? TIA, Sincerely, Wolfgang -- NO "Courtesy Copies" PLEASE! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to timeout when waiting for raw_input from user ?

2009-12-07 Thread Rune Strand
On Dec 5, 3:42 pm, Maxim Khitrov wrote: > I'm not talking about the Timer, I'm talking about the original > question. There's nothing (that I know of) you can do with a Timer on > Windows to interrupt a raw_input call. That is true. But if the issue here is to present a question, and await answe

Re: Organization of GUIs

2009-12-07 Thread Michael
On Dec 5, 11:50 pm, zeph wrote: > I highly recommend reading the Cocoa documentation, which has volumes > on all sorts of things like this.  Here's a link that talks about > views in that context, and should give you more ideas about well- > designed GUI layouts:http://bit.ly/6b8PYh Cool link. Th

Re: Why Can't I Delete a File I Created with Win XP?

2009-12-07 Thread John Machin
On Dec 5, 9:57 pm, "W. eWatson" wrote: [snip] >          s = self.current_path s referred to something ... >          s = "Analysis" but now s refers to "Analysis" ... at best, there is redundant & confusing code; at worst, the source of your problem. >          s = os.path.join("Analysis",s) and

Why Doesn't XP Pro Show Size, Time and Date Mod of a Created File?

2009-12-07 Thread W. eWatson
I created a folder, and wrote a file to it. When I look at what files are in it, they are correct. However, The Size, Type, and Date Mod are not shown. Why am I missing those columns? I'm writing files with a suffix of dat, which seem only to match up with video CD movie. -- http://mail.python.

Re: Why Doesn't XP Pro Show Size, Time and Date Mod of a Created File?

2009-12-07 Thread W. eWatson
Mensanator wrote: On Dec 5, 11:38�pm, "W. eWatson" wrote: I created a folder, and wrote a file to it. When I look at what files are in it, they are correct. However, The Size, Type, and Date Mod are not shown. Why am I missing those columns? I'm writing files with a suffix of dat, which seem on

Re: Are routine objects guaranteed mutable & with dictionary?

2009-12-07 Thread Duncan Booth
"Alf P. Steinbach" wrote: > The question is what guarantees or absence thereof the language > specification, PEPs, intentions, whatever gives/has. See the documentation: http://docs.python.org/3.1/reference/datamodel.html > > >> BTW, it's a function, not a "routine" > > Wikipedia is your frie

Re: python bijection

2009-12-07 Thread M.-A. Lemburg
Terry Reedy wrote: > M.-A. Lemburg wrote: > >> Integrating an easy-to-use graph library into the collections >> module (and it's C companion) is good idea. >> This would have to be written in C, though, >>> That's currently in the works, along with database backing. >>> We'd welcome any help

Re: Two questions ( Oracle and modules )

2009-12-07 Thread Michael Crute
On Mon, Dec 7, 2009 at 6:57 AM, Gabor Urban wrote: > 1. I have choice to introduce Python to my new employee. We are to > write and application that uses databases stored partially in Oracle > 10 and partially in Oracle 11. We have to execute standard SQL > commands and stored procedures as well.

Re: python bijection

2009-12-07 Thread M.-A. Lemburg
Carl Banks wrote: > On Dec 4, 4:42 pm, Lie Ryan wrote: >> On 12/5/2009 9:41 AM, Carl Banks wrote: >> >> >> >> >> >>> On Dec 4, 12:46 pm, geremy condra wrote: >>> more common than full-blown graph package). Sure, its a tree, which is also a graph. In this case it looks to me more like a

Re: What is the significance of after() in this code?

2009-12-07 Thread Neil Cerutti
On 2009-12-07, W. eWatson wrote: > See Subject. > def StackImages(self): > self.Upload("P") > self.after_id = self.master.after(1,self.GetFrameOne) It's a violation of the Law of Demeter. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Float precision and float equality

2009-12-07 Thread Mark Dickinson
On Dec 6, 7:34 pm, Anton81 wrote: > I do some linear algebra and whenever the prefactor of a vector turns > out to be zero, I want to remove it. Hmm. Comparing against zero is something of a special case. So you'd almost certainly be doing an 'if abs(x) < tol: ...' check, but the question is wh

Re: What is the significance of after() in this code?

2009-12-07 Thread Neil Cerutti
On 2009-12-07, Neil Cerutti wrote: > On 2009-12-07, W. eWatson wrote: >> See Subject. >> def StackImages(self): >> self.Upload("P") >> self.after_id = self.master.after(1,self.GetFrameOne) > > It's a violation of the Law of Demeter. Actually, I take that back. Dur. --

Re: Float precision and float equality

2009-12-07 Thread Mark Dickinson
On Dec 7, 12:16 am, David Cournapeau wrote: > If you can depend on IEEE 754 semantics, one relatively robust method > is to use the number of representable floats between two numbers. The > main advantage compared to the proposed methods is that it somewhat > automatically takes into account the a

Re: postgresql_autodoc in Python?

2009-12-07 Thread Simon Brunning
2009/12/6 Wolfgang Keller : > Hello, > > has anyone ever implemented something similar to postgresql_autodoc in Python? Dunno - what is it? -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
On Mon, Dec 7, 2009 at 7:14 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > Victor Subervi wrote: > >> >> global printTree = , allTrees = [{'prodCat1': {}, >> 'prodCat2': {}}, {'presCat1': {}, 'presCat2': {}}] >> /var/www/html/angrynates.com/cart/catTree.py < >> http://angrynates.com

Re: postgresql_autodoc in Python?

2009-12-07 Thread Jean-Michel Pichavant
Wolfgang Keller wrote: Hello, has anyone ever implemented something similar to postgresql_autodoc in Python? TIA, Sincerely, Wolfgang If by postgresql_autodoc you mean tools for generating html documentation from python code, yes. Starting from the ugliest: - pydoc - epydoc - sphinx

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Mon, Dec 7, 2009 at 7:14 AM, Jean-Michel Pichavant mailto:jeanmic...@sequans.com>> wrote: Victor Subervi wrote: global printTree = , allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, 'presCat2': {}}] /var/www/html/angr

Re: postgresql_autodoc in Python?

2009-12-07 Thread Tino Wildenhain
Am 07.12.2009 15:14, schrieb Jean-Michel Pichavant: Wolfgang Keller wrote: Hello, has anyone ever implemented something similar to postgresql_autodoc in Python? TIA, Sincerely, Wolfgang If by postgresql_autodoc you mean tools for generating html documentation from python code, yes. Starti

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
On Mon, Dec 7, 2009 at 9:36 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > Victor Subervi wrote: > > On Mon, Dec 7, 2009 at 7:14 AM, Jean-Michel Pichavant < >> jeanmic...@sequans.com > wrote: >> >>Victor Subervi wrote: >> >> >>global printT

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: printTree(aTree[name], level + 1) ... print aTree([name], level + 1) ... Traceback (most recent call last): File "", line 4, in ? TypeError: 'dict' object is not callable >>> Be cautious, you are now executing the same code ! Again, read carefully th

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Carsten Haese
Victor Subervi wrote: > I'll do my best to remember to do that from > now on to: > allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, > 'presCat2': {}}] level = 0 tree = [] for aTree in allTrees: > ... for name in sorted(aTree.keys()): > ... tree.append("%s%s"

opening a connection to quickbooks

2009-12-07 Thread jfabiani
Hi, Has anyone ever attempted to work with quickbooks in a real time fashion? I need some advise. I'm trying to work out a way to have real time updates/inserts/and queries. I'd also like not to use all the user licenses. But... I have discovered that opening a connection to quickbooks takes a l

Re: When will Python 3 be fully deployed

2009-12-07 Thread vsoler
On Dec 6, 11:53 pm, "Martin P. Hellwig" wrote: > Edward A. Falk wrote: > > > > > For development purposes, you should stick with the oldest version that will > > actually run your code.  Every time you move to a more modern version, > > you're > > leaving potential users/customers out in the col

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
On Mon, Dec 7, 2009 at 11:29 AM, Carsten Haese wrote: > Victor Subervi wrote: > > I'll do my best to remember to do that from > > now on to: > > > allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, > > 'presCat2': {}}] > level = 0 > tree = [] > for aTree in allTrees

Where is my namespace?

2009-12-07 Thread vsoler
I take the example from Mark Lutz's excellent book "Learning Python". *** In nested1.py I have: X=99 def printer(): print X *** In nested2.py I have: from nested1 import X, printer X=88 printer() What is amazing is that running nested2.py prints 99 and not 88. My questions are: 1. Using stat

Re: Where is my namespace?

2009-12-07 Thread Simon Brunning
2009/12/7 vsoler : > I take the example from Mark Lutz's excellent book "Learning Python". > > *** In nested1.py  I have: > X=99 > def printer(): print X > > *** In nested2.py  I have: > from nested1 import X, printer > X=88 > printer() > > What is amazing is that running nested2.py prints 99 and n

Re: Where is my namespace?

2009-12-07 Thread Benjamin Kaplan
On Mon, Dec 7, 2009 at 11:10 AM, vsoler wrote: > I take the example from Mark Lutz's excellent book "Learning Python". > > *** In nested1.py  I have: > X=99 > def printer(): print X > > *** In nested2.py  I have: > from nested1 import X, printer > X=88 > printer() > > What is amazing is that runni

Re: Where is my namespace?

2009-12-07 Thread Bruno Desthuilliers
vsoler a écrit : I take the example from Mark Lutz's excellent book "Learning Python". *** In nested1.py I have: X=99 def printer(): print X *** In nested2.py I have: from nested1 import X, printer X=88 printer() What is amazing is that running nested2.py prints 99 and not 88. It's "amazin

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Rami Chowdhury
On Mon, Dec 7, 2009 at 08:01, Victor Subervi wrote: > On Mon, Dec 7, 2009 at 11:29 AM, Carsten Haese > wrote: >> >> Victor Subervi wrote: >> > I'll do my best to remember to do that from >> > now on to: >> > >> allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, >> > 'presCat2': {

Re: python bijection

2009-12-07 Thread geremy condra
On Mon, Dec 7, 2009 at 7:51 AM, M.-A. Lemburg wrote: > Terry Reedy wrote: >> M.-A. Lemburg wrote: >> >>> Integrating an easy-to-use graph library into the collections >>> module (and it's C companion) is good idea. >>> > This would have to be written in C, though, That's currently in the

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Carsten Haese
Victor Subervi wrote: > Well, if you could point me in the right direction, it would be > appreciated. I've tried googling this with no luck. Apparently, "expand" > is not a well-documented term in python and, of course, it's an > often-used term in English, which further confuses the issue. Yes, I

Re: python bijection

2009-12-07 Thread M.-A. Lemburg
geremy condra wrote: > On Mon, Dec 7, 2009 at 7:51 AM, M.-A. Lemburg wrote: >> Terry Reedy wrote: >>> M.-A. Lemburg wrote: >>> Integrating an easy-to-use graph library into the collections module (and it's C companion) is good idea. >> This would have to be written in C, though,

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
On Mon, Dec 7, 2009 at 12:40 PM, Rami Chowdhury wrote: > Coming from PHP, > Wash your mouth out with soap, Rami! I might not be a good programmer, but I'm loyal to the Flying Circus. I only did one job, my first one, in PHP before I became "enlightened" :)) > I can see why you might be confused

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Victor Subervi
On Mon, Dec 7, 2009 at 12:52 PM, Carsten Haese wrote: > Victor Subervi wrote: > > Well, if you could point me in the right direction, it would be > > appreciated. I've tried googling this with no luck. Apparently, "expand" > > is not a well-documented term in python and, of course, it's an > > oft

Re: python bijection

2009-12-07 Thread geremy condra
On Mon, Dec 7, 2009 at 12:05 PM, M.-A. Lemburg wrote: > geremy condra wrote: >> On Mon, Dec 7, 2009 at 7:51 AM, M.-A. Lemburg wrote: >>> Terry Reedy wrote: M.-A. Lemburg wrote: > Integrating an easy-to-use graph library into the collections > module (and it's C companion) is goo

IO Gurus: what are the differences between these two methods?

2009-12-07 Thread dpapathanasiou
I have two methods for writing binaries files: the first works with data received by a server corresponding to a file upload, and the second works with data sent as email attachments. The odd thing is, they're not interchangeable: if I use the first one to saved data parsed from an email attachmen

Re: IO Gurus: what are the differences between these two methods?

2009-12-07 Thread Joe Riopel
On Mon, Dec 7, 2009 at 12:12 PM, dpapathanasiou wrote: > I have two methods for writing binaries files: the first works with > data received by a server corresponding to a file upload, and the > second works with data sent as email attachments. > > The odd thing is, they're not interchangeable: if

Re: how to convert string function to string method?

2009-12-07 Thread Terry Reedy
Steven D'Aprano wrote: On Sun, 06 Dec 2009 22:47:48 -0800, Dr. Phillip M. Feldman wrote: I wrote a handy-dandy function (see below) called "strip_pairs" for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke

Re: python proxy checker ,change to threaded version

2009-12-07 Thread Terry Reedy
r0g wrote: The trick to threads is to create a subclass of threading.Thread, define the 'run' function and call the 'start()' method. I find threading quite generally useful so I created this simple generic function for running things in threads... Great idea. Thanks for posting this. def ru

Re: Generators.

2009-12-07 Thread Jorge Cardona
2009/12/7 Lie Ryan : > On 12/7/2009 7:22 AM, Jorge Cardona wrote: >> >> Hi, >> >> I was trying to create a function that receive a generator and return >> a list but that each elements were computed in a diferent core of my >> machine. I start using islice function in order to split the job in a >>

Re: Python3: Sane way to deal with broken encodings

2009-12-07 Thread Johannes Bauer
Bruno Desthuilliers schrieb: >> Is that possible? If so, how? > > This might get you started: > > """ help(str.decode) > decode(...) > S.decode([encoding[,errors]]) -> object Hmm, this would work nicely if I called "decode" explicitly - but what I'm doing is: #!/usr/bin/python3 for li

Re: Python3: Sane way to deal with broken encodings

2009-12-07 Thread Benjamin Kaplan
On Mon, Dec 7, 2009 at 2:16 PM, Johannes Bauer wrote: > Bruno Desthuilliers schrieb: > >>> Is that possible? If so, how? >> >> This might get you started: >> >> """ > help(str.decode) >> decode(...) >>     S.decode([encoding[,errors]]) -> object > > Hmm, this would work nicely if I called "dec

unittest buffing output on windows?

2009-12-07 Thread Roy Smith
I'm running 2.5.1. I've got a test suite that takes about 15 minutes to complete. On my unix boxes, as each test case executes, it prints out a line (I'm using unittest.TextTestRunner(verbosity=2)) of status, but on my windows box (running under cygwin), it buffers everything until the entire tes

Re: Where is my namespace?

2009-12-07 Thread vsoler
On Dec 7, 5:39 pm, Benjamin Kaplan wrote: > On Mon, Dec 7, 2009 at 11:10 AM, vsoler wrote: > > I take the example from Mark Lutz's excellent book "Learning Python". > > > *** In nested1.py  I have: > > X=99 > > def printer(): print X > > > *** In nested2.py  I have: > > from nested1 import X, pri

Graph library for Python (was: Re: python bijection)

2009-12-07 Thread M.-A. Lemburg
geremy condra wrote: > How interested are you in a C port of graphine? I haven't had > any specific requests for it, but if its something you need I > can shuffle it towards the top of the to do pile. There are two main reasons for a C implementation: 1. performance 2. memory footprint These

Re: dict.fromkeys strange behavior

2009-12-07 Thread Terry Reedy
Tsviki Hirsh wrote: >>>dict.fromkeys('at',50) {'a': 50, 't': 50} This is obviously not what I wanted. Not obvious at all. It is precisely what you asked for ;-) Please read the doc: 5.8. Mapping Types — dict "classmethod fromkeys(seq[, value]) Create a new dictionary with keys from seq and

Re: Two questions ( Oracle and modules )

2009-12-07 Thread Terry Reedy
Gabor Urban wrote: Hi guys, 2. We have tp write a module that will be imported a couple of places. Though we must be sure, this module's initialization is performed only once. How can we implement this? I do not know what to google for. There are two ways to have one file executed twice

Re: unittest buffing output on windows?

2009-12-07 Thread Dave Angel
Roy Smith wrote: I'm running 2.5.1. I've got a test suite that takes about 15 minutes to complete. On my unix boxes, as each test case executes, it prints out a line (I'm using unittest.TextTestRunner(verbosity=2)) of status, but on my windows box (running under cygwin), it buffers everything u

question about imports in a class

2009-12-07 Thread J
Just a little newbie confusion about OS imports... Why does this give me an error: class Windows: def __init__(self): ''' Constructor ''' import os self.dmidecodePath="" #final path to dmidecode binary def parseDMI(self): # First, find dmi

Re: python proxy checker ,change to threaded version

2009-12-07 Thread Rhodri James
On Mon, 07 Dec 2009 18:21:23 -, Terry Reedy wrote: r0g wrote: The trick to threads is to create a subclass of threading.Thread, define the 'run' function and call the 'start()' method. I find threading quite generally useful so I created this simple generic function for running things in

Re: question about imports in a class

2009-12-07 Thread Diez B. Roggisch
J schrieb: Just a little newbie confusion about OS imports... Why does this give me an error: class Windows: def __init__(self): ''' Constructor ''' import os self.dmidecodePath="" #final path to dmidecode binary def parseDMI(self): # Fi

Re: question about imports in a class

2009-12-07 Thread J
On Mon, Dec 7, 2009 at 16:13, J wrote: > But why does importing in the init not make os available to every > other function in the class?  Do I have to import OS into every > function like this: > > class ClassA(): > >    def func1(self): >        import os > >    def func2(self): >        import

Re: question about imports in a class

2009-12-07 Thread Diez B. Roggisch
J schrieb: On Mon, Dec 7, 2009 at 16:13, J wrote: But why does importing in the init not make os available to every other function in the class? Do I have to import OS into every function like this: class ClassA(): def func1(self): import os def func2(self): import os

Re: question about imports in a class

2009-12-07 Thread Rhodri James
On Mon, 07 Dec 2009 21:13:25 -, J wrote: Just a little newbie confusion about OS imports... Why does this give me an error: It's generally helpful to say *what* error you get, including the traceback. Fortunately the source code is enough this time. class Windows: def __init__

Re: question about imports in a class

2009-12-07 Thread J
On Mon, Dec 7, 2009 at 16:57, Diez B. Roggisch wrote: >> if I put the import at the beginning of the class, it just dawned on >> me that perhaps I still have to explicitly call the function by class: >> >> sysinfo.py >> >> class myclass(): >>    import os >>    def findDMIDecode(self): >>        

Re: python proxy checker ,change to threaded version

2009-12-07 Thread Terry Reedy
Rhodri James wrote: On Mon, 07 Dec 2009 18:21:23 -, Terry Reedy wrote: def run(self): result = func(*func_args) # matching run_in_thread param names callback(result, *callback_args) Neat, but I think you mean if callback is not None: callback(res

Re: Where is my namespace?

2009-12-07 Thread Steven D'Aprano
On Mon, 07 Dec 2009 16:25:39 +, Simon Brunning wrote: > 2009/12/7 vsoler : [...] > If you do "from blah import" the imported module itself isn't bound to > any name in the importing module - you can't get at it at all. Not quite -- you can get to it if you're willing to do some more work. >>

Re: Graph library for Python (was: Re: python bijection)

2009-12-07 Thread geremy condra
On Mon, Dec 7, 2009 at 2:51 PM, M.-A. Lemburg wrote: > geremy condra wrote: >> How interested are you in a C port of graphine? I haven't had >> any specific requests for it, but if its something you need I >> can shuffle it towards the top of the to do pile. > > There are two main reasons for a C

Re: question about imports in a class

2009-12-07 Thread Rhodri James
On Mon, 07 Dec 2009 22:18:49 -, J wrote: On Mon, Dec 7, 2009 at 16:57, Diez B. Roggisch wrote: if I put the import at the beginning of the class, it just dawned on me that perhaps I still have to explicitly call the function by class: sysinfo.py class myclass(): import os def f

Re: question about imports in a class

2009-12-07 Thread Steven D'Aprano
On Mon, 07 Dec 2009 16:53:46 -0500, J wrote: > A little more education and playing around and I'm still not quite sure > how to do this... > > for the class i'm writing, I want to import os, sys and wmi globally for > the class... The best advice is Do Not Do It That Way. Just do your imports at

How decoupled are the Python frameworks?

2009-12-07 Thread shocks
Hi I'm getting back into Python after a long break. I've been developing large enterprise apps solely with Adobe Flex (ActionScript) for the past couple years. During that time I've used a number of 'MVC' frameworks to glue the bits together - among them Cairngorm, a modified implementation of C

Re: Float precision and float equality

2009-12-07 Thread Carl Banks
On Dec 7, 10:53 am, dbd wrote: > On Dec 7, 4:28 am, sturlamolden wrote: > > > ... > > > You don't understand this at all do you? > > > If you have a sine wave with an amplitude less than the truncation > > error, it will always be approximately equal to zero. > > > Numerical maths is about approx

Re: Float precision and float equality

2009-12-07 Thread sturlamolden
On 7 Des, 06:43, dbd wrote: > If you have > samples of a sine wave with peak amplitude of one half eps, the "abs(x- > y) < eps" test would report all values on the sine wave as equal to > zero. This would not be correct. You don't understand this at all do you? If you have a sine wave with an a

Re: Float precision and float equality

2009-12-07 Thread dbd
On Dec 7, 4:28 am, sturlamolden wrote: > ... > > You don't understand this at all do you? > > If you have a sine wave with an amplitude less than the truncation > error, it will always be approximately equal to zero. > > Numerical maths is about approximations, not symbolic equalities. > > > 1.0 +

Re: question about imports in a class

2009-12-07 Thread Diez B. Roggisch
J schrieb: On Mon, Dec 7, 2009 at 16:57, Diez B. Roggisch wrote: if I put the import at the beginning of the class, it just dawned on me that perhaps I still have to explicitly call the function by class: sysinfo.py class myclass(): import os def findDMIDecode(self): for r,d,f i

Re: Where is my namespace?

2009-12-07 Thread Simon Brunning
2009/12/7 Steven D'Aprano : > On Mon, 07 Dec 2009 16:25:39 +, Simon Brunning wrote: >> If you do "from blah import" the imported module itself isn't bound to >> any name in the importing module - you can't get at it at all. > > Not quite -- you can get to it if you're willing to do some more wo

Re: Graph library for Python (was: Re: python bijection)

2009-12-07 Thread Steven D'Aprano
On Mon, 07 Dec 2009 17:23:24 -0500, geremy condra wrote: >>  * Graph.__iter__ could be mapped to an iterator using >>   the fastest traversal method for the graph nodes (ie. order does not >>   matter, it's only important that all nodes are found as fast as >>   possible) > > Again, it seems amb

Re: Graph library for Python (was: Re: python bijection)

2009-12-07 Thread geremy condra
On Mon, Dec 7, 2009 at 5:48 PM, Steven D'Aprano wrote: > On Mon, 07 Dec 2009 17:23:24 -0500, geremy condra wrote: > > >>>  * Graph.__iter__ could be mapped to an iterator using >>>   the fastest traversal method for the graph nodes (ie. order does not >>>   matter, it's only important that all nod

Duplicates of third-party libraries (was: When will Python 3 be fully deployed)

2009-12-07 Thread Ben Finney
"Martin P. Hellwig" writes: > If the fear of customers disatification prevents you from using a > certain version of X, you should consider a deployment strategy that > cuts out dependencies as much as possible. Although this will result > in a larger end package and possible high amount of dupli

Re: Graph library for Python

2009-12-07 Thread M.-A. Lemburg
geremy condra wrote: > On Mon, Dec 7, 2009 at 2:51 PM, M.-A. Lemburg wrote: >> geremy condra wrote: >>> How interested are you in a C port of graphine? I haven't had >>> any specific requests for it, but if its something you need I >>> can shuffle it towards the top of the to do pile. >> >> There

Re: python proxy checker ,change to threaded version

2009-12-07 Thread r0g
Terry Reedy wrote: > r0g wrote: > >> The trick to threads is to create a subclass of threading.Thread, define >> the 'run' function and call the 'start()' method. I find threading quite >> generally useful so I created this simple generic function for running >> things in threads... > > Great ide

test if an input string starts with a python expression

2009-12-07 Thread Torsten Mohr
Hi, i'd like to test if an input string starts with a python expression and also where that expression ends. An example: a_func(3*7, '''abc''') +5 pls some more The first part until (inclusive) the 5 should be found as an expression and the length of that string should also be detected. Backg

Re: python proxy checker ,change to threaded version

2009-12-07 Thread r0g
Terry Reedy wrote: > r0g wrote: > >> The trick to threads is to create a subclass of threading.Thread, define >> the 'run' function and call the 'start()' method. I find threading quite >> generally useful so I created this simple generic function for running >> things in threads... > > Great ide

Re: python proxy checker ,change to threaded version

2009-12-07 Thread r0g
Rhodri James wrote: > On Mon, 07 Dec 2009 18:21:23 -, Terry Reedy wrote: > >> r0g wrote: >> >>> The trick to threads is to create a subclass of threading.Thread, define >>> the 'run' function and call the 'start()' method. I find threading quite >>> generally useful so I created this simple g

Re: test if an input string starts with a python expression

2009-12-07 Thread zeph
It sort of sounds like you want a templating system: http://wiki.python.org/moin/Templating -- http://mail.python.org/mailman/listinfo/python-list

Re: question about imports in a class

2009-12-07 Thread r0g
Diez B. Roggisch wrote: > J schrieb: >> On Mon, Dec 7, 2009 at 16:57, Diez B. Roggisch >> wrote: >> if I put the import at the beginning of the class, it just dawned on me that perhaps I still have to explicitly call the function by class: > I'm not annoyed. I just wonder from what

Fwd: Request for solution

2009-12-07 Thread 74yrs old
-- Forwarded message -- From: Sjoerd Mullender Date: Mon, Dec 7, 2009 at 11:57 PM Subject: Re: Request for solution To: 74yrs old Cc: python-list-ow...@python.org Please send this to python-list@python.org, not to python-list-ow...@python.org. The latter address is only to send

  1   2   >