Python Bootcamp - 2 weeks left, Register Now! (May 17-21, 2010)
Just a reminder that there are only 2 weeks remaining to register for the Open Technology Group's Python Bootcamp, a 5 day hands-on, intensive, in-depth introduction to Python. This course is confirmed and guaranteed to run. Travel not in the budget? Need to stay home? Now you can - our Virtual instructor-led option allows you to attend class from the comfort of your home - from anywhere in the world! As always, a live instructor-led option is available as well. Visit our web site (link below) today to learn more! Worried about the costs of air and hotel to travel for training? Don't! Our All-Inclusive Packages provide round-trip airfare and hotel accommodations and are available for all students attending from the Continental US, parts of Canada, and parts of Europe! Best of all, these packages can be booked up to May 14, 2010! For complete course outline/syllabus, or to enroll, call us at 877-258-8987 or visit our web site at: http://www.otg-nc.com/python-bootcamp Our Python bootcamp courses are taught by the same knowledgeable instructors that you see delivering tutorials at conferences such as LinuxWorld, PyCon, OSCON, and more! Attend our training to learn why the Army, Navy, NIST, NOAA, US Treasury, Federal Reserve, Wells Fargo and a wide range of Fortune 500, 100, and 50 companies repeatedly choose OTG to fulfill their Open Source training needs. OTG's Python Bootcamp is a 5 day intensive course that teaches programmers how to design, develop, and debug applications using the Python programming language. Over a 5 day period through a set of lectures, demonstrations, and hands-on exercises, students will learn how to develop powerful applications using Python and integrate their new found Python skills in their day-to-day job activities. Students will also learn how to utilize Python's Database API to interface with relational databases. This Python course is available for on-site delivery world-wide (we bring the class to you) for a group as small as 3, for as little as $8,000 (including instructor travel per-diem)! Our course is guaranteed to run, regardless of enrollment, and available in an all inclusive package that includes round-trip airfare, 5 nights of hotel accommodation, shuttle services (to/from the airport, to/from our facility, and to/from local eateries/shopping), and our training. All-inclusive packages are priced from $2,495 for the 5 day course (course only is $2,295). For more information - or to schedule an on-site course, please contact us at 877-258-8987 . The Open Technology Group is the world leader in the development and delivery of training solutions focused around Open Source technologies. -- Chander Ganesan Open Technology Group, Inc. One Copley Parkway, Suite 210 Morrisville, NC 27560 919-463-0999/877-258-8987 http://www.otg-nc.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Summer Python Training Courses with @dabeaz
** Upcoming Python Training Courses ** Chicago - Summer 2010 http://www.dabeaz.com/chicago/index.html David Beazley, author of the Python Essential Reference, is pleased to announce the following training courses for Summer 2010. - Python Networking and Distributed Computing http://www.dabeaz.com/chicago/network.html June 21-23, 2010 - Jamming with Django : An Introduction with Chad Glendenin and Rodrigo Guzman June 24, 2010 - Introduction to Python Programming http://www.dabeaz.com/chicago/intro.html July 13-15, 2010 - Advanced Python Mastery http://www.dabeaz.com/chicago/mastery.html August 17-19, 2010 These courses are strictly limited to 6 students and offer a highly personalized training experience is unlike any other. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Sphinx hosting
On Wed, May 5, 2010 at 3:35 PM, Michele Simionato michele.simion...@gmail.com wrote: I am sure it has, but I was talking about just putting in the repository an index.html file and have it published, the wayI hear it works in BitBucket and GitHub. I'm pretty sure Google Code Hosting doesn't support rendering text/html mime-type files in the repository (like Trac can). On a side-note, not sure if you're interested in this at all... I wrote (for the hell/fun of it) a Sphinx Server, here's the code: http://codepad.org/ywo8pscb This uses the latest development version of circuits (1) cheers James 1. http://bitbucket.org/prologic/circuits/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast Efficient way to transfer an object to another list
En Fri, 30 Apr 2010 23:16:04 -0300, Jimbo nill...@yahoo.com escribió: Hello I have a relatively simple thing to do; move an object from one to list into another. But I think my solution maybe inefficient slow. Is there a faster better way to move my stock object from one list to another? (IE, without having to use a dictionary instead of a list or is that my only solution?) [code] class stock: code = NULL price = 0 stock_list1 = [] stock_list2 = [] def transfer_stock(stock_code, old_list, new_list): Transfer a stock from one list to another # is there a more efficient faster way to index = 0 for stock in old_list: temp_stock = stock if temp_stock.code == stock_code: new_list.append(temp_stock) del old_list[index] index += 1 return new_list[/code] I'd do that in two steps: def transfer_stock(stock_code, old_list, new_list): # find the indexes to transfer indexes = [i for i,stock in enumerate(old_list) if stock.code==stock_code] # actually transfer them for index in reversed(indexes): stock = old_list[index] new_list.append(stock) del old_list[index] # I would not return anything -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: strange interaction between open and cwd
On Wed, 05 May 2010 02:41:09 +0100, Baz Walter wrote: i think the algorithm also can't guarantee the intended result when crossing filesystem boundaries. IIUC, a stat() call on the root directory of a mounted filesystem will give the same inode number as its parent. Nope; it will have the same dev/inode pair as if it wasn't mounted, i.e. the device will refer to the mounted device, not the device it's mounted on, and the inode will be the mounted filesystem's root inode (typically #2 for Linux ext2/ext3 filesystems). And stat()ing the appropriate entry in the parent directory will return the same information, i.e. the root inode of the mounted device, not the subdirectory of the parent device (as you would see if the filesystem was unmounted). IOW, if stat(foo) reports a different device to stat(.), foo is a mount point, while if stat(..) reports a different device to stat(.), the current directory is the root of a mounted filesystem. so if several filesystems are mounted in the same parent directory, there is no way to tell which of them is the right one. The only case which would cause a problem here is if you mount the same device on two different subdirectories of a common directory. But in that case, it doesn't really matter which answer you get, as they're both equivalent in any sense that matters. -- http://mail.python.org/mailman/listinfo/python-list
Re: Teaching Programming
alex23 wrote: Ed Keith e_...@yahoo.com wrote: Knuth wanted the generated source to be unreadable, so people would not be tempted to edit the generated code. This is my biggest issue with Knuth's view of literate programming. If the generated source isn't readable, am I just supposed to trust it? How can I tell if an error lies in my expression of the algorithm or in the code generation itself? Do you think a compiler is required to make its object file conveniently readable? Do you regularly read the machine code generated by your C compiler? I admit I've frequently studied compiler output over the years, but I think I'm very unusual in that respect. I've never disassembled a python byte code file, though I wrote tools to display and manipulate both java byte code files and dot-net (before it was called that). I think the question really boils down to whether you trust the compiler. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Django as exemplary design
TomF a écrit : On 2010-05-04 07:11:08 -0700, alex23 said: (snip) (I also think there's value to be gained in studying _bad_ code, too...) True, although whether that's time well spent is another question. The more bad code (mine or not) I have to maintain (or even just read and understand), the more I pay attention to my own design and code quality. Sometimes you only understand why something is bad, why it is bad and how bad it is when you have to deal with it :( -- http://mail.python.org/mailman/listinfo/python-list
Re: Python debuggers with sys.settrace()
On May 2, 11:06 am, Sarah Mount mount.sa...@gmail.com wrote: This is a bit of an odd question, but is there any way for a Python debugger to suppress I/O generated by the program which is being debugged? I guess an obvious thing to do would be to replace core parts of the standard library and change any relevant imports in the locals and globals dicts to fake ones which don't generate I/O, but this seems brittle as the standard library will change over time. Is it possible to modify the byte-compiled code in each stack frame? Or is there a simpler way to do this? It's not foolproof but you could try to reassign sys.stdout and sys.stderr to a bit bucket (sys.stdout = open(os.devull)), then invoke the debugger with stdout set to sys._stdout (the actual stdout). You'll have to create the Pdb() by hand since the built-in convience functions don't do it. Check the file pdb.py for details. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
the solution to your current problems........join this: http://www.thevoid1.net/para
the solution to your current problemsjoin this: http://www.thevoid1.net/para -- http://mail.python.org/mailman/listinfo/python-list
Re: Teaching Programming
--- On Tue, 5/4/10, alex23 wuwe...@gmail.com wrote: From: alex23 wuwe...@gmail.com Subject: Re: Teaching Programming To: python-list@python.org Date: Tuesday, May 4, 2010, 8:47 PM Ed Keith e_...@yahoo.com wrote: Knuth wanted the generated source to be unreadable, so people would not be tempted to edit the generated code. This is my biggest issue with Knuth's view of literate programming. If the generated source isn't readable, am I just supposed to trust it? How can I tell if an error lies in my expression of the algorithm or in the code generation itself? -- http://mail.python.org/mailman/listinfo/python-list My feelings exactly. I can see an argument for an option to emit obstructed code, but the default should be readable. -EdK Ed Keith e_...@yahoo.com Blog: edkeith.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
how to import subprocess into my 'subprocess.py' file
Hi, I am doing following in my 'subprocess.py' file... 1 from __future__ import absolute_import 2 from subprocess import * 3 from subprocess import call as myCall 4 from subprocess import Popen as myPopen 5 6 def getProperCmd(cmd): 7 cmd += 'time' # this is just an example; in fact I am doing lots of processing on cmd 8 return cmd 9 10 11 def call(cmd, **kwargs): 12 return myCall(getProperCmd(cmd), **kwargs) 13 14 def Popen(cmd, **kwargs): 15 return myPopen(getProperCmd(cmd), **kwargs) When running this it gives following error... error Traceback (most recent call last): File subprocess.py, line 2, in module from subprocess import * File subprocess.py, line 3, in module from subprocess import call as myCall ImportError: cannot import name call /error So how can I create a python file (with the same name as standard module name) with custom methods? Thank you in advance. -Hiral -- http://mail.python.org/mailman/listinfo/python-list
Python Embedding, no correct lib
Hi, I have a serious problem with Python. I am currently trying to implement Python into my app. Well this works fine, but get this: I have my own Python interpreter in a subfolder of my app. When I start my app, PYTHONHOME is set, and an environment variable is set to it can find the python DLL on startup. When Python is not installed on the system everything works fine as expected. When I now install Python on my system (so I have two python libs now) the system installation is the preferred one. print sys.path prints out ['', 'C:\Windows \system32\python26.zip', ...] and I cant explain whats going wrong here. I expected that it just uses the System lib when it cannot find it in the subfolder which I set in the environment variables before.. :-( Any ideas? Thanks a lot for help. Bye, moerchendiser2k3 -- http://mail.python.org/mailman/listinfo/python-list
Portable Python
Is there any difference in functionality between standard Python pack and portable Python? Why standard Python pack installation requires reboot after installation? Can portable Python used from hard drive folder? -- http://mail.python.org/mailman/listinfo/python-list
Re: strange interaction between open and cwd
On 05/05/10 07:24, Nobody wrote: On Wed, 05 May 2010 02:41:09 +0100, Baz Walter wrote: i think the algorithm also can't guarantee the intended result when crossing filesystem boundaries. IIUC, a stat() call on the root directory of a mounted filesystem will give the same inode number as its parent. Nope; it will have the same dev/inode pair as if it wasn't mounted, i.e. the device will refer to the mounted device, not the device it's mounted on, and the inode will be the mounted filesystem's root inode (typically #2 for Linux ext2/ext3 filesystems). And stat()ing the appropriate entry in the parent directory will return the same information, i.e. the root inode of the mounted device, not the subdirectory of the parent device (as you would see if the filesystem was unmounted). yes, that's actually what i meant (but probably put badly as usual). IOW, if stat(foo) reports a different device to stat(.), foo is a mount point, while if stat(..) reports a different device to stat(.), the current directory is the root of a mounted filesystem. so if several filesystems are mounted in the same parent directory, there is no way to tell which of them is the right one. The only case which would cause a problem here is if you mount the same device on two different subdirectories of a common directory. But in that case, it doesn't really matter which answer you get, as they're both equivalent in any sense that matters. nope! just to be clear: here's what i get on my system, where '/dev/sda1' and '/dev/sda6' are mounted at '/boot' and '/home' respectively: os.stat('/').st_ino 2L os.stat('/usr').st_ino 212993L os.stat('/boot').st_ino 2L os.stat('/home').st_ino 2L if the algorithm is climbing up from '/home/baz/tmp/xxx', what does it do when it searches os.listdir('../../../..')? how can it tell whether 'boot' or 'home' is the correct next parent if it only checks the inode number? i think the algorithm would at least need to take account of changes in the current device id. not sure whether that would be enough to cover all cases, though. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to import subprocess into my 'subprocess.py' file
On Wed, 05 May 2010 03:34:06 -0700, hiral wrote: So how can I create a python file (with the same name as standard module name) with custom methods? Don't do this. It will lead to nothing but trouble. Python doesn't support multiple modules with the same name. Unless you create a custom importer, a module called subprocess will shadow (hide) the original subprocess module. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Movable Python or ActivePython
I want Python pack that can run without being installed, mostly for testing programs. As I read, Movable Python can run without being installed. It needs no registry entries and knows the path to all the dlls (system or otherwise) that it uses. Whats about ActivePython http://www.activestate.com/activepython/downloads? Does it requires installation? -- http://mail.python.org/mailman/listinfo/python-list
Re: how to import subprocess into my 'subprocess.py' file
hiral wrote: Hi, I am doing following in my 'subprocess.py' file... 1 from __future__ import absolute_import 2 from subprocess import * 3 from subprocess import call as myCall 4 from subprocess import Popen as myPopen 5 6 def getProperCmd(cmd): 7 cmd += 'time' # this is just an example; in fact I am doing lots of processing on cmd 8 return cmd 9 10 11 def call(cmd, **kwargs): 12 return myCall(getProperCmd(cmd), **kwargs) 13 14 def Popen(cmd, **kwargs): 15 return myPopen(getProperCmd(cmd), **kwargs) When running this it gives following error... error Traceback (most recent call last): File subprocess.py, line 2, in module from subprocess import * File subprocess.py, line 3, in module from subprocess import call as myCall ImportError: cannot import name call /error So how can I create a python file (with the same name as standard module name) with custom methods? Thank you in advance. -Hiral Just don't do that, find another name. Dont use * in import statement: Namespaces are one honking great idea -- let's do more of those! (import this in a shell for more rules) Using * in import statements removes namespaces. JM -- http://mail.python.org/mailman/listinfo/python-list
Create a new process to run python function
Hi everyone, in my script (python 2.5 on windows xp) I need to run a simple function in a separate process. In other words I need something similar to the fork function under UNIX. I tried with threads: import os, threading def func(s) : print I'm thread number +s, os.getpid() threading.Thread(target=func, args=(1,)).start() threading.Thread(target=func, args=(2,)).start() but this does not work, since the two threads share the same pid. Can anyone give me a suggestion? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new process to run python function
On Wed, May 5, 2010 at 8:56 AM, Massi massi_...@msn.com wrote: but this does not work, since the two threads share the same pid. Can anyone give me a suggestion? Have you looked at os.fork ? http://docs.python.org/library/os.html#os.fork -- http://mail.python.org/mailman/listinfo/python-list
Re: Exclusively lock a file to prevent other processes from reading it?
Chris, Philip, Christian, John and others, Thank you all for your replies. Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new process to run python function
Joe Riopel wrote: On Wed, May 5, 2010 at 8:56 AM, Massimassi_...@msn.com wrote: but this does not work, since the two threads share the same pid. Can anyone give me a suggestion? Have you looked at os.fork ? http://docs.python.org/library/os.html#os.fork Fork on Windows XP? Have a lot of fun ... The NT Kernel has support for forking but neither the Win32 API nor Python supports it. Christian -- http://mail.python.org/mailman/listinfo/python-list
find out whther byte two .pyc files contain the same byte code.
Hi, I'd like to know whether the byte code of two .pyc files is identical. I thought, I could just compare the md5sums of thw .pyc files. However this does not work. It seems, that .pyc ontains the time stamp of the source file. the .pyc file changes its contents when I don't change the file's contents but just save it again. Is there any way to compare two .pyc files or to just strip the timestiam or set it to a fixed value? Example: # I create a python file $ echo 'print 1' tst.py # I compile it and display the md5sum of the .pyc file $ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc 1 0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc # now I recompile and will get the same md5sum $ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc 1 0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc now I change the time stamp of the python source touch tst.py now the md5sum will be different $ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc 1 f6faf2048b6f967c73e68951558f954c *tst.pyc thanks for any suggestions / ideas -- http://mail.python.org/mailman/listinfo/python-list
Re: Sharing a program I wrote
On 5 May, 04:25, Scott scott.freem...@gmail.com wrote: James, Thanks for the comprehensive reply. I would like to post it to comp.lang.python but the main file is 169 lines long and the file for functions is 316 lines long. I'm thinking that is a little long for this format. You're welcome. Yes, it sounds a bit long for a direct post. In general, comments are more forthcoming on smaller pithier code fragments. Maybe I can put them up on a basic web page or file sharing site and just post a link. Is that well received on this forum? I can't answer for how it would be received here but once you have addressed any Python issues you may want to let folks on either or both of comp.dcom.sys.cisco comp.dcom.net-management know about your utility. James -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new process to run python function
On Wed, May 5, 2010 at 10:56 PM, Massi massi_...@msn.com wrote: in my script (python 2.5 on windows xp) I need to run a simple function in a separate process. In other words I need something similar to the fork function under UNIX. I tried with threads: Use the new multiprocesing package. import os, threading def func(s) : print I'm thread number +s, os.getpid() threading.Thread(target=func, args=(1,)).start() threading.Thread(target=func, args=(2,)).start() Like this: import multiprocessing multiprocessing.Process(target=func, args=(1,)).start() multiprocessing.Process(target=func, args=(2,)).start() ... Surprise surprise it has almost the same API as the threading module :) --James -- http://mail.python.org/mailman/listinfo/python-list
abc don't play well with private method
i have a problem here : i want to make a plugin architecture using abstract base class , this is my base class : # -*- coding: utf-8 -*- import abc class BASE_Connector: Mount point for plugins which refer to actions that can be performed. Plugins implementing this reference should provide the following methods: connect the connection method that will initialize a transport layer __login the login method to use to login in to the server this one should be called from connect directly get this method is use for getting the files from the remote server close this method is called for closing the connection suddenly quitthis method is more polite to close the connection __metaclass__ = abc.ABCMeta @abc.abstractmethod def connect(self, host, user=, passwd=, port=, private_key_file=, timeout=100): connect to a remote server this function call the __login function after the connection is established -- host : remote server name -- user : the user name in the remote server Default : empty string for server that don't need authentication or use private key instead -- passwd : password of the user given Default : empty string for server that don't need authentication or use private key instead -- port : the connection port Default : it's known from the protocol -- private_key_file : the file containing the private key used special for ssh connection Default : empty string -- timeout : the timeout of the connection Default : empty string pass @abc.abstractmethod def __login(self): private method to login to the remote server . it use the user name and the password or the private key for that @abc.abstractmethod def get(self, remote_file_path, local_path=/tmp/ housead_matcher): method to download the file from the remote server -- remote_file_path : the path of the file in the remote server -- local_path : the local path where the file will be save pass @abc.abstractmethod def close(self): Close the connection unilaterally(from this host) @abc.abstractmethod def quit(self): close the connection. This is the “polite” way to close a connection and i define my plugins in a differents module like this : class FTP_Connector(FTP, Base_Connector) : this class is for the connection to a ftp server def __init__(self): FTP.__init__() def connect(self, host, port, user, passwd, timeout=): self.connect(host, port, timeout) self.___login(user, passwd) def ___login(self, username=, password=): self.login(username, password) def get(self, remote_file_path, local_path): remote_file_path = os.path.expanduser(remote_file_path) local_path = os.path.expanduser(local_path) remote_directory, remote_file_name = os.path.split(remote_file_path) local_file = os.path.join(local_path, remote_file_name) self.cwd(remote_directory) self.retrlines(RETR + remote_file_name, lambda s, w=local_file.write: w(s+\n)) def close(self): self.close() def quit(self): self.quit() and when i test my code i get this error : Can't instantiate abstract class FTP_Connector with abstract methods _BASE_Connector__login i can understand why. but my problem is why why ? i can't put private method in the ABC class ??? -- http://mail.python.org/mailman/listinfo/python-list
Re: Portable Python
Is there any difference in functionality between standard Python pack and portable Python? It is not so easy to install third party modules for portable Python... Why standard Python pack installation requires reboot after installation? It is not true for all operating systems. At least under Unbuntu Linux, BSD, Windows XP and Windows 7, you don't need to restart the OS after installation. What others have you tried? Can portable Python used from hard drive folder? Did you read its very front page? http://www.portablepython.com/ Just download it, extract to your portable storage device ***or hard drive*** and in 10 minutes you are ready to create your next Python application. Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: abc don't play well with private method
mouadino a écrit : i have a problem here : i want to make a plugin architecture using abstract base class , this is my base class : # -*- coding: utf-8 -*- import abc class BASE_Connector: Mount point for plugins which refer to actions that can be performed. Plugins implementing this reference should provide the following methods: connect the connection method that will initialize a transport layer __login the login method to use to login in to the server this one should be called from connect directly Removing one of the leading underscores would solve your problem. __metaclass__ = abc.ABCMeta @abc.abstractmethod def __login(self): private method to login to the remote server . it use the user name and the password or the private key for that and when i test my code i get this error : Can't instantiate abstract class FTP_Connector with abstract methods _BASE_Connector__login i can understand why. but my problem is why why ? i can't put private method in the ABC class ??? There's no such thing as a private attribute in Python. The name-mangling mechanism invoked by __name is really meant to avoid accidental redefinition of the attribute in a derived class. In this case, your attribute is expected to be redefined, so you definitly don't want any name mangling here. Also and FWIW, the naming convention for implementation attributes is a single leading underscore. Also and FWIW: class FTP_Connector(FTP, Base_Connector) : this class is for the connection to a ftp server def close(self): self.close() def quit(self): self.quit() Don't you see kind of a problem here ? Something like, say, an infinite recursion ? HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating nested code with context managers
I tried a very similar thing, but not using with statements: http://mail.python.org/pipermail/python-list/2010-March/1239577.html Dan On 04/05/2010 22:36, Terry Reedy wrote: In a current thread, people have claimed that generating properly indented nested blocks is a pain because of the need to keep track of indent levels. Someone countered with the now rather ancient http://effbot.org/zone/python-code-generator.htm The usage example c = CodeGeneratorBackend() c.begin(tab= ) c.write(for i in range(1000):\n) c.indent() c.write(print 'code generation is trivial') c.dedent() illustrates three problems with the CodeGeneratorBackend class. 1) it requires explicit \n on all lines (which the second omits, though it is non-fatal since it is also the last) 2) the user still has to manually match indents and dedents, and 3) the user *cannot* indent lines that produce indented code. The relatively new with statement and associated context managers are designed, among other things, for this situation, where one needs to alter and restore a global context. So here is my updated (3.1) proof-of-concept version. class PyCodeGen: def __init__(self, tab= ): self.code = [] self.tab = tab self.level = 0 # all attributes should be treated as read-only def end(self): return '\n'.join(self.code) def line(self, string): # new line self.code.append(self.tab * self.level + string) class For: def __init__(self, target, in_expression): target.line('for ' + in_expression + ':') self.target = target def __enter__(self): self.target.level += 1 def __exit__(self, t, v, tb): self.target.level -= 1 c = PyCodeGen() with For(c, 'i in range(1000)'): c.line('print(Code gen is easy)') c.line('# done') print(c.end()) # prints for i in range(1000): print(Code gen is easy) # done Note that the absence of .indent and .dedent is intentional. In a fleshed out system, there would be a context manager for each compound statement and these would handle all indents and dedents. If one really preferred to write, for instance, 'c.For(s); instead of 'For(c,s)' in the with statement, one could add a wrapper method like def For(self, s): return For(self, s) for each context manager. I left that out. Similar methods can be used to auto-match C braces and other open/close pairs. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new process to run python function
On Wed, May 5, 2010 at 10:33 AM, James Mills prolo...@shortcircuit.net.au wrote: On Wed, May 5, 2010 at 10:56 PM, Massi massi_...@msn.com wrote: in my script (python 2.5 on windows xp) I need to run a simple function in a separate process. In other words I need something similar to the fork function under UNIX. I tried with threads: Use the new multiprocesing package. import os, threading def func(s) : print I'm thread number +s, os.getpid() threading.Thread(target=func, args=(1,)).start() threading.Thread(target=func, args=(2,)).start() Like this: import multiprocessing multiprocessing.Process(target=func, args=(1,)).start() multiprocessing.Process(target=func, args=(2,)).start() ... Surprise surprise it has almost the same API as the threading module :) --James Multiprocessing wasn't added until Python 2.6. http://www.python.org/dev/peps/pep-0371/ In Python 2.5, it was still a 3rd party package. http://pypi.python.org/pypi/processing The project's website appears to be down right now though. http://developer.berlios.de/projects/pyprocessing -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new process to run python function
Am 05.05.2010 17:59, schrieb Benjamin Kaplan: Multiprocessing wasn't added until Python 2.6. http://www.python.org/dev/peps/pep-0371/ In Python 2.5, it was still a 3rd party package. http://pypi.python.org/pypi/processing The project's website appears to be down right now though. http://developer.berlios.de/projects/pyprocessing Why don't you try out our backport: http://pypi.python.org/pypi/multiprocessing/2.6.2.1 :) -- http://mail.python.org/mailman/listinfo/python-list
Where is python31.dll?
Hi, recently I've been wondering how to roll my own portable python 3.1 (since there seems to be no portable app specifically for this version). Thinking you can just copy your install folder (+ python's dll), I've noticed that there seems to be no python31.dll in my systems folder (c:\windows\system32\). I cannot find the dll inside the python installation folder either. Another reason I'm asking is because what I've found on the net so far tells you to look for this dll specifically. Am I missing something? Thanks, Alex PS: my setup is version 3.1.2 on windows vista -- http://mail.python.org/mailman/listinfo/python-list
Re: Teaching Programming
On 5/5/2010 4:50 AM, Dave Angel wrote: alex23 wrote: Ed Keith e_...@yahoo.com wrote: Knuth wanted the generated source to be unreadable, so people would not be tempted to edit the generated code. This is my biggest issue with Knuth's view of literate programming. If the generated source isn't readable, am I just supposed to trust it? How can I tell if an error lies in my expression of the algorithm or in the code generation itself? Do you think a compiler is required to make its object file conveniently readable? Do you regularly read the machine code generated by your C compiler? I admit I've frequently studied compiler output over the years, but I think I'm very unusual in that respect. I've never disassembled a python byte code file, The output from dis.dis() is quite readable, and people (developers and others) have used it to check on what the compiler is doing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Movable Python or ActivePython
On 5/5/2010 8:47 AM, balzer wrote: I want Python pack that can run without being installed, mostly for testing programs. As I read, Movable Python can run without being installed. It needs no registry entries and knows the path to all the dlls (system or otherwise) that it uses. Whats about ActivePython http://www.activestate.com/activepython/downloads? Does it requires installation? Yes. It is the standard distribution with extra stuff added and installed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Movable Python or ActivePython
On 2010-05-05, at 5:47 AM, balzer wrote: I want Python pack that can run without being installed, mostly for testing programs. As I read, Movable Python can run without being installed. It needs no registry entries and knows the path to all the dlls (system or otherwise) that it uses. Whats about ActivePython http://www.activestate.com/activepython/downloads? Does it requires installation? The .MSI installer does require installation, but there is also a .ZIP package which doesn't. It is not visible in the downloads page, but you can always get it here: http://downloads.activestate.com/ActivePython/releases/2.6.5.12/ (substitute with latest version) When I just tried the ActivePython-2.6.5.12-win64-x64.zip on my Win7 x64 machine - by extracting and running python.exe (from INSTALLDIR/) without installing - it just worked. -srid -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is python31.dll?
On 5/5/2010 1:26 PM, Pietro Campesato wrote: Hi, recently I've been wondering how to roll my own portable python 3.1 (since there seems to be no portable app specifically for this version). Thinking you can just copy your install folder (+ python's dll), I've noticed that there seems to be no python31.dll in my systems folder (c:\windows\system32\). That is where it is on my WinXP system, installed for all users. I cannot find the dll inside the python installation folder either. Another reason I'm asking is because what I've found on the net so far tells you to look for this dll specifically. Am I missing something? Your windows search command? Which is how I verified the above. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is python31.dll?
Am 05.05.2010 19:26, schrieb Pietro Campesato: Hi, recently I've been wondering how to roll my own portable python 3.1 (since there seems to be no portable app specifically for this version). Thinking you can just copy your install folder (+ python's dll), I've noticed that there seems to be no python31.dll in my systems folder (c:\windows\system32\). I cannot find the dll inside the python installation folder either. Another reason I'm asking is because what I've found on the net so far tells you to look for this dll specifically. Am I missing something? It's trivial to roll your own portable bundle of Python that doesn't installation. All you need is an installation for me instead of an installation for all users. When you install Python just for the current user all necessary files land in the installation directory -- including the main dll and msvcrt stuff. Note that some features like COM and Windows Services require some dependencies in the system32 directory. Christian -- http://mail.python.org/mailman/listinfo/python-list
ActiveState using different MS runtime files than official Python release? (was Re: Movable Python or ActivePython)
In a recent thread (Movable Python or ActivePython), Sridhar Ratnakumar pointed out that the ActiveState Python releases can be downloaded as ZIP files vs. MSI files. (Great idea - thank you ActiveState!) The .MSI installer does require installation, but there is also a .ZIP package which doesn't. It is not visible in the downloads page, but you can always get it here: http://downloads.activestate.com/ActivePython/releases/2.6.5.12/ I just took a look at the ActiveStatre 2.6.5.12 release (zip file version) and noticed that this file does not include the MSVCR90.DLL run time file - it includes MFC*.DLL files instead (and a different manifest file as well). Can anyone explain why the ActiveState release uses different MS Visual C runtime files than the official Python Foundation's release of Python? Thanks, Malcolm - Original message - From: Sridhar Ratnakumar sridh...@activestate.com To: balzer nos...@news.eternal-september.org Cc: python-list@python.org Date: Wed, 5 May 2010 11:19:35 -0700 Subject: Re: Movable Python or ActivePython On 2010-05-05, at 5:47 AM, balzer wrote: I want Python pack that can run without being installed, mostly for testing programs. As I read, Movable Python can run without being installed. It needs no registry entries and knows the path to all the dlls (system or otherwise) that it uses. Whats about ActivePython http://www.activestate.com/activepython/downloads? Does it requires installation? The .MSI installer does require installation, but there is also a .ZIP package which doesn't. It is not visible in the downloads page, but you can always get it here: http://downloads.activestate.com/ActivePython/releases/2.6.5.12/ (substitute with latest version) When I just tried the ActivePython-2.6.5.12-win64-x64.zip on my Win7 x64 machine - by extracting and running python.exe (from INSTALLDIR/) without installing - it just worked. -srid -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.11.6
Hello! I'm pleased to announce version 0.11.6, a minor bugfix release of 0.11 branch of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.11.6 News and changes: http://sqlobject.org/News.html What's New == News since 0.11.5 - * A bug was fixed in SQLiteConnection.columnsFromSchema(): pass None as size/precision to DecimalCol; DecimalCol doesn't allow default values (to force user to pass meaningful values); but columnsFromSchema() doesn't implement proper parsing of column details. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmanhttp://phd.pp.ru/p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.12.4
Hello! I'm pleased to announce version 0.12.4, a minor bugfix release of branch 0.12 of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.12.4 News and changes: http://sqlobject.org/News.html What's New == News since 0.12.3 - * Bugs were fixed in calling from_python(). * A bug was fixed in SQLiteConnection.columnsFromSchema(): pass None as size/precision to DecimalCol; DecimalCol doesn't allow default values (to force user to pass meaningful values); but columnsFromSchema() doesn't implement proper parsing of column details. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmanhttp://phd.pp.ru/p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check what is holding reference to object
On Apr 28, 3:59 pm, Christian Heimes li...@cheimes.de wrote: The trick works only for objects that are tracked by CPython's garbage collector. Simple and non-containerish objects like str, int, unicode and some other types aren't tracked by the gc. Yes they are -- have you ever tried import gc gc.get_referrers(42) ? Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check what is holding reference to object
On Apr 27, 11:45 pm, Michal M mich.mier...@googlemail.com wrote: I've just found out that one of objects is not destroyed when it should be. This means that something was holding reference to this object or part of it (i.e. method). Is there any way to check what holds that reference? I am unable to do that just looking to the code or debugging it because it is pretty complicated, but I am able to invoke this situation again. I wrote http://pypi.python.org/pypi/objgraph for this purpose. -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list
HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/
HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS WALLPAPERS SEXY HOLLYWOOD ACTRESS PRETTY HOLLYWOOD ACTRESS CUTE HOLLYWOOD ACTRESS HOLLYWOOD ACTRESS ON http://hollywood6y.blogspot.com/ HEIDI MONTAG PRATT HAYDEN PENETTIERE HAWKINS GWEN RENEE STEFANI FREIDA PINTO FAMKE JANSSEN EMMANUELLE VAUGIER EMMANUELLE GREY ROSSUM ELISHA ANN CUTHBERT DIANA PRINCESS OF WALES DIANA ROSS DANIELA PESTOVA COURTENEY BASS COX CLAUDIA SCHIFFER CHRISTINA APPLEGATE CHARLIZE THERON CATERINA MURINO BROOKE ELIZABETH BURNS BRITTANY ANNE MURPHY BRITENY JEAN SPEARS BLAKE CHRISTINA ASHLEY MICHELLE TISDALE ASHLEY MCCALL SCOTT ASHLEY JUDD ASHLEU FULLER OLSEN ASHLEE NICOLE WENTZ ARIELLE CAROLINE KEBBEL ANA BEATRIZ BARROS AMY LYSLE SMART AMY LOUISE ACKER ALEXA ELLESSE VEGA ADRIANA FRANCESCA LIMA ABIGAIL ROSE AMERICAN ACTRESS HOLLYWOOD ACTRESS BRITENY SPEARS ANGLIANA JOLI KATE VINSLATE NICOLE KIDMAN HOLLYWOOD ACTRESS BOLLYWOOD ACTRESS LOLLYWOOD ACTRES SEXY HOLLYWOOD ACTRESS GIRLS WITHOUT CLOTHSON http://hollywood6y.blogspot.com/ SEXY GIRLS HOLLYWOOD SEXY GIRLS SUPER SEXY GIRLS SEX WORLD SEXY THIEGH SEXY BELLY SEXY LEGS SEXY FIGURES SEXY GIRLS SEXY MOTHERS SEXY SISTERS SEXY WORLDHEIDI MONTAG PRATT HAYDEN PENETTIERE HAWKINS GWEN RENEE STEFANI FREIDA PINTO FAMKE JANSSEN EMMANUELLE VAUGIER EMMANUELLE GREY ROSSUM ELISHA ANN CUTHBERT DIANA PRINCESS OF WALES DIANA ROSS DANIELA PESTOVA COURTENEY BASS COX CLAUDIA SCHIFFER CHRISTINA APPLEGATE CHARLIZE THERON CATERINA MURINO BROOKE ELIZABETH BURNS BRITTANY ANNE MURPHY BRITENY JEAN SPEARS BLAKE CHRISTINA ASHLEY MICHELLE TISDALE ASHLEY MCCALL SCOTT ASHLEY JUDD ASHLEU FULLER OLSEN ASHLEE NICOLE WENTZ ARIELLE CAROLINE KEBBEL ANA BEATRIZ BARROS AMY LYSLE SMART AMY LOUISE ACKER ALEXA ELLESSE VEGA ADRIANA FRANCESCA LIMA ABIGAIL ROSE AMERICAN ACTRESS HOLLYWOOD ACTRESS BRITENY SPEARS ANGLIANA JOLI KATE VINSLATE NICOLE KIDMAN HOLLYWOOD ACTRESS BOLLYWOOD ACTRESS LOLLYWOOD ACTRES SEXY HOLLYWOOD ACTRESS GIRLS WITHOUT CLOTHSON http://hollywood6y.blogspot.com/ SEXY GIRLS HOLLYWOOD SEXY GIRLS SUPER SEXY GIRLS SEX WORLD SEXY THIEGH SEXY BELLY SEXY LEGS SEXY FIGURES SEXY GIRLS SEXY MOTHERS SEXY SISTERS SEXY WORLDHEIDI MONTAG PRATT HAYDEN PENETTIERE HAWKINS GWEN RENEE STEFANI FREIDA PINTO FAMKE JANSSEN EMMANUELLE VAUGIER EMMANUELLE GREY ROSSUM ELISHA ANN CUTHBERT DIANA PRINCESS OF WALES DIANA ROSS DANIELA PESTOVA COURTENEY BASS COX CLAUDIA SCHIFFER CHRISTINA APPLEGATE CHARLIZE THERON CATERINA MURINO BROOKE ELIZABETH BURNS BRITTANY ANNE MURPHY BRITENY JEAN SPEARS BLAKE CHRISTINA ASHLEY MICHELLE TISDALE ASHLEY MCCALL SCOTT ASHLEY JUDD ASHLEU FULLER OLSEN ASHLEE NICOLE WENTZ ARIELLE CAROLINE KEBBEL ANA BEATRIZ BARROS AMY LYSLE SMART AMY LOUISE ACKER ALEXA ELLESSE VEGA ADRIANA FRANCESCA LIMA ABIGAIL ROSE AMERICAN ACTRESS HOLLYWOOD ACTRESS BRITENY SPEARS ANGLIANA JOLI KATE VINSLATE NICOLE KIDMAN HOLLYWOOD ACTRESS BOLLYWOOD ACTRESS LOLLYWOOD ACTRES SEXY HOLLYWOOD ACTRESS GIRLS WITHOUT CLOTHSON http://hollywood6y.blogspot.com/ SEXY GIRLS HOLLYWOOD SEXY GIRLS SUPER SEXY GIRLS SEX WORLD SEXY THIEGH SEXY BELLY SEXY LEGS SEXY FIGURES SEXY GIRLS SEXY MOTHERS SEXY SISTERS SEXY WORLDHEIDI MONTAG PRATT HAYDEN PENETTIERE HAWKINS GWEN RENEE STEFANI FREIDA PINTO FAMKE JANSSEN EMMANUELLE VAUGIER EMMANUELLE GREY ROSSUM ELISHA ANN CUTHBERT DIANA PRINCESS OF WALES DIANA ROSS DANIELA PESTOVA COURTENEY BASS COX CLAUDIA SCHIFFER CHRISTINA APPLEGATE CHARLIZE THERON CATERINA MURINO BROOKE ELIZABETH BURNS BRITTANY ANNE MURPHY BRITENY JEAN SPEARS BLAKE CHRISTINA ASHLEY MICHELLE TISDALE ASHLEY MCCALL SCOTT ASHLEY JUDD ASHLEU FULLER OLSEN ASHLEE NICOLE WENTZ ARIELLE CAROLINE KEBBEL ANA
Re: Teaching Programming
On 05/04/10 12:59, superpollo wrote: Martin P. Hellwig ha scritto: cut For the corner cases (I can think of a couple) it is good to know you can use ';' most of the time. most but not always as i noted (think about loops or function definition) Well through in some exec magic then, for example: for number in [1,2,3,4]: def nprint(number): print(number) number += 1 nprint(number translates to: exec('for number in [1,2,3,4]:\n\tdef nprint(number):\n\t\tprint(number)\n\tnumber += 1\n\tnprint(number)') 2 3 4 5 But if you have an example why indentation is still a problem please give it :-) -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Teaching Programming
Martin P. Hellwig ha scritto: On 05/04/10 12:59, superpollo wrote: Martin P. Hellwig ha scritto: cut For the corner cases (I can think of a couple) it is good to know you can use ';' most of the time. most but not always as i noted (think about loops or function definition) Well through in some exec magic then, for example: for number in [1,2,3,4]: def nprint(number): print(number) number += 1 nprint(number translates to: exec('for number in [1,2,3,4]:\n\tdef nprint(number):\n\t\tprint(number)\n\tnumber += 1\n\tnprint(number)') 2 3 4 5 But if you have an example why indentation is still a problem please give it :-) i think your exec example solved most of my problems. thanks a lot. bye -- http://mail.python.org/mailman/listinfo/python-list
Re: ActiveState using different MS runtime files than official Python release? (was Re: Movable Python or ActivePython)
On 10-05-05 12:04 PM, pyt...@bdurham.com wrote: I just took a look at the ActiveStatre 2.6.5.12 release (zip file version) and noticed that this file does not include the MSVCR90.DLL run time file - it includes MFC*.DLL files instead (and a different manifest file as well). Can anyone explain why the ActiveState release uses different MS Visual C runtime files than the official Python Foundation's release of Python? It doesn't. We use the same MSVC version as the python.org builds. Note that MFC*.dll files (IIRC, it has been a while) are redistributable DLLs used by the included PyWin32 extensions that have Python bindings for the Microsoft Foundation Classes GUI APIs. Trent -- Trent Mick trentm at activestate.com http://trentm.com/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: find out whther byte two .pyc files contain the same byte code.
En Wed, 05 May 2010 10:34:34 -0300, gelonida gelon...@gmail.com escribió: I'd like to know whether the byte code of two .pyc files is identical. I thought, I could just compare the md5sums of thw .pyc files. However this does not work. It seems, that .pyc ontains the time stamp of the source file. the .pyc file changes its contents when I don't change the file's contents but just save it again. Yes, that's what happens. First 4 bytes in a .pyc file contain a magic number identifying the Python version used to create it. Next 4 bytes contain the timestamp of the source file. Just ignore the first 8 bytes when computing the checksum: tail -c +8 tst.pyc | md5sum (untested) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Embedding, no correct lib
En Wed, 05 May 2010 09:04:06 -0300, moerchendiser2k3 googler.1.webmas...@spamgourmet.com escribió: I have a serious problem with Python. I am currently trying to implement Python into my app. Well this works fine, but get this: I have my own Python interpreter in a subfolder of my app. When I start my app, PYTHONHOME is set, and an environment variable is set to it can find the python DLL on startup. You should not define any environment variables. You are embedding Python into your application, aren't you? That is, you call Py_Initialize and all that stuff - you don't invoke a separate python.exe, true? Python tries to find its standard library looking for [the directory containing the executable]\Lib\os.py and a few other places. Once it finds the Lib directory, all other are derived from it. When Python is not installed on the system everything works fine as expected. When I now install Python on my system (so I have two python libs now) the system installation is the preferred one. print sys.path prints out ['', 'C:\Windows \system32\python26.zip', ...] and I cant explain whats going wrong here. Such zip file doesn't even exist in a standard Python installation; but it means that your program loaded python26.dll from the system32 directory, not your own copy. You may want to use a .local file or a manifest; see http://msdn.microsoft.com/en-us/library/ms811694.aspx I expected that it just uses the System lib when it cannot find it in the subfolder which I set in the environment variables before.. :-( Note that this is a Windows issue, not a Python one. You have to ensure the Python DLL is loaded from your own directory, not the system one. (BTW, don't set any environment variables. There is no need to do so, and it may conflict with an existing installation. The reverse is true too: a PYTHONPATH variable set for the system Python will interfere with your private copy too. Global state is always a bad idea.) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Embedding, no correct lib
On 6 Mai, 01:30, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 05 May 2010 09:04:06 -0300, moerchendiser2k3 googler.1.webmas...@spamgourmet.com escribió: I have a serious problem with Python. I am currently trying to implement Python into my app. Well this works fine, but get this: I have my own Python interpreter in a subfolder of my app. When I start my app, PYTHONHOME is set, and an environment variable is set to it can find the python DLL on startup. You should not define any environment variables. You are embedding Python into your application, aren't you? That is, you call Py_Initialize and all that stuff - you don't invoke a separate python.exe, true? Python tries to find its standard library looking for [the directory containing the executable]\Lib\os.py and a few other places. Once it finds the Lib directory, all other are derived from it. When Python is not installed on the system everything works fine as expected. When I now install Python on my system (so I have two python libs now) the system installation is the preferred one. print sys.path prints out ['', 'C:\Windows \system32\python26.zip', ...] and I cant explain whats going wrong here. Such zip file doesn't even exist in a standard Python installation; but it means that your program loaded python26.dll from the system32 directory, not your own copy. You may want to use a .local file or a manifest; seehttp://msdn.microsoft.com/en-us/library/ms811694.aspx I expected that it just uses the System lib when it cannot find it in the subfolder which I set in the environment variables before.. :-( Note that this is a Windows issue, not a Python one. You have to ensure the Python DLL is loaded from your own directory, not the system one. (BTW, don't set any environment variables. There is no need to do so, and it may conflict with an existing installation. The reverse is true too: a PYTHONPATH variable set for the system Python will interfere with your private copy too. Global state is always a bad idea.) -- Gabriel Genellina Hi Gabriel, thanks very much for your information. I found the solution. This is related to this one. The order of the search path is the explanation why the system one is used: http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx So 'Alternate Search Order' is the solution. :) Bye, moerchendiser2k3 -- http://mail.python.org/mailman/listinfo/python-list
Re: strange interaction between open and cwd
On 05May2010 13:23, Baz Walter baz...@ftml.net wrote: | here's what i get on my system, where '/dev/sda1' and '/dev/sda6' | are mounted at '/boot' and '/home' respectively: | | os.stat('/').st_ino | 2L | os.stat('/usr').st_ino | 212993L | os.stat('/boot').st_ino | 2L | os.stat('/home').st_ino | 2L | | | if the algorithm is climbing up from '/home/baz/tmp/xxx', what does | it do when it searches os.listdir('../../../..')? how can it tell | whether 'boot' or 'home' is the correct next parent if it only | checks the inode number? i think the algorithm would at least need | to take account of changes in the current device id. not sure | whether that would be enough to cover all cases, though. Look at the st_rdev field (== the device holding this inode). When that changes, you've crossed a mount mount point. -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ Usenet is essentially a HUGE group of people passing notes in class. --R. Kadel -- http://mail.python.org/mailman/listinfo/python-list
Re: ActiveState using different MS runtime files than official Python release? (was Re: Movable Python or ActivePython)
Hi Trent, On 10-05-05 12:04 PM, pyt...@bdurham.com wrote: I just took a look at the ActiveStatre 2.6.5.12 release (zip file version) and noticed that this file does not include the MSVCR90.DLL run time file - it includes MFC*.DLL files instead (and a different manifest file as well). Can anyone explain why the ActiveState release uses different MS Visual C runtime files than the official Python Foundation's release of Python? It doesn't. We use the same MSVC version as the python.org builds. Note that MFC*.dll files (IIRC, it has been a while) are redistributable DLLs used by the included PyWin32 extensions that have Python bindings for the Microsoft Foundation Classes GUI APIs. Yes, you are correct about the MFC*.dll's being shipped as part of the Py2Win32 extensions. But I don't see the MSVCR90.DLL in your ZIP release. I do see a MSVCR71.DLL. Malcolm -- http://mail.python.org/mailman/listinfo/python-list
Encrypt password within source code.
I can't think of a way to do this, not sure it is possible but I feel as though I might not know what I don't know. I want to share and example of a python script, to run it needs a google username and password. Is there a way for me to encrypt my username and password in the source code? I though about openID but don't really know anything about it. *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list
Re: Encrypt password within source code.
On Wed, May 5, 2010 at 6:12 PM, Vincent Davis vinc...@vincentdavis.net wrote: I can't think of a way to do this, not sure it is possible but I feel as though I might not know what I don't know. I want to share and example of a python script, to run it needs a google username and password. Is there a way for me to encrypt my username and password in the source code? I though about openID but don't really know anything about it. Nope. What you're asking for is essentially a form of DRM by including the information in a way the program can use it but the user can't extract it; DRM schemes have been broken many times and the idea is flawed even in theory, for if a person has control of their computer (or in the limit case, at least physical access to its innards), they can just watch the computation (e.g. memory snoop) until the data gets converted to its plain form so the program can actually utilize it, and then bada-bing, they have your valuable data. Think of it this way. If you encrypted the information in your program, the program would need to be able to decrypt it later so it could actually use the login info. For it to be able to do that, you'd have to include the encryption key in plaintext somewhere in the program so it could pass it into the decryption algorithm. But then someone can put 2 and 2 together, see that there's his key!, and decrypt your info using the key. So, to prevent this, the key *itself* would then have to be encrypted...by another key, which again would be stored in plaintext in your program somewhere, where someone could then find it and use it to decrypt the first key and then your data, so you use yet another key to encrypt that key...(as you can see, this goes on ad infinitum, and thus the whole scheme is doomed). See also section 1, DRM Systems Don't Work, of http://changethis.com/manifesto/show/4.DRM You can alternatively just try to obfuscate it, but that's obviously not truly secure and is likewise easily circumvented. Just let the user input their own Google Account info. If you're trying to show an example that depends on your own exact account, just include a transcript of your terminal session (omitting your Google Account info obviously). Cheers, Chris -- DRM is http://defectiveByDesign.org http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Encrypt password within source code.
On 05/05/2010 08:12 PM, Vincent Davis wrote: I can't think of a way to do this, not sure it is possible but I feel as though I might not know what I don't know. I want to share and example of a python script, to run it needs a google username and password. Is there a way for me to encrypt my username and password in the source code? No-ish. You can encrypt it, but if you encrypt it, you need to include the keys or algorithm for decrypting it, and all it takes is a pdb.set_trace() before the decrypted uname/pwd get sent to Google to get it, and poof all your encryption/decryption has been in vain: uname = SUPER_ENCRYPTED_USER pwd = SUPER_ENCRYPTED_PASSWORD u = secret_decrypt(uname) p = secret_decrypt(pwd) # regardless of how good the stuff above is # you're vulnerable right here: # print %r %r % (u, p) do_google_stuff(u, p) Unless the Google API you're using allows for chain-of-authority creation of sub-credentials (so your account creates secondary accounts that are then distributed in your code/config files and managed via your dev login), two possibilities that come to mind: 1) put in a bogus uname/password and make them get their own Google login to put in (which can be done in a config file if they're squeamish about editing source code) This assumes that any arbitrary Google login can grant access to what you want (sometimes this is a developer key, in which case the user would need to get their own dev key). 2) create a web-service on a server somewhere that has your credentials, but your distributed code merely hits this web service instead of having your actual credentials in the source (plain-text or encrypted). The server would have them (I'd just put them in plain-text -- no need to be fancy. If you can't trust your hosting service, don't use them) but you wouldn't expose the credentials outside the application. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Is there a better way to set a system clock in Python (on a Linux system)
Is there a better way to do this? def SkewTime(): ''' Optional function. We can skew time by 1 hour if we'd like to see real sync changes being enforced ''' TIME_SKEW=1 logging.info('Time Skewing has been selected. Setting clock ahead 1 hour') # Let's get our current time t = TimeCheck() logging.info('Current time is: %s' % time.asctime(t)) # Now create new time string in the form MMDDhhmm for the date program hr = t.tm_hour + TIME_SKEW date_string = time.strftime('%m%d%H%M%Y',(t.tm_year, t.tm_mon, t.tm_mday, hr, t.tm_min, t.tm_sec, t.tm_wday, t.tm_yday, t.tm_isdst)) logging.debug('New date string is: %s' % date_string) logging.debug('Setting new system time/date') status = SilentCall('/bin/date %s' % date_string) logging.info('Pre-sync time is: %s' % time.asctime()) TimeCheck() as referenced above is a simple function that just returns the time.time_struct object from time.localtime(). I pull time a few times and it was a little cleaner to put that into a function and just call the function whenever I needed to. SilentCall() is a modification of subprocess.call() (which in reality just calls Popen(*popenargs,**kwargs).wait()) but it defaults to redirecting stdin and stdout to /dev/null to suppress shell output from the command being called. Anyway, what I'm wondering, is, while this works, is there a better way to do it than using part of the originally returned time_struct and injecting my own new hour argument (hr). The goal of this function is to just set the system clock one hour ahead, so when I call the Linux command 'ntpdate' I can get a real time change when it syncs the local clock to an NTP server. This just looks... well, big to me. I tried passing only the things I really needed to time.strftime(), but apparently, that requires the full 9-tuple from time_struct, not just individual parts of it. Like I said, it works well, I just wonder if there is a cleaner way of setting the local clock to a different time in python without having to do all this. The reason most of that exists, is because the linux date command expects to see the new date/time like this: MMDDhhmm.ss. Or am I just looking at this too hard and really did work it out nicely? Cheers Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to set a system clock in Python (on a Linux system)
On Wed, May 5, 2010 at 7:47 PM, J dreadpiratej...@gmail.com wrote: Is there a better way to do this? Yes: from datetime import datetime, timedelta def SkewTime(): ''' Optional function. We can skew time by 1 hour if we'd like to see real sync changes being enforced ''' TIME_SKEW=1 logging.info('Time Skewing has been selected. Setting clock ahead 1 hour') # Let's get our current time skewed = datetime.now() + timedelta(hours=TIME_SKEW) # Now create new time string in the form MMDDhhmm for the date program date_time_str = skewed.strftime('%m%d%H%M%Y') logging.debug('New date string is: %s' % date_time_str) logging.debug('Setting new system time/date') status = SilentCall('/bin/date %s' % date_time_str) logging.info('Pre-sync time is: %s' % time.asctime()) Anyway, what I'm wondering, is, while this works, is there a better way to do it than using part of the originally returned time_struct and injecting my own new hour argument (hr). Use the datetime module roughly as shown. (Disclaimer: Code is untested). Also, I'm not sure if your original code worked properly after 11PM; my code definitely should. This just looks... well, big to me. I tried passing only the things I really needed to time.strftime(), but apparently, that requires the full 9-tuple from time_struct, not just individual parts of it. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to set a system clock in Python (on a Linux system)
man 2 clock_settime call it with ctypes -- Best Regards, -- KDr2 http://kdr2.net On Thu, May 6, 2010 at 10:47 AM, J dreadpiratej...@gmail.com wrote: Is there a better way to do this? def SkewTime(): ''' Optional function. We can skew time by 1 hour if we'd like to see real sync changes being enforced ''' TIME_SKEW=1 logging.info('Time Skewing has been selected. Setting clock ahead 1 hour') # Let's get our current time t = TimeCheck() logging.info('Current time is: %s' % time.asctime(t)) # Now create new time string in the form MMDDhhmm for the date program hr = t.tm_hour + TIME_SKEW date_string = time.strftime('%m%d%H%M%Y',(t.tm_year, t.tm_mon, t.tm_mday, hr, t.tm_min, t.tm_sec, t.tm_wday, t.tm_yday, t.tm_isdst)) logging.debug('New date string is: %s' % date_string) logging.debug('Setting new system time/date') status = SilentCall('/bin/date %s' % date_string) logging.info('Pre-sync time is: %s' % time.asctime()) TimeCheck() as referenced above is a simple function that just returns the time.time_struct object from time.localtime(). I pull time a few times and it was a little cleaner to put that into a function and just call the function whenever I needed to. SilentCall() is a modification of subprocess.call() (which in reality just calls Popen(*popenargs,**kwargs).wait()) but it defaults to redirecting stdin and stdout to /dev/null to suppress shell output from the command being called. Anyway, what I'm wondering, is, while this works, is there a better way to do it than using part of the originally returned time_struct and injecting my own new hour argument (hr). The goal of this function is to just set the system clock one hour ahead, so when I call the Linux command 'ntpdate' I can get a real time change when it syncs the local clock to an NTP server. This just looks... well, big to me. I tried passing only the things I really needed to time.strftime(), but apparently, that requires the full 9-tuple from time_struct, not just individual parts of it. Like I said, it works well, I just wonder if there is a cleaner way of setting the local clock to a different time in python without having to do all this. The reason most of that exists, is because the linux date command expects to see the new date/time like this: MMDDhhmm.ss. Or am I just looking at this too hard and really did work it out nicely? Cheers Jeff -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Encrypt password within source code.
Thanks for the replies I though the answer was no. Vincent On Wed, May 5, 2010 at 7:48 PM, Tim Chase python.l...@tim.thechases.comwrote: On 05/05/2010 08:12 PM, Vincent Davis wrote: I can't think of a way to do this, not sure it is possible but I feel as though I might not know what I don't know. I want to share and example of a python script, to run it needs a google username and password. Is there a way for me to encrypt my username and password in the source code? No-ish. You can encrypt it, but if you encrypt it, you need to include the keys or algorithm for decrypting it, and all it takes is a pdb.set_trace() before the decrypted uname/pwd get sent to Google to get it, and poof all your encryption/decryption has been in vain: uname = SUPER_ENCRYPTED_USER pwd = SUPER_ENCRYPTED_PASSWORD u = secret_decrypt(uname) p = secret_decrypt(pwd) # regardless of how good the stuff above is # you're vulnerable right here: # print %r %r % (u, p) do_google_stuff(u, p) Unless the Google API you're using allows for chain-of-authority creation of sub-credentials (so your account creates secondary accounts that are then distributed in your code/config files and managed via your dev login), two possibilities that come to mind: 1) put in a bogus uname/password and make them get their own Google login to put in (which can be done in a config file if they're squeamish about editing source code) This assumes that any arbitrary Google login can grant access to what you want (sometimes this is a developer key, in which case the user would need to get their own dev key). 2) create a web-service on a server somewhere that has your credentials, but your distributed code merely hits this web service instead of having your actual credentials in the source (plain-text or encrypted). The server would have them (I'd just put them in plain-text -- no need to be fancy. If you can't trust your hosting service, don't use them) but you wouldn't expose the credentials outside the application. -tkc *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list
Looking for a gettext and/or Babel tutorial for Windows
I'm looking for a gettext and/or Babel tutorial for Windows. Any suggestions? Specific topics I'm interested in: 1. Understanding the full life cycle of PO/POT and MO files from their initial creation to their ongoing maintenance (under Windows) 2. Automating the use of pygettext and msgfmt.py (or their GNU gettext equivalents) to update PO and MO files (under Windows) 3. Where to store my MO files (under Windows) - is there a best practice location for these files? In the absence of a tutorial, I'm open to looking at source code and/or batch/command/script/make files. Thanks, Malcolm -- http://mail.python.org/mailman/listinfo/python-list
PyCon Australia Early-Bird running out!
Registration is open and the Early Bird tickets are running out. Register here: http://pycon-au.org/reg We offer two levels of registration for PyCon Australia 2010: Full (Early Bird) - $165 This is the registration rate for regular attendees. We're offering a limited Early Bird rate for the first 50 to registration. Once the Early Bird slots are filled registration will increase to $198. Full registration includes one seat at the conference dinner on Saturday night. Student - $44 For students able to present a valid student card we're offering this reduced rate. Student registrations do not include a seat at the conference dinner. Additional seats at the conference dinner may be purchased for $77 each. All prices include GST. Information about the registration process is on the PyCon Australia website. Register here: http://pycon-au.org/reg -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is python31.dll?
Your windows search command? Which is how I verified the above. I looked at the folder visually. Simply using os.listdir shows there is in fact a python31.dll there: somehow it was an invisible file. This is strange since I've never touched any system folder. Thanks and forgive me if I have asked the group a silly question. -- http://mail.python.org/mailman/listinfo/python-list
Re: strange interaction between open and cwd
On Wed, 05 May 2010 13:23:03 +0100, Baz Walter wrote: so if several filesystems are mounted in the same parent directory, there is no way to tell which of them is the right one. The only case which would cause a problem here is if you mount the same device on two different subdirectories of a common directory. But in that case, it doesn't really matter which answer you get, as they're both equivalent in any sense that matters. nope! just to be clear: here's what i get on my system, where '/dev/sda1' and '/dev/sda6' are mounted at '/boot' and '/home' respectively: os.stat('/').st_ino 2L os.stat('/usr').st_ino 212993L os.stat('/boot').st_ino 2L os.stat('/home').st_ino 2L Right. /, /boot and /home are separate filesystems; ext2/ext3 filesystems normally use inode #2 as the root directory. If you look at the st_dev field, all three will be different (for /boot and /home, they'll correspond to sda1 and sda6 respectively). if the algorithm is climbing up from '/home/baz/tmp/xxx', what does it do when it searches os.listdir('../../../..')? how can it tell whether 'boot' or 'home' is the correct next parent if it only checks the inode number? It doesn't. Inode numbers are only unique within a single device; you need to use both st_dev and st_ino to uniquely identify an inode within a complete filesystem. i think the algorithm would at least need to take account of changes in the current device id. not sure whether that would be enough to cover all cases, though. st_dev+st_ino is sufficient. -- http://mail.python.org/mailman/listinfo/python-list
Re: strange interaction between open and cwd
On Thu, 06 May 2010 10:21:45 +1000, Cameron Simpson wrote: Look at the st_rdev field (== the device holding this inode). When that changes, you've crossed a mount mount point. st_dev reports the device on which the inode resides. st_rdev is only meaningul if the inode type is block device (S_IFBLK) or character device (S_IFCHR), in which case it identifies the device to which the inode refers, e.g.: os.stat(/).st_dev 2049L os.stat(/).st_rdev 0 os.stat(/dev/sda1).st_dev 2049L os.stat(/dev/sda1).st_rdev 2049 os.stat(/dev/sda2).st_dev 2049L os.stat(/dev/sda2).st_rdev 2050 (/dev/sda1 is mounted as the root filesystem). -- http://mail.python.org/mailman/listinfo/python-list
[issue8619] Doc bug for urllib.request._urlopener in Python 3.1+
sri sriram.thai...@gmail.com added the comment: You missed the code part: urllib._urlopener = AppURLopener() -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8619] Doc bug for urllib.request._urlopener in Python 3.1+
Senthil Kumaran orsent...@gmail.com added the comment: Fixed in r80775 and r80776 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8610] Python3/POSIX: errors if file system encoding is None
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: I don't think it's a good idea to display an fatal error at runtime. If nl_langinfo(CODESET) is not available, configure should fail or we should fallback to an hardcoded encoding (ok but which one?). If nl_langinfo(CODESET) fails, Python should assume the default locale, which is C on POSIX platforms. The C locale uses ASCII as encoding, so Python should use that as well. Note that the manpage for nl_langinfo() doesn't mention any errors that could be raised by it: RETURN VALUE If no locale has been selected for the appropriate category, nl_langinfo() returns a pointer to the corresponding string in the C locale. If item is not valid, a pointer to an empty string is returned. This pointer may point to static data that may be overwritten on the next call to nl_lang‐ info() or setlocale(3). As with all locale APIs, it is not thread-safe, which can become an issues if Python gets embedded in a multi-threaded application. There's also another issue: it's possible that nl_langinfo(CODESET) returns an encoding which is not known to Python. In such a case, it would be best to issue a warning to the user and fall back to ASCII as in the C locale case. Terminating Python with a fatal error would provide the worst of all user experiences. -1 on that. -- nosy: +lemburg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8603] Create a bytes version of os.environ and getenvb()
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: The documentation of os.environb and os.getenvb() in my last patch is very short. I'm not inspired. We told me on IRC to not use function annotations because annotation semantic was not decided yet. I will try to improve the documentation and remove the annotations in my next patch. Patch looks good. +1 on adding it. One nit: I'd rename the keymap function to encodekey. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8603 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8617] Non-existent variables documented
Tarek Ziadé ziade.ta...@gmail.com added the comment: site definitely needs more documentation about the per-user site-packages. We need to add a section about that. I am adding Christian to the nosy list, since he added those feature. I can work on a section sometimes next week and propose a patch here btw. -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8617 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8610] Python3/POSIX: errors if file system encoding is None
STINNER Victor victor.stin...@haypocalc.com added the comment: manpage for nl_langinfo() doesn't mention any errors that could be raised by it It's more about get_codeset(). This function can fail for different reasons: - nl_langinfo() result is an empty string: If item is not valid, a pointer to an empty string is returned. say the manpage - _PyCodec_Lookup() failed: unable to import the encoding codec module, there is no such codec, codec machinery is broken, etc. - the codec has no name attribute - strdup() failure (no more memory) Do you think that you should fallback to ASCII if nl_langinfo() result is an empty string, and UTF-8 otherwise? get_codeset() failure is very unlikely, and I think that fallback to UTF-8 is just fine. A warning is printed to stderr, the user should try to understand why get_codeset() failed. You can at least reproduce the _PyCodec_Lookup() error with #8611. My problem is also that the file system encoding is required (encoding != None) by os.environ mapping with my os.environb patch. (#8603) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8603] Create a bytes version of os.environ and getenvb()
STINNER Victor victor.stin...@haypocalc.com added the comment: MaL Patch looks good. +1 on adding it. Cool. I didn't understood if MvL is +1, but at least he's not -1 on this, and we are at least two at +1 :-) MaL One nit: I'd rename the keymap function to encodekey. Ok, I will also change that in the final patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8603 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8610] Python3/POSIX: errors if file system encoding is None
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: manpage for nl_langinfo() doesn't mention any errors that could be raised by it It's more about get_codeset(). This function can fail for different reasons: - nl_langinfo() result is an empty string: If item is not valid, a pointer to an empty string is returned. say the manpage - _PyCodec_Lookup() failed: unable to import the encoding codec module, there is no such codec, codec machinery is broken, etc. - the codec has no name attribute - strdup() failure (no more memory) Do you think that you should fallback to ASCII if nl_langinfo() result is an empty string, and UTF-8 otherwise? get_codeset() failure is very unlikely, and I think that fallback to UTF-8 is just fine. A warning is printed to stderr, the user should try to understand why get_codeset() failed. I think that using ASCII is a safer choice in case of errors. Using UTF-8 may be safe for reading file names, but it's not safe for creating files or directories. I also think that an application should be able to update the file system encoding in such an error case (and only in such a case). The application may have better knowledge about how it's being used and can provide correct encoding information by other means. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8610] Python3/POSIX: errors if file system encoding is None
STINNER Victor victor.stin...@haypocalc.com added the comment: I think that using ASCII is a safer choice in case of errors. I choosed UTF-8 to keep backward compatibility: PyUnicode_DecodeFSDefaultAndSize() uses utf-8 if Py_FileSystemDefaultEncoding==NULL. If the OS has no nl_langinfo(CODESET) function at all, Python3 uses utf-8. Using UTF-8 may be safe for reading file names, but it's not safe for creating files or directories. Well, I don't know. You are maybe right. And which encoding should be used if nl_langinfo(CODESET) function is missing: ASCII or UTF-8? UTF-8 is also an optimist choice: I bet that more and more OS will move to UTF-8. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8313] unprintable AssertionError object message in unittest tracebacks
Michael Foord mich...@voidspace.org.uk added the comment: Changing traceback._some_str to return unicode rather than str seems like a bad idea. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8313 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8313] unprintable AssertionError object message in unittest tracebacks
Changes by Michael Foord mich...@voidspace.org.uk: -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8313 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8610] Python3/POSIX: errors if file system encoding is None
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: I think that using ASCII is a safer choice in case of errors. I choosed UTF-8 to keep backward compatibility: PyUnicode_DecodeFSDefaultAndSize() uses utf-8 if Py_FileSystemDefaultEncoding==NULL. If the OS has no nl_langinfo(CODESET) function at all, Python3 uses utf-8. Ouch, that was a poor choice. In Python we have a tradition to avoid guessing, if possible. Since we cannot guarantee that the file system will indeed use UTF-8, it would have been safer to use ASCII. Not sure why this reasoning wasn't applied for the file system encoding. Nothing we can do about now, though. Using UTF-8 may be safe for reading file names, but it's not safe for creating files or directories. Well, I don't know. You are maybe right. And which encoding should be used if nl_langinfo(CODESET) function is missing: ASCII or UTF-8? UTF-8 is also an optimist choice: I bet that more and more OS will move to UTF-8. I think we should also add a new environment variable to override the automatic determination of the file system encoding, much like what we have for the I/O encoding: PYTHONFSENCODING: Encoding[:errors] used for file system. (that would need to go on a new ticket, though) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8313] unprintable AssertionError object message in unittest tracebacks
Michael Foord mich...@voidspace.org.uk added the comment: I would prefer to try str(...) first and only attempt to convert to unicode and do the backslash replace if the str(...) call fails. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8313 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8620] wrong truncation of line in Cmd.cmd
New submission from Mattelaer olivier.mattel...@uclouvain.be: When using the Cmd module on a file. it happens that the last line is truncated from the last caracther. The problem is simply that it can happen that the last line doesn't finish by '\n' charcacter. In consequence the line which is suppose to suppress the '\n' suppress another character. Cheers, Olivier -- components: None messages: 105012 nosy: omatt priority: normal severity: normal status: open title: wrong truncation of line in Cmd.cmd type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8620 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8621] Mac OS X
New submission from yig yo...@yotamgingold.com: Calling uuid.uuid4() while using the multiprocessing module leads to the same exact UUIDs being generating in each process. It is an artifact resulting from the built-in uuid_generate_random() of my underlying platform, Mac OS X 10.6.3. A Linux machine I have does not exhibit this problem. I have tested it with both Python 2.5 and 2.6. -- assignee: ronaldoussoren components: Macintosh files: multiprocessing_uuid.py messages: 105013 nosy: ronaldoussoren, yig priority: normal severity: normal status: open title: Mac OS X type: behavior versions: Python 2.5, Python 2.6 Added file: http://bugs.python.org/file17216/multiprocessing_uuid.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8613] Decimal module flags undetermined when a signal is trapped.
Stefan Krah stefan-use...@bytereef.org added the comment: I agree that the spec is not unambiguous, but consider the Overflow and Underflow passages here: http://speleotrove.com/decimal/daexcep.html == Overflow == In all cases, Inexact and Rounded will also be raised. Raise here of course means raising the flags Inexact and Rounded, not Python exceptions. So I would think that if the overflow trap handler is engaged, the flags Inexact and Rounded must be raised (set to 1) in the context. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8613 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Mark Dickinson dicki...@gmail.com added the comment: Since r80665, a ./configure --with-pydebug seems to give compilation with -O2 (tested on OS X and Linux). Is this intentional? I'm getting, e.g., gcc -c -g -O2 -g -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c -- nosy: +mark.dickinson status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8619] Doc bug for urllib.request._urlopener in Python 3.1+
R. David Murray rdmur...@bitdance.com added the comment: Why do we have a public API that begins with an '_'? -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8613] Decimal module flags undetermined when a signal is trapped.
Mark Dickinson dicki...@gmail.com added the comment: Yes, that's a good point. It would be nice for e.g. Inexact = Rounded invariants to be, well, invariant. I agree that the cdecimal behaviour is the correct one. I'm looking for wiggle room here because I don't really want to make a set of complicated and possibly performance-degrading changes to the decimal module unless it's really necessary for correctness. Having said that, I can see at least one reasonable way of fixing this in the decimal module: (1) Create a delay_traps context manager, so that: with delay_traps(): do arithmetic disables traps for the duration of the with block, keeps track of all flags set (disregarding those set before the with block was entered), and then on leaving the with block re-raises signals corresponding to the traps set in the original context (respecting precedence, of course). (2) Also create a _delayed_traps (names could do with improvement, probably) decorator that effectively wraps an entire function in 'with delay_traps() (3) Decorate all the primitive decimal operations with this decorator. Thoughts? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8613 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8621] Mac OS X
yig yo...@yotamgingold.com added the comment: For the record, I filed a bug against the underlying platform. (I wrote a simple program to reproduce this in C and filed a bug report with Apple rdar://7944700. The OpenRadar page for it is here: http://openradar.appspot.com/radar?id=334401 ) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Marc-Andre Lemburg m...@egenix.com added the comment: Mark Dickinson wrote: Mark Dickinson dicki...@gmail.com added the comment: Since r80665, a ./configure --with-pydebug seems to give compilation with -O2 (tested on OS X and Linux). Is this intentional? Yes. I've restored the previous behavior of configure to have AC_PROG_CC determine CFLAGS defaults. Please open a new ticket to have --with-pydebug disable use of any optimization flags. We need to find a different solution for that. Unconditionally ignoring the AC_PROG_CC CFLAGS defaults is not solution. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Changes by Marc-Andre Lemburg m...@egenix.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Marc-Andre Lemburg m...@egenix.com added the comment: Marc-Andre Lemburg wrote: Marc-Andre Lemburg m...@egenix.com added the comment: Mark Dickinson wrote: Mark Dickinson dicki...@gmail.com added the comment: Since r80665, a ./configure --with-pydebug seems to give compilation with -O2 (tested on OS X and Linux). Is this intentional? Yes. I've restored the previous behavior of configure to have AC_PROG_CC determine CFLAGS defaults. Please open a new ticket to have --with-pydebug disable use of any optimization flags. We need to find a different solution for that. Unconditionally ignoring the AC_PROG_CC CFLAGS defaults is not solution. Note that using the following line will disable the AC_PROG_CC defaults: ./configure --with-pydebug CFLAGS='' This is a new feature that was introduced previously by Victor and that I corrected in r80665. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8619] Doc bug for urllib.request._urlopener in Python 3.1+
Senthil Kumaran orsent...@gmail.com added the comment: That is actually a private attribute of urllib (not urllib2) module present from the very first version. It is intended strictly for overriding purposes not for anything else. During the merge in py3k, it has taken its place in urllib.request. I see no harm in it being there. If it needs to be un-advertised, perhaps we can remove its reference from the docs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8313] unprintable AssertionError object message in unittest tracebacks
STINNER Victor victor.stin...@haypocalc.com added the comment: Commited: r80777 (trunk) and r80779 (2.6); blocked: r80778 (py3k). Open a new issue if you would like to use something better than ASCII+backslashreplace in unittest (using runner stream encoding?). -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8313 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Mark Dickinson dicki...@gmail.com added the comment: Yes. I've restored the previous behavior of configure to have AC_PROG_CC determine CFLAGS defaults. Just to be clear, the previous behaviour has *not* been restored. Up until r80665, a '--with-pydebug' build did not include optimization. Since r80665, it does. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8621] uuid.uuid4() generates non-unique values on OSX
Ronald Oussoren ronaldousso...@mac.com added the comment: As the bug is in the underlying platform the best we can do is to warn about this in the documentation, as in the attached patch. BTW. I've updated the title to be slightly more informative. -- keywords: +patch title: Mac OS X - uuid.uuid4() generates non-unique values on OSX versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.5 Added file: http://bugs.python.org/file17217/issue8621-doc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Mark Dickinson dicki...@gmail.com added the comment: Ah, I understand now: -O2 started appearing in debug builds in r79218, which changed the Makefile to respect CFLAGS. I tested a variety of revision, but failed to test revision in between that and Victor's change... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8211] configure: allow user-provided CFLAGS to override AC_PROG_CC defaults
Marc-Andre Lemburg m...@egenix.com added the comment: Mark Dickinson wrote: Mark Dickinson dicki...@gmail.com added the comment: Ah, I understand now: -O2 started appearing in debug builds in r79218, which changed the Makefile to respect CFLAGS. I tested a variety of revision, but failed to test revision in between that and Victor's change... Right. I was referring to r79391, ie. the state before Victor checked in his patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4661] email.parser: impossible to read messages encoded in a different encoding
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4661 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1467619] Header.decode_header eats up spaces
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1467619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1368247] unicode in email.MIMEText and email/Charset.py
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1368247 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1379416] email.Header encode() unicode P2.6
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1379416 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8621] uuid.uuid4() generates non-unique values on OSX
yig yo...@yotamgingold.com added the comment: Why not default to not use the Python implementation on darwin instead of the underlying platform's uuid_generate_random(), until it's proven safe? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6521] Contradictory documentation for email.mime.text.MIMEText
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6521 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1685453] email package should work better with unicode
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1685453 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8621] uuid.uuid4() generates non-unique values on OSX
yig yo...@yotamgingold.com added the comment: Ahem. Why not use the Python implementation on darwin until its uuid_generate_random() is deemed to be safe? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1555570] email parser incorrectly breaks headers with a CRLF at 8192
Changes by Barry A. Warsaw ba...@python.org: -- assignee: barry - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue170 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com