Re: import dll instead of pyd
Yes it is in the same directory. The problem is it does not seem to look for dll's at all. So is this by design, or am I missing something? On 25 Juli, 10:03, Nick Dumas <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Is this DLL in the same directory as your script? If not, is it part of > your pythonpath? If neither are true, then you won't be able to import > it, regardless of whether it's a good file or not. > > > > jrh wrote: > > Hello, > > > From previous posts and documentation it seems python should be able > > to import a module that is compiled into a .dll just as well as > > a .pyd. I have a pyd that works fine, but after renaming it to dll the > > import fails. Running python with -vv flag indicates it doesn't > > actually look for the dll (see below). Has dll import been defeatured > > in python? > > > Thanks! > > import _mydllpythonmodule > > # trying _mydllpythonmodule.pyd > > # trying _mydllpythonmodule.py > > # trying _mydllpythonmodule.pyw > > # trying _mydllpythonmodule.pyc > > # trying C:\Python25\DLLs\_mydllpythonmodule.pyd > > # trying C:\Python25\DLLs\_mydllpythonmodule.py > > # trying C:\Python25\DLLs\_mydllpythonmodule.pyw > > # trying C:\Python25\DLLs\_mydllpythonmodule.pyc > > # trying C:\Python25\lib\_mydllpythonmodule.pyd > > # trying C:\Python25\lib\_mydllpythonmodule.py > > # trying C:\Python25\lib\_mydllpythonmodule.pyw > > # trying C:\Python25\lib\_mydllpythonmodule.pyc > > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyd > > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.py > > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyw > > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyc > > # trying C:\Python25\_mydllpythonmodule.pyd > > # trying C:\Python25\_mydllpythonmodule.py > > # trying C:\Python25\_mydllpythonmodule.pyw > > # trying C:\Python25\_mydllpythonmodule.pyc > > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyd > > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.py > > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyw > > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyc > > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyd > > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.py > > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyw > > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyc > > # trying C:\Python25\lib\site-packages\win32\lib > > \_mydllpythonmodule.pyd > > # trying C:\Python25\lib\site-packages\win32\lib\_mydllpythonmodule.py > > # trying C:\Python25\lib\site-packages\win32\lib > > \_mydllpythonmodule.pyw > > # trying C:\Python25\lib\site-packages\win32\lib > > \_mydllpythonmodule.pyc > > # trying C:\Python25\lib\site-packages\Pythonwin > > \_mydllpythonmodule.pyd > > # trying C:\Python25\lib\site-packages\Pythonwin\_mydllpythonmodule.py > > # trying C:\Python25\lib\site-packages\Pythonwin > > \_mydllpythonmodule.pyw > > # trying C:\Python25\lib\site-packages\Pythonwin > > \_mydllpythonmodule.pyc > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: No module named _mydllpythonmodule > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org > > iEYEARECAAYFAkiJNGwACgkQLMI5fndAv9hykgCcDf4cTZU0iDo+ELQ5aFGs9FIO > 8GEAn3+egrPDtNrlbsssqti8YeZXXIeM > =q31k > -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Function editing with Vim throws IndentError
On Thu, Jul 24, 2008 at 9:32 PM, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message > <[EMAIL PROTECTED]>, > Matimus > wrote: > > > On Jul 24, 2:54 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] > > central.gen.new_zealand> wrote: > >> In message > >> <[EMAIL PROTECTED]>, > >> > >> Matimus wrote: > >> > That isn't the standard. With that setup tabs will show up as 4 > >> > spaces, and still confuse you. > >> > >> Why should that be confusing? The most common tab-stop setting is 4 > >> columns. > > > > A tab character is specified as 8 spaces. > > Specified by whom? The most common setting these days is 4 columns. > -- > http://mail.python.org/mailman/listinfo/python-list > A tab-stop has historically been 8 spaces. Most terminals, printers and other devices understand the tab as 8 characters. Smart editors have made it easy to make tabs APPEAR as four spaces, but they are almost universally interpreted elsewhere as 8 characters. http://en.wikipedia.org/wiki/Tab_key -- Stand Fast, tjg. [Timothy Grant] -- http://mail.python.org/mailman/listinfo/python-list
2d graphics - what module to use?
What is the easiest way to draw to a window? I'd like to draw something like sine waves from a mathematical equation. Newbie to python. -- http://mail.python.org/mailman/listinfo/python-list
Questions on 64 bit versions of Python
Background: I'm going to be processing some raw transaction logs that are 30G in size. As part of this processing I may need to create some very large dictionary structures. I will be running my scripts on a version of Windows 2003 Server Enterprise Edition that supports 16G of RAM. Yes, I could use a database in place of dictionaries, but I'm looking for maximum performance. The following page lists two 64 bit versions of Python for Windows: http://www.python.org/download/releases/2.5.2/ For Win64-Itanium users: python-2.5.2.ia64.msi For Win64-AMD64 users: python-2.5.2.amd64.msi 1. It looks like the 64 bit versions of Python for Windows are CPU vendor specific, eg. it doesn't look like there's a single, universal executable for Windows 64 bit platforms. Is this true? 2. Are there limitations to the using the 64 bit versions of Python? I seem to remember reading that many 3rd party modules (especially Windows OS specific modules) may not be compatible with the 64 bit versions of Python for Windows. 3. If I wanted to run a 64 bit version of Python under Linux, would I need to recompile from source on 64 bit version of Linux or do 64 bit versions of Linux automatically ship with 64 bit versions of Python? (Any recommendations on a flavor of 64 bit of Linux for the Intel architecture would be appreciated) 4. Is there a stable version of IronPython compiled under a 64 bit version of .NET? Anyone have experience with such a beast? Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On Jul 24, 5:01 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message > <[EMAIL PROTECTED]>, Jordan > wrote: > > > Except when it comes to Classes. I added some classes to code that had > > previously just been functions, and you know what I did - or rather, > > forgot to do? Put in the 'self'. In front of some of the variable > > accesses, but more noticably, at the start of *every single method > > argument list.* > > The reason is quite simple. Python is not truly an "object-oriented" > language. It's sufficiently close to fool those accustomed to OO ways of > doing things, but it doesn't force you to do things that way. You still > have the choice. An implicit "self" would take away that choice. By that logic, C++ is not OO. By that logic, Ruby is not OO. By that logic, I know of only one OO language: Java :) The fact that a language doesn't force you to do object-oriented programming doesn't mean that it's not object-oriented. In other words, your words are nonsense. Sebastian -- http://mail.python.org/mailman/listinfo/python-list
Re: pci card adjusting
"Oguz Yarimtepe" <[EMAIL PROTECTED]> wrote: > >I need to adjust the dimming property of my video card. There is >currently a written application called nvclock but it is not >supporting my card right now. So i need to implement the requiered >register jobs on the card. This is already done to a degree in C. But >i don't want to dive in to the C code right now. > >I prefer Python so may i implement such a feature by Python? Not easily, at least not without a helper DLL in C. And since the app won't be that large, you might as well just do it in C. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt
You wrote: > How to represent the loop > for ($a = $b; $a<=$c;$a++){ > } in Python As other pointed out, iterating through a list or range is often a far more elegant way to do a loop than a C-style loop. But the C-style for loop is just syntactic sugar for a while loop. In some cases, C-style for loops can have an initializer, a set of conditions, and incrementer parts that are all based on different variables. For example: for (a=begin_func() ; x < 3 and sometest(b) ; i=somefunc() ) This highly illogical and contrived function could not be represented in python with a simple "for x in blah" statement. Rather you have to represent it in its true form, which is a while loop: a=begin_func() while x < 3 and sometest(b): #do stuff #loop body i=somefunc() In fact, the perl/c for loop of the form: for (;;) always translates directly to: while : #loop body -- http://mail.python.org/mailman/listinfo/python-list
Re: Broken examples
norseman <[EMAIL PROTECTED]> wrote: > >I'm only talking about IPC related. >I have googled, yahooed, and so forth for several months now. ALL >examples I've come across have failed including those pertinent in the >Python doc area. > >Outline: > cd somedir > ls -1 *.xls >thislist #ls hyphen one > python process.py > (yes - ls can go here if wanted. easier to edit outside) > open thislist > loop until done > start excel (or scalc) > have it open file > have it save file as a .csv (or .dbf) > close excell (or scalc) > >Would seem to be a trivial exercise. Excel is a COM-driven application. You have to drive it through the object model. import win32com.client excel = win32com.client.Dispatch( 'Excel.Application' ) xlCSV = 6 ... for nm in list_of_file_names: csv = os.path.splitext( nm )[0] + '.csv' wb = excel.Workbooks.Open( nm ) wb.SaveAs( csv, xlCSV ) wb.Close() If you want to watch the progress, add "excel.Visible=1" after the dispatch. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
object persistency, store instances relationship externally
This is a new test for object persistency. I am trying to store the relationship between instances externally. It's not working as expected. May be I am doing it in wrong way. Any suggestions? import shelve class attrib(object): pass class node(object): def __init__(self): self.a = attrib() self.b = attrib() self.c = attrib() self.d = attrib() a = node() #store pair relationship. This relationship is created at run time. lst = [[a.a, a.b], [a.c, a.d]] #Write objects into file shelf = shelve.open('shelve_test_01.txt', writeback=True) shelf['node'] = a shelf['lst'] = lst shelf.sync() shelf.close() #Read objects from file shelf = shelve.open('shelve_test_01.txt', 'r') a = shelf['node'] lst = shelf['lst'] print a.a, a.b, a.c, a.d #lst does not contains the relationship of object 'a''s attributes, instead it's creating new instances #of 'attrib' class print lst -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On 25 Jul., 03:01, Terry Reedy <[EMAIL PROTECTED]> wrote: > Torsten Bronger wrote: > > Hallöchen! > > > And why does this make the implicit insertion of "self" difficult? > > > I could easily write a preprocessor which does it after all. > > class C(): >def f(): > a = 3 > > Inserting self into the arg list is trivial. Mindlessly deciding > correctly whether or not to insert 'self.' before 'a' is impossible when > 'a' could ambiguously be either an attribute of self or a local variable > of f. Or do you and/or Jordan plan to abolish local variables for methods? > > tjr This isn't the problem Jordan tries to address. It's really just about `self` in the argument signature of f, not about its omission in the body. Some problems occur when not `self` shall be used but e.g. `this`. Here one has to specify more: class C(): __self__ = 'this' # use `this` instead of `self` def f(a): this.a = a or class C(): def f($this, a):# use `this` instead of `self` this.a = a When an $-prefixed parameter is found the automatic insertion of `self` will be blocked and the $-prefixed parameter name will be used instead but without the prefix. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about inheritence
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Python doesn't really have constructors; when you create an object, > Python first creates the object and then calls the __init__ method, if > available That's the usual meaning of "constructor". It doesn't actually "construct" the object, it really "initializes" it. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.walk question
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lanny wrote: > >> How would one make a list of the files in the top directory >> using os.walk. >> >> I need to pick a random file from said list. > > if you want a list of files from a single directory, use listdir, not > walk: > > >>> import os, random > >>> random.choice(os.listdir("/")) > 'python25' Won't that return any subdirectories as well as files? -- http://mail.python.org/mailman/listinfo/python-list
Re: Broken examples
In message <[EMAIL PROTECTED]>, norseman wrote: > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, norseman >> wrote: >> >>> The OOo examples do not work. >> >> I have done OOo scripting in Python. What exactly does not work? > > soffice "-accept=socket,host=localhost,port=2002;urp;" & > sleep 9 > > ./python ./zhw.py I've never tried that. I've run Python scripts from the "Tools/Macros/Run Macro..." dialog. -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
In message <[EMAIL PROTECTED]>, Jordan wrote: > On Jul 24, 8:01 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] > central.gen.new_zealand> wrote: > >> In message >> <[EMAIL PROTECTED]>, >> Jordan wrote: >> >> > Except when it comes to Classes. I added some classes to code that had >> > previously just been functions, and you know what I did - or rather, >> > forgot to do? Put in the 'self'. In front of some of the variable >> > accesses, but more noticably, at the start of *every single method >> > argument list.* >> >> The reason is quite simple. Python is not truly an "object-oriented" >> language. It's sufficiently close to fool those accustomed to OO ways of >> doing things, but it doesn't force you to do things that way. You still >> have the choice. An implicit "self" would take away that choice. > > You could still explicitly request non-implicit self on a method by > method basis. That would mean making OO the default. Which Python doesn't do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Function editing with Vim throws IndentError
In message <[EMAIL PROTECTED]>, Matimus wrote: > On Jul 24, 2:54 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] > central.gen.new_zealand> wrote: >> In message >> <[EMAIL PROTECTED]>, >> >> Matimus wrote: >> > That isn't the standard. With that setup tabs will show up as 4 >> > spaces, and still confuse you. >> >> Why should that be confusing? The most common tab-stop setting is 4 >> columns. > > A tab character is specified as 8 spaces. Specified by whom? The most common setting these days is 4 columns. -- http://mail.python.org/mailman/listinfo/python-list
Re: interpreter vs. compiled
castironpi <[EMAIL PROTECTED]> wrote: > >Compiling a program is different than running it. A JIT compiler is a >kind of compiler and it makes a compilation step. I am saying that >Python is not a compiler and in order to implement JIT, it would have >to change that fact. And I'm saying you are wrong. There is NOTHING inherent in Python that dictates that it be either compiled or interpreted. That is simply an implementation decision. The CPython implementation happens to interpret. The IronPython implementation compiles the intermediate language to native machine language. >> of Python that uses .NET. In that case, the code *IS* JIT compiled to >> assembly when the program starts. > >But still not the user's code, only the interpreter, which is running >in assembly already anyway in CPython. In CPython, yes. In IronPython, no; the user's code is compiled into machine language. Both of them are "Python". -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
.............................on line jobs........................................
we are selecting you for this online jobs. For more information see this website in this.. we are selecting you for this online jobs. For more information see this website in this.. Details .. Name of the job.Online job.. Nature of work...Like data entry.. Qualification requiredgood knowledge in computer Basics EarningsMore then Rs=1000 per day..Earnings depends on your work. FOR MORE DETAILS: WWW.Bigconstructions5.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
.............................on line jobs........................................
we are selecting you for this online jobs. For more information see this website in this.. we are selecting you for this online jobs. For more information see this website in this.. Details .. Name of the job.Online job.. Nature of work...Like data entry.. Qualification requiredgood knowledge in computer Basics EarningsMore then Rs=1000 per day..Earnings depends on your work. FOR MORE DETAILS: WWW.Bigconstructions5.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
.............................on line jobs........................................
we are selecting you for this online jobs. For more information see this website in this.. we are selecting you for this online jobs. For more information see this website in this.. Details .. Name of the job.Online job.. Nature of work...Like data entry.. Qualification requiredgood knowledge in computer Basics EarningsMore then Rs=1000 per day..Earnings depends on your work. FOR MORE DETAILS: WWW.Bigconstructions5.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On Jul 24, 11:43 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > "explicit-is-etc" - just like the remaining of Python's zen - is a > general philosophy statement, not an absolute rule. Another quote states > that practicality beats purity. Very much so. In fact, I'd like you all to take a detour to a recent bug report [1] where I gained some interesting insight into the Zen. [1] http://bugs.python.org/issue3364 -- http://mail.python.org/mailman/listinfo/python-list
Re: Your message to CMake awaits moderator approval
On Thu, 24 Jul 2008 18:43:34 -0400, cmake-bounces wrote: > Your mail to 'CMake' with the subject > > Status > > Is being held until the list moderator can review it for approval. > > The reason it is being held: > > Post by non-member to a members-only list > > Either the message will get posted to the list, or you will receive > notification of the moderator's decision. If you would like to cancel > this posting, please visit the following URL: > > Should this be showing up in a usenet group? -- http://mail.python.org/mailman/listinfo/python-list
Re: import dll instead of pyd
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Is this DLL in the same directory as your script? If not, is it part of your pythonpath? If neither are true, then you won't be able to import it, regardless of whether it's a good file or not. jrh wrote: > Hello, > > From previous posts and documentation it seems python should be able > to import a module that is compiled into a .dll just as well as > a .pyd. I have a pyd that works fine, but after renaming it to dll the > import fails. Running python with -vv flag indicates it doesn't > actually look for the dll (see below). Has dll import been defeatured > in python? > > Thanks! > import _mydllpythonmodule > # trying _mydllpythonmodule.pyd > # trying _mydllpythonmodule.py > # trying _mydllpythonmodule.pyw > # trying _mydllpythonmodule.pyc > # trying C:\Python25\DLLs\_mydllpythonmodule.pyd > # trying C:\Python25\DLLs\_mydllpythonmodule.py > # trying C:\Python25\DLLs\_mydllpythonmodule.pyw > # trying C:\Python25\DLLs\_mydllpythonmodule.pyc > # trying C:\Python25\lib\_mydllpythonmodule.pyd > # trying C:\Python25\lib\_mydllpythonmodule.py > # trying C:\Python25\lib\_mydllpythonmodule.pyw > # trying C:\Python25\lib\_mydllpythonmodule.pyc > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyd > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.py > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyw > # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyc > # trying C:\Python25\_mydllpythonmodule.pyd > # trying C:\Python25\_mydllpythonmodule.py > # trying C:\Python25\_mydllpythonmodule.pyw > # trying C:\Python25\_mydllpythonmodule.pyc > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyd > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.py > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyw > # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyc > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyd > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.py > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyw > # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyc > # trying C:\Python25\lib\site-packages\win32\lib > \_mydllpythonmodule.pyd > # trying C:\Python25\lib\site-packages\win32\lib\_mydllpythonmodule.py > # trying C:\Python25\lib\site-packages\win32\lib > \_mydllpythonmodule.pyw > # trying C:\Python25\lib\site-packages\win32\lib > \_mydllpythonmodule.pyc > # trying C:\Python25\lib\site-packages\Pythonwin > \_mydllpythonmodule.pyd > # trying C:\Python25\lib\site-packages\Pythonwin\_mydllpythonmodule.py > # trying C:\Python25\lib\site-packages\Pythonwin > \_mydllpythonmodule.pyw > # trying C:\Python25\lib\site-packages\Pythonwin > \_mydllpythonmodule.pyc > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named _mydllpythonmodule -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkiJNGwACgkQLMI5fndAv9hykgCcDf4cTZU0iDo+ELQ5aFGs9FIO 8GEAn3+egrPDtNrlbsssqti8YeZXXIeM =q31k -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
import dll instead of pyd
Hello, >From previous posts and documentation it seems python should be able to import a module that is compiled into a .dll just as well as a .pyd. I have a pyd that works fine, but after renaming it to dll the import fails. Running python with -vv flag indicates it doesn't actually look for the dll (see below). Has dll import been defeatured in python? Thanks! >>> import _mydllpythonmodule # trying _mydllpythonmodule.pyd # trying _mydllpythonmodule.py # trying _mydllpythonmodule.pyw # trying _mydllpythonmodule.pyc # trying C:\Python25\DLLs\_mydllpythonmodule.pyd # trying C:\Python25\DLLs\_mydllpythonmodule.py # trying C:\Python25\DLLs\_mydllpythonmodule.pyw # trying C:\Python25\DLLs\_mydllpythonmodule.pyc # trying C:\Python25\lib\_mydllpythonmodule.pyd # trying C:\Python25\lib\_mydllpythonmodule.py # trying C:\Python25\lib\_mydllpythonmodule.pyw # trying C:\Python25\lib\_mydllpythonmodule.pyc # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyd # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.py # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyw # trying C:\Python25\lib\lib-tk\_mydllpythonmodule.pyc # trying C:\Python25\_mydllpythonmodule.pyd # trying C:\Python25\_mydllpythonmodule.py # trying C:\Python25\_mydllpythonmodule.pyw # trying C:\Python25\_mydllpythonmodule.pyc # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyd # trying C:\Python25\lib\site-packages\_mydllpythonmodule.py # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyw # trying C:\Python25\lib\site-packages\_mydllpythonmodule.pyc # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyd # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.py # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyw # trying C:\Python25\lib\site-packages\win32\_mydllpythonmodule.pyc # trying C:\Python25\lib\site-packages\win32\lib \_mydllpythonmodule.pyd # trying C:\Python25\lib\site-packages\win32\lib\_mydllpythonmodule.py # trying C:\Python25\lib\site-packages\win32\lib \_mydllpythonmodule.pyw # trying C:\Python25\lib\site-packages\win32\lib \_mydllpythonmodule.pyc # trying C:\Python25\lib\site-packages\Pythonwin \_mydllpythonmodule.pyd # trying C:\Python25\lib\site-packages\Pythonwin\_mydllpythonmodule.py # trying C:\Python25\lib\site-packages\Pythonwin \_mydllpythonmodule.pyw # trying C:\Python25\lib\site-packages\Pythonwin \_mydllpythonmodule.pyc Traceback (most recent call last): File "", line 1, in ImportError: No module named _mydllpythonmodule >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a metacharacter to match transitions between any two of a set of non intersected char classes?
On Jul 24, 6:48 pm, Peng Yu <[EMAIL PROTECTED]> wrote: > Hi, > > '\b' only match the boundary between alphanumerical char and > nonalphanumerical char. I'm wonder if there is a generic metacharacter > to match the boundary between any non intersected char set defined in > regex and its complement. > > For example, I have a few non intersected char sets [a-zA-Z_0-9], [:] > and [\s], and lets call the new metacharactor \m. > > r"abc\m" would be the same as r"abc\b" > r"abc:\m' would match "abc:" in r"abc:xy" but not "abc::xy" > r"a \m" (with one space) would match "a " (with one space) in "a abc" > but not "a abc" (with two spaces). > > I would like that I have the flexibility to define more non > intersected char sets, while I don't want change the regex that I have > written. > Interesting idea. It could be added, but how much demand is there for it? -- http://mail.python.org/mailman/listinfo/python-list
Re: file operations.
aditya shukla wrote: Guys thanks for your previous help .I have a doubt again My text file is :- 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll ... now this is what happens >>> x=open("c:\\test2.txt","rb") >>> x.readline() '\n' ---? i am not able to understand why is new line character returned here Either because your text file starts with a blank line or because .readline does not work when you open in binary mode. In any case, you should probably change 'rb' to 'r'. >>> l =x.readline() >>> print l Also , because of this i am not able to extract the floating point values ie 0.50,0.50,0.66 respectively cause when i use the proposed solution given earlier data=[] for line in x: line=line.split("|") data.append(float(line[-2])) --> i am trying to get the floating point values from the back i receive this error message Traceback (most recent call last): File "", line 3, in d.append(float(line[-2])) IndexError: list index out of range If you have a blank line, splitting returns a list of length 0 or 1, so there is no -2 element. Add something like if len(line) < 2: raise SomeError(message) after the split. If you should always have 3 parts, check '==3' and index to line[1]. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding for Devanagari Script.
Atul. wrote: Hello All, I wanted to know what encoding should I use to open the files with Devanagari characters. I was thinking of UTF-8 but was not sure, any leads on this? Anyone used it earlier? You cannot hurt your machine by giving that a try. This is a general comment for all beginners. Before posting, open the interactive interpreter (or IDLE) and try something(s). If the result puzzles you, copy and paste into a post. Or if more appropriate, open the Python manuals and search a bit, or try a search engine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Jordan wrote: I wish in retrospect I'd had the time, patience and focus to edit the initial post to make it more measured and less inflammatory, because its clear the tone I will ignore that. > detracts from the argument I'm making, which I feel still stands. class C(): def f(): a = 3 You made a complaint and an incomplete proposal identical to what others have proposed. But here is where the idea always sinks. Suppose as you propose 'self' is added to the arg list. How is a mindless algorithm to decide whether to change a to 'self.a' to make it an attribute or leave it alone as a local variable? Or would you abolish local vars from methods (which would slow them down)? As near as I can see, any concrete detailed implementable proposal would be a more major change in Python or its implementation than 'down-with-self'ers usually admit. If the argument you refer to is instead that 'Explicit is better than Implicit' is a bit overused and inadequate as a technical response, then I agree. But excuse me for being unsure ;-). Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Torsten Bronger wrote: Hallöchen! > And why does this make the implicit insertion of "self" difficult? I could easily write a preprocessor which does it after all. class C(): def f(): a = 3 Inserting self into the arg list is trivial. Mindlessly deciding correctly whether or not to insert 'self.' before 'a' is impossible when 'a' could ambiguously be either an attribute of self or a local variable of f. Or do you and/or Jordan plan to abolish local variables for methods? tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: curses problem
On Thu, 24 Jul 2008 21:28:24 +0200, Dariusz Malec wrote: > forgot to post the code. Server does not allow to post attachments. The > code is here http://www.kos.wsiz.rzeszow.pl/~dmalec/src.zip You might google about SIGWINCH and see where that gets you. Of course, to my great disappointment, python programs that use signals become quite a bit more complex than they should because you have to restart interrupted system calls explicitly. Please, someone fix this! IMO, python functions and methods that could be be interrupted by a signal should restart themselves by default, and have an option to allow them to require themselves to be interrupted. Many Kernel programmers have negative perspectives on application programmers who don't bother this; python seems to have a significant culture of ignoring the issue. This makes me sad. I love python. I want it to do better. -- http://mail.python.org/mailman/listinfo/python-list
Re: repr(string)
On Jul 23, 4:04 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > I've been saving data in a file with one line per field. > Now some of the fields may become multi-line strings... > > I was about to start escaping and unescaping linefeeds > by hand, when I realized that repr() and eval() should > do. Hence the question: If s is a string, is repr(s) > guaranteed not to contain line breaks? > Might I suggest you use encode and decode instead? >>> 'first line\nsecond line'.encode('string-escape') 'first line\\nsecond line' >>> _.decode('string-escape') 'first line\nsecond line' >>> u'first line\nsecond line'.encode('unicode-escape') 'first line\\nsecond line' >>> _.decode('unicode-escape') u'first line\nsecond line' -- http://mail.python.org/mailman/listinfo/python-list
Re: Confounded by Python objects
On Jul 24, 6:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jul 24, 11:59 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > tip: if you're not 100% sure why you would want to put an attribute > > on the class level, don't do it. > > The reason I did it was sort of C++ish (that's where I come from): I > somehow wanted a list of attributes on the class level. More for > readibility than anything elase, really. > > > hope this helps! > > Yup, did the trick. Thanks! > robert yes, i thought your code is kind of static, so it didn't work for a dynamic language like python. in python, you don't have to say "static" to make an variable a class variable, so the "name" and "sample" you kind of "declared" is indeed class variables. you may wonder why then the two instaces of "Channel" has different names, that's because you assign to name in "__init__" and make it an instance variable that shared the name "name" with a class variable. As to "sample", it never get assigned to and when you say "append" the class variable is changed in place. hope my explaination helps. -- http://mail.python.org/mailman/listinfo/python-list
File operations.
Guys i just understood the problem.Thanks for all your help Aditya -- http://mail.python.org/mailman/listinfo/python-list
Your message to CMake awaits moderator approval
Your mail to 'CMake' with the subject Status Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. If you would like to cancel this posting, please visit the following URL: http://www.cmake.org/mailman/confirm/cmake/42b7f3960ed3942796005bcc10ef862779cd7985 -- http://mail.python.org/mailman/listinfo/python-list
file operations.
Guys thanks for your previous help .I have a doubt again My text file is :- 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll 0\9\10\11|0.50|c:\windows\apppatch/AcRedir.dll 0\9\10|0.66|c:\windows\apppatch/AcSpecfc.dll 0\9|0.83|c:\windows\apppatch/iebrshim.dll 0|0.92|c:\windows\apppatch/pcamain.sdb 0|0.92|c:\windows\apppatch/sysmain.sdb 0|0.93|c:\windows\apppatch/AcXtrnal.dll 0|0.97|c:\windows\apppatch/msimain.sdb 0|0.98|c:\windows\apppatch/AcRes.dll 0|0.98|c:\windows\apppatch/drvmain.sdb 0|0.98|c:\windows\apppatch/en-US/AcRes.dll.mui 0|0.99|c:\windows\apppatch/apihex86.dll 0|1.00|c:\windows\apppatch/AcGenral.dll now this is what happens >>> x=open("c:\\test2.txt","rb") >>> x.readline() '\n' ---? i am not able to understand why is new line character returned here >>> l =x.readline() >>> print l Also , because of this i am not able to extract the floating point values ie 0.50,0.50,0.66 respectively cause when i use the proposed solution given earlier data=[] for line in x: line=line.split("|") data.append(float(line[-2])) --> i am trying to get the floating point values from the back i receive this error message Traceback (most recent call last): File "", line 3, in d.append(float(line[-2])) IndexError: list index out of range Whereas the solution works well with the dummy text file which i have created which is a.txt jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc x=open("a.txt","r") data=[] for line in x: line=line.split("|") data.append(float(line[-2])) print data 0.332,0.936 Please help me fix this problem Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: Gracefull application exit.
On 24Jul2008 17:30, Robert Rawlins <[EMAIL PROTECTED]> wrote: | > but mind the caveats: | | Thanks Tim, the main caveat which worries me is the fact that it doesn't get | called when being killed by SIGTERM. When I look at implementing the | application as Daemon will cause complications. | The implementation looks nice and is certainly the way I would like to go, | but unless it'll work when killed by sigterm it likely won't be for me. If you catch SIGTERM with the signal module and call sys.exit() they should fire. This all gets harder with threads. -- Cameron Simpson <[EMAIL PROTECTED]> DoD#743 http://www.cskk.ezoshosting.com/cs/ We _like_ the starter! Wouldn't have it any other way. If it doesn't grind, take it back to the dealer and make them fix it! - Jon N. Steiger, DoD#1038, <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about optimization
On Thu, 24 Jul 2008 17:19:41 -0400, Wei Hao <[EMAIL PROTECTED]> wrote: Hi: I'm pretty new to python and I have some optimization issues. I'll show you the piece of code which is causing it, with pseudo-code before it and comments. I'm accessing a gigantic table (like 15 million rows) in SQL. d is some dictionary, r is a precompiled regex string Big loop, so I search through the table in chunks given by delta SQL query ("select * from table where rowID >= n and rowID < (n + delta)"), result of query stored in a. Each individual row is a[n1], columns of rows are a[n1][n2]. [snip] I am 100% sure it's this code snippet that's the cause of my problems. Here's what I can tell you. Each chunk of rows that I grab is essentially equal in size (rowID skips over stuff, but rather arbitrarily). The time it takes to fetch the SQL query doesn't change. But as the program progresses, this snippet gets slower. Here's the output: 2500 0.441551299341 5000 1.26162739664 7500 2.35092688403 1 3.48417469666 12500 4.59031305491 15000 5.78972588775 17500 6.28305527139 2 6.73344570903 22500 8.31732146487 25000 9.65322872159 27500 8.98186042757 3 11.8042818095 32500 12.1965593712 35000 13.2735763291 37500 14.0282617344 What is it in the code snippet that slows down as n increases? Is there something about the way low level python functions I don't understand which is slowing me down? Perhaps you need an index on rowID. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On Jul 24, 11:43 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Jordan a écrit : > > >> I don't really mind, what you think about my response. Python will suffer > >> from it as little as it will suffer from your complaints: These things > >> will not change, whatever any of us says about them. So this discussion > >> unlikely to produce any new insight, especially because this as been > >> discussed over and over again in the past, without any effect on Python. > > > You're right, of course. Because Python is in so many ways what I'm > > looking for in a language, I transform it in my mind to my own, > > personal ideal, close to the real existing language but with what I > > consider to be the imperfections removed. > > I guess you'll find a lot of us guilty here too - but do we really agree > on what we consider to be "imperfections" ?-) > > (snip) > > > I was trying not to change explicit self, or even != (which has a much > > better case.) I was trying to ask the community to reconsider a > > premise that the language is built around. Explicit is actually kinda > > annoying a lot of the time, viz., java. This is about social and > > philosophical adjustments, not technical ones. > > "explicit-is-etc" - just like the remaining of Python's zen - is a > general philosophy statement, not an absolute rule. Another quote states > that practicality beats purity. > > So yes, Python has warts, and one can't get away dogmatically quoting > Python's zen. Even if I'm sometimes myself guilty here, it's certainly > worth taking time to better address criticism, either by aknowledging > effective warts when someone points them out or by explaining (or > pointing to explanations of) the unusual parts of Python's design. > > Now since most of the times, criticisms expressed here fall in the > second category, we're happy to learn you'll now take appropriate action > here and help us keep c.l.py a newbie-friendly place !-) Something that is pure and explicit is a conflict of priorities with something that is practical and implicit. As with any rules, there are going to be times when the priorities in the Zen conflict with one another, and the Zen is silent on which combination ranks higher. Some people will hate you for using 'sf' instead of 'self'... but some hate you for spelling errors too. A temper lost is a flamewar earned. If you post two equivalent code snippets that both work, we can help you compare them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Neat way to get rid of [" "] in sys.argv[n:] returns
korean_dave wrote: python test.py "testparameter" I get this output: - ['testparameter'] Is there a way to neatly, in one call to the parameter, to get rid of the [' and '] without bothering to replace() '[ with "" and replace() '] with ''? Since you're using slicing instead of indexing, you're printing a list, not a single string. There is no '[ or ]' in the string itself, and no need to replace it with anything. To print just that string, do print sys.argv[1] # fetch item instead of print sys.argv[1:] # slice list I suggest working through a tutorial or two. Pay special attention to the difference between an object's value and the various ways that value can be output. -- http://mail.python.org/mailman/listinfo/python-list
Re: need help with introducing more traffic
Fredrik Lundh wrote: (when do we get the ability to edit our c.l.python messages for, say, 30 minutes after they're posted? ;-) The IETF is waiting to borrow Guido's time machine for study before releasing the RFC for NNTTP (Network News Time Travel Protocol). Of course, if you have you get to borrow Guido's time machine, too, you can already comment on the RFC before the C's were R'ed. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Question about optimization
Hi: I'm pretty new to python and I have some optimization issues. I'll show you the piece of code which is causing it, with pseudo-code before it and comments. I'm accessing a gigantic table (like 15 million rows) in SQL. d is some dictionary, r is a precompiled regex string Big loop, so I search through the table in chunks given by delta SQL query ("select * from table where rowID >= n and rowID < (n + delta)"), result of query stored in a. Each individual row is a[n1], columns of rows are a[n1][n2]. t1 = time.clock() #to track speed for m in a: for temp in m: if str(temp) == "None": #basically skip over the columns that are null for this particular row continue s += temp #get the columns into one long string s = s.replace("between", "") s = s.replace("and", "") s = s.replace("where", "") s = s.replace("like", "") #these words cause problems, need to get rid of them. b = re.findall(r,s) #looking for the stuff I want, always at least one per row of table, about 3-4 on average. for t in b: #store count of things I want in dictionary if t in d: d[t] += 1 else: d[t] = 1 print n, (time.clock()-t1) #to track speed I am 100% sure it's this code snippet that's the cause of my problems. Here's what I can tell you. Each chunk of rows that I grab is essentially equal in size (rowID skips over stuff, but rather arbitrarily). The time it takes to fetch the SQL query doesn't change. But as the program progresses, this snippet gets slower. Here's the output: 2500 0.441551299341 5000 1.26162739664 7500 2.35092688403 1 3.48417469666 12500 4.59031305491 15000 5.78972588775 17500 6.28305527139 2 6.73344570903 22500 8.31732146487 25000 9.65322872159 27500 8.98186042757 3 11.8042818095 32500 12.1965593712 35000 13.2735763291 37500 14.0282617344 What is it in the code snippet that slows down as n increases? Is there something about the way low level python functions I don't understand which is slowing me down? Thanks in advance for your time. -Wei -- http://mail.python.org/mailman/listinfo/python-list
Re: Neat way to get rid of [" "] in sys.argv[n:] returns
korean_dave a écrit : so, i code this: - #!/usr/bin/python import sys import os for param in os.environ.keys(): print "%20s %s" % (param,os.environ[param]) print(os.environ['PATH']) print(sys.argv[1:]) -- and then when i type in --> python test.py "testparameter" I get this output: - ['testparameter'] Is there a way to neatly, in one call to the parameter, to get rid of the [' and '] without bothering to replace() '[ with "" and replace() '] with ''? exact-but-useless-answer: print sys.argv[1] to-the-point-answer: print " ".join(sys.argv[1:]) and-if-I-may-ask: - do you understand why you get these "[' ']" ? -- http://mail.python.org/mailman/listinfo/python-list
www efukt com - Amazing porn video collection
www efukt com . >>Best Collection of Efukt Videos<< http://vids365.com/watch.php<<< >>FREE www efukt com VIDEOS<<< . www efukt com -- http://mail.python.org/mailman/listinfo/python-list
www Efukt - Amazing porn video collection
www efukt . >>Best Collection of Efukt Videos<< http://vids365.com/watch.php<<< >>FREE www efukt VIDEOS<<< . www efukt -- http://mail.python.org/mailman/listinfo/python-list
Efukt com - Amazing porn video collection
efukt com . >>Best Collection of Efukt Videos<< http://vids365.com/watch.php<<< >>FREE efukt com VIDEOS<<< . efukt com -- http://mail.python.org/mailman/listinfo/python-list
Shown on efukt com - Amazing porn video collection
shown on efukt com . >>Best Collection of Efukt Videos<< http://vids365.com/watch.php<<< >>FREE shown on efukt com VIDEOS<<< . shown on efukt com -- http://mail.python.org/mailman/listinfo/python-list
Peachy18 com - Amazing porn video collection
peachy18 com . >>Best Collection of Peachy18 Videos<< http://vids365.com/watch.php<<< >>FREE peachy18 com VIDEOS<<< . peachy18 com -- http://mail.python.org/mailman/listinfo/python-list
Peachy18 forum - Amazing porn video collection
peachy18 forum . >>Best Collection of Peachy18 Videos<< http://vids365.com/watch.php<<< >>FREE peachy18 forum VIDEOS<<< . peachy18 forum -- http://mail.python.org/mailman/listinfo/python-list
Peachy18 com - Amazing porn video collection
peachy18 com . >>Best Collection of Peachy18 Videos<< http://vids365.com/watch.php<<< >>FREE peachy18 VIDEOS<<< . peachy18 com -- http://mail.python.org/mailman/listinfo/python-list
Peachy18 - Amazing porn video collection
peachy18 . >>Best Collection of Peachy18 Videos<< http://vids365.com/watch.php<<< >>FREE peachy18 VIDEOS<<< . peachy18 -- http://mail.python.org/mailman/listinfo/python-list
www spankwire com - Amazing porn video collection
www spankwire com . >>Best Collection of Spankwire Videos<< http://vids365.com/watch.php<<< >>FREE www spankwire VIDEOS<<< . www spankwire com -- http://mail.python.org/mailman/listinfo/python-list
www Spankwire - Amazing porn video collection
www spankwire . >>Best Collection of Spankwire Videos<< http://vids365.com/watch.php<<< >>FREE www spankwire VIDEOS<<< . www spankwire -- http://mail.python.org/mailman/listinfo/python-list
www Xxxstash - Amazing porn video collection
www xxxstash . >>Best Collection of Xxxstash Videos<< http://vids365.com/watch.php<<< >>FREE www xxxstash VIDEOS<<< . www xxxstash -- http://mail.python.org/mailman/listinfo/python-list
Xxxstash com - Amazing porn video collection
xxxstash com . >>Best Collection of Xxxstash Videos<< http://vids365.com/watch.php<<< >>FREE xxxstash com VIDEOS<<< . xxxstash com -- http://mail.python.org/mailman/listinfo/python-list
Xxxstash - Amazing porn video collection
xxxstash . >>Best Collection of Xxxstash Videos<< http://vids365.com/watch.php<<< >>FREE xxxstash VIDEOS<<< . xxxstash -- http://mail.python.org/mailman/listinfo/python-list
free sextv1 tv - Amazing porn video collection
free sextv1 tv . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE sextv1 tv VIDEOS<<< . free sextv1 tv -- http://mail.python.org/mailman/listinfo/python-list
sextv1 tv com - Amazing porn video collection
sextv1 tv com . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE sextv1 tv com VIDEOS<<< . sextv1 tv com -- http://mail.python.org/mailman/listinfo/python-list
sextv1 player - Amazing porn video collection
sextv1 player . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE sextv1 player VIDEOS<<< . sextv1 player -- http://mail.python.org/mailman/listinfo/python-list
sextv1 net - Amazing porn video collection
sextv1 net . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE sextv1 net VIDEOS<<< . sextv1 net -- http://mail.python.org/mailman/listinfo/python-list
sextv1 tv - Amazing porn video collection
sextv1 tv . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE sextv1 tv VIDEOS<<< . sextv1 tv -- http://mail.python.org/mailman/listinfo/python-list
www sextv1 pl - Amazing porn video collection
www sextv1 pl . >>Best Collection of Sextv1 Videos<< http://vids365.com/watch.php<<< >>FREE www sextv1 pl VIDEOS<<< . www sextv1 pl -- http://mail.python.org/mailman/listinfo/python-list
Neat way to get rid of [" "] in sys.argv[n:] returns
so, i code this: - #!/usr/bin/python import sys import os for param in os.environ.keys(): print "%20s %s" % (param,os.environ[param]) print(os.environ['PATH']) print(sys.argv[1:]) -- and then when i type in --> python test.py "testparameter" I get this output: - ['testparameter'] Is there a way to neatly, in one call to the parameter, to get rid of the [' and '] without bothering to replace() '[ with "" and replace() '] with ''? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Reading a file
Thanks a lot guys , i got it now. Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading a file
aditya shukla wrote: I have a text file whose contents are like this:- jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc I am trying to read the file like this:- >>> x = open("c:\\a.txt","r") Better to use "rb" (for binary read) rather than "r" mode. >>> x.read() Now, tell us what you *really* did. Not that -- that would read the contents of the file, put throw the returned result away. You must have done something like c = x.read() the result that i get is ike this:- 'jd|fj|dnv|jd|0.33|c:windowswin32\nshcbsbs|nscsjsj|0.93|hsbcjsnc\n' My doubt is how can i read the file as it is? You *have* read the file as it is. Examine each character, and you'll see that the string is exactly as you expect. However, your output to the screen is escaping some character with backslashes. But that's just because of the method you used to print to the screen. What method *did* you use to print? If you just typed the variable into which you had read the contents, then you get the equivalent of print repr(c) which explains the escapes. Try print c and that won't happen. Gary Herron ie my output should be d|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Undocumented Python 2.6 change: Py_None vs NULL when C implementation raises exception
> I have no plans to track down the exact change in Python code that > caused this. There does not seem to be much point, since according to > Fredrik this seems to be an area that is practically undefined and the > M2Crypto code was clearly buggy. I see, and I agree with Fredrik's analysis. It might actually be that there was *no* change in 2.6 causing this change in behavior, but just a difference in data returned in the actual application. E.g. if a PyInt_FromLong returns -1, the caller also needs to check for PyErr_Occurred, which would then detect an earlier exception. So it might be that if you have -1 in your data, you see the exception, but if you have -2 instead, you won't see it. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading a file
aditya shukla wrote: I have a text file whose contents are like this:- jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc I am trying to read the file like this:- >>> x = open("c:\\a.txt","r") >>> x.read() eh, wouldn't it be easier if you actually read the replies to your last post on this topic? here's an excerpt from the reply you got last time: > Extracting is easy; you can do something like > > data = [] > for line in open("test.txt"): > line = line.split("|") > data.append(float(line[1])) which fetches floating point values from the text file example you posted last time: > 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll > 0\9\10\11|0.50|c:\windows\apppatch/AcRedir.dll > 0\9\10|0.66|c:\windows\apppatch/AcSpecfc.dll > 0\9|0.83|c:\windows\apppatch/iebrshim.dll if the values have moved to some other column, adjust line[1] accordingly. -- http://mail.python.org/mailman/listinfo/python-list
Re: need help with introducing more traffic
Fredrik Lundh wrote: "load testing" other people's sites are known as something else, of course. message.replace(" are ", " is ") # do'h! (when do we get the ability to edit our c.l.python messages for, say, 30 minutes after they're posted? ;-) -- http://mail.python.org/mailman/listinfo/python-list
Reading a file
I have a text file whose contents are like this:- jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc I am trying to read the file like this:- >>> x = open("c:\\a.txt","r") >>> x.read() the result that i get is ike this:- 'jd|fj|dnv|jd|0.33|c:windowswin32\nshcbsbs|nscsjsj|0.93|hsbcjsnc\n' My doubt is how can i read the file as it is? ie my output should be d|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: need help with introducing more traffic
Diez B. Roggisch wrote: umm. are you saying that you run ruby-lang.org and want to write a stress tester in Python just for the fun of it, or are we missing something here... This: http://www.pylot.org/ Seems as if he *is* using various languages for fun... "load testing" other people's sites are known as something else, of course. -- http://mail.python.org/mailman/listinfo/python-list
Re: Function editing with Vim throws IndentError
On Jul 24, 2:54 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message > <[EMAIL PROTECTED]>, > > Matimus wrote: > > That isn't the standard. With that setup tabs will show up as 4 > > spaces, and still confuse you. > > Why should that be confusing? The most common tab-stop setting is 4 columns. I think if you continued reading my post you would see. The tabstop feature in Vi(m) sets how many spaces a tab character is displayed as. A tab character is specified as 8 spaces. The real problem is that the python interpreter itself follows the spec and interprets a tab as 8 spaces. If you are viewing the code and have mixed tabs and spaces and all of the tabs are showing up as 4 spaces you will not be able to spot the issues that will come up. 4 columns is not the most common setting, the most common setting is the default, which is 8. It is just very common for people to change it. I suggest that instead of changing the tabstop, just use spaces (not both) and use the `softtabstop` setting to allow a press of the tab key to insert four spaces instead. Matt -- http://mail.python.org/mailman/listinfo/python-list
Re: curses problem
forgot to post the code. Server does not allow to post attachments. The code is here http://www.kos.wsiz.rzeszow.pl/~dmalec/src.zip -- Dariusz Malec http://www.kos.wsiz.rzeszow.pl JID:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
curses problem
Hi, I'm very new to python and to curses but i guess someone can help me understand the problem: I wrote a little application (attachment) and the problem is when I resize the terminal the sub-window (log window) gets wrong size (rows) and when restoring previous terminal size the window row size does not change at all. Is there some kind of method to set directly window size in python curses? I'm using mvwin() method to set the windows new position but the problem is the size. -- Dariusz Malec http://www.kos.wsiz.rzeszow.pl JID:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: readln() until EOF
korean_dave a écrit : a = open("Thefile.txt","r") while ?: result = a.readln() I assume you meant "a.readline()" ? Anyway... what do i put in if i want to keep reading line by line until i reach the end of the file? a = open("path/to/file.ext") for line in a: do_something_with(line) a.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python, familiar with Perl - Seeking info sources
Brett Ritter a écrit : After many years happily coding Perl, I'm looking to expand my horizons. [no flames please, I'm pretty aware of Perl's strengths and weaknesses and I'm just here to learn more, not to enter religious debates]. I've gone through some of the online tutorials and I'll be browsing the reference before starting the "code a lot" phase. My question is: What are the best sources to learn best practices or get the answers to questions? Are there any good sources to tell me what Perl habits are good/bad in the Python paradigm? What about common packages that will change my life? (I do a lot of web work, but also a lot of DB reporting) wrt/ "best practices" and writing pythonic code, the best thing to do is probably to lurk here and post code snippets asking for code reviews (we just *love* that !-) Others already pointed you to useful readings like diveintopython. I'd like to add Fredrik Lundh (aka the effbot)'s excellent website to the list: http://effbot.org/ wrt/ packages, first take time to read the stdlib's package index - I've a couple time Reinvented The Square Wheel(tm) when a well-rounded one was just an import away. You'll also find useful resources on pypi (the Python's Package Index). I'm also working as a Java developer primarily, so I'm glad to see that Jython has been resurrected, but I'm focusing on vanilla Python for the moment. As examples: PerlMonks has been my info source. The Perl Best Practices and Higher Order Perl books have been my tutors into better coding practices. This newsgroup, diveintopython, effbot.org... CPAN has my life easy, Not quite close to CPAN, but the closest we actually have IMHO: pypi (for the package index) and easy_install. giving me access to the DBI, Class::DBI (and its successors), low-level : Python db-api hi-level : SQLAlchemy HTML::FillInForm, Don't know what this one do... Data::FormValidator, FormEncode CGI::Application, cgi and wsgi... and Text::CSV::Simple modules You probably want the csv package (in the stdlib). You may also want to have a look at templating engines like Mako or Genshi. that are staples of my coding. The (occasionally complete) Perl Advent calendars have proven to be a good source to learn about helpful modules that I might not otherwise stumble across. python-announces ? (I've encountered Django, but I'm getting my fill of "frameworks" from Java for the moment, so I'm looking for lightweight pieces at the moment) While not exactly lighweight by Python's standards, Django is certainly way lighter than the usual Java web framework. But Python is known to have more web frameworks than keywords, so you may find something lightweight enough for your taste - or of course write your own !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: readln() until EOF
the_file = open(path, 'r') for this_line in the_file: #do stuff with this_line -Steve Johnson On Jul 24, 2008, at 3:09 PM, korean_dave wrote: a = open("Thefile.txt","r") while ?: result = a.readln() what do i put in if i want to keep reading line by line until i reach the end of the file? I don't want to break the loop if there is a blank line, because there will be. Ex. of a file: map1 result1 map2 result 2 map3 result3 comments thanks... -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
readln() until EOF
a = open("Thefile.txt","r") while ?: result = a.readln() what do i put in if i want to keep reading line by line until i reach the end of the file? I don't want to break the loop if there is a blank line, because there will be. Ex. of a file: map1 result1 map2 result 2 map3 result3 comments thanks... -- http://mail.python.org/mailman/listinfo/python-list
RE: New to Python, familiar with Perl - Seeking info sources
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Brett Ritter > Sent: Thursday, July 24, 2008 9:54 AM > To: python-list@python.org > Subject: New to Python, familiar with Perl - Seeking info sources > > After many years happily coding Perl, I'm looking to expand my > horizons. [no flames please, I'm pretty aware of Perl's strengths and > weaknesses and I'm just here to learn more, not to enter religious > debates]. > > > Any recommendations? Thanks in advance. > I have a Perl background and have found the O'Reilly books to be useful. The Learning Python book (or whatever it's called) is good because it covers the paradigm shifts and potential gotchas that you won't even consider thinking about otherwise. Only downside is wading through the novice 'how to program' parts. The Cookbook is also good for getting 'standard' apps up and running quickly (meaning you know how to do it in Perl, and just need the equivalent Python syntax/paradigm.) The Python help can be very hit or miss. You're going to have _fun_ with the Python regex module. *twitch*winch*sputter* Generally speaking, there's a Python module to do just about everything you could do in Perl. The only gap I've found is in the win32com with a class in a .tlb file (works fine in Perl, fails in Python.) But someone on the python-win32 list posted a potential workaround which I need to test. The really spiffy part is that when I converted a few Perl scripts to Python, the Python scripts were a bit smaller. =O Python does less compile time type checking than Perl. And finally, this mailing list does produce useful, polite answers about syntax to theory, despite some noise. -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt
>> How to convert the perl notation >> $a = ""; expression in Python ? a = "" >> How to represent the loop >> for ($a = $b; $a<=$c;$a++){ >> >> } in Python for a in range(b, c + 1): do_something() ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Jordan a écrit : I don't really mind, what you think about my response. Python will suffer from it as little as it will suffer from your complaints: These things will not change, whatever any of us says about them. So this discussion unlikely to produce any new insight, especially because this as been discussed over and over again in the past, without any effect on Python. You're right, of course. Because Python is in so many ways what I'm looking for in a language, I transform it in my mind to my own, personal ideal, close to the real existing language but with what I consider to be the imperfections removed. I guess you'll find a lot of us guilty here too - but do we really agree on what we consider to be "imperfections" ?-) (snip) I was trying not to change explicit self, or even != (which has a much better case.) I was trying to ask the community to reconsider a premise that the language is built around. Explicit is actually kinda annoying a lot of the time, viz., java. This is about social and philosophical adjustments, not technical ones. "explicit-is-etc" - just like the remaining of Python's zen - is a general philosophy statement, not an absolute rule. Another quote states that practicality beats purity. So yes, Python has warts, and one can't get away dogmatically quoting Python's zen. Even if I'm sometimes myself guilty here, it's certainly worth taking time to better address criticism, either by aknowledging effective warts when someone points them out or by explaining (or pointing to explanations of) the unusual parts of Python's design. Now since most of the times, criticisms expressed here fall in the second category, we're happy to learn you'll now take appropriate action here and help us keep c.l.py a newbie-friendly place !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: need help with introducing more traffic
Fredrik Lundh schrieb: leo davis skrev: I found this code snippet(reference http://www.goldb.org) and wish to do more with it than just send out a Http Get request.I would like to introduce more traffic -say by downloading files,crawling through all the links,logging in etc etc,and wish to see how the web server reacts.I'm trying to stress the server to its limitsappreciate if anyone could provide me code/ideas to inject into this. the website -http://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ selected as example has many downloads.i tried from urllib import umm. are you saying that you run ruby-lang.org and want to write a stress tester in Python just for the fun of it, or are we missing something here... This: http://www.pylot.org/ Seems as if he *is* using various languages for fun... Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Jordan a écrit : Then why do you write, let me quote: """ (snip) coding __eq__ (snip) buys you nothing from the != operator. != isn't (by default) a synonym for the negation of == (unlike in, say, every other language ever); not only will Python let you make them mean different things, without documenting this fact - it actively encourages you to do so. """ My words aren't as clear as they should be. I mean that Python lets *you* do something without documenting, or rather stating to use a better term, that your intention is the non-obvious one. I'm not saying that Python itself lacks documentation for its own behaviour; I'm saying it should force you to make your intentions clear and visible to someone reading your code when you want to do something non- obvious. One could then answer than, the behaviour of __eq__ / __ne__ being clearly defined and documented, implementing one without the other - or in such a way that a != b is different from not(a == b) - is by itself an explicit 'statement of intention' !-) (snip strawmens) Please understand that I'm not arguing about this particular design choice (and FWIW, I'd mostly agree on the point that having a != b different from not (a == b) is actually a wart). Good, at least we've come to a point in this discussion where I can firmly agree with somebody. On that concrete case, a priori, yes. wrt/ the 'explicit self', there are in fact two points: 1/ The mandatory use of 'self' to access the current instance. As far as I'm concerned, and *even if there was no other technical reasons*, I wholefully, happily and definitively agree with this choice - specially in a language like Python (it's not quite the same problem with Java where you just can't put anything outside a class). It's truly (and IMHO, of course) a case where explicit-is-better-than-implicit, period. Strange enough, I never heard of anyone complaining about the mandatory use of $this-> in PHP. Nor about the mandatory use of @/@@ in Ruby. Nor about the 'm_whatever' naming convention in C++. Nor about [add your own example here]. 2/ The need to explicitely declare the 'target' object (self or cls) as first param of a 'function-to-be-used-as-method'. Granted, this one may feel a bit "unfinished" at first. And I would not bet my life on it, but I think one could possibly find some "solution" that would not as a side-effect impose any restriction wrt/ the current implementation. OTHO, given 1/, and since the way Python builds "methods" out of just two more general constructs (the def statement and the descriptor protocol) is part of what makes it's object model so powerful, I don't feel like the price to pay to keep the implementation as simple as possible is too high. IOW, while I would not turn down a "solution" like the one mentionned above (let's say -0 as far as I'm concerned), I just don't think it would be worth the time spent. Anyway, "explicit is better than implicit" is not the appropriate dogmatic justification here - but a couple other quotes from the Python's Zen could apply (left as an exercice to the reader) !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: instance comparison
On Jul 24, 2008, at 7:53 PM, King wrote: The the class is not subclass of another one. Problem still persist. The code is pretty huge and I am trying to post the information as clear as possible. Mark V. Shaney, from Dissociated Press, I presume? -- PA. http://alt.textdrive.com/nanoki/ -- http://mail.python.org/mailman/listinfo/python-list
Re: instance comparison
King skrev: The the class is not subclass of another one. Problem still persist. The code is pretty huge and I am trying to post the information as clear as possible. feel free to *add* stuff to the following example until it breaks, if that's easier: >>> class Spam: ... def __init__(self, label): ... self.label = label ... def __str__(self): ... return self.label ... >>> a = Spam("an object") >>> a <__main__.Spam instance at 0xb7e8faac> >>> print a an object >>> b = Spam("an object") >>> b <__main__.Spam instance at 0xb7e8fb6c> >>> print b an object >>> a == b False >>> a is b False >>> str(a) == str(b) True -- http://mail.python.org/mailman/listinfo/python-list
Re: instance comparison
No, The the class is not subclass of another one. Problem still persist. The code is pretty huge and I am trying to post the information as clear as possible. -- http://mail.python.org/mailman/listinfo/python-list
Is there a metacharacter to match transitions between any two of a set of non intersected char classes?
Hi, '\b' only match the boundary between alphanumerical char and nonalphanumerical char. I'm wonder if there is a generic metacharacter to match the boundary between any non intersected char set defined in regex and its complement. For example, I have a few non intersected char sets [a-zA-Z_0-9], [:] and [\s], and lets call the new metacharactor \m. r"abc\m" would be the same as r"abc\b" r"abc:\m' would match "abc:" in r"abc:xy" but not "abc::xy" r"a \m" (with one space) would match "a " (with one space) in "a abc" but not "a abc" (with two spaces). I would like that I have the flexibility to define more non intersected char sets, while I don't want change the regex that I have written. Thanks, Peng -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 23, 12:10 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 23 Jul 2008 09:42:29 -0700, castironpi wrote: > > On Jul 23, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Wed, 23 Jul 2008 14:10:22 +0200, mk wrote: > >> > Marc 'BlackJack' Rintsch wrote: > >> >> I can't even remember when I deleted something from a list in the past. > > >> > Still, doesn't that strike you as.. workaround? > > >> No, I find it actually safer; I don't have to care where modifications of > >> the list might be seen elsewhere in the program. > > >> Ciao, > >> Marc 'BlackJack' Rintsch > > > a[:]= newlist > > > and > > > a= newlist > > > have two completely different effects, and one is just as safe as > > 'del'. Besides, del isn't safe to be seen elsewhere in the program in > > other threads, if they aren't locking the GIL. > > As usual you are talking nonsense… > > Ciao, > Marc 'BlackJack' Rintsch As usual you are taking flamebait! -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Hallöchen! Sebastian \"lunar\" Wiesner writes: > Torsten Bronger <[EMAIL PROTECTED]>: > >> Bruno Desthuilliers writes: >> >>> Torsten Bronger a écrit : >>> Bruno Desthuilliers writes: [...] Just like this. However, the compiler could add "self" to non-decorated methods which are defined within "class". >>> >>> What's defined within classes are plain functions. It's actually >>> the lookup mechanism that wraps them into methods (and manage to >>> insert the current instance as first argument). >> >> And why does this make the implicit insertion of "self" >> difficult? I could easily write a preprocessor which does it >> after all. > > Who said, that it would be "difficult"? He just corrected your > statement about definitions inside a class, and did not make any > assumption about making "self" implicit. If it is not the implementation, I don't see why the "definition inside a class" matters at all. It can be realised as a transformation of the syntax tree and would even be transparent for the compiling steps after it. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On Jul 24, 11:49 am, "Sebastian \"lunar\" Wiesner" <[EMAIL PROTECTED]> wrote: > Torsten Bronger <[EMAIL PROTECTED]>: > > > > > Hallöchen! > > > Bruno Desthuilliers writes: > > >> Torsten Bronger a écrit : > > >>> Bruno Desthuilliers writes: > > [...] > > How would you handle this case with an implicit 'self' : > > class Foo(object): > pass > > def bar(self): > print self > > Foo.bar = bar > > >>> Just like this. However, the compiler could add "self" to > >>> non-decorated methods which are defined within "class". > > >> What's defined within classes are plain functions. It's actually > >> the lookup mechanism that wraps them into methods (and manage to > >> insert the current instance as first argument). > > > And why does this make the implicit insertion of "self" difficult? > > I could easily write a preprocessor which does it after all. > > Who said, that it would be "difficult"? He just corrected your statement > about definitions inside a class, and did not make any assumption about > making "self" implicit. > > I'd assume, that making self implicit wouldn't be that difficult to assume. > But does the fact, that it could easily be done, alone mean, that it > _should_ be done? The explicit "self" was a design decision, that can't > really be judged by technical arguments from implementation side. Its a > discussion about design from a programmers point of view ... > > -- > Freedom is always the freedom of dissenters. > (Rosa Luxemburg) I don't think you can infer from 'explicit is better than implicit' that 'the more explicit the better'. For instance, we don't use: python.callbyvalue.foo( bar, 1, 2 ) python.callbyref.foo2( bar, x, y ) or further: foo( byref bar, byval 1, byval 2 ) foo2( byref bar, byref x, byref x ) though some languages do. Python doesn't do that much implicity, like copying, with the exception of copying strings, which some string functions do, such as lower, replace, strip. (Does slicing return a new string?) What is the most surprisingly implicit behavior in Python? What is the most explicit? -- http://mail.python.org/mailman/listinfo/python-list
Free Online Trading Courses - Online Trading Academy - Stock Trading ...
Free Online Trading Courses - Online Trading Academy - Stock Trading ... http://dayonlinetrading.blogspot.com _ -- http://mail.python.org/mailman/listinfo/python-list
Re: Broken examples
Lawrence D'Oliveiro wrote: In message <[EMAIL PROTECTED]>, norseman wrote: The OOo examples do not work. I have done OOo scripting in Python. What exactly does not work? -- http://mail.python.org/mailman/listinfo/python-list === file: z.scr -- #!/bin/bash cd /opt/openoffice.org2.0/program soffice "-accept=socket,host=localhost,port=2002;urp;" & sleep 9 ./python ./zhw.py echo "Did this Run?" # end of file - file: zhw.py - import uno # get the uno component context from the PyUNO runtime localContext = uno.getComponentContext() # create the UnoUrlResolver resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.b ridge.UnoUrlResolver", localContext ) # connect to the running office ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.Compo nentContext" ) smgr = ctx.ServiceManager # get the central desktop object desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx) # access the current writer document model = desktop.getCurrentComponent() # access the document's text property text = model.Text # create a cursor cursor = text.createTextCursor() # insert the text into the document text.insertString( cursor, "Hello World", 0 ) # Do a nasty thing before exiting the python process. In case the # last call is a oneway call (e.g. see idl-spec of insertString), # it must be forced out of the remote-bridge caches before python # exits the process. Otherwise, the oneway call may or may not reach # the target object. # I do this here by calling a cheap synchronous call (getPropertyValue). ctx.ServiceManager # end of file file: results --- SysOp(P):> sh z.scr Traceback (most recent call last): File "./zhw.py", line 20, in ? text = model.Text AttributeError: Text Did this Run? SysOp(P):> =NO!! --- Haven't found any specific to scalc. The zhw contents is closest to working I have found to date. The z script was used to get to stated place and minimize typos. As results shows - I ran as root. As user it screams lots. (Permissions) The above is best effort so far. Others before it were even worse. If you have working code I would like to tryout your linkage (process). Before you send anything, can you use python to have scalc open a .xls and save it as a csv? I can get python to have scalc open a specific file and then point'n'click myself, but that isn't productive. I cannot get scalc to do a saveas instruction issued by a python program. I have no intentions of staying up all night pointing and clicking. Humans think, computers do the repetitive. Yes? Besides, it is far easier to train the computer than to train the . :) Any help is appreciated. Steve [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Torsten Bronger a écrit : Hallöchen! Bruno Desthuilliers writes: Torsten Bronger a écrit : Bruno Desthuilliers writes: [...] How would you handle this case with an implicit 'self' : class Foo(object): pass def bar(self): print self Foo.bar = bar Just like this. However, the compiler could add "self" to non-decorated methods which are defined within "class". What's defined within classes are plain functions. It's actually the lookup mechanism that wraps them into methods (and manage to insert the current instance as first argument). And why does this make the implicit insertion of "self" difficult? Did I say such a thing ? Call me pedantic if you want, but I find it easier to understand how something works when using the appropriate terms, that's all. I could easily write a preprocessor which does it after all. A source-code-preprocessor based solution wouldn't do IMHO. But that was not the point. The point is that a working solution would require to handle "functions-or-else" defined within a class statement as a special case, which obviously makes thing more compl[ex|icated]. Now as far as I'm concerned, as long as such a solution 1/ doesn't impose any restriction wrt/ current features of Python's object model and 2/ doesn't make any of the currently used "metaprogramming" idioms more difficult, I just wouldn't care. -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
On Jul 25, 1:39 am, Torsten Bronger <[EMAIL PROTECTED]> wrote: > I could easily write a preprocessor which does it after all. Have you considered actually doing so? That might resolve the whole issue, if a tool exists for those who want implicit self. After all, if -you- have the itch... Perhaps you could leverage off of EasyExtend? "EasyExtend (EE) is a preprocessor generator and metaprogramming framework written in pure Python and integrated with CPython. The main purpose of EasyExtend is the creation of extension languages i.e. adding custom syntax and semantics to Python." http://www.fiber-space.de/EasyExtend/doc/EE.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Attack a sacred Python Cow
Torsten Bronger <[EMAIL PROTECTED]>: > Hallöchen! > > Bruno Desthuilliers writes: > >> Torsten Bronger a écrit : >> >>> Bruno Desthuilliers writes: >>> [...] How would you handle this case with an implicit 'self' : class Foo(object): pass def bar(self): print self Foo.bar = bar >>> >>> Just like this. However, the compiler could add "self" to >>> non-decorated methods which are defined within "class". >> >> What's defined within classes are plain functions. It's actually >> the lookup mechanism that wraps them into methods (and manage to >> insert the current instance as first argument). > > And why does this make the implicit insertion of "self" difficult? > I could easily write a preprocessor which does it after all. Who said, that it would be "difficult"? He just corrected your statement about definitions inside a class, and did not make any assumption about making "self" implicit. I'd assume, that making self implicit wouldn't be that difficult to assume. But does the fact, that it could easily be done, alone mean, that it _should_ be done? The explicit "self" was a design decision, that can't really be judged by technical arguments from implementation side. Its a discussion about design from a programmers point of view ... -- Freedom is always the freedom of dissenters. (Rosa Luxemburg) -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python, familiar with Perl - Seeking info sources
On Jul 24, 11:53 pm, Brett Ritter <[EMAIL PROTECTED]> wrote: > My question is: What are the best sources to learn best practices or > Are there any good sources to tell me > what Perl habits are good/bad in the Python paradigm? I've never used Perl myself, so I can't comment on the quality, but this document was recommended earlier this week: http://wiki.python.org/moin/PerlPhrasebook > What about > common packages that will change my life? (I do a lot of web work, > but also a lot of DB reporting) If you're not anti-ORM, I highly recommend checking out SQLAlchemy. It's not part of the standard lib, but it's an amazing tool: http://www.sqlalchemy.org/ > The (occasionally complete) Perl > Advent calendars have proven to be a good source to learn about > helpful modules that I might not otherwise stumble across. You might appreciate Doug Hellman's Python Module of the Week blog: http://www.doughellmann.com/projects/PyMOTW/ > (I've encountered Django, but I'm getting my fill of "frameworks" from > Java for the moment, so I'm looking for lightweight pieces at the > moment) The Web Services Gateway Interface (WSGI) was designed to promote the building of web applications using interchangeable middleware. It's definitely worth having an understanding of if you plan on developing web apps in Python: http://www.wsgi.org/wsgi/ If you're wanting to avoid the larger frameworks, check out CherryPy, it's a thing of beauty: http://www.cherrypy.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml, comparing nodes
code_berzerker wrote: > Thanks for help. Thats inspiring, tho not exactly what I need, coz > ignoring document order is requirement (ignoring changes in order of > different siblings of the same type, etc). I plan to try something > like that: > > def xmlCmp(xmlStr1, xmlStr2): > et1 = etree.XML(xmlStr1) > et2 = etree.XML(xmlStr2) > > queue = [] > tmpq = deque([et1]) > tmpq2 = deque([et2]) > > while tmpq: > el = tmpq.popleft() > tmpq.extend(el) > queue.append(el.tag) > > while queue: > el = queue.pop() > foundEl = findMatchingElem(el, et2) > if foundEl: > et1.remove(el) > tmpq2.remove(foundEl) > else: > return False > > if len(tmpq2) == 0: > return True > else: > return False If document order doesn't matter, try sorting the elements of each level in the two documents by some arbitrary deterministic key, such as (tag name, text, attr count, whatever), and then compare them in order, instead of trying to find matches in multiple passes. itertools.groupby() might be your friend here. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: repr(string)
In article <[EMAIL PROTECTED]>, Peter Otten <[EMAIL PROTECTED]> wrote: > David C. Ullrich wrote: > > > In article <[EMAIL PROTECTED]>, > > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > >> David C. Ullrich wrote: > >> > >> > I've been saving data in a file with one line per field. > >> > Now some of the fields may become multi-line strings... > >> > > >> > I was about to start escaping and unescaping linefeeds > >> > by hand, when I realized that repr() and eval() should > >> > do. Hence the question: If s is a string, is repr(s) > >> > guaranteed not to contain line breaks? > >> > >> yes. > >> > >> just keep in mind that using eval() on untrusted data isn't a very good > >> idea. > > > > Right. This data comes from me, gets put into a file and then > > read by me. Someone _could_ corrupt that file, but someone who > > could do that could more easily just throw the machine out > > the window... > > You could also use a csv file with a single row. Excellent suggestion. I have a different point of view on all this than most of you guys (see reply to F). From my curious point of view csv was no fun anymore when csvlib got added to Python... > Peter -- David C. Ullrich -- http://mail.python.org/mailman/listinfo/python-list
RE: Gracefull application exit.
> but mind the caveats: Thanks Tim, the main caveat which worries me is the fact that it doesn't get called when being killed by SIGTERM. When I look at implementing the application as Daemon will cause complications. The implementation looks nice and is certainly the way I would like to go, but unless it'll work when killed by sigterm it likely won't be for me. Thanks Tim, if you're aware of any other methods then give me a shout. Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: repr(string)
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > David C. Ullrich skrev: > > >> just keep in mind that using eval() on untrusted data isn't a very good > >> idea. > > > > Right. This data comes from me, gets put into a file and then > > read by me. Someone _could_ corrupt that file, but someone who > > could do that could more easily just throw the machine out > > the window... > > and then your boss finds your program useful, and it's installed on a > shared server, and then the guys at the office in Eggkleiva wants a > copy, and then people start shipping save files via mail to keep things > synchronized, and then someone sets up a web service... ;-) Heh-heh. Good point, except that the idea that someone's going to find it useful is utterly implausible. Nobody but me has ever found a program I wrote useful. People think it's funny that I write little Python programs to do things I could just do in Excel or Open Office. (When I have some accounting/secretarial sort of thing to do doing it by hand in Python is one way to make it tolerably interesting. Easier to add new features - instead of trying to find an Excel way to do something like delete the smallest _two_ items in a list I just do it.) > -- David C. Ullrich -- http://mail.python.org/mailman/listinfo/python-list
Re: Gracefull application exit.
Robert Rawlins wrote: I’m looking to implement an exit/termination process for an application which can be triggered by A) a keyboard interrupt or B) termination of the application as a Daemon using a signal. I have a whole bunch of tasks I want to perform as a cleanup before the application is terminated, cleaning files, database calls, closing open connections and a few other things. I know we have: # I'm the main application started method. if __name__ == /"__main__"/: For starting an application, but do we have an equivalent methods for when an application is terminated which we can use to close down any current internal processes before the application exits? I’d really love to have your thoughts and experience on gracefully killing an application. You want to look at the atexit module: http://docs.python.org/lib/module-atexit.html but mind the caveats: """ Note: the functions registered via this module are not called when the program is killed by a signal, when a Python fatal internal error is detected, or when os._exit() is called. """ TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Python / PAMIE
On Jul 24, 10:45 am, Tim Golden <[EMAIL PROTECTED]> wrote: > frankrentef wrote: > > THNX for your response. Based on the authors code it's very simple. > > > from cPAMIE import PAMIE > > ie=PAMIE () > > > #ie.navigate ("google.com") > > > #ie.linkClick > > #ie.textBoxSet > > #ie.writeScript > > > ie.navigate ('https://login.yahoo.com/config/mail?.intl=us') > > #ie.scriptWrite () > > > ie.scriptWrite() > > > Below is the error I get... > > > File "C:\Python24\lib\site-packages\cPAMIE.py", line 1837, in > > scriptWrite > > nameProp = getattr(x,"nameProp") > > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > > line 500, in __getattr__ > > raise AttributeError, "%s.%s" % (self._username_, attr) > > AttributeError: .nameProp > > I'm afraid I'm no IE expert (read: never use it if I can > avoid it) but I suspect here a combination of slightly > flaky code in the Python module plus, maybe, a change in > the IE dom object model. > > If you change lines 1832-1836 of cPAMIE.py to be as follows: > > > for j in range(doc.length): > x = doc[j] > etype = getattr(x,"type", "") > name = getattr(x,"name", "") > nameProp = getattr(x,"nameProp", "") > > > > then at least some kind of output is produced. But I'm > not entirely sure what this function is trying to achieve > so I don't guarantee it's doing the right thing yet. > > TJG- Hide quoted text - > > - Show quoted text - The idea is to run through a given url, detect any "form fields" that require populating and build a script listing the field names, etc. >From there a PAMIE user can take the script returned and build a test case. In other words the user does not have to search through the HTML code for all the field names (blanks) radio button names, etc. It works "great" on the video tutorial but dang if I or any of our senior guys can get it to work here in house. THNX for input, we'll give it a try. -- http://mail.python.org/mailman/listinfo/python-list
Gracefull application exit.
Chaps, I'm looking to implement an exit/termination process for an application which can be triggered by A) a keyboard interrupt or B) termination of the application as a Daemon using a signal. I have a whole bunch of tasks I want to perform as a cleanup before the application is terminated, cleaning files, database calls, closing open connections and a few other things. I know we have: # I'm the main application started method. if __name__ == "__main__": For starting an application, but do we have an equivalent methods for when an application is terminated which we can use to close down any current internal processes before the application exits? I'd really love to have your thoughts and experience on gracefully killing an application. Robert -- http://mail.python.org/mailman/listinfo/python-list