Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Peter Otten
Joel Hedlund wrote: > There's one thing about dictionaries and __hash__() methods that puzzle > me. I have a class with several data members, one of which is 'name' (a > str). I would like to store several of these objects in a dict for quick > access ({name:object} style). Now, I was thinking tha

Re: stripping unwanted chars from string

2006-05-03 Thread Edward Elliott
Bryan wrote: > >>> keepchars = set(string.letters + string.digits + '-.') Now that looks a lot better. Just don't forget the underscore. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Defining class methods outside of classes

2006-05-03 Thread Peter Otten
Lord Landon wrote: > Hi, I'm working on a bot written in python. It will consist of a > mostly empty class that will then call a loader which in turn defines > functions and adds them to the class. At the moment, I do this by > using execfile(file,globals()) and calling a load(bot) method defined

Re: basic python programing

2006-05-03 Thread Terry Hancock
gregarican wrote: >Ravi Teja wrote: > >>How To Ask Questions The Smart Way >>http://www.catb.org/~esr/faqs/smart-questions.html >> >> > >Actual the parent post on the thread wasn't asking a question. They >were making a somewhat puzzling dangling statement. > >"here we discuss the most basic c

Re: Playability of a file in windows media player

2006-05-03 Thread Roger Upole
The below code will catch the OnError event that's triggered when you specify a bad URL. import win32com.client class wmpevents: def OnOpenStateChange(self, NewState): """Sent when the control changes OpenState""" print 'OnOpenStateChange', NewState if NewState==win32co

Re: stripping unwanted chars from string

2006-05-03 Thread Edward Elliott
John Machin wrote: > [expletives deleted] and it was wrong anyway (according to your > requirements); > using \w would keep '_' which is *NOT* alphanumeric. Actually the perl is correct, the explanation was the faulty part. When in doubt, trust the code. Plus I explicitly allowed _ further down,

Re: stripping unwanted chars from string

2006-05-03 Thread Bryan
> >>> keepchars = set(alphabet + alphabet.upper() + '1234567890-.') or >>> keepchars = set(string.letters + string.digits + '-.') bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: stripping unwanted chars from string

2006-05-03 Thread John Machin
On 4/05/2006 1:36 PM, Edward Elliott wrote: > I'm looking for the "best" way to strip a large set of chars from a filename > string (my definition of best usually means succinct and readable). I > only want to allow alphanumeric chars, dashes, and periods. This is what I > would write in (b

Re: Newbie question on code vetting

2006-05-03 Thread Robert Kern
[EMAIL PROTECTED] wrote: > Hi. > > I have visited the Python web site and read some information on who the > commiters are and how to go about submitting code to them, but I have not > been able to locate any information regarding the process for vetting the > code to identify any possible IP infr

Re: pythonic way to sort

2006-05-03 Thread Jay Parlar
On May 4, 2006, at 12:12 AM, [EMAIL PROTECTED] wrote: > hi > I have a file with columns delimited by '~' like this: > > 1SOME STRING ~ABC~12311232432D~20060401~ > 2SOME STRING ~DEF~13534534543C~20060401~ > 3SOME STRING ~ACD~14353453554G~20060401~ > > . >

Re: Newbie question on code vetting

2006-05-03 Thread william.boquist
Edward, I agree with your point, which is why I asked the question. Risk cannot be eliminated, but it can be understood and managed so that useful work can still be done. If there is any way I can find out what the commiters do prior to reaching a decision to accept or reject a particular submissi

Re: pythonic way to sort

2006-05-03 Thread Robert Kern
[EMAIL PROTECTED] wrote: > hi > I have a file with columns delimited by '~' like this: > > 1SOME STRING ~ABC~12311232432D~20060401~ > 2SOME STRING ~DEF~13534534543C~20060401~ > 3SOME STRING ~ACD~14353453554G~20060401~ > > . > > What is the pythonic way

pythonic way to sort

2006-05-03 Thread micklee74
hi I have a file with columns delimited by '~' like this: 1SOME STRING ~ABC~12311232432D~20060401~ 2SOME STRING ~DEF~13534534543C~20060401~ 3SOME STRING ~ACD~14353453554G~20060401~ . What is the pythonic way to sort this type of structured text file? Sa

Re: python strings

2006-05-03 Thread Bryan
Gerhard Häring wrote: > Python 2.4.2 (#2, Sep 30 2005, 21:19:01) > [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. s = "\x000" s[0] == chr(0) > True > > - -- Gerhard this works too :) >>> s =

Fwd: what is the 'host' for SMTP?

2006-05-03 Thread Marco Carvalho
Uh, I don't sent to list :P -- Forwarded message -- From: Marco Carvalho <[EMAIL PROTECTED]> Date: May 4, 2006 12:45 AM Subject: Re: what is the 'host' for SMTP? To: John Salerno <[EMAIL PROTECTED]> On 5/3/06, John Salerno <[EMAIL PROTECTED]> wrote: > Steve R. Hastings wrote: > >

RE: Packet finding and clicking...

2006-05-03 Thread Delaney, Timothy (Tim)
Grant Edwards wrote: > On 2006-05-04, klauts <[EMAIL PROTECTED]> wrote: > >> anyone have any help on this subjecT? > > I use tcpdump or ethereal for packet finding. > > For clicking, I use a logitech optical wheel mouse for desktops > or the integrated touchpoint/touchpad on my IBM ThinkPad. O

stripping unwanted chars from string

2006-05-03 Thread Edward Elliott
I'm looking for the "best" way to strip a large set of chars from a filename string (my definition of best usually means succinct and readable). I only want to allow alphanumeric chars, dashes, and periods. This is what I would write in Perl (bless me father, for I have sinned...): $filename =~

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
Thank you all for the great info and education. rick -- http://mail.python.org/mailman/listinfo/python-list

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
Grant > Having sleep() take orders of magnitude longer than it should I seen a few times where sleep returns after some seconds or even after tens of seconds (my code above check for that). But most of the time it gets stuck forever. Olaf -- http://mail.python.org/mailman/listinfo/python-list

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Grant Edwards
On 2006-05-04, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Please try. > > The sleep statement does not return! Never, or does it just take a long time? > And this should not happen. Dude, it's MS Windows. It does all _sorts_ of stuff that it shouldn't. Having sleep() take orders of magnit

Re: Packet finding and clicking...

2006-05-03 Thread Grant Edwards
On 2006-05-04, klauts <[EMAIL PROTECTED]> wrote: > anyone have any help on this subjecT? I use tcpdump or ethereal for packet finding. For clicking, I use a logitech optical wheel mouse for desktops or the integrated touchpoint/touchpad on my IBM ThinkPad. -- Grant Edwards g

Re: Any useful benefit to a tiny OS written in Python?

2006-05-03 Thread James Stroud
[EMAIL PROTECTED] wrote: > I was curious if there was any benefit to having an OS written > in Python. > > The only benefit I can think of is that maybe Python is easier > to audit for security bugs than C is. > > > Any other benefits? > > Chris > http://unununium.org/ -- James Stroud UCLA-

Re: This coding style bad practise?

2006-05-03 Thread Heiko Wundram
Am Donnerstag 04 Mai 2006 01:04 schrieb Martin P. Hellwig: > Because of: > id = IDGenerator("01",99) > id() > > > > Traceback (most recent call last): > > File "", line 1, in ? > > id() > > TypeError: 'IDGenerator' object is not callable > > But i do appreciate your comment, thanks!

Any useful benefit to a tiny OS written in Python?

2006-05-03 Thread [EMAIL PROTECTED]
I was curious if there was any benefit to having an OS written in Python. The only benefit I can think of is that maybe Python is easier to audit for security bugs than C is. Any other benefits? Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
Tim > I didn't run it for hours ;-) Please try. The sleep statement does not return! And this should not happen. The code above does nothing special or unusual. The problem only occurs if 2 threads use the sleep statement and hyper-threading is enabled. We discovered this bug perhaps a year

Re: Packet finding and clicking...

2006-05-03 Thread klauts
anyone have any help on this subjecT? -- http://mail.python.org/mailman/listinfo/python-list

Re: Gettings subdirectories

2006-05-03 Thread Adonis
Florian Lindner wrote: > Hello, > how can I get all subdirectories of a given directories? os.listdir() gives > me all entries and I've found no way to tell if an object is a file or a > directory. > > Thanks, > > Florian Here is a quick hack: import os import os.path givenDir = "/" listing =

Re: scope of variables

2006-05-03 Thread Rob E
> is the code below correct? > > b = 3 > def adding(a) > print a + b > > it seams not to see the up-level scope where b is defined. Yes except for the missing : at the end of the "def" line. Rob -- http://mail.python.org/mailman/listinfo/python-list

Fastest quoting

2006-05-03 Thread Ivan Voras
What is the fastest way (execution speed) to backslash-escape characters from a specific set? Specifically: \r, \n and \0? (i.e. I need "some\r\nstring\0" to become "some\\r\\nstring\\0") -- http://mail.python.org/mailman/listinfo/python-list

OT: CAD

2006-05-03 Thread Usenet Loser
I am completely empty and shallow. I use no CAD package at all now. I would like to buy one for recreational use, instead of watching American Idol. What CAD package has integrated FEA and rigid body calculations so that I could design a bar stool, and easily determine: a) if it is top-heavy, so

Re: Can Python kill a child process that keeps on running?

2006-05-03 Thread I. Myself
Dennis Lee Bieber wrote: > On Tue, 02 May 2006 17:00:42 GMT, "I. Myself" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >> I'm an intermediate Python programmer. Can you explain to me how ctypes >> will let me kill a child process? >> >> > ctypes allows you

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
Sorry that I was unclear. I sorta know how os.walk works. It's the .next() trick that I had never seen before. For instance, if you run that statement without the .next() on it, it says "Too many items to unpack" but with the .next() it stops it somehow, right where I want it to stop. It's an ite

Re: Gettings subdirectories

2006-05-03 Thread Edward Elliott
Ben Finney wrote: > We must be reading different Python websites. > > walk(top[, topdown=True [, onerror=None]]) > > walk() generates the file names in a directory tree, by walking > the tree either top down or bottom up. For each directory in the > tree rooted at directory top (

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: > As I understand it, the point was not what the code does, but to give > a sample input (a Python program) for the "simple text processor" you > described to wade through. Ah, well then, there's no need for a full-blown parser. It should suffice to recognize a class definition

Re: Python & SSL

2006-05-03 Thread Edward Elliott
Sybren Stuvel wrote: > I'm curious. Can you give me an example? AFAIK you need to know who > you're talking to before transmitting sensitive information, otherwise > you could be talking to anybody - and that's just what you wanted to > prevent with the encryption, right? Encryption has multiple m

Re: milliseconds are not stored in the timestamp KInterbasDB + Firebird

2006-05-03 Thread Petr Jakes
to provide feedback: David Rushby (the autor of the KInterbasDB) has solved the problem applying such a future in the code. Thank you David. snapshots: http://kinterbasdb.sourceforge.net/snapshots/3.2/kinterbasdb-3.2_pre_20060503.src.tar.gz http://kinterbasdb.sourceforge.net/snapshots/3.2/kinterb

Re: This coding style bad practise?

2006-05-03 Thread Martin P. Hellwig
keirr wrote: > Martin P. Hellwig wrote: >> Hi all, >> >> I created a class which creates a relative unique id string, now my >> program just works fine and as expected but somehow I get the feeling >> that I misused the __repr__ since I guess people expect to 'execute' a >> function in an instance

Re: scope of variables

2006-05-03 Thread Ryan Forsythe
Gary Wessle wrote: > the example was an in-accuretlly representation of a the problem I am > having. my apologies. > > a = [] > def prnt(): >print len(a) > prnt > > > I expect to get 0 "the length of list a" You want prnt(), not prnt: >>> a = [] >>> def prnt(): ... print len(a) ...

Re: Gettings subdirectories

2006-05-03 Thread Ben Finney
"BartlebyScrivener" <[EMAIL PROTECTED]> writes: > >> root, dirnames, filenames = os.walk(r"C:\").next() > > Wow. How does that work? Just point me to where I can read about it. I > don't see it under os.walk. We must be reading different Python websites. walk(top[, topdown=True [, onerror=

Re: This coding style bad practise?

2006-05-03 Thread Martin P. Hellwig
Bruno Desthuilliers wrote: > > Why not just use the call operator instead ? ie: > > >>> id = IDGenerator(...) > >>> id() > 01_20060424_151903_1 > >>> id() > 01_20060424_151905_2 > Because of: id = IDGenerator("01",99) id() > Traceback (most recent call last): > File "", line 1,

Re: __init__.py, __path__ and packaging

2006-05-03 Thread Scott David Daniels
Sandro Dentella wrote: > The structure of my package: > > python/ > `-- dbg/ >|-- __init__.py >`-- lib >|-- __init__.py >|-- debug.py >`-- gtk_dbg.py > > my sys.path includes 'python' and I wanted that the content of debug.py was > simply included by: 'import dbg',

Re: scope of variables

2006-05-03 Thread Leif K-Brooks
Gary Wessle wrote: > the example was an in-accuretlly representation of a the problem I am > having. my apologies. > > a = [] > def prnt(): >print len(a) > prnt > > > I expect to get 0 "the length of list a" Python requires parenthesis to call a function. >>> a = [] >>> def prnt(

Re: scope of variables

2006-05-03 Thread Lord Landon
Try >>> prnt() o.o' On 04 May 2006 08:25:01 +1000, Gary Wessle <[EMAIL PROTECTED]> wrote: > "Steve R. Hastings" <[EMAIL PROTECTED]> writes: > > > On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote: > > > b = 3 > > > def adding(a) > > > print a + b > > > > > > it seams not to see the up-leve

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Ben Finney
Edward Elliott <[EMAIL PROTECTED]> writes: > Marc 'BlackJack' Rintsch wrote: > > Edward Elliott wrote: > >> I can prove that assertion too: make a simple text processor that > >> reads Python source code and outputs the same source code with > >> only one change: insert the string 'self" as the fi

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
>> root, dirnames, filenames = os.walk(r"C:\").next() Wow. How does that work? Just point me to where I can read about it. I don't see it under os.walk. That's cool. Thanks, Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: Mutable String

2006-05-03 Thread Scott David Daniels
Pierre Thibault wrote: > I would like to know if there are modules offering a mutable version of > strings in Python? Nope. But, for some uses: import array stringish = array.array{'c', 'Whatever, kiddo!') stringish[-6:-1] = array.array('c', 'dudes') print stringish.tostring()

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Marc 'BlackJack' Rintsch wrote: > Edward Elliott wrote: >> I can prove that assertion too: make a simple text processor that reads >> Python source code and outputs the same source code with only one change: >> insert the string 'self" as the first parameter of every "def >> somemethod". Next run t

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: > My basis for rejecting the proposal is that it claims to offer net > simplicity, yet it breaks at least two of the admonishments that > simplify Python. As do other features of Python. Or did you forget the follow-up to the special cases "rule"? Special cases aren't special

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: > Edward Elliott <[EMAIL PROTECTED]> writes: >> As long as we're trotting out aphorisms > > The ones I quoted were from Python. > >>> import this Yes I know where it's from. > You've misunderstood "don't repeat yourself". It advocates *one* > definition of any given thing i

Re: scope of variables

2006-05-03 Thread Gary Wessle
"Steve R. Hastings" <[EMAIL PROTECTED]> writes: > On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote: > > b = 3 > > def adding(a) > > print a + b > > > > it seams not to see the up-level scope where b is defined. > > Assuming you put a ':' after the "def adding(a)", this should work in >

Re: Because of multithreading semantics, this is not reliable.

2006-05-03 Thread Edward Elliott
Tim Peters wrote: > That puts them in the > "attractive nuisance" category for many people. Argh. That gives me bad flashbacks to my torts final from Mon, which had a bona-fide "attractive nuisance" problem on it. Damn you, Tim Peters! ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of variables

2006-05-03 Thread Ben Finney
Gary Wessle <[EMAIL PROTECTED]> writes: > is the code below correct? It's best to post an example that you've tried yourself, and that is small but completely demonstrates the issue in question. > b = 3 > def adding(a) > print a + b This, for example, would fail the syntax check (the 'def'

Re: Python & SSL

2006-05-03 Thread Sybren Stuvel
John J. Lee enlightened us with: > Of course, remembering that the first thing to ask in response to > "is it secure?" is "against what?", for lots of purposes it just > doesn't matter that it ignores certificates. I'm curious. Can you give me an example? AFAIK you need to know who you're talking

Re: This coding style bad practise?

2006-05-03 Thread Carl Friedrich Bolz
Bruno Desthuilliers wrote: > Martin P. Hellwig a écrit : >>I created a class which creates a relative unique id string, now my >>program just works fine and as expected but somehow I get the feeling >>that I misused the __repr__ since I guess people expect to 'execute' a >>function in an instanc

Re: This coding style bad practise?

2006-05-03 Thread Carl Friedrich Bolz
Bruno Desthuilliers wrote: > Martin P. Hellwig a écrit : >>I created a class which creates a relative unique id string, now my >>program just works fine and as expected but somehow I get the feeling >>that I misused the __repr__ since I guess people expect to 'execute' a >>function in an instanc

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Ben Finney
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > Ben Finney a écrit : > > So now you're proposing that this be a special case when a > > function is declared by that particular syntax, and it should be > > different to when a function is created outside the class > > definition and added as a met

Re: Python & SSL

2006-05-03 Thread John J. Lee
Benji York <[EMAIL PROTECTED]> writes: > James Stroud wrote: > > I have been trying to make an https client with python > > You probably don't want to use the standard library for HTTPS; here's a > quote from the socket module docs about SSL: > > Warning: This does not do any certificate

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Ben Finney
Edward Elliott <[EMAIL PROTECTED]> writes: > As long as we're trotting out aphorisms The ones I quoted were from Python. >>> import this > how about DRY: Don't Repeat Yourself. The rule couldn't be clearer: > don't repeat your SELF. ;) Yet that's exactly what explicitly > declaring self do

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Tim Peters
>> What do you mean "stop responding"? [EMAIL PROTECTED] > Both threads print their thread numbers (either 1 or 2) approximately > every 10 seconds. However, after a while (minutes to hours) both > programs (see above) hang! Where "hang" means they stop printing. > Pressing ctrl-c (after the pr

Defining class methods outside of classes

2006-05-03 Thread Lord Landon
Hi, I'm working on a bot written in python. It will consist of a mostly empty class that will then call a loader which in turn defines functions and adds them to the class. At the moment, I do this by using execfile(file,globals()) and calling a load(bot) method defined in every "module" which take

Re: scope of variables

2006-05-03 Thread Steve R. Hastings
On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote: > b = 3 > def adding(a) > print a + b > > it seams not to see the up-level scope where b is defined. Assuming you put a ':' after the "def adding(a)", this should work in recent versions of Python. In Python 2.0 and older, this will not

Re: Because of multithreading semantics, this is not reliable.

2006-05-03 Thread OlafMeding
Tim and Grant >>> if q.empty(): return >>> Of course you explanation is understood and ideally should be included as a note in the Python documentation. And the "not reliable" should be removed from the documentation! Anyway, many thanks for your explanations (I feel "safer" now).

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
Serge > I got bored and tried to stop it with ctrl-c ... Yes, you have to use the ctrl-break key to stop the first program. And neither program every hangs on a single core CPU. It also does not hang on a hyper-threading CPU if hyper-threading is turned off in the BIOS. Olaf -- http://mail.p

Re: scope of variables

2006-05-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gary Wessle wrote: > is the code below correct? No... > b = 3 > def adding(a) ...a colon is missing at the end of the above line. > print a + b > > it seams not to see the up-level scope where b is defined. It does. And you could easily find out yourself by just

Re: list*list

2006-05-03 Thread bearophileHUGS
Ziga Seilnach: >c = map(operator.mul, a, b) Usually I like map a lot, but this time for me the l.c. version is a bit simpler to understand (even if it's longer, and maybe slower too): >>> from operator import mul >>> from itertools import izip >>> a = [1, 2, 3] >>> b = [4, 5, 6] >>> map(mul, a, b

Re: This coding style bad practise?

2006-05-03 Thread keirr
Martin P. Hellwig wrote: > Hi all, > > I created a class which creates a relative unique id string, now my > program just works fine and as expected but somehow I get the feeling > that I misused the __repr__ since I guess people expect to 'execute' a > function in an instance instead of using it'

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit : (snip) > > Okay, let's start with writing a simple text processor for this little > mess:: > > def b(c): > def d(r, *s, **t): > print '***' > c(r, *s, **t) > return d > > What a nice, readable, highly pythoni

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > > What do you mean "stop responding"? > > Both threads print their thread numbers (either 1 or 2) approximately > every 10 seconds. However, after a while (minutes to hours) both > programs (see above) hang! > > Pressing ctrl-c (after the printing stops) causes the thre

Re: Because of multithreading semantics, this is not reliable.

2006-05-03 Thread Tim Peters
[EMAIL PROTECTED] > Because of multithreading semantics, this is not reliable. This > sentence is found in the Python documentation for "7.8.1 Queue > Objects". > > This scares me! Why would Queue.qsize(), Queue.empty( ), and a > Queue.full() not be reliable? Because they may not be telling the

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
Tim > Do you want someone running this test to hit the ENTER key, or not? The purpose of the "sys.stdin.read(1)" statement is simply to prevent the main thread from exiting and thus ending the test. And yes, I also get an exception when I press the enter key. Olaf -- http://mail.python.org/ma

Re: This coding style bad practise?

2006-05-03 Thread Bruno Desthuilliers
Martin P. Hellwig a écrit : > Hi all, > > I created a class which creates a relative unique id string, now my > program just works fine and as expected but somehow I get the feeling > that I misused the __repr__ since I guess people expect to 'execute' a > function in an instance instead of usi

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
Time >>> 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 >>> This is exactly what you should see. The problem I see is that after a while (minutes to hours) the printing of 1s and 2s stops! If you pres

scope of variables

2006-05-03 Thread Gary Wessle
Hi is the code below correct? b = 3 def adding(a) print a + b it seams not to see the up-level scope where b is defined. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
Beautiful! But how come my attempt didn't work? I've seen docs that explain how __hash__() methods are used to put objects in dict buckets: http://docs.python.org/ref/customization.html#l2h-195 But if it's really hash(str(o)) that's used for dict keys, what good are __hash__() methods? Or am I

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread OlafMeding
> What do you mean "stop responding"? Both threads print their thread numbers (either 1 or 2) approximately every 10 seconds. However, after a while (minutes to hours) both programs (see above) hang! Pressing ctrl-c (after the printing stops) causes the threads to "wake up" from their sleep stat

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Edward Elliott wrote: > I can prove that assertion too: make a simple text processor that reads > Python source code and outputs the same source code with only one change: > insert the string 'self" as the first parameter of every "def somemethod". > Next run the output so

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Tim Peters
[EMAIL PROTECTED] > Below are 2 files that isolate the problem. Note, both programs hang > (stop responding) What does "stop responding" mean? > with hyper-threading turned on (a BIOS setting), but > work as expected with hyper-threading turned off. > > Note, the Windows task manager shows 2 CPU

Re: Python & SSL

2006-05-03 Thread James Stroud
John J. Lee wrote: > James Stroud <[EMAIL PROTECTED]> writes: > > >>I have been trying to make an https client with python, but it seems > > > What exactly do you mean by "make an https client"? Something that can communicate with an https server. Fetch web pages, send POST and GET informati

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Below are 2 files that isolate the problem. Note, both programs hang > (stop responding) with hyper-threading turned on (a BIOS setting), but > work as expected with hyper-threading turned off. What do you mean "stop responding"? Not responding when you press ctrl-c? Th

Re: SciTE: Printing in Black & White

2006-05-03 Thread Sandy
Alexander Anderson: > ...I like to study large files of (hobby) code on paper. I have a > black and white bubble-jet printer. However, my (Win NT4) screen > syntax-highlighting setup has a couple of problems when it comes to > doing print-outs. > > The _chief_ problem is that my on-scree

Re: Because of multithreading semantics, this is not reliable.

2006-05-03 Thread Grant Edwards
On 2006-05-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Because of multithreading semantics, this is not reliable. > This sentence is found in the Python documentation for "7.8.1 > Queue Objects". > > This scares me! Why would Queue.qsize(), Queue.empty( ), and a > Queue.full() not be relia

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread johnzenger
Actually, come to think of it, __str__ works just as well. >>> class NamedThing(object): def __init__(self, name): self.name = name def __str__(self): return self.name >>> d = {} >>> d[a] = 1 >>> d[b] = 50 >>> d {<__main__.NamedThing object at 0x00C528D0>: 1, <__main__.

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Bruno Desthuilliers
Joel Hedlund a écrit : (snip) > How illegal is it? If I document it and put it in an opensource project, > will people throw tomatoes? Don't know, but they'll sure do if you insist on top-posting !-) -- http://mail.python.org/mailman/listinfo/python-list

This coding style bad practise?

2006-05-03 Thread Martin P. Hellwig
Hi all, I created a class which creates a relative unique id string, now my program just works fine and as expected but somehow I get the feeling that I misused the __repr__ since I guess people expect to 'execute' a function in an instance instead of using it's representation string of the in

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Bruno Desthuilliers
Edward Elliott a écrit : > bruno at modulix wrote: > >>Technically, they are still function objects. They are later wrapped >>into method descriptor objects (at lookup time IIRC, but ask a guru or >>read the doc to know for sure). And don't forget the case of nested >>functions... > > > I don't

Re: list*list

2006-05-03 Thread BBands
Very useful comments... Thanks to all! Once again this community has demonstrated why Python is THE language. jab -- http://mail.python.org/mailman/listinfo/python-list

__init__.py, __path__ and packaging

2006-05-03 Thread Sandro Dentella
Hi everybody, I'm trying to fix the packaging of a very simple package, but some problem show me that I have not well understood the whole mechanism The structure of my package (some debug functions) is as follows: python/ `-- dbg/ |-- __init__.py `-- lib |-- __init__.py |--

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
Hi! Thanks for the quick response! > Although this is a bit illegal, because repr is not supposed to be used > this way. How illegal is it? If I document it and put it in an opensource project, will people throw tomatoes? /Joel [EMAIL PROTECTED] wrote: > Use __repr__. Behold: > > cla

Because of multithreading semantics, this is not reliable.

2006-05-03 Thread OlafMeding
Because of multithreading semantics, this is not reliable. This sentence is found in the Python documentation for "7.8.1 Queue Objects". This scares me! Why would Queue.qsize(), Queue.empty( ), and a Queue.full() not be reliable? Looking at the source code of Queue.py, all 3 calls use a mutex (

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread johnzenger
Use __repr__. Behold: >>> class NamedThing(object): def __init__(self, name): self.name = name def __repr__(self): return self.name >>> a = NamedThing("Delaware") >>> b = NamedThing("Hawaii") >>> d = {} >>> d[a] = 1 >>> d[b] = 50 >>> print d {Delaware: 1, Hawaii: 50}

OT: SourceForge Tracker offline?

2006-05-03 Thread Heiko Wundram
Is anybody else also experiencing the SourceForge tracker to be offline? I can't log in at the moment, and can't view any tracker items... --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list

Re: python strings

2006-05-03 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [EMAIL PROTECTED] wrote: > Is it possible for python strings to contain a zero byte? Yes. Here's how to produce one: [EMAIL PROTECTED]:~$ python Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on lin

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
bruno at modulix wrote: > Technically, they are still function objects. They are later wrapped > into method descriptor objects (at lookup time IIRC, but ask a guru or > read the doc to know for sure). And don't forget the case of nested > functions... I don't see how nested functions change anyth

Re: python strings

2006-05-03 Thread Grant Edwards
On 2006-05-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is it possible for python strings to contain a zero byte? Yes. -- Grant Edwards grante Yow! Actually, what at I'd like is a little toy

Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
Hi! There's one thing about dictionaries and __hash__() methods that puzzle me. I have a class with several data members, one of which is 'name' (a str). I would like to store several of these objects in a dict for quick access ({name:object} style). Now, I was thinking that given a list of obj

Ann: pyDia2Code

2006-05-03 Thread Mario Lacunza
Hello,This is a GUI program for Dia2Code lib under GPL licence: "Dia2Code basically reads a Dia diagram file that contains an UML class diagram and creates files in the language of choice that contain the bare bones of the classes represented in the diagram...""Generates code for: Ada, C, C+

python strings

2006-05-03 Thread mike7411
Is it possible for python strings to contain a zero byte? -- http://mail.python.org/mailman/listinfo/python-list

python modules for openAFS client functionalities

2006-05-03 Thread tobi
Did anybody try to provide python modules for the openAFS (http://www.openafs.org/) client functionalities (C API)? I think that there are already bindings available for Perl and Java. What could be the best aproach to provide bindings for Python? Using Swig? -- http://mail.python.org/mailman/lis

Re: Recommended data structure for newbie

2006-05-03 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "manstey" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi, > > > > I have a text file with about 450,000 lines. Each line has 4-5 fields, > > separated by various delimiters (spaces, @, etc). > > > >

Re: simultaneous assignment

2006-05-03 Thread Steve R. Hastings
On Wed, 03 May 2006 17:51:03 +, Edward Elliott wrote: > Steve R. Hastings wrote: >> You could also use a function that counts all different values in a list, >> reducing the list to a dictionary whose keys are the unique values from >> the list. > > Wouldn't reducing to a set instead of a di

  1   2   3   >