How to script DOS app that doesn't use stdout
There's a DOS console application I am trying to script (in Python), but it doesn't seem to use stdout or stderr... For example, if I redirect output to a file ("cmd > file.txt"), the output still appears on screen. Similarly, the output pipes returned by popen* don't catch the app's output. How might this app be generating its output? Any thoughts on how it could be captured (perhaps with something in the win32 extensions)? Thanks, Greg. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to script DOS app that doesn't use stdout
> "Gregor" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> There's a DOS console application I am trying to script (in Python), >> but it >> doesn't seem to use stdout or stderr... For example, if I redirect >> output to a file ("cmd > file.txt"), the output still appears on >> screen. Similarly, the output pipes returned by popen* don't catch >> the app's output. How might this app be generating its output? Any >> thoughts on how it >> could be captured (perhaps with something in the win32 extensions)? "Paul Watson" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > The good-ole DOS app could be doing many things. It could be making > BIOS calls or writing directly to the video display memory at segment > 0xB800. One would think that if it did a DUP of stdout that it might > get captured, but apparently you have tried the popen* family. > > Any hints as to what the DOS app is? If it is known by anyone, > perhaps a workaround is also known. Hmmm. Sounds like scripting this app might be a bit of a problem... I don't think the program was available to the general public... It's called "PC-Bill." It's used to send doctors' bills to the Canadian government. Greg. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to script DOS app that doesn't use stdout
Timothy Grant <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On Sun, 06 Mar 2005 13:41:57 GMT, Gregor <[EMAIL PROTECTED]> > wrote: >> There's a DOS console application I am trying to script (in Python), >> but it doesn't seem to use stdout or stderr... For example, if I >> redirect output to a file ("cmd > file.txt"), the output still >> appears on screen. Similarly, the output pipes returned by popen* >> don't catch the app's output. How might this app be generating its >> output? Any thoughts on how it could be captured (perhaps with >> something in the win32 extensions)? >> >> Thanks, >> >> Greg. > > I've had to do this a couple of times but never in recent years. I > don't know your exact needs, but the best tool I ever found for this > sort of job was called Phantom of the Keyboard. > > I ran into a couple of apps that I needed data out of and couldn't get > it. They'd only output to screen, never to disk. I used Phantom to > automate the app to dump data to screen and then capture the screen to > disk. > Hmmm, interesting. I'll give that app a try. Thanks for the info. Greg. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check the date validity?
Am Mon, 23 Dec 2013 16:30:35 -0800 schrieb Igor Korot : > > Now, it looks that the python way of validating the date/time of the > string is to call strptime(). However looking at the docs and trying > to use the function I didn't find a way to check for the milliseconds. > Now the dates can be formatted differently I think according to the > locale under which the csv is generated. you can also use an validator package like formencode: http://www.formencode.org/en/latest/Validator.html It has an TimeConverter but it does not understand milliseconds either. But it should be trivial to implement it based on TimeConverter. Using formencode the validation / conversion is seperated and therefore reusable. You also get nice human readable validation messages in different languages. It supports also Schemas to validate complete records. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
Am 13 May 2014 01:18:35 GMT schrieb Steven D'Aprano : > > - have a simple way to write bytes to stdout and stderr. there is the underlying binary buffer: https://docs.python.org/3/library/sys.html#sys.stdin greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Execute a python script with CGI ?
Hi, Am Thu, 26 Jun 2014 08:24:56 -0700 (PDT) schrieb dandrigo : > I coded a python script (web service with query postgresql/postgis). > Up to now, i did several test on my local laptop station (windows). > > Now i want to execute this python script on our remote server (Web > server : Apache;OS : Linux). > > How to write a CGI template please? > > Could you throw light for me? https://docs.python.org/2/library/cgi.html -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: In defence of 80-char lines
Am Wed, 3 Apr 2013 21:32:33 -0700 (PDT) schrieb llanitedave : > I would hate to have to break up this line, for instance: > > self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, > faceName = "FreeSans")) I think this is much more readable: self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = "FreeSans")) Emacs for example does this indentation with the TAB key automatically. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > > Name mangling is a poor substitute for private variables. If you want > to be able to share private variables with other classes under certain > circumstances, it's better to use something like C++'s "friend" > declaration, where you can export the variables to a specific other class. That assumes that you always know for sure that the given variable will always be used as a private/friend variable in the lifecycle of the software. Software is too complictated to know everything in advance. "Software lives" and totalitarian laws destroy easy living. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > Gregor Horvath <[EMAIL PROTECTED]> writes: > >>>to be able to share private variables with other classes under certain >>>circumstances, it's better to use something like C++'s "friend" >>>declaration, where you can export the variables to a specific other class. >> >>That assumes that you always know for sure that the given variable >>will always be used as a private/friend variable in the lifecycle of >>the software. > > > Obviously if you find you need to use it in another place later, you > update the declaration. The idea is for you (or an automatic tool) to If its your code this is possible, but if not and the maintainer is not willing or able to change it, then you have a problem. The fact that in other languages there are wired tricks to get to private instance variables is a strong indicator that there is a need for that. Guided freedom is better than enforced authority. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > allowed to do that--that's why the variable is private. Is he > supposed to get your permission every time he wants to change how the > private variables in his class work? > No, but the assumption here is that the maintainer / designer of a class alaways knows everything and things are static. Unfortunatly this is wrong in real live. When you use a _ variable in python you know that this may break in the future because of changing interfaces. Thats a typical engineering Trade Off on my side. One that is in other languages not even possible. A clear disadvantage. Python gives me power and does not take it away like the others. > stuff off. And it's certainly not intended for normal classes in an > application to get at the private variables of other classes. > So is in Python. It is certainly not intended to use _ variables. But you can do it, at your own risk. I do not need an authority that forbiddes things, but one that guides in the correct direction without coming in my way. The engineering decisions regarding my application should be on my side, not the language lawyers. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > > Huh? If my car has a "feature" that lets someone blow it to > smithereens from hundreds of miles away without even intending to, > that's somehow an advantage? I would not accept a car that does constraint my driving directions. I want to drive for myself, because its fun. > > No problem, but any decision like that should be expressed in > "writing", by re-declaring the variable so it's no longer private. Remember, its Python not Java. Tastes are different and so are programming languages, but please do not make Python to a Java Clone. I love python because of its simplicity, freedom, power and because its fun to program. One reason is that it does not restrict the programer to tight und has genuine simple solutions, like the one with "private" instance variables. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > > If you don't want the compiler to make sure your private instance > variables stay private, then don't declare them that way. You're the > one asking for less flexibility. I want to declare them as privat, but want to give the flexibilty to access them at the users own risk. Declaring everything as public is nonsene, because there should be a garanteed stable interface. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > > You could have a "friend" declaration like in C++, if you want to let > some class see the private instance variables of another class. Everything is said on this topic. There are two ligitimate solutions to the problem of private instance variables. Its a matter of taste, and mine is the pythonic one. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > Bill Mill <[EMAIL PROTECTED]> writes: > >>Python is for consenting adults. > > Python might be for consenting adults, but multi-person software > projects are supposed to be done in the workplace, not the bedroom. Are the numerous working python open source projects not multi-person software projects? Even multiple persons that even dont know each other and can discuss the latest news at the coffee machine? The fact that they are working and there is not much demand for a bastion is a strong signal that pythons attitude: advise but not enforce is actually working. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > > I don't know of a single program that's actually relying on the > non-enforcement. I've asked for examples but have only gotten > theoretical ones. As far as I can tell, the feature is useless. Real open source live example from yesterdays mailinglists: quick question: I just updated both my python install (241->242) as well as updating webware from the svn ( I know I should not have done both at the same time) and when i tried to run webware (after running install.py again) I received an error that in application.py at line 125 I could not do float - none. It appears to me that the Profiles.starttime is not being set and so it defaults to none. I added a line setting the starttime to self._startTime which fixed the problem for me but I thought I would pass the info to the group. Has anyone else had this problem? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin schrieb: > Gregor Horvath <[EMAIL PROTECTED]> writes: > >>Real open source live example from yesterdays mailinglists: > > > I don't see any use of name mangling in that example. Someone has a problem and tweaks a private variable as a workaround. No python program will rely by definition on access to privat variables, it just lets the door open, just for the case that the program is not used in steril theoretical environment with a lot of flipcharts but in real dirty live with bugs, version conflicts, changing demands, ill spezifications, crazy public interfaces and so on. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin wrote: > Gregor Horvath <[EMAIL PROTECTED]> writes: >>Someone has a problem and tweaks a private variable as a workaround. > > They should have patched the source instead. > I think they are going to do that. In the meantime our friend has a working solution otherwise he would have nothing but broken code today. > > Believe it or not, not all development environments are that > disorganized. Martians? Examples? This has nothing to do with organisation but a lot with natural influances and constraints of software development (except really simple programs) -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
El Pitonero schrieb: > > The fact that you can override Python's "list()" function can be either > viewed as pro or con. The fact that you can override member variables > can also be viewed as pro or con. > If there is a tool like pyChecker, which can detect such pitfalls and warns but not forbidds - one can avoid the cons and still can use the pros. The computer should be an assistent not a dominator of humans. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
modifying source at runtime - jython case
Hello folks I want to apply changes in my source code without stopping jython and JVM. Preferable are modifications directly to instances of classes. My application is a desktop app using swing library. Python solutions also interest me. Solution similiar to "lisp way" is ideal. Thanks for response, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: modifying source at runtime - jython case
In article <[EMAIL PROTECTED]>, Alan Kennedy wrote: > [Jan Gregor] >> I want to apply changes in my source code without stopping jython >> and JVM. Preferable are modifications directly to instances of >> classes. My application is a desktop app using swing library. >> >> Python solutions also interest me. >> >> Solution similiar to "lisp way" is ideal. > > OK, I'll play 20 questions with you. > > How close is the following to what you're thinking? I see. Following try showed me that instances aren't affected by modification in class definition. but this helped x.test = a().test OR x.test = y.test The only thing left is how to initiate modification, it's a swing application and i think interp.exec don't stop until it's done. Maybe somehow call it from jython itself - but need to pass PythonInterpreter instance. Thanks. class a: def test(self): print 'first' x= a() class a: def test(self): print 'second' y= a() x.test() y.test() > > begin SelfMod.java --- > // > import org.python.util.PythonInterpreter; > import org.python.core.*; > > class SelfMod >{ > >static String my_class_source = > "class MyJyClass:\n" + > " def hello(self):\n" + > "print 'Hello World!'\n"; > >static String create_instance = "my_instance = MyJyClass()\n"; > >static String invoke_hello = "my_instance.hello()"; > >static String overwrite_meth = > "def goodbye():\n"+ > " print 'Goodbye world!'\n" + > "\n" + > "my_instance.hello = goodbye\n"; > >public static void main ( String args[] ) > { > PythonInterpreter interp = new PythonInterpreter(); > interp.exec(my_class_source); > interp.exec(create_instance); > interp.exec(invoke_hello); > interp.exec(overwrite_meth); > interp.exec(invoke_hello); > } > >} > // > end SelfMod.java - > > need-to-complete-my-coursework-for-telepathy-101-ly y'rs > -- http://mail.python.org/mailman/listinfo/python-list
Re: modifying source at runtime - jython case
In article <[EMAIL PROTECTED]>, Kent Johnson wrote: > Jan Gregor wrote: >> Hello folks >> >> I want to apply changes in my source code without stopping jython >> and JVM. Preferable are modifications directly to instances of >> classes. My application is a desktop app using swing library. > > Can you be more specific? Python and Jython allow classes to be modified at > runtime without changing the source code or compiling new code. For example > you can add and remove methods and attributes from a class and change the > base classes of a class. You can also modify individual instances of a class > to change their attributes and behaviour independently of other instances of > the class. What are you trying to do? For example see > http://groups.google.com/group/comp.lang.python/browse_frm/thread/8f7d87975eab0ca4/18215f7ce8f5d609?rnum=15#18215f7ce8f5d609 > http://groups.google.com/group/comp.lang.python/browse_frm/thread/a0b19b37ac48deaa/e599041de4b8feb0?rnum=22#e599041de4b8feb0 > > Kent thanks for links, I'll look at them. Alan showed me some possibilities, i'm not quite sure how to initiate modification and the way import keyword works in case of modified imported modules. my typical scenario is that my swing application is running, and i see some error or chance for improvement - modify sources of app, stop and run application again. so task is to reload class defitions (from source files) and modify also existing instances (their methods). Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: modifying source at runtime - jython case
Kent Johnson wrote: > Jan Gregor wrote: > >> my typical scenario is that my swing application is running, and i see >> some error or chance for improvement - modify sources of app, stop and >> run >> application again. >> so task is to reload class defitions (from source files) and modify also >> existing instances (their methods). > > > Ok, I think my first reply completely missed the mark. IIUC what you > want is hard. This recipe might help: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 > > Kent Yes, this is right way. And it's working. Thanks, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: Reaching the real world
Hi, I have just written a python module to program the M232 measurement unit from elv. It has 8 digital I/O and 6 analog ports (0-5V). Works fine, although it is a little bit slow (0,2 s to measure) Furthermore the digital ports do not have enough power to switch a relay directly, I had to do it with additional transistors. It controls my heating together with a python program an a eletric motor / gearbox and some sensors. german store: http://www.elv.de/ Type M232 into the search field. english: http://www.elv.de/shopping/elvcom/ If you are intersted in the python code, just drop a note. -- Greg Fuzzyman wrote: I have a friend who would like to move and program lights and other electric/electro-mechanical devices by computer. I would like to help - and needless to say Python would be an ideal language for the 'programmers interface'. What I'd like is an electronic interface that connects to several relays and a python extension module to switch on and off the relays. I've had a quick google and can't see anything too similar to what I want. pyro (python robotics) seems to require expensive (relatively) robotic equipment. Does anyone know anything *similar* to what I have in mind, or have alternative suggestions ? Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
HTML table input data grid
Hi, I googled for a possibilty to create a html table where the user can input data. I just found this site: http://www.codeproject.com/aspnet/I3HTree2.asp That is what I am looking for. Is there an existing solution for python? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: redirect of standard output of jython to JTextArea
problem solved. in class: sys.stdout = StdOutRedirector(self) class StdOutRedirector: def __init__(self, console): self.console = console def write(self, data): #print >> sys.stderr, ">>%s<<" % data if data != '\n': # This is a sucky hack. Fix printResult self.console.textArea.append(data) Jan Jan Gregor wrote: Hello I want to redirect output of jython's functions print and println to JTextArea component. Is it possible ? I tried this (swingConsole.textArea is instance): In my class self.printStream= MyPrintStream(System.out) System.setOut(self.printStream) class MyPrintStream (PrintStream): def println (str): swingConsole.textArea.append(str) def print (str): swingConsole.textArea.append(str) Output is still directed to standard output. Thanks for help, Jan -- http://mail.python.org/mailman/listinfo/python-list
redirect of standard output of jython to JTextArea
Hello I want to redirect output of jython's functions print and println to JTextArea component. Is it possible ? I tried this (swingConsole.textArea is instance): In my class self.printStream= MyPrintStream(System.out) System.setOut(self.printStream) class MyPrintStream (PrintStream): def println (str): swingConsole.textArea.append(str) def print (str): swingConsole.textArea.append(str) Output is still directed to standard output. Thanks for help, Jan -- http://mail.python.org/mailman/listinfo/python-list
HTML Tree View with and
Hi, Before I reinvent the wheel I`d like to ask if someone has done this before since I did not find an advice at Google. The goal is to create a dynamic Tree View in HTML. Say I have a data strucure like this: structList = {'Sun':{'Sun.1':['Sun1.1','Sun1.2'],'Sun.2':['Sun2.1','Sun2.2']},'Kupa':['Kupa1']} I want to transform this into HTML: Sun Sun.1 Sun1.1 Sun1.2 Sun.2 Sun2.1 Sun2.2 Kupa Kupa1 If the user clicks on a branch-link say 'Sun.1' then the branch below opens/closes (not printed by the servlet). Like a tree view control in an native GUI app. Has this, or a similar approach, been done before in python ( I am using webware/cheetah)? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
String from File -> List without parsing
Hi, given the dynamic nature of python I assume that there is an elegant solution for my problem, but I did not manage to find it. I have a file that contains for example on line: ['147', '148', '146'] when I read the file f = file("I050901.ids").readlines() I have a string f[0] == "['147', '148', '146']" How can I turn this string into a list li == ['147', '148', '146'] without parsing? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: String from File -> List without parsing
John Machin wrote: >> f = file("I050901.ids").readlines() > > Y3K bug alert :-) but then there is Python 3000 and Hurd, which solves all problems of this universe :-) > Something like this: > > >>> def munch(astrg): > ...return [x[1:-1] for x in astrg.rstrip("\n")[1:-1].split(", ")] Thanks! > (1) You neither want nor need to use eval. I wanted to avoid parsing, but when parsing is an 1 liner, I think its the better solution. > > (2) What is creating files like that? If it is a Python script, consider > writing them using the csv module; that way, other software can read > them easily. > Its a Python script. But the file is not intended to be used by another sotware, although it should be readable by humans. I think the python syntax is better human readable than csv. After all the sense of this file is to make a list persistant quickly and easily and human readable. Maybe pickleing is a third option? -- Gregor -- http://mail.python.org/mailman/listinfo/python-list
python script under windows
Hello I run python script on another computer and want to "survive" that script after my logout. the script also uses drive mapping to network drive. Can you help me ? Or better is there some info for unix person how to survive with python on windows ;-) thanks, jan gregor -- http://mail.python.org/mailman/listinfo/python-list
Why tuple with one item is no tuple
Hi, >>>type(['1']) >>>type(('1')) I wonder why ('1') is no tuple Because I have to treat this "special" case differently in my code. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Why tuple with one item is no tuple
thanks are given to all "problem" solved... -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
James wrote: You will probably find migrating to VB.NET easier than to Python if you have to do WYSIWYG data bound form design. VB.NET is quite a nice language (I personally prefer C#). Much nicer than VB6. Python is better but it may not meet YOUR needs infrastructure wise. This is more a strategic decision than a technical one. MS has proven that it uses and forces its developers community to maximize their own profits and spread of technologies. Personally I dont want to be forced ("Where do you want me to go today?") Who guarantees that VB.NET will not have the same tragic kismet that VB6 had? Open Source is totally different and thats the real difference between VB and python. As long as their are users and working code, there will be a community around an OSS tools project. This is not true for commercial tools, as perfectly proven by MS with VB6. Its users are crying and MS is deaf because of strategic MS considerations. http://news.com.com/Developers+slam+Microsofts+Visual+Basic+plan/2100-1007_3-5615331.html?tag=nl http://news.com.com/Microsoft+walks+VB+tight+rope/2100-1007_3-5620821.html?tag=nefd.lede -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Newby Q: nested classes, access of upper method
Hello, class A(self): def A1(): pass class B(self): def B1(): # #*** How can I access A1 here *** # self.A1() # doesnet work because self references to B self.self.A1() #doesnt work either Renanimg class B(self1): doesnt work either because self is not bound. How can I access a method of a "upper" class? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Newby Q: nested classes, access of upper method
Hello Nick, thank you, your answer really helped me.. -- Greg Nick Coghlan wrote: Gregor Horvath wrote: Hello, class A(self): def A1(): pass class B(self): def B1(): # #*** How can I access A1 here *** # self.A1() # doesnet work because self references to B self.self.A1() #doesnt work either Renanimg class B(self1): doesnt work either because self is not bound. OK, I suspect you're a little confused about how classes work. The items in brackets after a class name are the *base* classes of a class, not the way the class refers to itself. So Python will complain if the listed items can't be inherited from for one reason or another. I suggest having another read of the tutorial section on classes to figure out exactly what you want to be doing: http://www.python.org/doc/2.3.4/tut/node11.html How can I access a method of a "upper" class? Merely defining one class inside another class does not automatically give instances of that inner class a reference to an instance of the outer class - if such a reference is needed, it must be provided in the inner class's constructor. E.g. class A(object): class B(object): def __init__(self, owner): self._owner = owner def B1(self): self._owner.A1() def A1(self): pass def makeB(self): return A.B(self) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and concatenation of strings
Ok, thanks. I didn't think that += operator is nondestructive operation - but strings are immutable so this makes sense. On 2004-12-13, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> I found that price of += operator on string is too high in jython. For >> example 5000 such operations took 90 seconds (i generated html copy of >> table with 1000 rows and 5 columns). Generation of row data into separate >> string and joining after lead to time 13 seconds !!! > > Its generally not recommended to use simple string concatenation for > building larger strings - neither in python nor in java/jython. > > afaik there are two solutions to this: The java-way and the jython way: > > java: Use StringBuffer > python: use a list, and append the strings to that. Then, when you want the > result, do > > "".join(stringlist) > -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
Hi, Adam DePrince wrote: computers of the day. This was in a misguided effort to make computers understandable to their target audience. The goal of the day was to build a system that a manager would want to buy; it was believed that [..] BASIC = Beginners all purpose symbolic instruction code ABC = laerning language Python = Follows IMHO the same goals as BASIC did, make programming as simple as possible, they are related Sure for people loving technology and complexity this goals (simplicity, easy to understand) are the opposite of their interests. Therefore both BASIC and Python do have the same opposition with very similar arguments. Complexity is the evil of all programming. Reducing it is a win. Therefore BASIC was right and python is also because they follow the same philosophy. For example: I even think that the meaningful identation in python is the continuation of the absence of a line delimiter in BASIC. Braces and semicolons are essentially useless and redundant because indentation and LF are already there, therefore leave it out; well this is indeed the meaning of the word basic. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
Peter Otten wrote: May you could give us an idea of the current state of basic affairs then by translating the following example snippet: yes you can do it in VB6, but pythons lists and dictionarys are superior to those built in in VB and I think to those in most other languages. It's me wrote: I saw this code from an earlier post: lst1 = ["ab", "ac", "ba", "bb", "bc"] lst2 = ["ac", "ab", "bd", "cb", "bb"] dct1 = dict.fromkeys(lst1) print [x for x in lst1 if x not in dct1] print [x for x in lst1 if x in dct1] I think line3 should be >>dct1 = dict.fromkeys(lst2) correct? VB6 Code: Sub xy() Dim lst1 As New Collection Dim lst2 As New Collection lst1.Add "ab", "ab": lst1.Add "ac", "ac": lst1.Add "ba", "ba": lst1.Add "bb", "bb": lst1.Add "bc", "bc" lst2.Add "ac", "ac": lst2.Add "ab", "ab": lst2.Add "bd", "bd": lst2.Add "cb", "cb": lst2.Add "bb", "bb" For Each item In lst1 If ColHasKey(lst2, item) Then Debug.Print "in:" & item Next For Each item In lst1 If Not ColHasKey(lst2, item) Then Debug.Print "not in:" & item Next End Sub Function ColHasKey(col As Collection, item) As Boolean On Error GoTo er A = col(item) ColHasKey = True Exit Function er: If Err.Number = 5 Then ColHasKey = False Else Err.Raise Err.Number End If End Function -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
It's me wrote: Absolutely *ugly*! But still, your point is well taken. Thank you for pointing this out. Adam was right: "Don't do it, unless your goal is simply to embarrass and insult programmers". OK. Then please schow me, how you can create a complex form with grids, explorer like trees etc. in 2 minutes in standard python. Or make any given standard python object accessible from MS Excel in 2 minutes. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
jython and concatenation of strings
Hello I found that price of += operator on string is too high in jython. For example 5000 such operations took 90 seconds (i generated html copy of table with 1000 rows and 5 columns). Generation of row data into separate string and joining after lead to time 13 seconds !!! What's alternative way to do that ? (similiar parts of my code are terribbly slow and such simple solution as above didn't help). Thanks, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Daniel T. wrote: [EMAIL PROTECTED] wrote: A paper finding that OOP can lead to more buggy software is at http://www.leshatton.org/IEEE_Soft_98a.html Sure, OOP *can* lead to more buggy software, that doesn't mean it always does. I think that costs(=time) to develop and maintain software depends not on wheter it is based on OOP or not but on two factors: * Number of NEW Code lines to solve the given problem * Complexity of this new code The anwser to the question if OOP is better is: it depends If the given problem is solved with less code and complexity in OOP then it is the better approach if not the reverse is true. Thats why I like python because it does not force to use OOP or procedural programming. But isnt the main argument to code in Python (or other high level languages) easy of use and compact code? Therefore should Python code be less buggy and cheaper to develop and maintain. Are there any papers on that? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and concatenation of strings
StringBuffer class from java was right solution - yours looses encoding, and in jython I was unable to get it back - in python it worked fine. Jan > I don't use Jython, but are you not able to do something like: > > string_list = [] > for ... in ...: > ... > string_list.append(...) > ... > string = ''.join(string_list) > > This is the usual Python idiom and is usually faster than the += idiom. > > Note too that +ing strings in Java also has this problem -- hence > StringBuffer or whatever it's called. > > Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
Thomas Bartkus wrote: > On what basis do you think the mechanics of producing a working > language are easier because the language is interpreted. Because: Type code Run code. VB6 goes a step further: Run Code Type Code That means that you can set a breakpoint. While the debugger stops you can edit the sourcecode (to some extent) without stopping program execution and let the interpreter run this new code without restarting the program. Essentially you can code inside the debugger. That gives you the possibilty to fix a bug on the fly since on an exception the debugger stops at the wrong line. Try different possibilities and see the result immediatly in the given context. That would be an nice feature for python (debugger), because this is true interactive development. Or is it already there and I missed it? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
Adam DePrince wrote: On Fri, 2004-12-17 at 09:25, Steve Holden wrote: Or make any given standard python object accessible from MS Excel in 2 minutes. What you describe is a political, not technical, challenge. What I describe is a daily costumer demand. Like or not, the world uses Excel and costumers want to access apps from it. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
Andrew Dalke wrote: Huh? I'm talking about my views of myself. I said that BASIC was a programming language I could learn without access to anyone else, on a microcomputer circa 1982. All I had was the book that came with the computer, and after a while a book on BASIC games. The machine I had was a TI 99/4A. My Dad got it because the marketing said "it's a 16 bit processor which is the wave of the future; the other machine only have 8 bit processors." It came with BASIC. LOGO was available, now that others reminded Seems that we had the same career. :-) I liked the TI 99/4A. Mine is still running, sometimes :-) TI really made a good job in producing a educational machine. It was simple, and you could make good results with little effort. Same with python today. And whow knows, without the TI, would I post here right now? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Use macros in Excel via win32com
chris wrote: I'm creating an excel document dynamically from scratch using Python and the win32com module. All is well, but now I need to add a macro to the spreadsheet and run it (to enable some sorting features in the spreadsheet). I think I know how to run a macro once it's installed (using the Run method of the excel application object...I think), but I can't figure out how to "install" the VBA macro code into the spreadsheet to begin with from my Python script. Any tips appreciated. Make a xla in Excel including your VBA macro first and then create your spreadshet from python using that xla as template. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: what would you like to see in a 2nd edition Nutshell?
RM wrote: What you say is true. However, I didn't think the target audience of this book was newbies. Python newbies yes, but not programming newbies. For programming newbies I would recommend the "Learning Python" book instead. The availability argument, however, is a good point. I was/am a python newbie beginning to learn python with this excellent book. I think it would have been much easier if there were more comparisions of features to other mainstream languages which one likely already knows (C, VB, Java ...) I liked the following Java book especially because of those comparisions: http://www.amazon.de/exec/obidos/ASIN/0130894680/qid=1104474997/ref=sr_8_xs_ap_i1_xgl/302-1345611-4845666 The included comparisions helped me to get into the Java language more quickly. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Logging: Formatter: name of the function
Hi, Is there a possibility to format a log message to give the function name where the log appears? Example import logging def aTestFunction(): logger.debug("This is a message") The log should read: aTestFunction This is a message. There is a possibilty to format the module namewith %(module)s, but I did not find one for the function name. Is there a possibilty or can I create it myself? How can I determine the function name within a function? Introspection? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to read, and analyze a log file?
Hi, [EMAIL PROTECTED] schrieb: > I am reading a log file, and wondering what is the best way to read and > analize this. Look at: http://pyparsing.wikispaces.com/ There is also an example for parsing an apache log. -- Servus, Gregor http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Grammar parsing
Paolo Pantaleo schrieb: > How can I write a pareser for a certain gramamr? I found PyPy that > does it, is thare any other tool? Maybe something built-in the python > interpreter? > http://pyparsing.wikispaces.com/ -- Servus, Gregor http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Dallas One wire tempreture measurement.
[EMAIL PROTECTED] schrieb: > a previous thread > > http://mail.python.org/pipermail/python-list/2002-June/107616.html > > discussed this issue, and Dave Moor kindly pointed to his solution. > However this is no longer a current link, does anyone know if there is > a currently available solution? > I am using digitemp with this code: def GetActT(): "Liest aus Digittemp die temp" digi = os.popen("digitemp -q -a -o2 -c /home/gh/.digitemprc") f = digi.readlines() digi.close() return float(f[0].split()[1]) -- Servus, Gregor http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a text file based wiki system written in Python
Jack schrieb: > I'd like to set up a wiki system for a project I'm working on. > Since I'm not good at databases, and there's really not much > stuff to put into the wiki, I hope it is text file-based. > I used DokuWiki before, which is very nice but it's written > in PHP. Is there a similar system that's written in Python? > I found pwyky but it's functionality is a bit too simple. http://moinmoin.wikiwikiweb.de/ -- Servus, Gregor http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Using SVN with Python and .pyc files
James Stroud schrieb: > project or package. How do people manage this? Do you run a script to > find files with the .pyc extension and delete those before every commit, > or is there a more elegant way? It seems like a lot of wasted bandwidth > an memory on the server side to constantly be dealing with these files > that contain no real information. in /etc/subversion/config global-ignores = *.pyc *~ #*# -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Hosting
Sir Psycho schrieb: > > Im looking at making a site in Python, however, Im lost as to what ISPs > actually support. Some ISPs say they support Python so does that mean > if I wanted to use TurboGears It would just work anyway? http://docs.turbogears.org/1.0/Hosting?highlight=%28hosting%29 -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: python's OOP question
neoedmund schrieb: > python use multiple inheritance. > but "inheritance" means you must inherite all methods from super type. > now i just need "some" methods from one type and "some" methods from > other types, > to build the new type. > Do you think this way is more flexible than tranditional inheritance? > Probably your problem is better solved with delegation instead of inheritance. -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Scope of decorator argument
Hi, this: class base(object): @adecorator(xy) def edit(self): print "edit" class child(base): xy = 3 obviously fails because "xy" is not bound at class creation time of the base object. One solution could be delegation: class base(object): @classmethod def edit(self): print "do the real work here" class child(object): xy = 3 mybase = base @adecorator(xy) def edit(self, *args, **kwargs): self.mybase.edit(*args, **kwargs) But then I have the ugly boiler plate delegation code in child. Is there any other solution, probably with metaclasses ? -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Scope of decorator argument
Gregor Horvath schrieb: > > Is there any other solution, probably with metaclasses ? > I've found this one: class mymeta(type): def __new__(meta, class_name, bases, new_attrs): new_attrs["edit"] = adecorator(new_attrs['xy'])(bases[0].edit)) return type.__new__(meta, class_name, bases, new_attrs) class base(object): def edit(self): print "%s edit" % self class child(base): __metaclass__ = mymeta xy = 3 Don't know if it's the best solution but it seems to work. -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Webprogr: Link with automatic submit
Hi, As I am no expert web programmer I thought I'd better ask the experts if there is a simpler or better solution to my problem than the one I am thinking of. (using TurboGears) The problem --- I have a form. Ok. you can submit, validate it etc. Now I have a link on that form to another page. What I want is that the form gets automatically submitted and validated before the browser follows the link. If the validation has errors the link should not be followed. My solution --- 1. client side solution First I thought I just make a little javascript function like this: function xy(url) { document.form.submit(); parent.location=url; } The problem is that submit works ansynchronisly. I do not get a return code to decide if to follow the url or not. Furthermore the form does not get submitted if there is the line parent.location=url; . 2. server side solution I thought of including a hidden field and include directives for my controller method to raise the redirection if no validation errors are there. function xy(url) { document.form.hiddenfield.value = "redirect_to: " + url; document.form.submit(); } @expose def mycontroller(self, *args, **kwargs): #do the usual saving stuff if hasattr(kwargs, 'hiddenfield'): #parse the JSON or mini-langage and do the redirection, when no #validation errors As there might be more other directives necessery for client-server communciation I thought of setting the hiddenfield value to JSON or a self made mini-language and parse this in the controller. Is this a good solution? Are there any other options? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Webprogr: Link with automatic submit
Bruno Desthuilliers schrieb: > yes : replace the link with another submit button, then in your > controller check which submit has been successful and take appropriate > action. Thanks ! -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Good Form
[EMAIL PROTECTED] schrieb: > Would you normally write methods to retrive and set your class > variables or just refrence them directly? > you start by referencing them directly and ONLY if you need you can add getters and setters later on without breaking any client code. see the property function. An explanation for the motivation behind this and python's thinking can be found here: http://tinyurl.com/wfgyw -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: The fastest search
Fulvio schrieb: > > Is there some trick to apply the best search in wise use of resources while > using the above said methods? > measure it: http://docs.python.org/lib/module-timeit.html Regarding your debugger question in the seperate thread I don't know since I am not using a debugger at all. Most people coming from other languages are looking for a debugger and are overlooking that in python a interactive interpreter, a good editor, print statements and the tracebacks are all a lot of python developers need. Small snippets of code are developed in the interpreter and when they are working assembled in the editor. If something goes wrong a print on the suspect place or the traceback is all I need. (of course this is matter of taste) -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Interpretation of UnhandledException.rpt
Hi, in a windows server python application I receive once a week suddenly and not reproducible the following error. UnhandledException.rpt file: //=== Exception code: C090 FLT_INVALID_OPERATION Program: C:\Python24\python.exe Date: 6/ 6/2006 14:36:13 (MM/DD/ HH:MM:SS) Fault address: 00E9ADF0 01:00019DF0 C:\in4\inforCOM\Prod\InforDbCOM_Server.dll Registers: EAX:012BDAA0 EBX:012ADF50 ECX:B0D6 EDX:012BDAA0 ESI:012ADF50 EDI:0096A8C0 CS:EIP:001B:00DC4DC7 SS:ESP:0023:0021EF4C EBP:02E91EF0 DS:0023 ES:0023 FS:003B GS: Flags:00010212 Call stack: Address Frame 00DC4DC7 02E91EF0 0001:3DC7 C:\Python24\DLLs\psycopg.pyd 2D36302D 36303032 *** Exception while writing report! *** Do I read this correct, that the problem is in the InforDbCOM_Server.dll? The call stack mentions the psycopg.pyd, can it be related to this problem? How can I track down this problem? -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
win32 Service: path to .py script
Hi, I have a testservice.py (see below). I installed the Windows-Service successfully. (via commandlineoption install) The problem is that it runs only when it is in c:\windows\system32 or in the python path. I added the desired path (Y:\) to the PYTHONPATH environment variable for the system account and rebooted. When I start command line python and do a import testservice everything is fine. Starting the service with the script only in Y:\ gives the error in the event log: Python could not import the service's module exceptions.ImportError: No module named testservice Thanks for your help. -- Greg testservice.py: import win32serviceutil, win32service import servicemanager import win32api import win32event import sys class TestPipeService(win32serviceutil.ServiceFramework): _svc_name_ = "MDE Dispatcher" _svc_display_name_ = "MDE-Dispatcher" _svc_description_ = "Dispatches machine events from the Siemens ODC to registrered MDE clients (windows) over the network via XML-RPC" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # Write an event log record - in debug mode we will also # see this message printed. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) while 1: win32api.Sleep(2) rc = win32event.WaitForSingleObject(self.hWaitStop, 2000) if rc == win32event.WAIT_OBJECT_0: break # Write another event log record. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, " TEST ") ) if __name__=='__main__': win32serviceutil.HandleCommandLine(TestPipeService) -- http://mail.python.org/mailman/listinfo/python-list
Re: win32 Service: path to .py script
Larry Bates schrieb: > I believe that your problem is that services run under Local > System account. Normally Local System account would not have > a drive mapping Y:\. You can change the account that a service You are absolutly correct. I moved the script to a local drive instead of a mapped network drive, now it works perfectly. Thank you a lot. -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: What do I look for in a shared Python host?
walterbyrd schrieb: > > What other "gotchas" would I look for? > Maybe this is helpfull for you: http://docs.turbogears.org/1.0/Hosting -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Can Python help?
Lad schrieb: > On my website I allow users to upload files. I would like a user to see > how much time is left before a file is uploaded. So, I would like to > have a progress bar during a file uploading. Can Python help me with > that?Or how can be a progress bar made? > Thank you for ideas. > La. > http://docs.turbogears.org/1.0/FileUploadProgressBar -- Greg -- http://mail.python.org/mailman/listinfo/python-list
_tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check"
Hi, I searched the web and docs but cannot figure out whats wrong with this code: #!/usr/bin/python import Tkinter as Tk class testtk(Tk.Frame): def __init__(self): self.root = Tk.Tk() Tk.Frame.__init__(self,self.root) self.frame = Tk.Frame(self.root) self.var = Tk.StringVar() self.var.trace_variable('w',self.check) Tk.Entry(self.frame, textvariable = self.var).pack() self.frame.pack() Tk.mainloop() def check(): pass if __name__ == "__main__": t = testtk() t.var.set("TEST") Result: Traceback (most recent call last): File "", line 22, in ? File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 191, in set return self._tk.globalsetvar(self._name, value) _tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check" Any ideas, why I cant set the variable var? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: _tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check"
Gregor Horvath schrieb: > if __name__ == "__main__": > t = testtk() > t.var.set("TEST") > > Result: > > _tkinter.TclError: can't set "PY_VAR0": invalid command name > "-1210125972check" > > > Any ideas, why I cant set the variable var? Ok. The problem is that the program enters the mainloop on t = testtk() and t.var.set("TEST") is executed when the program ends. But, what I want to do is to let another program create my tkinter GUI via initiating my class through COM. Then the COM-Client should be able to set values of the tkinter variables from "the outside". How to do this? Do I have to make my GUI program threaded ? like described here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 The mainloop resides in one thread and the other thread provides the COM object and queues the foreign COM method calls to the GUI thread? Is there a simpler solution? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: The best platform and editor for Python
kimiraikkonen schrieb: > My another aim is: Can i develop graphical applications (like in > Windows) which contain menus, interactive dialog boxes etc. using > Ptyhon? > > I got it quite but not sure. I don't know Ptyhon's capability skills > for creating interactive softwares like in Windows's created by C++ or > Delphi. > have a look at Dabo http://www.dabodev.com/ Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: The best platform and editor for Python
Kay Schluehr schrieb: > That's what I love most about the Python community. Whenever there is > just a non-standard, platform-dependent or crappy implementation of a > feature you get told that you don't need it. When printf was good for > little David print is good enough for me. > That's a property of open source projects. Features nobody really needs are not implemented. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: The best platform and editor for Python
Kay Schluehr schrieb: > The problem is simply that the Python community has failed in this > respect. There are many platform dependent and ideology driven ways to > do deal with code editing / debugging but not actually a recommend or > "pythonic" way. Other than Smalltalk, Python has not created an own Again, that's how Open Source or a Toolkit driven development (Unixy) works. For every problem there are 5 solutions. One size does not fit all. It's no fault that for example Linux Distributions do not have only one GUI but a lot of them. It's a great fortune. Gregor -- http://mail.python.org/mailman/listinfo/python-list
jython: user-defined modules
Dear all, I hope my question is here in the right place... What I want to achieve is a communication between Java and Python. We have a pretty strong framework of existing python scripts and modules. Now I want to use jython in order to faciliate the communication between another Java framework. But I`m currently stuck with jython: Trying to import the user-defined python modules, these cannot be found. I read a lot about the jython registry and I setup a $HOME/.jython file where I created a python.path=... resource, however, when I start the jython command line and type print python.path then this property is not found. Passing it with the -D option does not work as well, or maybe I`m too confused to make it work anyway? Any help would be great! Best regards Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: howto check is object a func, lambda-func or something else?
dmitrey schrieb: > howto check is object Arg1 > - a func, lambda-func > - something else? > > I tried callable(Arg1), but callable(lambda-func) returnes False I don't understand your problem: >>> callable(lambda:0) True Please post your relevant code. Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
René Fleschenberg schrieb: > > We all know what the PEP is about (we can read). The point is: If we do > not *need* non-English/ASCII identifiers, we do not need the PEP. If the > PEP does not solve an actual *problem* and still introduces some > potential for *new* problems, it should be rejected. So far, the > "problem" seems to just not exist. The burden of proof is on those who > support the PEP. > A good product does not only react to problems but acts. Solving current problems is only one thing. Great products are exploring new ways, ideas and possibilities according to their underlying vision. Python has a vision of being easy even for newbies to programming. Making it easier for non native English speakers is a step forward in this regard. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Ross Ridge schrieb: > non-ASCII identifiers. While it's easy to find code where comments use > non-ASCII characters, I was never able to find a non-made up example > that used them in identifiers. If comments are allowed to be none English, then why are identifier not? This is inconsistent because there is a correlation between identifier and comment. The best identifier is one that needs no comment, because it self-describes it's content. None English identifiers enhance the meaning of identifiers for some projects. So why forbid them? We are all adults. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
René Fleschenberg schrieb: > today, to the best of my knowledge. And "in some form or another" > basically means that the PEP would create more possibilities for things > to go wrong. That things can already go wrong today does not mean that > it does not matter if we create more occasions were things can go wrong > even worse. Following this logic we should not add any new features at all, because all of them can go wrong and can be used the wrong way. I love Python because it does not dictate how to do things. I do not need a ASCII-Dictator, I can judge myself when to use this feature and when to avoid it, like any other feature. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
René Fleschenberg schrieb: >> I love Python because it does not dictate how to do things. >> I do not need a ASCII-Dictator, I can judge myself when to use this >> feature and when to avoid it, like any other feature. > > *That* logic can be used to justify the introduction of *any* feature. > No. That logic can only be used to justify the introduction of a feature that brings freedom. Who are we to dictate the whole python world how to spell an identifier? Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
[EMAIL PROTECTED] schrieb: > code on the (GUI-less) production servers over a terminal link. They > have to use all kinds of environments where they can't install the > latest and greatest fonts. Promoting code that becomes very hard to > read and debug in real situations seems like a sound negative to me. If someone wants to debug a Chinese program, he has in almost all cases obviously already installed the correct fonts and his machine can handle unicode. Maybe yours and mine not, but I doubt that we are going to debug a chinese program. I have debugged German programs (not python) with unicode characters in it for years and had no problem at all, because all customers and me have obviously German machines. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Hendrik van Rooyen schrieb: > It is not so much for technical reasons as for aesthetic > ones - I find reading a mix of languages horrible, and I am > kind of surprised by the strength of my own reaction. This is a matter of taste. In some programs I use German identifiers (not unicode). I and others like the mix. My customers can understand the code better. (They are only reading it) > > "Beautiful is better than ugly" Correct. But why do you think you should enforce your taste to all of us? With this logic you should all drive Alfa Romeos! Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Eric Brunel schrieb: > Highly improbable in the general context. If I stumble on a source code > in Chinese, Russian or Hebrew, I wouldn't be able to figure out a single > sound. If you get source code in a programming language that you don't know you can't figure out a single sound too. How is that different? If someone decides to make *his* identifiers in Russian he's taking into account that none-Russian speakers are not going to be able to read the code. If someone decides to program in Fortran he takes into account that the average Python programmer can not read the code. How is that different? It's the choice of the author. Taking away the choice is not a good thing. Following this logic we should forbid all other programming languages except Python so everyone can read every code in the world. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Eric Brunel schrieb: > > The point is that today, I have a reasonable chance of being able to > read, understand and edit any Python code. With PEP 3131, it will no > more be true. That's what bugs me. That's just not true. I and others in this thread have stated that they use German or other languages as identifiers today but are forced to make a stupid and unreadable translation to ASCII. > > Same question again and again: how does he know that non-Russian > speakers will *ever* get in touch with his code and/or need to update it? If you didn't get non English comments and identifiers until now, you will not get any with this PEP either. And if you do get them today or with the PEP it doesn't make a difference for you to get some glyphs not properly displayed, doesn't it? Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Istvan Albert schrieb: > Here is something that just happened and relates to this subject: I > had to help a student run some python code on her laptop, she had > Windows XP that hid the extensions. I wanted to set it up such that > the extension is shown. I don't have XP in front of me but when I do > it takes me 15 seconds to do it. Now her Windows was set up with some > asian fonts (Chinese, Korean not sure), looked extremely unfamiliar > and I had no idea what the menu systems were. We have spent quite a > bit of time figuring out how to accomplish the task. I had her read me > back the options, but something like "hide extensions" comes out quite > a bit different. Surprisingly tedious and frustrating experience. > So the solution is to forbid Chinese XP ? Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
[EMAIL PROTECTED] schrieb: >> 2) Create a way to internationalize the standard library (and possibly >> the language keywords, too). Ideally, create a general standardized way >> to internationalize code, possibly similiar to how people >> internationalize strings today. > > Why? Or more acurately why before adopting the PEP? > The library is very usable by non-english speakers as long as > there is documentation in their native language. It would be Microsoft once translated their VBA to foreign languages. I didn't use it because I was used to "English" code. If I program in mixed cultural contexts I have to use to smallest dominator. Mixing the symbols of the programming language is confusing. Long time ago at the age of 12 I learned programming using English Computer books. Then there were no German books at all. It was not easy. It would have been completely impossible if our schools system would not have been wise enough to teach as English early. I think millions of people are handicapped because of this. Any step to improve this, is a good step for all of us. In no doubt there are a lot of talents wasted because of this wall. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
[EMAIL PROTECTED] schrieb: > On May 16, 12:54 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote: >> Istvan Albert schrieb: >> >> So the solution is to forbid Chinese XP ? >> > > It's one solution, depending on your support needs. > That would be a rather arrogant solution. You would consider dropping the language and culture of millions of users because a small number of support team staff does not understand it? I would recommend to drop the support team and the management that even considers this. This PEP is not a technical question. Technically it would no change much. The underlying question is a philosophical one. Should computer programming only be easy accessible to a small fraction of privileged individuals who had the luck to be born in the correct countries? Should the unfounded and maybe xenophilous fear of loosing power and control of a small number of those already privileged be a guide for development? Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Hendrik van Rooyen schrieb: > I can sympathise a little bit with a customer who tries to read code. > Why that should be necessary, I cannot understand - does the stuff > not work to the extent that the customer feels he has to help you? > You do not talk as if you are incompetent, so I see no reason why > the customer should want to meddle in what you have written, unless > he is paying you to train him to program, and as Eric Brunel has > pointed out, this mixing of languages is all right in a training environment. That is highly domain and customer specific individual logic, that the costumer knows best. (For example variation logic of window and door manufacturers) He has to understand the code, so that he can verify it's correct. We are in fact developing it together. Some costumers even are coding this logic themselves. Some of them are not fluent in English especially not in the computer domain. Translating the logic into a documentation is a waste of time if the code is self documenting and easy to grasp. (As python usually is) But the code can only be self documenting if it is written in the domain specific language of the customer. Sometimes these are words that are not even used in general German. Even in German different customers are naming the same thing with different words. Talking and coding in the language of the customer is a huge benefit. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Sending a JavaScript array to Python script?
placid schrieb: > Just wondering if there is any way of sending a JavaScript array to a > Python cgi script? A quick Google search didn't turn up anything > useful. http://mochikit.com/doc/html/MochiKit/Base.html#json-serialization http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.3/docs/index.html Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Declaring variables
HMS Surprise schrieb: > > #~~ > createdIncidentId = 0 > . > . > . > #attempt to change varialbe > createdIncidentID = 1 > . > . > . > if createdIncidentId == 1: >... > test.py is your code above $ pychecker -v test.py Processing test... Warnings... test.py:7: Variable (createdIncidentID) not used Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Martin v. Löwis schrieb: > I've reported this before, but happily do it again: I have lived many > years without knowing what a "hub" is, and what "to pass" means if > it's not the opposite of "to fail". Yet, I have used their technical > meanings correctly all these years. That's not only true for computer terms. In the German Viennese slang there are a lot of Italian, French, Hungarian, Czech, Hebrew and Serbocroatien words. Nobody knows the exact meaning in their original language (nor does the vast majority actually speak those languages), but all are used in the correct original context. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Istvan Albert schrieb: > > After the first time that your programmer friends need fix a trivial > bug in a piece of code that does not display correctly in the terminal > I can assure you that their mellow acceptance will turn to something > entirely different. > Is there any difference for you in debugging this code snippets? class Türstock(object): höhe = 0 breite = 0 tiefe = 0 def _get_fläche(self): return self.höhe * self.breite fläche = property(_get_fläche) #--- class Tuerstock(object): hoehe = 0 breite = 0 tiefe = 0 def _get_flaeche(self): return self.hoehe * self.breite flaeche = property(_get_flaeche) I can tell you that for me and for my costumers this makes a big difference. Whether this PEP gets accepted or not I am going to use German identifiers and you have to be frightened to death by that fact ;-) Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
[EMAIL PROTECTED] schrieb: > With the second one, all my standard tools would work fine. My user's > setups will work with it. And there's a much higher chance that all > the intervening systems will work with it. > Please fix your setup. This is the 21st Century. Unicode is the default in Python 3000. Wake up before it is too late for you. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Hendrik van Rooyen schrieb: > I suppose that this "one language track" - mindedness of mine > is why I find the mix of keywords and German or Afrikaans so > abhorrent - I cannot really help it, it feels as if I am eating a > sandwich, and that I bite on a stone in the bread. - It just jars. Please come to Vienna and learn the local slang. You would be surprised how beautiful and expressive a language mixed up of a lot of very different languages can be. Same for music. It's the secret of success of the music from Vienna. It's just a mix up of all the different cultures once living in a big multicultural kingdom. A mix up of Python key words and German identifiers feels very natural for me. I live in cultural diversity and richness and love it. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Istvan Albert schrieb: > On May 17, 2:30 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote: > >> Is there any difference for you in debugging this code snippets? > >> class Türstock(object): > > Of course there is, how do I type the ü ? (I can copy/paste for > example, but that gets old quick). > I doubt that you can debug the code without Unicode chars. It seems that you do no understand German and therefore you do not know what the purpose of this program is. Can you tell me if there is an error in the snippet without Unicode? I would refuse to try do debug a program that I do not understand. Avoiding Unicode does not help a bit in this regard. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Paul Boddie schrieb: > Perhaps, but the treatment by your mail/news software plus the > delightful Google Groups of the original text (which seemed intact in > the original, although I don't have the fonts for the content) would > suggest that not just social or cultural issues would be involved. I do not see the point. If my editor or newsreader does display the text correctly or not is no difference for me, since I do not understand a word of it anyway. It's a meaningless stream of bits for me. It's save to assume that for people who are finding this meaningful their setup will display it correctly. Otherwise they could not work with their computer anyway. Until now I did not find a single Computer in my German domain who cannot display: ß. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
[EMAIL PROTECTED] schrieb: > opposed. But dismissing the fact that Outlook and other quite common > tools may have severe problems with code seems naive (or disingenuous, > but I don't think that's the case here). Of course there is broken software out there. There are even editors that mix tabs and spaces ;-) Python did not introduce braces to solve this problem but encouraged to use appropriate tools. It seems to work for 99% of us. Same here. It is the 21st century. Tools that destroy Unicode byte streams are seriously broken. Face it. You can not halt progress because of some broken software. Fix or drop it instead. I do not think that this will be a big problem because only a very small fraction of specialized local code will use Unicode identifiers anyway. Unicode strings and comments are allowed today and I didn't heard of a single issue of destroyed strings because of bad editors, although I guess that Unicode strings in code are way more common than Unicode identifiers would ever be. Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to iniatilize a function
Jack schrieb: > I didn't call del explicitly. I'm expecting Python to call it when > the program exits. I put a logging line in __del__() but I never > see that line printed. It seems that __del__() is not being called > even when the program exits. Any idea why? > > http://effbot.org/pyfaq/my-class-defines-del-but-it-is-not-called-when-i-delete-the-object.htm better solutions: http://docs.python.org/ref/try.html http://docs.python.org/whatsnew/pep-343.html Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Why PHP is so much more popular for web-development
walterbyrd schrieb: > Don't get me wrong: I am not saying that PHP is better than Python for > web-development. But, I sometimes think that Python could learn a few > things from PHP. Yes, indeed we can learn that popularity is not superiority. ;-) Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: advice about `correct' use of decorator
Gerardo Herzig schrieb: > > @is_logued_in > def change_pass(): >bla >bla > > And so on for all the other functions who needs that the user is still > loged in. > > where obviosly the is_logued_in() function will determine if the dude is > still loged in, and THEN execute change_pass(). If the dude is not loged > in, change_pass() is NOT executed at all. Instead, it will be redirected > to the `login' screen. > > Something in my mind tells me that this is not the pythonic way...But i > like the idea, so please tell me that im in the right way :) > That's how turbogears does it. See: http://docs.turbogears.org/1.0/UsingIdentity?highlight=%28identity%29 Greg -- http://mail.python.org/mailman/listinfo/python-list
pickle error/instancemethod
Hello, I have some of these nefarious pickle errors I do not understand, maybe some of you have a clue. This is what I get (nd is the object which I want to pickle [cPickle.dumps(nd,2)], with the printout of nd.__dict__): ERROR Error: Can't pickle : attribute lookup __builtin__.instancemethod failed, nd: {'dvzLogger': , '_DVZnetzDataBase__netzentries': [], '_DVZnetzDataBase__option_fqdn_alias': set(['a.b.c']), '_DVZnetzDataBase__admins': set([]), '_DVZnetzDataBase__aliasentries': []} I follow the hints on http://docs.python.org/lib/node318.html, so I do not understand the source of the problem. I do not try to pickle an instancemethod directly. The dict does apparently contains only top level tuples, lists, sets, and dictionaries, classes/instances. So if more Data is needed to analyse the problem - demand. gfk -- gfk smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Class design (information hiding)
Alexander Eisenhuth schrieb: > > I'm wodering how the information hiding in python is ment. As I > understand there doesn't exist public / protected / private mechanism, > but a '_' and '__' naming convention. > > As I figured out there is only public and private possible as speakin in > "C++ manner". Are you all happy with it. What does "the zen of python" > say to that design? (protected is useless?) My favourite thread to this FAQ: http://groups.google.at/group/comp.lang.python/browse_thread/thread/2c85d6412d9e99a4/b977ed1312e10b21#b977ed1312e10b21 Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Class design (information hiding)
Alex Martelli schrieb: > > Why, thanks for the pointer -- I'm particularly proud of having written > """ > The only really workable way to develop large software projects, just as > the only really workable way to run a large business, is a state of > controlled chaos. > """ Yes, indeed a good saying. The problem is that we do not understand those complex systems, despite the fact that some megalomaniacal people think they do. Declaring a method as private, public or protected assumes that the author fully understands the uses of this class by other programmers or even himself later on. But if the software is complex enough, chances are good that he does *NOT* understand it fully at the time he writes "Protected". Programming means attempting. Attempt implies failure. Flexible systems that are built for easy correction are therefore superior. Greg -- http://mail.python.org/mailman/listinfo/python-list