Re: Symlinks already present
In article , Cameron Simpson wrote: > >Yeah, makes me ill. That's because these days "pwd" is usually a shell >builtin with funny semantics and a cache/sanity=check against $PWD >(which gets computed as you cd around, typically). And if has a -P >option and friends explicitly because of this hideous stuff. Would you be a fan of nash , the Never Again so complicated SHell ? The base idea that it is a Forth interpreter that has a few shell like features tucked onto it, like executing programs. And if you type pwd, sure as hell it would look through $PATH and execute the exact program you want. (You could defined `pwd' in the interpreter yourself to do something different. If you do that, probably you want it.) > >Cheers, >Cameron Simpson Groetjes Albert -- This is the first day of the end of your life. It may not kill you, but it does make your weaker. If you can't beat them, too bad. albert@spe &=n http://home.hccnet.nl/a.w.m.van.der.horst -- https://mail.python.org/mailman/listinfo/python-list
Re: Symlinks already present
In article , Grant Edwards wrote: >On 2020-09-01, Richard Damon wrote: > >> Remember, we are talking about a hypothetical OS that handles hardlinks >> to directories, and defines that .. will point to the parent used to >> come to it, NOT just having current *NIX allowing hardlinks to >> directories with no remediation of the issues cause. > >I can testify from personal experience that SunOS 3/4 was in the >latter category. After creating a hard-link to a directory, things >like fsck and the filesystem dump backup utility got very upset and >confused. IIRC the only way to recover was to nuke the involved >inodes then let fsck try to pick up the pieces and put them in the >lost+found. IIRC, I managed to recover without losing any files, but >it wasn't a fun day. It was a defect ("bug") in the SUNOS that this was possible. So reread this thread. "Let us imagine the situation that a severe, known defect was reintroduced in linux, just for the fun of it." > >-- >Grant Groetjes Albert -- This is the first day of the end of your life. It may not kill you, but it does make your weaker. If you can't beat them, too bad. albert@spe &=n http://home.hccnet.nl/a.w.m.van.der.horst -- https://mail.python.org/mailman/listinfo/python-list
[issue25451] PhotoImage transparency methods
New submission from None Becoming: The transparency methods of tkinter.PhotoImage seem to be missing. Presumably, they would go something like: def transparency_get(self, x, y): """Returns a boolean indicating if the pixel at (x,y) is transparent. """ return self.tk.call(self.name, 'transparency', 'get', x, y) def transparency_set(self, x, y, boolean=True): """Make pixel at (x,y) transparent if boolean is true, opaque otherwise. """ self.tk.call(self.name, 'transparency', 'set', x, y, boolean) -- components: Tkinter messages: 253281 nosy: None Becoming priority: normal severity: normal status: open title: PhotoImage transparency methods type: enhancement ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25451> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
how update MultipartPostHandler pypi
Hi, As Wrote in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 http://pypi.python.org/pypi/MultipartPostHandler/0.1.0 is not updated , the author email doesn't not exist , how I send a comment update MultipartPostHandler anyway patch attach Only in MultipartPostHandler-0.1.0: build Only in MultipartPostHandler-0.1.0: dist Common subdirectories: MultipartPostHandler-0.1.0.orig/doc and MultipartPostHandler-0.1.0/doc Common subdirectories: MultipartPostHandler-0.1.0.orig/MultipartPostHandler.egg-info and MultipartPostHandler-0.1.0/MultipartPostHandler.egg-info diff -u MultipartPostHandler-0.1.0.orig/MultipartPostHandler.py MultipartPostHandler-0.1.0/MultipartPostHandler.py --- MultipartPostHandler-0.1.0.orig/MultipartPostHandler.py 2010-06-05 20:35:37.0 +0100 +++ MultipartPostHandler-0.1.0/MultipartPostHandler.py 2011-06-04 12:54:31.958597227 +0100 @@ -1,4 +1,5 @@ #!/usr/bin/python +# From http://peerit.blogspot.com/2007/07/multipartposthandler-doesnt-work-for.html # 02/2006 Will Holcomb wholc...@gmail.com @@ -13,6 +14,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # +# 7/26/07 Slightly modified by Brian Schneider +# in order to support unicode files ( multipart_encode function ) Usage: Enables the use of multipart/form-data for posting forms @@ -42,6 +45,7 @@ import urllib2 import mimetools, mimetypes import os, stat +from cStringIO import StringIO class Callable: def __init__(self, anycallable): @@ -86,22 +90,23 @@ if boundary is None: boundary = mimetools.choose_boundary() if buffer is None: -buffer = '' +buffer = StringIO() for(key, value) in vars: -buffer += '--%s\r\n' % boundary -buffer += 'Content-Disposition: form-data; name=%s' % key -buffer += '\r\n\r\n' + value + '\r\n' +buffer.write('--%s\r\n' % boundary) +buffer.write('Content-Disposition: form-data; name=%s' % key) +buffer.write('\r\n\r\n' + value + '\r\n') for(key, fd) in files: file_size = os.fstat(fd.fileno())[stat.ST_SIZE] filename = fd.name.split('/')[-1] contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' -buffer += '--%s\r\n' % boundary -buffer += 'Content-Disposition: form-data; name=%s; filename=%s\r\n' % (key, filename) -buffer += 'Content-Type: %s\r\n' % contenttype +buffer.write('--%s\r\n' % boundary) +buffer.write('Content-Disposition: form-data; name=%s; filename=%s\r\n' % (key, filename)) +buffer.write('Content-Type: %s\r\n' % contenttype) # buffer += 'Content-Length: %s\r\n' % file_size fd.seek(0) -buffer += '\r\n' + fd.read() + '\r\n' -buffer += '--%s--\r\n\r\n' % boundary +buffer.write('\r\n' + fd.read() + '\r\n') +buffer.write('--' + boundary + '--\r\n\r\n') +buffer = buffer.getvalue() return boundary, buffer multipart_encode = Callable(multipart_encode) -- http://mail.python.org/mailman/listinfo/python-list
Re: str(int_var) formatted
On 29/10/10 16:59, Tracubik wrote: Hi all, i've to convert integer x to string, but if x 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) -- '09' x = 32 str(x) -- '32' x represent hour/minute/second. I can easily add '0' with a if then block, but is there a built-in way to add the '0' automatically? Thanks Nico Python2: %02d % x Python3: format(x,02d) -- http://mail.python.org/mailman/listinfo/python-list
python module for data comparison of 2 MySQL servers
I have 2 MySQL servers in 2 different data centers. Between them, there is data replication setup. Is there a python tool so I can do data comparison for daily records? Basically, just access both servers and do a diff in memory and print out records. Thanks -- http://mail.python.org/mailman/listinfo/python-list
How to Teach Python Variables
Hello, IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Thanks, Ami -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Teach Python Variables
Aurélien Campéas wrote: none a écrit : Hello, IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Thanks, Ami That's something I've often heard and I don't get it. Somehow I don't understand how C variables are not like python bindings (the differences being that C variables are statically typed and completely disappear at run-time; are these differences important enough to warrant such a shift in terminology ? (yes there are some other differences, but then the question is asked in a context of pedagogy, where the audience is introduced to the basics)) I mean : aren't C variables also bindings from names to objects ? Or what ? Thanks. It's very possible you're right - I don't know. There seem to be some differences however. To name a few: 1. A C variable exists regardless of whether you're storing something in it. Not so for a python variable - so it's a bit really more like a name for something that exists independently. 2. C variables (or C++ objects) completely disappear when out of scope, but that's not necessarily true of Python objects. 3. C++ references have the semantics that if a = b, and you write a.c = 3, then b.c == 3. This is also true in Python. But then if a = b, and then you write b = 5, then a is still bound to the original value of b, so it's not exactly like a reference. 4. Etc. So on the one hand, you're obviously right, and maybe there's no room for a paradigm shift. OTOH, if the simplest explanation is it's like a C/C++ variable/reference/pointer except for 1, 2, 3, 4,..., then maybe it is different. I just don't know, hence my question. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Teach Python Variables
Aahz wrote: In article [EMAIL PROTECTED], none atavory\@(none) wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? http://starship.python.net/crew/mwh/hacks/objectthink.html Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Teach Python Variables
Ben Finney wrote: none atavory\@(none) writes: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? In addition to the good answers you've had already, I highly recommend David Goodger's Code like a Pythonista page URL:http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html, which contains a very good cardboard boxes versus paper tags analogy of the topic you're asking about. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Python and Combinatorics
Hello, Is there some package to calculate combinatorical stuff like (n over k), i.e., n!/(k!(n - k!) ? I know it can be written in about 3 lines of code, but still... Thanks, Ami -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Combinatorics
[EMAIL PROTECTED] wrote: On Oct 24, 5:20 pm, none atavory\@(none) wrote: Hello, Is there some package to calculate combinatorical stuff like (n over k), i.e., n!/(k!(n - k!) ? Sure, the gmpy module. Excellent, many thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with wxPanel derivation class ~ thanks
none wrote: wxGlade created a simple Frame with a panel a sizer and 3 wxControls , saticText, TextCtrl, and a Button. The resulting code works fine. Now the problem. I wish to make a separate class derrived from wxPanel that has the sized and controls as above. It jusst won't work code id=gladeGen class=works_ok #!/usr/bin/env python # -*- coding: ISO-8859-1 -*- # generated by wxGlade 0.4cvs on Thu Oct 11 13:26:19 2007 import wx class MyFrameOne(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrameOne.__init__ kwds[style] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel = wx.Panel(self, -1) self.staticbox = wx.StaticBox(self.panel, -1, StaticBox) self.label = wx.StaticText(self.panel, -1, Field Name) self.textBox = wx.TextCtrl(self.panel, -1, Field Value) self.button = wx.Button(self.panel, -1, Edit) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): # begin wxGlade: MyFrameOne.__set_properties self.SetTitle(frame_1) self.label.SetMinSize((-1, 15)) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrameOne.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) sizer.Add(self.label, 0, wx.ALL, 3) sizer.Add(self.textBox, 0, wx.ALL, 3) sizer.Add(self.button, 0, wx.ALL, 3) self.panel.SetAutoLayout(True) self.panel.SetSizer(sizer) sizer.Fit(self.panel) sizer.SetSizeHints(self.panel) sizer_1.Add(self.panel, 1, wx.EXPAND, 0) self.SetAutoLayout(True) self.SetSizer(sizer_1) sizer_1.Fit(self) sizer_1.SetSizeHints(self) self.Layout() # end wxGlade # end of class MyFrameOne ## modified from BoaApp class App(wx.App): def OnInit(self): wx.InitAllImageHandlers() self.main = MyFrameOne(None) self.main.Show() self.SetTopWindow(self.main) return True def main(): application = App(0) application.MainLoop() if __name__ == '__main__': main() /code code id=modifiedFromGlade class=fails #!/usr/bin/env python # -*- coding: ISO-8859-1 -*- #The commented out code from MyFrame was moved to class Panel \ # and appropriately modified by changing self.panel to self etc import wx class MyFrameTwo(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrameTwo.__init__ kwds[style] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) ##self.panel = panel(self, -1) self.panel = Panel(self, -1) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): # begin wxGlade: MyFrameTwo.__set_properties self.SetTitle(frame_1) self.label.SetMinSize((-1, 15)) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrameTwo.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) ##sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) ##sizer.Add(self.label, 0, wx.ALL, 3) ##sizer.Add(self.textBox, 0, wx.ALL, 3) ##sizer.Add(self.button, 0, wx.ALL, 3) self.panel.SetAutoLayout(True) ##self.panel.SetSizer(sizer) ##sizer.Fit(self.panel) ##sizer.SetSizeHints(self.panel) sizer_1.Add(self.panel, 1, wx.EXPAND, 0) self.SetAutoLayout(True) self.SetSizer(sizer_1) sizer_1.Fit(self) sizer_1.SetSizeHints(self) self.Layout() # end wxGlade # end of class MyFrameTwo class Panel (wx.Panel): def __init__(self, *args, **kwds): self.staticbox = wx.StaticBox(self, -1, StaticBox) self.label = wx.StaticText(self, -1, Field Name) self.textBox = wx.TextCtrl(self, -1, Field Value) self.button = wx.Button(self, -1, Edit) __doLayout() def __doLayout(): sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) sizer.Add(self.label, 0, wx.ALL, 3) sizer.Add(self.textBox, 0, wx.ALL, 3) sizer.Add(self.button, 0, wx.ALL, 3) # maybe comment this and uncommennt frame2's corresponding line panel.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self.panel) sizer.SetSizeHints(self.panel) ## modified from BoaApp class App(wx.App): def
problem with wxPanel derivation class
wxGlade created a simple Frame with a panel a sizer and 3 wxControls , saticText, TextCtrl, and a Button. The resulting code works fine. Now the problem. I wish to make a separate class derrived from wxPanel that has the sized and controls as above. It jusst won't work code id=gladeGen class=works_ok #!/usr/bin/env python # -*- coding: ISO-8859-1 -*- # generated by wxGlade 0.4cvs on Thu Oct 11 13:26:19 2007 import wx class MyFrameOne(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrameOne.__init__ kwds[style] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel = wx.Panel(self, -1) self.staticbox = wx.StaticBox(self.panel, -1, StaticBox) self.label = wx.StaticText(self.panel, -1, Field Name) self.textBox = wx.TextCtrl(self.panel, -1, Field Value) self.button = wx.Button(self.panel, -1, Edit) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): # begin wxGlade: MyFrameOne.__set_properties self.SetTitle(frame_1) self.label.SetMinSize((-1, 15)) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrameOne.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) sizer.Add(self.label, 0, wx.ALL, 3) sizer.Add(self.textBox, 0, wx.ALL, 3) sizer.Add(self.button, 0, wx.ALL, 3) self.panel.SetAutoLayout(True) self.panel.SetSizer(sizer) sizer.Fit(self.panel) sizer.SetSizeHints(self.panel) sizer_1.Add(self.panel, 1, wx.EXPAND, 0) self.SetAutoLayout(True) self.SetSizer(sizer_1) sizer_1.Fit(self) sizer_1.SetSizeHints(self) self.Layout() # end wxGlade # end of class MyFrameOne ## modified from BoaApp class App(wx.App): def OnInit(self): wx.InitAllImageHandlers() self.main = MyFrameOne(None) self.main.Show() self.SetTopWindow(self.main) return True def main(): application = App(0) application.MainLoop() if __name__ == '__main__': main() /code code id=modifiedFromGlade class=fails #!/usr/bin/env python # -*- coding: ISO-8859-1 -*- #The commented out code from MyFrame was moved to class Panel \ # and appropriately modified by changing self.panel to self etc import wx class MyFrameTwo(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrameTwo.__init__ kwds[style] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) ## self.panel = panel(self, -1) self.panel = Panel(self, -1) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): # begin wxGlade: MyFrameTwo.__set_properties self.SetTitle(frame_1) self.label.SetMinSize((-1, 15)) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrameTwo.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) ## sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) ## sizer.Add(self.label, 0, wx.ALL, 3) ## sizer.Add(self.textBox, 0, wx.ALL, 3) ## sizer.Add(self.button, 0, wx.ALL, 3) self.panel.SetAutoLayout(True) ## self.panel.SetSizer(sizer) ## sizer.Fit(self.panel) ## sizer.SetSizeHints(self.panel) sizer_1.Add(self.panel, 1, wx.EXPAND, 0) self.SetAutoLayout(True) self.SetSizer(sizer_1) sizer_1.Fit(self) sizer_1.SetSizeHints(self) self.Layout() # end wxGlade # end of class MyFrameTwo class Panel (wx.Panel): def __init__(self, *args, **kwds): self.staticbox = wx.StaticBox(self, -1, StaticBox) self.label = wx.StaticText(self, -1, Field Name) self.textBox = wx.TextCtrl(self, -1, Field Value) self.button = wx.Button(self, -1, Edit) __doLayout() def __doLayout(): sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) sizer.Add(self.label, 0, wx.ALL, 3) sizer.Add(self.textBox, 0, wx.ALL, 3) sizer.Add(self.button, 0, wx.ALL, 3) # maybe comment this and uncommennt frame2's corresponding line panel.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self.panel) sizer.SetSizeHints(self.panel) ## modified from BoaApp class App(wx.App): def OnInit(self
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Bitpacked Data
i need to interface python with a bitpacked data file, the structure recorded in the file is the following: struct { var_1 4bit var_2 6bit var_3 2bit var_3 4bit } how can read the struct and convert data into dictionary Thnx -- http://mail.python.org/mailman/listinfo/python-list
Re: deepcopy alternative?
Szabolcs Nagy wrote: I believe the only thing stopping me from doing a deepcopy is the function references, but I'm not sure. If so is there any way to transform a string into a function reference(w/o eval or exec)? what's your python version? for me deepcopy(lambda:1) does not work in py2.4 but it works in py2.5 (in py2.4 i tried to override __deepcopy__ but it had no effect) Thanks that fixed the problem real quick :) Jack Trades -- http://mail.python.org/mailman/listinfo/python-list
deepcopy alternative?
I have a very complex data structure which is basically a class object containing (sometimes many) other class objects, function references, ints, floats, etc. The man for the copy module states pretty clearly that it will not copy methods or functions. I've looked around for a while (prob just using the wrong keywords) and haven't found a good solution. As a workaround I've been using cPickle, loads(dumps(obj)) which is incredibly slow (~8 sec for a 1000 elem list). I believe the only thing stopping me from doing a deepcopy is the function references, but I'm not sure. If so is there any way to transform a string into a function reference(w/o eval or exec)? Example from copy import deepcopy a = ClassObj([ClassObj([3.2, 'str', funcRef]), 4, ClassObj[funcRef]) b = deepcopy(a) TypeError: function() takes at least 2 arguments (0 given) All I want is a deepcopy of the list. Any suggestions would be appreciated. Jack Trades PS: If the answer to this is in __getstate__() or __setstate__() is there some reference to how these should be implemented besides the library reference? -- http://mail.python.org/mailman/listinfo/python-list
help with recursion on GP project
I'm trying to create a recursive function to evaluate the expressions within a list. The function uses eval() to evaluate the list. Like a lisp interpreter but very limited. What I'm looking for is a function to recursively traverse the list and provide answers in place of lists, so that ... Example = ['add', ['sub', 5, 4], ['mul', 3, 2]] Becomes:Example = ['add', 1, 6] Becomes:Example = 7 *Functions are defined in the script The code I currently have, which isn't pretty (bottom), doesn't work because it doesn't return the value of the evaluated list. But I can't figure out how to do that. Any help would be greatly appreciated. Jack Trades def recursive(tree): if type(tree[1]) != type([]) and type(tree[2]) != type([]): eval(a[0]+'('+str(tree[1])+','+str(tree[2])+')') if type(tree[2]) == type([]): recursive(tree[2]) if type(tree[1]) == type([]): recursive(tree[1]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Assignment in a while?
So it seems that I stumbled on the idiomatic way of doing this then. Well, as they say, When in Rome... :). Thanks for pointing out the FAQ. I'll be reading up on it. Cheers, Ben Paul Boddie wrote: none/Ben wrote: Assignment within a while loop seems like a pretty standard thing, so I'm just curious what I'm missing. The FAQ on this subject? ;-) http://www.python.org/doc/faq/general/#why-can-t-i-use-an-assignment-in-an-expression It's standard in C-flavoured languages, certainly, but probably not ubiquitous. Paul -- http://mail.python.org/mailman/listinfo/python-list
Assignment in a while?
Hi all, First, let me preface this by the fact that I'm completely new to the language, but not to programming in general. I'm trying to get my feet wet with something near and dear to my heart: database programming. Here's what I've got: import pgdb; dbh = pgdb.connect(database = 'test') sth = dbh.cursor() sth.execute(SELECT * FROM capitals) #while 1: #results = sth.fetchone() #if results == None: #break #print results while results = sth.fetchone(): print results If I try to run the above code, I get a SyntaxError indicating that I can't do an assignment in the while loop. I found a way around this (see the commented out while loop), but it seems hackish. Assignment within a while loop seems like a pretty standard thing, so I'm just curious what I'm missing. Thanks in advance, Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for help about python-sane
JW wrote: Every time, or just this run? every time -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a Zen language?
Cameron Laird wrote: In article [EMAIL PROTECTED], Kay Schluehr [EMAIL PROTECTED] wrote: . . . Lucid in the mid 80s that gone down a few years later. As it turned out that time Lisp was not capable to survive in what we call today a heterogenous environment. It was strongly too self-centered. So I . . . Smalltalk, too. And, in a different way, Pascal. I had the same thought. Smalltalk is a wonderful environment but it doesn't really play well with others. Smalltalk really wants to be *the* environment where the language is just a scripting tool within this larger environment of object manipulation, and it's really cool at that, but as a language for 'business apps' ina heterogenous environment out it's own image, it's akward sometimes -- http://mail.python.org/mailman/listinfo/python-list
Problem with Property
I'm trying to implement a simple repeateable property mechansism so I don't have to write accessors for every single instance variable I have. classMyObject: def __init__ (self): self.initialize() def initialize(self): self._value=None def _setProperty (self, name, value): print set property setattr (self, name, value) def _getProperty (self, name): print get property return getattr (self, name) #properties value = property (lambda self: self._getProperty(_value), lambda self, value: self._setProperty(_value, value)) def testObject(): o = MyObject() print o.__dict__ print o.value o.value = 123 print o.value print o.__dict__ if __name__ == __main__: testObject() - The outout looks like this {'_value': None} get property None 123 {'_value': None, 'value': 123} --- As you can see, the _getProperty() method gets called properly when I do 'o.value' but 'o.value = 123' does not seem to use the property stucture. I can't figure out why 'o.value=123' does not call _setProperty() Any ideas? Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with Property
André Malo wrote: * none wrote: classMyObject: [...] As you can see, the _getProperty() method gets called properly when I do 'o.value' but 'o.value = 123' does not seem to use the property stucture. I can't figure out why 'o.value=123' does not call _setProperty() Any ideas? property only works as intended with new style classes. duh.. I changed that to class MyObject(object): and it worked fine Thanks Take care, Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with Property
André Malo wrote: * none wrote: classMyObject: [...] As you can see, the _getProperty() method gets called properly when I do 'o.value' but 'o.value = 123' does not seem to use the property stucture. I can't figure out why 'o.value=123' does not call _setProperty() Any ideas? property only works as intended with new style classes. duh.. I changed that to class MyObject(object): and it worked fine Thanks Take care, Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with Property
Steve Holden wrote: none @bag.python.org wrote: It seems particularly odd to want to put getters and setters behind property access. What does the extra layer buy you? The purpose is that there is more to the accessors then I posted. The setters do some 'mark dirty' bookeeping whenever the object state changes. (I had coded something similar in a prior project but had forgotten a bit of my own work...in that project the setters also did some event signaling as the objects were part of an Observer-Observable pattern) The getters also have some code in them for dealing with default values if the given variable behind the property does not exist (which happened when I was pickling objects and the class structure changed over time; it was helpful to be able to have the getter be able to check if the variable existed and, if not, provide a default value...a way of migrating objects to new class definitions) So, the use of properties allowed me let clients of the class to use direct access syntax... o.value versues o.value() or o.value = 123 versus o.value(123) ...but still allow me to do the bookkeeping needed for my object state. The use of the _getProperty() and _setProperty() and using lambdas in the actual property definition allowed me to have a default setter/getter of sorts so I didn't need to write a seperate getter and setter method for each variable Take care, Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a Zen language?
John Coleman wrote: Bryan Olson wrote: John Coleman wrote: I have a rough classification of languages into 2 classes: Zen languages and tool languages. A tool language is a language that is, well, a *tool* for programming a computer. C is the prototypical tool language. Most languages in the Algol family are tool languages. Visual Basic and Java are also tool languages. On the other hand, a Zen language is a language which is purported to transform your way of thinking about programming. Lisp, Scheme, Forth, Smalltalk and (maybe) C++ are Zen languages. I think that's a horrible classification. Every language is both. Transform your way of thinking from what? There is no distinguished canonical view of what a programming language looks like, from which all others must be strange and wondrous transformations. Lisp and Forth are not tools for programming a computer? Of course they are. Algol and Java don't transform people's thinking about programming? Nonsense. -- --Bryan You seem to have completly overlooked both the hedge word rough in my first sentence and the qualifications in my third paragraph. I probably was not sufficiently clear that I was describing some fairly sunjective impressions. It is a simple observation that devotees of the Scheme language view their language as more than *just* a tool for programming computers. To quote from the introduction to the first edition of SICP: we want to establish the idea that a computer language is not just a way of getting a computer to perform operations but rather that it is a novel formal medium for expressing ideas about methodology (http://mitpress.mit.edu/sicp/full-text/book/book.html). It is also a simple observation that experts in VBScript *don't* walk around talking like that. Scheme and VBScript are of course both Turing complete, but they seem to have radically different cultures. Do you disagree? Or, if you agree that there is a difference but don't like the words Zen vs. tool to describe it, how would you articulate the difference? Again, just curious. It's a metter of perspective. Python didn't change my thinking about programming. Smalltalk changed my way of thinking about programming very radically. All Python changed my thinking about was how to better program in Python. Python to me just happened to be a very pragmmatic and productive tool for getting the job done. It happens to be comfrotable because large parts of it already fit into my way of thinking from long use in Smalltalk, but my description of Pythong would be 'cleanly practical' not 'zen' -- http://mail.python.org/mailman/listinfo/python-list
Code to read Cobol data files
Hi, Any one know of some code to read cobol data files thanks timb -- http://mail.python.org/mailman/listinfo/python-list
Newer than a Newbe
Hello, I am just starting to look into python.I have been prog with php for several years.My question is: Can/Is Python used as a web scripting language , and if so do many hosts support it? Thanks Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Faster GUI text control
Fredrik Lundh wrote: none @bag.python.org wrote: no, it would mean writing some python code. if all you need is a scrolling text list, you can simply use the code on this page: http://effbot.org/zone/wck-4.htm (see A scrollable list view, with scrollbar support and, optionally, the virtual data modifications under Displaying Huge Data Sets) the resulting widget will update at constant speed, independent of the data size. /F Thanks for the suggestion. I looked at that, but I need to be able to selectively change colors on parts of the text and I didn't think I could do that with a list box. Am I misunderstanding that? yes. the list view isn't a listbox, it's a new widget. with the list view, you control the drawing yourself, and can draw things in whatever way you want. (the section Non-Standard Rendering talks about this; reading http://effbot.org/zone/wck-3.htm also helps). /F Thanks for the clarification. I'm going to go back and read the Writing widgets articles in detail. -- http://mail.python.org/mailman/listinfo/python-list
Re: Faster GUI text control
That's a good point about the amount of text available at once. As long as I could swap the visible section fast enough that might be a good solution. This will run mostly on Windows, but I'd like for it to be equally usable on Linux. -- http://mail.python.org/mailman/listinfo/python-list
Faster GUI text control
Hi, I wrote a program for work that processed and formatted some collected text data in a Tkinter based GUI display. I've found that as my data files get longer (a few thousand lines), there seems to be a real lag when it comes to clearing or updating the Text control, enough so that the program just isn't useful. I poked around some and saw several people mention that is was a known issue with Tkinter. I'm trying to decide what is the best replacement for the control. I was originally planning on redoing the GUI with wxpython, but I've seen people indicate I would have the same problem. I also was looking at Fredrik Lundh's widget construction kit info. That looks like it could be useful, but it would still require building a new control and I'm not sure if it would solve my base problem. I'm still pretty inexperienced with Python, so I'd like to concentrate on using a working text control and writing the data processor part of my program rather than writing and debugging a text control to use. Does anyone have any recommendations they could share? Thanks very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: Postgres COPY Command with python 2.3 pg
Michael Lang wrote: using psql it works fine, but i dont know how to get it working in python. Ive already made the calls but the changes never apper, and no error. Which Postgres module are you using? I had the exct same problem when I first started using pyPgSQL, until I figured out that I needed to do: db = PgSQL.connect(DSN) db.autocommit = 1 con = db.cursor() In my code. -- http://mail.python.org/mailman/listinfo/python-list
get the IP address of a host
I want to determine the outside (non local, a.k.a. 127.0.0.x) ip addresses of my host. It seems that the socket module provides me with some nifty tools for that but I cannot get it to work correctly it seems. Can someone enlightened show a light on this: import socket def getipaddr(hostname='default'): Given a hostname, perform a standard (forward) lookup and return a list of IP addresses for that host. if hostname == 'default': hostname = socket.gethostname() ips = socket.gethostbyname_ex(hostname)[2] return [i for i in ips if i.split('.')[0] != '127'][0] It does not seem to work on all hosts. Sometimes socket.gethostbyname_ex only retrieves the 127.0.0.x ip adresses of the local loopback. Does someone has a more robust solution? Targetted OS'es are Windows AND linux/unix. -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuations Based Web Framework - Seaside.
Mike Thompson wrote: 'Seaside' is a Smalltalk framework for what might be called Modal Web Development or Synchronous Web Programming, or even Continuation Based Web Apps. Continuation Based Frameworks seem to be getting quite some attention lately. For example in the Lisp world. Check out Bill Clementson's blog for some excellent posts. http://home.comcast.net/~bc19191/blog/041229.html And Seaside looks indeed very nice. Would be good to see it generate some new interests in Smalltalk/Squeak. I googled for the python spin-off but didn't find one. Does Python really need yet another framework? Apart from the intellectual excersise, wouldn't it be nice if Python would get a framework for the rest of us (meaning: mere mortals) which would focus upon getting work done in a simple manner instead of creating yet another, new, hip, exciting, way of creating dynamic websites? If Python cannot deliver a PHP clone, at least you would expect a Rails lookalike. And though part of the Rails stack may be surpassed easily by Python equivalents, no Python alternative offers (imho of course) the same level of simplicity, elegance and pragmatism (!!) as Rails does. Regards, Iwan -- http://mail.python.org/mailman/listinfo/python-list