Re: reading from a txt file

2005-03-30 Thread MyHaz
you should have that file i/o in some try: except: pairs for starters. and you should close data_file when you are done. isn't it just data_file.read() ? -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie - threading

2005-03-30 Thread martijn
Thanks MyHaz, Now its oke :) thanks for that example -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-30 Thread Fuzzyman
Undoubtably Wax :-) Easier to learn than TKinter, with none of the limitations (it's built on top of wxPython). See http://zephyfalcon.org I've just started using it and I'm really impressed. Best Regards, Fuzzy http://www.voidspace.org.uk/python -- http://mail.python.org/mailman/listinfo/pyth

Re: Secure scripts variables

2005-03-30 Thread Paul Rubin
Florian Lindner <[EMAIL PROTECTED]> writes: > I have a script which is readable and executable by a user, but not > writable. > The users executes the scripts, it reads in a value and based on this value > it computes a result and stores it in a variable. > Can the user read out the value of this v

Re: IMAP4.search by message-id ?

2005-03-30 Thread Sean Dodsworth
Max M wrote: > Sean Dodsworth wrote: >> Can anyone tell me how to get a message's number from the message-id >> using IMAP4.search? >> I've tried this: >> resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) >> but it gives me a 'bogus search criteria' error > > > Why do you ne

Re: File Uploads

2005-03-30 Thread Tim Roberts
"Doug Helm" <[EMAIL PROTECTED]> wrote: >Hey, Folks: > >I'm trying to write a very simple file upload CGI. I'm on a Windows server. >I *am* using the -u switch to start Python for CGIs, as follows: > >c:\python\python.exe -u %s %s > >I *do* have write permissions on the directory I'm trying to wri

Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread MyHaz
I posted a question about string concatination just last week. There is plenty of discussion on it, if you just search the group. -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with tkinter

2005-03-30 Thread Eric Brunel
On Tue, 29 Mar 2005 22:32:59 +0200, Pierre Quentel <[EMAIL PROTECTED]> wrote: Instead of indexing self.lab by strings, you can index them by the attributes themselves : self.lab[self.i], and change line 23 into for var in (self.s, self,i) I really think this is asking for trouble: I suppose t

Re: Newbie Shell Editor Question

2005-03-30 Thread Tim Roberts
Kash <[EMAIL PROTECTED]> wrote: >Hi Everyone, > >I am new to python. I have just installed it. I am went to the python >website and used it to download python and a beginners tutorial. I set >the environment variables as explained in the faq. >However when I start idle and run a program from it;

Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread Bengt Richter
On 29 Mar 2005 23:41:15 -0800, [EMAIL PROTECTED] (OPQ) wrote: [...] >> > for k in hash.keys()[:]: # Note : Their may be a lot of keys here >> >if len(hash[k])<2: >> > del hash[k] >> >> - Try if it isn't faster to iterate using items instead of iterating >> over keys > >items are huge l

Re: Things you shouldn't do

2005-03-30 Thread Eric Brunel
On Wed, 30 Mar 2005 07:02:57 GMT, Andrew Dalke <[EMAIL PROTECTED]> wrote: Steve wrote: [an anecdote on distinguishing l1 and 11] What are some of other people's favourite tips for avoiding bugs in the first place, as opposed to finding them once you know they are there? There's a good book on this

Re: convert user input to Decimal objects using eval()?

2005-03-30 Thread Raymond Hettinger
> > [Julian Hernandez Gomez] > >> is there a "easy way" to make eval() convert all floating > >> numbers to Decimal objects and return a Decimal? [Raymond Hettinger] > > from decimal import Decimal > > import re > > > > number = > > re.compile(r"((\b|(?=\W))(\d+(\.\d*)?|\.\d+)([eE][+-]?\d{1,3})?)"

Re: Little Q: how to print a variable's name, not its value?

2005-03-30 Thread Duncan Booth
Ron_Adam wrote: > I've been playing around with a way to explore name spaces, but once > you drop into class's, and functions, the references can lead you into > an endless loops. > Here is a rough attempt at printing the names of a variable. It will pick up several names where appropriate, but

Re: Things you shouldn't do

2005-03-30 Thread Richie Hindle
[Steven] > If you have access to a syntax-aware editor, it will > help avoid such problems Seconded. Here's my favourite real-world example of where the lack of syntax colouring cost several man-days of work (though this couldn't happen with modern C compilers): extern void get_s(short* s); v

Re: Queue.Queue-like class without the busy-wait

2005-03-30 Thread Antoon Pardon
Op 2005-03-30, Paul Rubin schreef : >> > I think the best bet for the short term is handling it at the C level, >> > with sigalarm. Another way is to have chained sigalarm handlers in >> > the main thread. >> >> Possible, but I don't have the time to investigate that possibility now. > > Actuall

Re: distutils: package data

2005-03-30 Thread Qiangning Hong
ehh.. I did a little more reading and found that this function can be easily done by the new distutils parameter "package_data" in 2.4. However, I am using python2.3 :( So, my question becomes: how to emulate the package_data function in python 2.3? -- http://mail.python.org/mailman/listinfo/p

Re: How to build pyogg/pyvorbis for Python 2.3 with MinGW

2005-03-30 Thread Marek Kubica
Hi! > Can someone please tell me how to compile pyogg/pyvorbis for Python 2.3 with > MinGW. Build lobogg, build pyogg, build libvorbis (linked against your libogg), build pyvorbis. I haven't been able to produce any working binaries.. greets, Marek -- http://mail.python.org/mailman/listinfo/pyt

Re: Problem in designing a global directory in python

2005-03-30 Thread Serge Orlov
Tian wrote: > I have tried using "sysctx=None" instead of "global sysctx", but it > doesn't work either. > It seems my initialization work in the previous calling of init() has > no persistent effect when "utils" is imported using "from > myproj.utils import getContext". > > What's weird, when a mo

Re: Queue.Queue-like class without the busy-wait

2005-03-30 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I'm not sure that this would be an acceptable approach. I did the man > semop and it indicates this is part of system V IPC. This makes me > fear that semaphores will use file descriptors or other resources > that are only available in a limited amount. N

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-30 Thread Steven Bethard
Ville Vainio wrote: The issue that really bothers me here is bloating the builtin space. We already have an uncomfortable amount of builtin functions. Of course the additions that have been suggested would not pollute the builtin namespace, but they would still be there, taking space. I'd rather se

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Steven Bethard
Ron Garret wrote: Note that you don't need the class redirection: py> ref('') Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'str' object But I don't know why strings aren't valid arguments to ref... None of the native types (int, float, list,

Re: BF interpreter in Python

2005-03-30 Thread Will McGugan
Do Re Mi chel La Si Do wrote: Hi ! Good idea. I take this interpreter with jubilation. Can I add your URL at http://mclaveau.com/esolang ? Certainly, be my guest. Other question : do you know PATH ? (http://pathlang.sourceforge.net) Yes, a wonderfully expressive language! Will McGugan -- http:/

Re: distutils: package data

2005-03-30 Thread Serge Orlov
Qiangning Hong wrote: > ehh.. I did a little more reading and found that this function can > be easily done by the new distutils parameter "package_data" in 2.4. > > However, I am using python2.3 :( > > So, my question becomes: how to emulate the package_data function in > python 2.3? There is di

Re: problem with tkinter

2005-03-30 Thread max(01)*
Pierre Quentel wrote: Instead of indexing self.lab by strings, you can index them by the attributes themselves : self.lab[self.i], and change line 23 into for var in (self.s, self,i) For your example, I wouldn't have used the "text" option in the definition of the labels, then "textvariable

RELEASED Python 2.4.1 (final)

2005-03-30 Thread Anthony Baxter
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.4.1 (final). Python 2.4.1 is a bug-fix release. See the release notes at the website (also available as Misc/NEWS in the source distribution) for details of the bugs squished in this re

Re: problem with tkinter

2005-03-30 Thread max(01)*
Eric Brunel wrote: On Tue, 29 Mar 2005 22:32:59 +0200, Pierre Quentel <[EMAIL PROTECTED]> wrote: [...] mr brunel, i thank you for prompt reply. i will take my time to read it carefully. meanwhile, i inform you and the ng that someone else gave me a quick and dirty answer to my problem, namely sub

Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread Daniel Dittmar
OPQ wrote: - Try if it isn't faster to iterate using items instead of iterating over keys items are huge lists of numbers. keys are simple small strings. And even if it is faster, how can I find the key back, in order to delete it ? for v in hashh.items(): if len(v)<2: del ???

twistedSnmp and hexadecimal values ...

2005-03-30 Thread Francesco Ciocchetti
Hi all ml. I'm tryng to use TwistedSnmp to make query and walk directly inside my python code. The problem i'm facing is that any time there is an hexadecimal value to be returned by the snmpwalk it is returened in a weird and useless way... does anyone had any (successfull) experience with twist

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-30 Thread Ville Vainio
> "Steven" == Steven Bethard <[EMAIL PROTECTED]> writes: Steven> Certainly a valid point. How would you feel about adding Steven> just a select few itertools functions, perhaps just Steven> islice, chain and tee? A minimal set would not be that offensive, yes. But then we would h

PyQt on Python 2.4

2005-03-30 Thread Franz Steinhäusler
Hello, I installed PyQt-win-nc-msvc-3.13.exe then complained: no, qt-mt230nc.dll, i found this and copied into system32 directory. I installed then: PyQwt_Qt333-4.2.win32-py2.4.exe Traceback (most recent call last): File "Grab.pyw", line 65, in ? from qt import * ImportError: Module use o

oddness in string.find(sub,somestring)

2005-03-30 Thread MyHaz
OK i find this a quark in string.find that i think needs some consideration. Normally if a substring is not in the searched_string then string.find returns -1 (why not len(searched_string) + 1, i don't know but nevermind that) but what if a searched_string == '' ? Then string.find(substring,search

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Fredrik Lundh
"MyHaz" wrote: searched_string="" print string.find(substring,searched_string) > 0 > > why would this be? And when is someone going to fix it :P >>> substring[0:0+len(searched_string)] == searched_string True -- http://mail.python.org/mailman/listinfo/python-list

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Diez B. Roggisch
MyHaz wrote: > OK i find this a quark in string.find that i think needs some > consideration. You shouldn't use the module string anymore, instead use string-methods. > Normally if a substring is not in the searched_string then string.find > returns -1 (why not len(searched_string) + 1, i don't

Re: What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-30 Thread Kent Johnson
Fuzzyman wrote: Undoubtably Wax :-) Easier to learn than TKinter, with none of the limitations (it's built on top of wxPython). See http://zephyfalcon.org http://zephyrfalcon.org/labs/wax.html works better. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Max M
MyHaz wrote: import string searched_string="abcdefg" substring="123" print string.find(substring,searched_string) -1 searched_string="" print string.find(substring,searched_string) 0 why would this be? And when is someone going to fix it :P I don't know. When are you going to fix it? -- hilsen/reg

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Max M
MyHaz wrote: why would this be? And when is someone going to fix it :P Whoops ... This missed the previous message together with the wink ... ;-) "When *are* you going to fix it ..." substring="123" import string searched_string="abcdefg" print string.find(searched_string, substring) # note the or

Re: PyQt on Python 2.4

2005-03-30 Thread Phil Thompson
> Hello, > > I installed PyQt-win-nc-msvc-3.13.exe > > then complained: no, qt-mt230nc.dll, i found this > and copied into system32 directory. > > I installed then: > PyQwt_Qt333-4.2.win32-py2.4.exe > > Traceback (most recent call last): > File "Grab.pyw", line 65, in ? > from qt import * > I

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread MyHaz
thanks all that clears things up nicely - Haz -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-30 Thread Fuzzyman
True enough :-) Thanks Fuzzy http://www.voidspace.org.uk/python -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread Kent Johnson
OPQ wrote: for (2): for k in hash.keys()[:]: # Note : Their may be a lot of keys here if len(hash[k])<2: del hash[k] - use the dict.iter* methods to prevent building a list in memory. You shouldn't use these values directly to delete the entry as this could break the iterator: for key i

Re: author index for Python Cookbook 2?

2005-03-30 Thread Fuzzyman
Premshree Pillai wrote: > There's an index here: http://harvestman.freezope.org/cookbook/creds.html > > But dunno if all the recipes were finally included. Maybe somebody > (Alex?) can confirm? > > [snip..] Well - my copy just arrived :-) Three of my recipes are in - but one has been merged with

redundant imports

2005-03-30 Thread max(01)*
hi everybody. suppose that code-1.py imports code-2.py and code-3.py (because it uses names from both), and that code-2.py imports code-3.py. if python were c, code-1.c should only *include* code-2.c, because the latter in turns includes code-3.c. inclusion of modules in c is a purely preproces

Re: problem with tkinter

2005-03-30 Thread max(01)*
Eric Brunel wrote: On Tue, 29 Mar 2005 22:32:59 +0200, Pierre Quentel <[EMAIL PROTECTED]> wrote: Instead of indexing self.lab by strings, you can index them by the attributes themselves : self.lab[self.i], and change line 23 into for var in (self.s, self,i) I really think this is asking fo

ANN: pyMinGW support for Python 2.4.1 (final) is available

2005-03-30 Thread A.B., Khalid
This is to inform those interested in compiling Python in MinGW that an updated version of pyMinGW is now available. Get it from here: http://jove.prohosting.com/iwave/ipython/pyMinGW.html Regards Khalid -- http://mail.python.org/mailman/listinfo/python-list

RE: Need Help: Server to pass py objects-THANKS

2005-03-30 Thread Sells, Fred
Thanks to all who responded. Although overwhelmed by the hits from a Google search initially, it looks like pyro is a good choice for my needs. -Original Message- From: Ken Godee [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 29, 2005 3:45 PM To: python-list@python.org Subject: Re: Need He

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Peter Hansen
Steven Bethard wrote: Ron Garret wrote: None of the native types (int, float, list, tuple, etc.) can have weak references, but wrapping them in a class is supposed to get around that. And it does -- for all classes except str. Interesting. Is the wrapping thing documented somewhere? I didn't s

Suggesting methods with similar names

2005-03-30 Thread bearophileHUGS
I have a class Surface with many methods. Working in the interactive window I receive an error like this when I write the wrong method name: >>> table.addGlas() Traceback (most recent call last): File "", line 1, in ? AttributeError: 'Surface' object has no attribute 'addGlas' Is it possibile t

Re: redundant imports

2005-03-30 Thread Tim Jarman
max(01)* wrote: > hi everybody. > > suppose that code-1.py imports code-2.py and code-3.py (because it uses > names from both), and that code-2.py imports code-3.py. > > if python were c, code-1.c should only *include* code-2.c, because the > latter in turns includes code-3.c. > > inclusion of

Re: redundant imports

2005-03-30 Thread Peter Hansen
max(01)* wrote: hi everybody. suppose that code-1.py imports code-2.py and code-3.py (because it uses names from both), and that code-2.py imports code-3.py. if python were c, code-1.c should only *include* code-2.c, because the latter in turns includes code-3.c. inclusion of modules in c is a

Re: global name "Result" is not defined

2005-03-30 Thread Fredrik Lundh
Elmar Haneke wrote: > I do have an problem with Python and Capisuite. what's Capisuite? have you check the Capisuite site for support options? (mailing lists, etc). > On calling one of the Capisuite functions I get an Exception "global name > 'Result' is not defined". > > Where to search for th

Py2exe and dotNet Python

2005-03-30 Thread Harlin Seritt
I downloaded PythonDotNet from the Zope site to my laptop. According to the docs I can use this with my regular Python installation. I copied CLR.dll and Python.Runtime.dll to my root folder (c:\\Python24). Doing this I was able to run the dotNet examples with no problems. When I tried to run py2ex

Re: twistedSnmp and hexadecimal values ...

2005-03-30 Thread Larry Bates
You really should give an example so that we will know what you mean by "weird and useless". Otherwise you are asking us to implement TwistedSnmp to see what you are referring to. Larry Bates Francesco Ciocchetti wrote: > Hi all ml. > > I'm tryng to use TwistedSnmp to make query and walk dire

Using something other than ';' to separate statements

2005-03-30 Thread Jaime Wyant
I know I've seen this somewhere, but can't seem to google it. Is there a way to use an alternate statement separator, other than the default ';'? jw -- http://mail.python.org/mailman/listinfo/python-list

Impacket & sequence numbers

2005-03-30 Thread ias0nas
Hello, I have been using Impacket to produce some packets, but unfortunatelly it does not provide functionality for changing the sequence number of a packet and leaves it to 0. Is it possible to cjange the sequense number in some way? Thank you -- http://mail.python.org/mailman/listinfo/python-

Re: Things you shouldn't do

2005-03-30 Thread Thomas Bartkus
"Steve" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What are some of other people's favourite tips for > avoiding bugs in the first place, as opposed to finding > them once you know they are there? > Fonts with slashed zeros and serifs. -Tom -- http://mail.python.org/mailman

Re: Secure scripts variables

2005-03-30 Thread Florian Lindner
Paul Rubin wrote: > Florian Lindner <[EMAIL PROTECTED]> writes: >> I have a script which is readable and executable by a user, but not >> writable. >> The users executes the scripts, it reads in a value and based on this >> value it computes a result and stores it in a variable. >> Can the user re

(no subject)

2005-03-30 Thread python-list-bounces+archive=mail-archive . com
#! rnews 1551 Newsgroups: comp.lang.python Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp From: Harry George <[EMAIL PROTECTED]> Subject: Re: why and when we should do it? X-Nnt

Re: how do you use a closure in a class

2005-03-30 Thread erinhouston
What I wanted it to know how to. Take a function like. Note replace ... with spaces. def makeAddr(tAdd): def add(tNum): return tNum + tAdd return add In a class so I make several functions that do the same thing but on diffrent objects. I ended up writing a base function and just

Re: Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-30 Thread Rakesh
George Yoshida wrote: > Rakesh wrote: > > > To quote a much smaller trimmed-down example, here is how it looks > > like: > > ## --- > > # Entry Point to the whole program > > ## --- > > def main(): > >

Re: how do you use a closure in a class

2005-03-30 Thread erinhouston
Also note I can't read or type is seems. what I want to know is how to take a function like. I realley need to fininsh my coke before I try to think. -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you use a closure in a class

2005-03-30 Thread Paul McGuire
See the following. -- Paul class X(object): pass def makeAddr(tAdd): def add(self, tNum): return tNum + tAdd return add # add methods to class X X.add1 = makeAddr(1) X.add100 = makeAddr(100) # create an X object x = X() # invoke new methods print x.add1( 50 ) print x.add100

Re: Things you shouldn't do

2005-03-30 Thread Paul McGuire
Here's another real world example, although it was in C: char* ptr; assert( ptr = malloc( memsize ); ) Of course, this worked when built in debug, but it took a while to track down why it wasn't working in the release build (the assert()'s were stripped out in the release builds, so ptr didn't al

Re: how do you use a closure in a class

2005-03-30 Thread erinhouston
Thanks I will try that. -- http://mail.python.org/mailman/listinfo/python-list

Re: twistedSnmp and hexadecimal values ...

2005-03-30 Thread Mike C. Fletcher
Francesco Ciocchetti wrote: >I'm tryng to use TwistedSnmp to make query and walk directly inside my >python code. > >The problem i'm facing is that any time there is an hexadecimal value to >be returned by the snmpwalk it is returened in a weird and useless >way... does anyone had any (successfull

Re: Re: Want to meet any of these people? They are registered for PyCon

2005-03-30 Thread Garry Hodgson
Steve Holden <[EMAIL PROTECTED]> wrote: > Sorry you can't make it to Python. My even-naiver way of approaching the > problem was to use the sort utility built into Cygwin, thereby avoiding > writing any code at all. an easier way is to publish it unsorted, but claim it is sorted. someone is sur

urllib problem (maybe bugs?)

2005-03-30 Thread Timothy Wu
Hi, I'm trying to fill the form on page http://www.cbs.dtu.dk/services/TMHMM/ using urllib. There are two peculiarities. First of all, I am filling in incorrect key/value pairs in the parameters on purpose because that's the only way I can get it to work.. For "version" I am suppose to leave it u

Re: how do you use a closure in a class

2005-03-30 Thread erinhouston
Thanks that made it work. If I did it that way I think the other programmers on my team would kill me so I will stick with wrapping the function over and over again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggesting methods with similar names

2005-03-30 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote: > I have a class Surface with many methods. Working in the interactive > window I receive an error like this when I write the wrong method name: > table.addGlas() > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'Surface' object has no

Re: Want to meet any of these people? They are registered for PyCon

2005-03-30 Thread TZOTZIOY
On Wed, 30 Mar 2005 14:42:52 GMT, rumours say that Garry Hodgson <[EMAIL PROTECTED]> might have written: >Steve Holden <[EMAIL PROTECTED]> wrote: > >> Sorry you can't make it to Python. My even-naiver way of approaching the >> problem was to use the sort utility built into Cygwin, thereby avoidin

Re: distutils: package data

2005-03-30 Thread David Fraser
Qiangning Hong wrote: I am writing a setup.py for my package. I have a pre-compiled myextmod.pyd file in my package and I want the distutils to automatically copy it to C:\Python23\Lib\site-packages\mypackage\myextmod.pyd. I try to add the following parameter to setup(): data_file = [('mypackag

Re: PyParsing module or HTMLParser

2005-03-30 Thread Lad
Paul, Thank you for your reply. Here is a test page that I woul like to test with PyParsing http://www.ourglobalmarket.com/Test.htm >From that I would like to extract the tittle ( it is below Lanjin Electronics Co., Ltd. ) (Sell 2.4GHz Wireless Mini Color Camera With Audio Function ) descriptio

Re: author index for Python Cookbook 2?

2005-03-30 Thread beliavsky
Premshree Pillai wrote: > There's an index here: http://harvestman.freezope.org/cookbook/creds.html That lists the authors. Where is a list of the recipes? -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-30 Thread Steven Bethard
Ville Vainio wrote: A minimal set would not be that offensive, yes. But then we would have two places to look for itertools functionality, which may not be desirable. True, though this is currently necessary with str objects if you want to use, say string.maketrans, so it's not without some prece

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Steven Bethard
Peter Hansen wrote: I believe it's here: http://docs.python.org/lib/module-weakref.html if you search for the string "Not all" and read the next two paragraphs. On the other hand, it says (there) only that "several builtin types such as list and dict ... can add support through subclassing", and do

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: > Steven Bethard wrote: > > Ron Garret wrote: > >> None of the native types (int, float, list, tuple, etc.) can have weak > >> references, but wrapping them in a class is supposed to get around > >> that. And it does -- fo

Re: urllib problem (maybe bugs?)

2005-03-30 Thread Fredrik Lundh
Timothy Wu wrote: > After I've done that it works fine for small SEQ values. Then, when I > try to send large amount of data (1.4MB), it fails miserably with > AttributeError exception. the page states that you should send no more than 4000 proteins. how many proteins do you have in your 1.4 meg

PIL

2005-03-30 Thread suresh mathi
I use PIL for image manipulation. For drawing rectangles and other shapes PIL was really good. Now i am trying to paste 3 images into a single image. All 3 images that i try to paste are having a transparent background. When i try to open the image and paste the background becomes black. I masked

Re: list-comprehension and map question (simple)

2005-03-30 Thread runsun pan
Thx, Robert. I did some tests: >>> xs = range(1) >>> ys = range(0,2,2) >>> def m1(x, count=100): ... for c in range(count): ...y = map(float, x) ... return y >>> def L1(x, count=100): ... for c in range(count): ...y = [float(z) for z in x] ... return y >>> d

Re: Suggesting methods with similar names

2005-03-30 Thread Terry Reedy
> You could achieve this by overriding __getattribute__ (untested): I believe OP would do better to use __getattr__, which is only called when the attribute is not found by the normal lookup, which is the only time he needs/wants customized control. TJR -- http://mail.python.org/mailman/lis

Re: Using something other than ';' to separate statements

2005-03-30 Thread Terry Reedy
"Jaime Wyant" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I know I've seen this somewhere, but can't seem to google it. Is > there a way to use an alternate statement separator, other than the > default ';'? Other than \n, no. Both are builtin to the language definition and i

Re: how do you use a closure in a class

2005-03-30 Thread Terry Reedy
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > See the following. > -- Paul > > class X(object): > pass > > def makeAddr(tAdd): > def add(self, tNum): > return tNum + tAdd > return add > > # add methods to class X > X.add1 = makeAddr(1) > X.add100

Re: Using something other than ';' to separate statements

2005-03-30 Thread Peter Hansen
Jaime Wyant wrote: I know I've seen this somewhere, but can't seem to google it. Is there a way to use an alternate statement separator, other than the default ';'? The validity of Terry's answer (which is true for the general case) aside, it might be possible to do what you are trying to do if yo

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Peter Hansen
Ron Garret wrote: foo(int) foo(float) foo(dict) foo(list) foo(str) TypeError: cannot create weak reference to 'C' object foo(tuple) TypeError: cannot create weak reference to 'C' object foo(long) TypeError: cannot create weak reference to 'C' object Ah, it appears that non-immediate immutable type

Write an hexadecimal file

2005-03-30 Thread Cesar Andres Roldan Garcia
Hi I'm trying to write an hexadecimal file... I mean not a text plain... I have to convert a float decimal number in float hexadecimal one, and that's done. That number is the one I'm gonna write in the hex file... can anybody help me 'cause i don't know how python write an hex file! Thanks! -

Re: Using something other than ';' to separate statements

2005-03-30 Thread Jaime Wyant
Well, I'm embedding python in an old C console app. This app uses a lot of ; delimited records. I want to allow the execution of arbitrary python statements inside some of these records. I was hoping there was an easy way to set the statement terminator. I will simply make up a new terminator a

Re: Good use for Jython

2005-03-30 Thread Tim Tyler
Mike Wimpe <[EMAIL PROTECTED]> wrote or quoted: > Other than being used to wrap Java classes, what other real use is > there for Jython being that Python has many other GUI toolkits > available? Also, these toolkits like Tkinter are so much better for > client usage (and faster) than Swing, so wha

Re: Weakrefs to classes that derive from str

2005-03-30 Thread Raymond Hettinger
[Ron Garret] > Why doesn't this work? > > >>> from weakref import ref > >>> class C(str): pass > ... > >>> ref(C()) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: cannot create weak reference to 'C' object . . . > Everything but strs. Also subclasses of tuple are not

Re: Weekly Python Patch/Bug Summary

2005-03-30 Thread Terry Reedy
Over 2 days, this link consistently gives 500 Internal Server Error (from python.org, says IE): Decimal interaction with __rop__ (2005-03-19) http://python.org/sf/1166602 opened by Facundo Batista while this one works fine: Fix _tryorder in webbrowser.py (2005-03-20) http://py

Re: Suggesting methods with similar names

2005-03-30 Thread bearophileHUGS
Thank you, __getattr__ does what I need :-) A smart help can be designed easely... Bear hugs, Bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Write an hexadecimal file

2005-03-30 Thread Larry Bates
There is not such thing as a hexadecimal file. Files are either binary or text. Hexadecimal is a representation of binary data where 4 bits are displayed as a single hex digit (0-F) as shorthand (because 0000111 is just too difficult to deal with). To write binary data to a file in P

Re: html tags and python

2005-03-30 Thread Timo Virkkala
Hansan wrote: I also want the user to choose a date I will make this with another dropdownbox. But if the first month is selected, then there should be 31 days in the days dropdownbox, if the second month is selected there should be 28 days in the dropdownbow. I know this isn't the solution to your

Dr. Dobb's Python-URL! - weekly Python news and links (Mar 30)

2005-03-30 Thread Cameron Laird
QOTW: "This is a Python newsgroup. Assume that we all have been brainwashed." -- Peter Otten "[M]y experience porting Java to Jython is that it mostly involves deleting stuff :-)" -- Kent Johnson "[K]eep in mind, however, that not all problems in life can be solved with software." -- Roy Smith

Re: Write an hexadecimal file

2005-03-30 Thread Raymond Hettinger
[Cesar Andres Roldan Garcia] > I'm trying to write an hexadecimal file... I mean not a text plain... >I have to convert a float decimal number in float hexadecimal one, > and that's done. The struct module provides a portable way to convert a float to and from a sequence of bytes. The binascii mo

return the last item in a list

2005-03-30 Thread David Bear
I've googled for the above and get way too many hits.. I'm looking for an 'easy' way to have the last item in a list returned. I've thought about list[len(list)-1] but thought there would be a more gracefull way. -- http://mail.python.org/mailman/listinfo/python-list

Re: return the last item in a list

2005-03-30 Thread TZOTZIOY
On 30 Mar 2005 10:48:17 -0700, rumours say that David Bear <[EMAIL PROTECTED]> might have written: >I've googled for the above and get way too many hits.. > >I'm looking for an 'easy' way to have the last item in a list returned. > >I've thought about > >list[len(list)-1] > >but thought there wou

Re: Suggesting methods with similar names

2005-03-30 Thread Raymond Hettinger
[Bearophile] > Working in the interactive window I receive an error like > this when I write the wrong method name: > > >>> table.addGlas() > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'Surface' object has no attribute 'addGlas' > > Is it possibile to make the ob

Re: [DB-SIG] Looking for Stephen Turner, maintainer of informixdb

2005-03-30 Thread Eric Brunson
Read the license. If he's released it under GPL or BSD, then you could, in all good faith, release a fork of the code until he surfaces. Carsten Haese wrote: Hello everybody: I have discovered that the functionality for connecting Python to an Informix database is currently in a frustrating stat

Re: Grouping code by indentation - feature or ******?

2005-03-30 Thread Javier Bezos
"Myles Strous" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] >>> satisfy some handy properties, the first of which being: >>> l[:n] + l[n:] = l >> >> I don't think l[:5] + l[5:] = l is a handy property >> and to me is clearly counterintuitive. Further, > > It can be quite usef

Re: author index for Python Cookbook 2?

2005-03-30 Thread Raymond Hettinger
[Fuzzyman] > Three of my recipes are in - but one has been merged with someone elses > and improved beyond all recognition :-) Gets my vote for QOTW quote of the week. The comment captures the spirit of the cookbook and highlights the benefits of the process (public review, reader comments, compe

Re: return the last item in a list

2005-03-30 Thread Raymond Hettinger
[David Bear] > I'm looking for an 'easy' way to have the last item in a list returned. Try mylist.pop() or mylist[-1]. Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >