Re: How to change the file creation timestamp?
On Sat, 26 Nov 2011 00:51:34 +1100, Alec Taylor wrote: > import os > import time > from stat import * > > #returns a list of all the files on the current directory files = > os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images if f.lower().endswith('jpg') > or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time The original poster asks for how to change the file creation timestamp. (The poster assumes that there is a creation timestamp, which is not necessarily the case -- many file systems do not store the creation time.) > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) Note that this is from the posix module, so it probably won't work under Windows. > > On Fri, Nov 25, 2011 at 11:47 PM, 刘振海 <1989l...@gmail.com> wrote: >> Hi, >> I want to change the file creation timestamp using python, but I can >> not find a solution to do it. >> I know the way to change the file creation timestamp in C under >> Windows, but I want to change it using python. >> I really need help! >> >> Regards, >> Liu Zhenhai >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
On Nov 25, 10:16 pm, Roy Smith wrote: > In article > <581dab49-e6b0-4fea-915c-4a41fa887...@p7g2000pre.googlegroups.com>, > > rusi wrote: > > First you must figure out how to structure data -- jargon is > > normalization. After that you can look at transactions, ACID, > > distribution and all the other good stuff. > > And when you're all done with that, you can start unlearning everything > you've learned about normalization (not that you shouldn't learn about > it in the first place, just that you should also learn when excessive > normalization is a bad thing). > > And then start looking at BASE (Basic Availability, Soft-state, > Eventually consistent) as an alternative to ACID. > > Don't get me wrong. SQL is a powerful tool, and truly revolutionized > the database world. Anybody who is thinking about going into databases > as a career needs to know SQL. But, it's not the end of the road. > There is life after SQL, and that's worth exploring too. Yes going all the way up to fifth normal form can be nonsensical. Putting it less jargony -- Given a real world scenario involving data can you organize it into tables with reasonable foreign-key relations, and integrity constraints? If so you can start looking beyond sql. -- http://mail.python.org/mailman/listinfo/python-list
Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.
On Nov 25, 11:52 am, Sibylle Koczian wrote: > Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > > I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" > and "Edit with PythonWin" in my context menu. I installed Python from > the Python.org site, the Windows extensions from Sourceforge, both of > them for all users and without any changes to the standard installation > or to file associations. > > This isn't the first Python 3 version on this machine, I don't know if > that might be relevant. > > But it's a fact that changing the applications shown in the context menu > for a file association isn't obvious any more on Windows 7. > > HTH > Sibylle I'm also using Python 2.7 and Python 3.3 on Windows 7, 64-bit, and have both "Edit" menu items as well. Changing the application defaults is now in "Default Programs" right on the Start Menu. It's more "obvious" than the old location, but the old location is just known by more people and Microsoft loves to move things around. -Mark -- http://mail.python.org/mailman/listinfo/python-list
RE: Using the Python Interpreter as a Reference
I'm looking at a variation on this theme. I currently use Flex/ActionScript for client side work, but there is pressure to move toward HTML5+Javascript and or iOS. Since I'm an old hand at Python, I was wondering if there is a way to use it to model client side logic, then generate the javascript and ActionScript. I don't see an issue using custom python objects to render either mxml, xaml or html5 but I'm not aware if anyone has already solved the problem of converting Python (byte code?) to these languages? Any suggestions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic import of submodules
On Nov 25, 11:00 pm, Massi wrote: > plugins > | > -- wav_plug > | > -- __init__.py > -- WavPlug.py > -- mp3_plug > | > -- __init__.py > -- Mp3Plug.py > ... > -- etc_plug > | > -- __init__.py > -- EtcPlug.py What do you gain by having each plugin as a package? Unless you're storing other resources with each plugin, I'd move all your XXXPlug.py files into plugins/ I'd also probably call the modules 'wavplug' and the class 'WavPlug' to always make it clear to which you're referring. > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? It's not exactly automatic, but you could move all of those imports into plugins/__init__.py, then just do a single from plugins import * in your main module. -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
On Nov 25, 6:58 pm, Tim Golden wrote: > Do you have the pyreadline module installed? ISTR that that takes > over from the standard cmd processing... I'm pretty sure I do. It's really not an issue, though, as I tend to stick to linux & iPython where possible :) -- http://mail.python.org/mailman/listinfo/python-list
Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.
On 25.11.2011 05:49, Dennis Lee Bieber wrote: On Fri, 25 Nov 2011 01:32:08 +0100, Alexander Kapps declaimed the following in gmane.comp.python.general: The main difference here is, that Linux makes it easy to seperate administrative accounts from end-user accounts, So does Win7... Heck -- I have to answer prompts to OK an installer even while logged into my admin account! For Windows, Left-Clicking an OK button to confirm potentionally dangerous admin tasks is like linking the acceleration pedal in your car to the brake pedal(If the traffic light shows Red/Stop, push the acceleration pedal to break) I mean, seriously, left-clicking an OK button is something *SO* unusual to Windows users that you could also just remove that "barrier" altogether. Now, OK, I don't really know any Windows version after XP, so things might have changed. But what I see from the casual Win users in my environment is that nothing has really changed. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to change the file creation timestamp?
Hi Alec Thanks for your help. I want to change the creation timestamp. the code that you give is to change the modification and access time. I already find a solution using pywin32's win32file module import win32file filehandle = win32file.CreateFile(file_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, 0) win32file.SetFileTime(filehandle, ctime, atime, mtime) Regards, Liu Zhenhai 2011/11/25 Alec Taylor > import os > import time > from stat import * > > #returns a list of all the files on the current directory > files = os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images > if f.lower().endswith('jpg') or f.lower().endswith('crw'): >st = os.stat(f) >atime = st[ST_ATIME] #access time >mtime = st[ST_MTIME] #modification time > >new_mtime = mtime + (4*3600) #new modification time > >#modify the file timestamp >os.utime(f,(atime,new_mtime)) > > On Fri, Nov 25, 2011 at 11:47 PM, 刘振海 <1989l...@gmail.com> wrote: > > Hi, > > I want to change the file creation timestamp using python, but I can not > > find a solution to do it. > > I know the way to change the file creation timestamp in C under Windows, > but > > I want to change it using python. > > I really need help! > > > > Regards, > > Liu Zhenhai > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
> Except that, intriguingly, I'm also using an ActiveState distro > and it neither adds Ctrl-D nor prevents history. But I'm > fairly sure that pyreadline does both of those things. > > TJG In python I can spawn a process to run python byte code that will produce a file with results. Easy to avoid a lot import A,B,C,D.. on the top level. -- http://mail.python.org/mailman/listinfo/python-list
Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.
Am 25.11.2011 01:16, schrieb Steven D'Aprano: As far as I can tell, nobody running the 64-bit version of Windows 7 has chimed in to either confirm or refute W. eWatson's claim that IDLE doesn't show up, so we have no way of telling whether it doesn't show up due to a lack in the installer, or because eWatson has (slightly) broken his system and has inadvertently prevented it from showing up. I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" and "Edit with PythonWin" in my context menu. I installed Python from the Python.org site, the Windows extensions from Sourceforge, both of them for all users and without any changes to the standard installation or to file associations. This isn't the first Python 3 version on this machine, I don't know if that might be relevant. But it's a fact that changing the applications shown in the context menu for a file association isn't obvious any more on Windows 7. HTH Sibylle -- http://mail.python.org/mailman/listinfo/python-list
Re: What replaces log4py under Python 3.2?
On 22/11/2011 18:32, Rob Richardson wrote: My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? How about the core logging package included in Python itself? cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Return of an old friend
On 25/11/2011 10:13, Noah Hall wrote: On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: I haven't heard of you before, but feel like I've missed out on something. Do you (or someone else) care to link to some of your more contentious work? Ignore him, he's a troll with an unjustly inflated ego. He has previously posted under the name "rantingrick". In brief, his posts have been about how Python is doomed unless it's rescued from the elite who are ignoring the needs of the silent majority by not fixing this or that, and he offers himself as the one who'll lead the Python community into the promised land, or something like that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python Interpreter as a Reference
On Nov 21, 5:46 am, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > > Can anyone list a good introduction to the files found in the source > code? I have been poking around the source code for a little bit and > there is a lot there. So, I was hoping someone could point me to the > "good parts". I am also wondering whether some of the code was > generated because I see state transition tables, which I doubt someone > built by hand. > > Any help would be greatly appreciated. It will be cool to see how the > interpreter works internally. I am still wonder whether designing the > language (going on 4 months now) will be harder than implementing it. > > Thanks, > Travis Parks - compiled language - indentation based - functional programming features Looks like a description of Haskell. You may want to look there. Back end: LLVM is gaining a lot of traction these days. Seems to give best of both worlds -- compiling to C and to machine code -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
In article <581dab49-e6b0-4fea-915c-4a41fa887...@p7g2000pre.googlegroups.com>, rusi wrote: > First you must figure out how to structure data -- jargon is > normalization. After that you can look at transactions, ACID, > distribution and all the other good stuff. And when you're all done with that, you can start unlearning everything you've learned about normalization (not that you shouldn't learn about it in the first place, just that you should also learn when excessive normalization is a bad thing). And then start looking at BASE (Basic Availability, Soft-state, Eventually consistent) as an alternative to ACID. Don't get me wrong. SQL is a powerful tool, and truly revolutionized the database world. Anybody who is thinking about going into databases as a career needs to know SQL. But, it's not the end of the road. There is life after SQL, and that's worth exploring too. -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
On Nov 14, 3:41 pm, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management > Idea: create a simple, 1 window program that show me a db of movies i've > seen with few (<10) fields (actors, name, year etc) > technologies i'll use: python + gtk > db: that's the question > > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) > > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? > Thank you all > > MedeoTL > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) To learn DBMS you need to learn sql [Note sql is necessary but not sufficient for learning DBMS] I recommend lightweight approaches to start with -- others have mentioned access, libreoffice-base. One more lightweight playpen is firefox plugin sqlite-manager > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) Correct. First you must figure out how to structure data -- jargon is normalization. After that you can look at transactions, ACID, distribution and all the other good stuff. -- http://mail.python.org/mailman/listinfo/python-list
Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.
On Nov 24, 10:49 pm, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:16:06 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > I guess I will put in my 2 cents. I installed EPD from Enthought on 64 bit Win 7 Enterprise. Both 32 bit and 64 versions resulted in having "Edit with Idle" when I right-click on a file. I don't have system administration privileges on this machine so I have no idea how the installer did it. Cheers, Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get path to Python standard library directory?
You can try PYLIB = $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()') (or pack the long command line in a script). -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
On Sat, Nov 26, 2011 at 2:44 AM, HoneyMonster wrote: > Just for information, PostgreSQL works very well indeed with Psycopg (a > PostgreSQL adapter for Python), but for learning purposes straightforward > PSQL is best to start with. Thanks for that. I've used PgSQL from C++ (using libpqxx), PHP, Pike, and the command line, but not from Python. (Yeah, a lot of Ps in that.) Once you start looking to write actual code, Python will be an excellent choice. But master the basics of database/schema/table/column, primary keys, etc, etc, etc, first. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
On Mon, 14 Nov 2011 21:55:43 +1100, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 9:41 PM, Tracubik wrote: >> Hi all, >> i'm developing a new program. >> Mission: learn a bit of database management > > If your goal is to learn about databasing, then I strongly recommend a > real database engine. > >> since i'm mostly a new-bye for as regard databases, my idea is to use >> sqlite at the beginning. >> >> Is that ok? any other db to start with? (pls don't say mysql or >> similar, >> they are too complex and i'll use this in a second step) > > The complexity, in most cases, is a direct consequence of the job at > hand. I recommend PostgreSQL generally, although I've never used it with > Python and can't speak for the quality of the APIs. > > The most important thing to consider is a separation of the back end > (the "guts") from the front end (the "interface"). Since your goal is to > explore databases, the guts of your code will basically just be working > with the database (no heavy computation or anything). Make sure you can > work with that, separately from your GUI. You may find it easier to > dispense with GTK and just work through the console; you can always > change later to make a pretty window. > > If you've never worked with databases before, it may be best to skip > Python altogether and explore the fundamentals of relational database > engines. There's plenty of excellent tutorials on the web. Get to know > how things are done generally, and you'll be able to figure out how > things are done in Python. I agree that given "Mission: learn a bit of database management", Python is not really relevant at this stage. I also entirely concur with your recommendation of PostgreSQL. Just for information, PostgreSQL works very well indeed with Psycopg (a PostgreSQL adapter for Python), but for learning purposes straightforward PSQL is best to start with. -- http://mail.python.org/mailman/listinfo/python-list
ANN: python-ldap 2.4.5
Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.4 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. Released 2.4.5 2011-11-25 Changes since 2.4.4: Installation: * defines for SASL and SSL in setup.cfg to be more friendly to Python setup tools (easy_install) Lib/ * Fixed typo in ldap.functions._ldap_function_call() which always released ldap._ldap_module_lock instead of local lock * ldap.controls.ppolicy: Fixed decoding the password policy response control Demo/ * Demo script for ldap.controls.ppolicy -- http://mail.python.org/mailman/listinfo/python-list
Re: getting svn tag in version
On 25-11-2011 12:15, Andrea Crotti wrote: > Given a project with many eggs, I would like to make it easy to have all the > version > numbers synchronized > to the upper level SVN version. > > So for example I might have svn tags > 0.1, > 0.2 > and a development version. > The development version should get version -dev, and the others 0.1 and 0.2 > > I found few examples around that read and parse the .svn/entries file, is it > really > the best way to do it? I wouldn't do that, you'll be dependent on the svn implementation. For instance, in svn 1.7, they changed the .svn folder. Easiest is probably parsing the output of the command line svn: svn info --xml Irmen -- http://mail.python.org/mailman/listinfo/python-list
suppressing bad characters in output PCDATA (converting JSON to XML)
I'm converting JSON data to XML using the standard library's json and xml.dom.minidom modules. I get the input this way: input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') big_json = json.load(input_source) input_source.close() Then I recurse through the contents of big_json to build an instance of xml.dom.minidom.Document (the recursion includes some code to rewrite dict keys as valid element names if necessary), and I save the document: xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') doc.writexml(xml_file, encoding='UTF-8') xml_file.close() I thought this would force all the output to be valid, but xmlstarlet gives some errors like these on a few documents: PCDATA invalid Char value 7 PCDATA invalid Char value 31 I guess I need to process each piece of PCDATA to clean out the control characters before creating the text node: text = doc.createTextNode(j) root.appendChild(text) What's the best way to do that, bearing in mind that there can be multibyte characters in the strings? I found some suggestions on the WWW involving filter with string.printable, which AFAICT isn't unicode-friendly --- is there a unicode.printable or something like that? -- "Mrs CJ and I avoid clichés like the plague." -- http://mail.python.org/mailman/listinfo/python-list
Re: How to change the file creation timestamp?
import os import time from stat import * #returns a list of all the files on the current directory files = os.listdir('.') for f in files: #my folder has some jpegs and raw images if f.lower().endswith('jpg') or f.lower().endswith('crw'): st = os.stat(f) atime = st[ST_ATIME] #access time mtime = st[ST_MTIME] #modification time new_mtime = mtime + (4*3600) #new modification time #modify the file timestamp os.utime(f,(atime,new_mtime)) On Fri, Nov 25, 2011 at 11:47 PM, 刘振海 <1989l...@gmail.com> wrote: > Hi, > I want to change the file creation timestamp using python, but I can not > find a solution to do it. > I know the way to change the file creation timestamp in C under Windows, but > I want to change it using python. > I really need help! > > Regards, > Liu Zhenhai > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic import of submodules
Massi wrote: Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. Hi, Try something like (*untested code*) plugins = {} classes = {} for plugin, className in [('wav_plug', 'WavPlug'), ('mp3_plug', 'Mp3Plug')]: plugins[plugin] = __import__(os.path.join('plugins', plugin, className)) classes[className] = getattr(plugins[plugin], className) # raise a keyError if the plugin has not been imported wav = classes['wav_plug']() Make sure all subdirs have the __init__.py file, including the plugins directory. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get path to Python standard library directory?
On Fri, Nov 25, 2011 at 6:24 AM, user wrote: > In a Makefile (or sometimes inside python) I need the path to the root of > the Python standard lib folder used by "env python". > > e.g. /usr/lib/python2.6/ or C:\Python27\Lib\ > > what is the best/canonical way to get that? This should get you what you're looking for. Just look relative to a known stdlib module. import os stdlib_dir = os.path.dirname(os.__file__) > -- > http://mail.python.org/mailman/listinfo/python-list > -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic import of submodules
On 11/25/2011 08:00 AM, Massi wrote: Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. I think the key to the problem is the __import__() function, which takes a string and returns a module object. So you make a list of the fully qualified module names (filenames less the extension), and loop through that list, Then for each one, you can extract items from the module. It doesn't make sense to define the class names at your top-level, though, since you'd not have any code to reference any new plugin if it has a unique class name. So at some point, you're probably going to have a list or map of such class objects. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get path to Python standard library directory?
On 11/25/2011 06:24 AM, user wrote: In a Makefile (or sometimes inside python) I need the path to the root of the Python standard lib folder used by "env python". e.g. /usr/lib/python2.6/ orC:\Python27\Lib\ what is the best/canonical way to get that? You could look at sys.executable. However, on my Linux, it's a symlink, so you have to dereference that to get the directory involved. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Automatic import of submodules
Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
How to change the file creation timestamp?
Hi, I want to change the file creation timestamp using python, but I can not find a solution to do it. I know the way to change the file creation timestamp in C under Windows, but I want to change it using python. I really need help! Regards, Liu Zhenhai -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
On 25/11/2011 10:37, Ulrich Eckhardt wrote: Am 25.11.2011 04:49, schrieb alex23: On Nov 24, 6:51 pm, Tim Golden wrote: The Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D on Linux). With ActivePython, Ctrl-D works as well, which is a godsend as I'm constantly working across Windows& linux. In short - on Windows, within one cmd shell you can open and exit the interpreter as many times as you like and the Python command history will be retained via the cmd shell's history mechanism, and kept distinct from the history of other things you may type into the cmd shell. And again, I'm definitely not seeing this. Inside the one cmd shell, each instance of Python has no recollection of the history of the last. I'm seeing history browsing in Python on MS Windows XP here and it also works for every other commandline-based program. Well, it seems with the exception of the ActivePython distribution of Python. That one intentionally changes the MS Windows defaults like Control-Z behaviour and at the same time, maybe even as a side effect, it breaks the shell's history browsing. Except that, intriguingly, I'm also using an ActiveState distro and it neither adds Ctrl-D nor prevents history. But I'm fairly sure that pyreadline does both of those things. TJG -- http://mail.python.org/mailman/listinfo/python-list
How to get path to Python standard library directory?
In a Makefile (or sometimes inside python) I need the path to the root of the Python standard lib folder used by "env python". e.g. /usr/lib/python2.6/ orC:\Python27\Lib\ what is the best/canonical way to get that? -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
Am 25.11.2011 04:49, schrieb alex23: On Nov 24, 6:51 pm, Tim Golden wrote: The Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D on Linux). With ActivePython, Ctrl-D works as well, which is a godsend as I'm constantly working across Windows& linux. In short - on Windows, within one cmd shell you can open and exit the interpreter as many times as you like and the Python command history will be retained via the cmd shell's history mechanism, and kept distinct from the history of other things you may type into the cmd shell. And again, I'm definitely not seeing this. Inside the one cmd shell, each instance of Python has no recollection of the history of the last. I'm seeing history browsing in Python on MS Windows XP here and it also works for every other commandline-based program. Well, it seems with the exception of the ActivePython distribution of Python. That one intentionally changes the MS Windows defaults like Control-Z behaviour and at the same time, maybe even as a side effect, it breaks the shell's history browsing. You don't happen to have an installation of the vanilla Python distribution to test, do you? This is getting me curious... Uli -- http://mail.python.org/mailman/listinfo/python-list
getting svn tag in version
Given a project with many eggs, I would like to make it easy to have all the version numbers synchronized to the upper level SVN version. So for example I might have svn tags 0.1, 0.2 and a development version. The development version should get version -dev, and the others 0.1 and 0.2 I found few examples around that read and parse the .svn/entries file, is it really the best way to do it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python Interpreter as a Reference
On Fri, Nov 25, 2011 at 9:55 PM, Travis Parks wrote: > I have been thinking about compiling into a > language like C++ or C instead of assembler for my first time through. Yep, or any other language you feel like using as an intermediate. Or alternatively, just start with an interpreter - whatever's easiest. Compiling to C gives you a massive leg-up on portability; so does writing an interpreter in C, as either way your language is easily made available on every platform that gcc's been ported to. As long as you're happy with the idea of building a massively language that'll never be used by anybody but yourself, you can have immense fun with this. And hey, Unit might turn out to be a beautiful niche language, or even go mainstream. But mainly, you'll have fun doing it. And if you're not having fun, what's the use of living forever? (Oh wait, you're not a vampire from Innistrad. Sorry about that.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python Interpreter as a Reference
On Nov 22, 1:37 pm, Alan Meyer wrote: > On 11/20/2011 7:46 PM, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. ... > > I have great respect for people who take on projects like this. > > Your chances of popularizing the language are small. There must be > thousands of projects like this for every one that gets adopted by other > people. However your chances of learning a great deal are large, > including many things that you'll be able to apply to programs and > projects that, at first glance, wouldn't appear to benefit from this > kind of experience. If you get it working you'll have an impressive > item to add to your resume. > > I suspect that you'll also have a lot of fun. > > Good luck with it. > > Alan I've been learning a lot and having tons of fun just designing the language. First, I get think about all of the language features that I find useful. Then I get to learn a little bit how they work internally. For instance, functions are first-class citizens in Unit, supporting closures. To make that happen meant wrapping such functions inside of types and silently elavating local variables to reference counted pointers. Or, I realized that in order to support default arguments, I would have to silently wrap parameters in types that were either set or not set. That way calls to the default command could simply be replaced by an if statement. It was a really subtle implementation detail. It is also fun thinking about what makes sense. For instance, Unit will support calling methods with named arguments. Originally, I thought about using the '=' operator: Foo(name="bob" age=64) but, then I realized that the equals sign could be confused with assignment. Those types of syntactic conflicts occur quite often and lead to a lot of rethinking. Ultimately, somewhat good ideas get replaced with much better ideas. I had been contemplating Unit for months before the final look and feel of the language came into view. It isn't what I started out imagining, but I think it turned out better than I had originally planned. Recently, I rethought how functions looked, since the headers were too long: alias Predicate = function (value: & readonly T) throws() returns(Boolean) let Any = public function (values: & readonly IIterable) (?predicate: Predicate) throws() # ArgumentNullException inherits from UncheckedException returns(Boolean): # this can be on one line default predicate = (function value: true) assert predicate != null "The predicate cannot be null." ArgumentNullException for value in values: if predicate(value): return true return false Most of the time, throws clauses, returns clauses and parameter type constraints can be left off. Plus, now they can all appear on one line. Assertions and default statements now appear in the body. Assertions now optionally take a message and the exception type to throw. So, yeah, this has been an awesome project so far. I have dozens of documents and I have been keeping up on a blog. I've even started implementing a simple recursive descent parser just to make sure the syntax doesn't conflict. Now it will be a matter of formally defining a grammer and implementing the backend of the compiler... which I've never done before. I have been thinking about compiling into a language like C++ or C instead of assembler for my first time through. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange result ffor object to bool
On Fri, Nov 25, 2011 at 9:09 PM, ZhouPeng wrote: > Thanks all. > if not obj: (in python) and if (!obj) {(in c/c++) > > / if obj: (in python) and if (obj) {(in c/c++) > > Yea, you are right. > And I got it later, when I run my program in python 2.7.2, > It complains: > FutureWarning: The behavior of this method will change in future versions. > Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: Yep, this is exactly what you need to do. Check if 'elem is None' to see if it's there or not. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Return of an old friend
On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: > I haven't heard of you before, but feel like I've missed out on something. > > Do you (or someone else) care to link to some of your more contentious work? Ignore him, he's a troll with an unjustly inflated ego. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange result ffor object to bool
Thanks all. I am a c/c++ programer before, So I directly think it is the same roughly between if not obj: (in python) and if (!obj) {(in c/c++) / if obj: (in python) and if (obj) {(in c/c++) That if obj is not None, 'if obj:' goes true branch, 'if not obj:' goes false branch, and I don't need to care where the obj is from (what type or what lib) But, Now it seem not be consistent, so I feel strange. And it seem be obj's library related in python. On Fri, Nov 25, 2011 at 4:59 PM, Peter Otten <__pete...@web.de> wrote: >What is a listen element? It is not a standard Python object. What >library is it from? from xml.etree.ElementTree On Fri, Nov 25, 2011 at 5:06 PM, Peter Otten <__pete...@web.de> wrote: > ZhouPeng wrote: > >> In my program, I get a listen element by >> listen = graphics.find("listen") >> >> print listen is >> print type listen is >> I am sure listen is not None and can be accessed properly. >> >> But print bool(listen) is False >> if not listen is True > > bool(listen) is False here means that the Element has no children. > Quoting > http://effbot.org/zone/elementtree-13-intro.htm#truth-testing Thanks, > """ > Truth testing # > The Element type now issues a warning when used in a “boolean context”. To > get rid of the warning, make the test explicit: > if len(elem): > ... has at least one children ... > > elem = root.find("tag") > if elem is not None: > ... found ... > Explicit tests work just fine in ET 1.2, of course. > The boolean interpretation will most likely change in future versions, so > that all elements evaluate to true, also if they have no children. > """ Yea, you are right. And I got it later, when I run my program in python 2.7.2, It complains: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Zhou Peng -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange result ffor object to bool
ZhouPeng wrote: > In my program, I get a listen element by > listen = graphics.find("listen") > > print listen is > print type listen is > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen is True bool(listen) is False here means that the Element has no children. Quoting http://effbot.org/zone/elementtree-13-intro.htm#truth-testing """ Truth testing # The Element type now issues a warning when used in a “boolean context”. To get rid of the warning, make the test explicit: if len(elem): ... has at least one children ... elem = root.find("tag") if elem is not None: ... found ... Explicit tests work just fine in ET 1.2, of course. The boolean interpretation will most likely change in future versions, so that all elements evaluate to true, also if they have no children. """ -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange result ffor object to bool
On Fri, 25 Nov 2011 14:52:25 +0800, ZhouPeng wrote: > Hi all, > > In my program, I get a listen element by listen = > graphics.find("listen") What is a listen element? It is not a standard Python object. What library is it from? > print listen is print type listen is 'instance'> I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False What makes you think this is a strange result? Many things are false: py> for obj in (None, [], {}, 0, 0.0, "", 42): ... print bool(obj), ... False False False False False False True -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
On 25/11/2011 03:47, alex23 wrote: Tim Golden wrote: The interpreter inherits the command shell's history function: Open a cmd window and then a Python session. Do some stuff. Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: dir, cd, etc. Start a second Python session. up-arrow etc. will bring back the previous Python session's commands (and not the ones you entered in the surrounding shell) This isn't true, at least not for ActivePython 2.7.2.5 under Windows 7-64. The second session has no history whatsoever. Well I don't know what to say. It works for me with an almost identical setup. (ActivePython 2.7.1.4 Win7 x64). And has worked for me over countless setups on different machines / versions of Windows / versions of Python etc. Do you have the pyreadline module installed? ISTR that that takes over from the standard cmd processing... TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange result ffor object to bool
On Fri, Nov 25, 2011 at 5:52 PM, ZhouPeng wrote: > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen is True Casting something to boolean follows strict rules derived from the notion that emptiness is false and nonemptiness is true. For instance: >>> bool(""),bool([]),bool({}),bool(0) (False, False, False, False) Details here: http://docs.python.org/library/stdtypes.html Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
MailingLogger 3.6.0 Released!
I'm pleased to announce a new release of Mailinglogger. Mailinglogger provides two handlers for the standard python logging framework that enable log entries to be emailed either as the entries are logged or as a summary at the end of the running process. The handlers have the following features: - customisable and dynamic subject lines for emails sent - emails sent with a configurable headers for easy filtering - flood protection to ensure the number of emails sent is not excessive - support for SMTP servers that require authentication - fully documented and tested The only change for this release is to allow summaries sent by SummarisingLogger to contain messages logged at a lower level than those which triggered the summary to be emailed. Full docs can be found here: http://packages.python.org/mailinglogger/ For more information, please see: http://www.simplistix.co.uk/software/python/mailinglogger or http://pypi.python.org/pypi/mailinglogger cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.
On Fri, Nov 25, 2011 at 3:49 PM, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:04:04 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > >> My Linux system includes compilers or interpreters for C, Pascal, >> Haskell, Forth, Python, Ruby, PHP, Javascript, Java, bash, csh, zsh, sh, >> awk, sed, Perl, SQL, Tcl, Tk, OpenXion, and very likely others. Most of > > What? No REXX? > > {Granted, other than IBM's mainframes, the only decent REXX > implementation [heck, maybe even better] was the Amiga version -- it was > integrated well into the Amiga message passing IPC system, such that > pretty much any application with an ARexx port could connect to and > control any other application with an ARexx port} IBM's non-mainframes too - their OS/2 implementation was - and still is - awesome. I use REXX for a variety of odds and ends, everything from simple scripts up to full-on GUI applications. Yes, we still use OS/2 (as well as Windows and Linux - mixed LANs are fun). ChrisA -- http://mail.python.org/mailman/listinfo/python-list