Re: Access from one class to methode of other class
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > On Thu, 26 May 2005 14:33:45 +0200, VK <"myname"@example.invalid> > declaimed the following in comp.lang.python: > >> Hi, all! >> >> In my programm i have to insert a variable from class 2 to class 1 and I >> get error NameError: global name 'd' is not defined. How do I get access >> to d.entry.insert() method of class 1 >> >> class 1: >Does Python even allow numeric class names? Fortunately, no: >>> class 1: File "", line 1 class 1: ^ SyntaxError: invalid syntax -- Aaron Bingham Software Engineer Cenix BioScience GmbH -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Execution Times
On May 26, 2005, at 3:22 PM, John Machin wrote: > > Then post your summarised results back to the newsgroup for the > benefit of all -- there's this vague hope that folk actually read > other peoples' posts before firing off questions :-) Here is my new version. It runs in about .65 seconds. The trick? Reading lines one at a time. Please let me know if there's any bad coding practices in it! def main(): import md5 import time f = open("data.xml", "rU") out = open("out.xml", "w") p1 = "" p2 = "" adjust = len(p1) t1 = time.clock() for line in f: start, end = line.find(p1) + adjust, line.find(p2) if end != -1: digest = md5.new(line[start:end]).hexdigest() out.write(line[:start] + digest + line[end:]) else: out.write(line) t2 = time.clock() print round(t2-t1, 5) f.close() out.close() if __name__ == '__main__': main() -- Elliot Temple http://www.curi.us/ --- [This E-mail scanned for viruses by Declude Virus] -- http://mail.python.org/mailman/listinfo/python-list
Re: using timeit for a function in a class
"flupke" wrote: > ? i think you missed some of the code > ... > s = """ > test = TimeTest() > test.f() > """ > ... > > So the function is being called (as i said, it prints the hello message). timeit is a benchmark utility. it's supposed to call your function enough times to get an accurate result. if you want to time a single call, using timeit instead of time is just plain silly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python analog of Ruby on Rails?
> "Shane" == Shane Hathaway <[EMAIL PROTECTED]> writes: Shane> BTW, here's the proper response to that religious thread Shane> that keeps invading this list: Shane> python -c 'print sum([ord(c) for c in "HOLYBIBLE"])' Shane> I'm Christian and I think it's funny. ;-) Some background: Shane> http://scriptures.lds.org/rev/13/16-18#16 Shane> http://www.greaterthings.com/Word-Number/666HolyBible.htm Ah, it was *obvious* from the start that the placement of ASCII letters was a conspiracy of american freemasons... -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Re: Just remember that Python is sexy
> "Greg" == Greg Ewing <[EMAIL PROTECTED]> writes: >> The name index implies it returns something you can use as an index >> to get at the substring. Greg> But that's no fun -- it doesn't involve sex! Greg> How about this: "index" and "sex" both end with "ex", which Greg> is short for "exception". Or something about the use of index finger being an exception from the conventional strategy... -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Lanunching Process from Python Script
Hello, In windows, I am launching Python process to execute python script in the back ground. This Python script which internally launches another windows exe. Here, how do I redirect output of windows.exe to caller process. (python.exe). I would appreciate, if any one provides sample code for the same. thanks. saravanan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Challenge 10?
[Greg Ewing] > Can someone give me a hint for No. 10? My MindBlaster > card must be acting up -- I can't seem to tune into > the author's brain waves on this one. There are hints on the site; for level 10, http://www.pythonchallenge.com/forums/viewtopic.php?t=20 > I came up with what I thought was a perfectly good > solution, but apparently it's wrong. :-( The On-Line Encyclopedia of Integer Sequences should be better known -- it's an amazing resource: http://www.research.att.com/~njas/sequences/ It knows about this sequence, so don't use it unless you want the answer given to you. If it doesn't know about your sequence, "perfectly good" is debatable . -- http://mail.python.org/mailman/listinfo/python-list
Python Challenge 10?
Can someone give me a hint for No. 10? My MindBlaster card must be acting up -- I can't seem to tune into the author's brain waves on this one. I came up with what I thought was a perfectly good solution, but apparently it's wrong. :-( -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex: step in for loop
Luis P. Mendes wrote: > I'm trying to improve speed in a module and substituted the pythonic > 'for in range()' for 'for i from min < i < max:' > > But, I need to define a step for the i variable. How can I do it? If you want maximum clarity, I'd suggest using the for-loop to iterate over a contiguous range of integers and an expression that maps the loop variable to whatever you want. If you want the maximum possible speed, it *may* be faster to use a while loop instead and do your own index updating. But profile to make sure. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list
Re: What are OOP's Jargons and Complexities?
Joe: So I gave my girlfriend some flowers. Dave: What, like tulips? John: No, no, he gave her roses. Mike: Were they red roses? Xah: You MORONS, they were JUST _flowers_! Enough with the mother fucking jargon already!! The moral of the story being that when you're not active in a specific domain, the intricacies of it can easily look irrelevant to you. -alex23 -- http://mail.python.org/mailman/listinfo/python-list
Re: Just remember that Python is sexy
Duncan Booth wrote: > The name index implies it returns something you can use as an index to get > at the substring. But that's no fun -- it doesn't involve sex! How about this: "index" and "sex" both end with "ex", which is short for "exception". (Of course, you could get straight from "index" to "exception" that way too, but then there wouldn't be any excuse for mentioning sex. :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list
Re: dirrection for simple record keeping app.
wow thanks, i think i am going to check out sqlite. acce$$ is not possible because of the cash. ick. i am interested in learning the code anyway, but just want to learn python instead of javascript right now. i have a simple cgi-script working to display info to the browser (from apache) but the script will not let me write the info to a text file. if you are keen, perhaps you could help me find the error in my script? thanks for your help by the way... still a real newbie here. -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
If you really want, you can customize the object system to automatically call __init__, via a custom metaclass. There is an example in my ACCU lectures (cooperative_init.py): http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble with regexes
Fernando Rodriguez <[EMAIL PROTECTED]> wrote: > >I'm trying to write a regex that matches a \r char if and only if it >is not followed by a \n (I want to translate text files from unix >newlines to windows\dos). > >I tried this, but it doesn't work: >p = re.compile(r'(\r)[^\n]', re.IGNORECASE) > >it still matches a string such as r'\r\n' Hint: the string r'\r\n' contains four characters. It contains neither carriage return nor newline. Bigger hint: the string '\r\n' contains two characters. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: dirrection for simple record keeping app.
As much as I hate to suggest anything Microsoft, you would probably save yourself a lot of work by using MS Access. That is what it is designed for. That said mySQL is probably a bit of a sledgehammer solution to the problem. If you want a database, you might want to look at SQLite. Is is pretty lightweight has python bindings and runs out of a file. pyGTK is one good option. wxWidgets is another. pyGTK tends to be a bit more unix centric while wxWidgets is more Windows centric. pyGTK is nicer to program in, but wxWidgets will give you more of what you need. Printing in Windows is hard (one of the advantages of MS Access is that it will take care of that for you) but wxWidgets apparently has a printing framework that you could use. Of course if you are already familliar with HTML and javascript, CGI route is a good one. It is easy to get a decent user interface set up pretty quickly with CGI and printing is taken care of by the browser. Multiuser is taken care of almost automatically. The main disadvantage is you need a web server and a connection to the web server whenever you want to use your system. That should get you going, -Chris On 26 May 2005 17:41:59 -0700, nephish <[EMAIL PROTECTED]> wrote: > Hey there, > i have been spending some time learning python. i do enjoy it so. > Heres the deal. i need some dirrection advice. > i have a friend that wants me to set up a customer database for him. > Easy stuff like name, phone number, email address. and current status. > he also wants to be able to print this stuff out. > Heres the deal. He runs windows xp. > how could i write something to help him out ? i thought of glade, since > its gtk and gtk can use a windows runtime i also thought of making > something web-based and doing this with cgi scripts. but what would be > easier to learn using a database like mysql, or writing text files > and reading them to retrieve the info. The scripting itself could just > be a simple dictionary... so > any suggestions? > thanks > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Christopher Lambacher [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
Elliot Temple wrote: > Thanks for the link on case sensitivity. I'm curious about the person > who found case sensitivity useful though: what is it useful for? I wasn't that person, but I do find case sensitivity very useful. Mainly it's useful in that it allows me not to spend any time at all worrying that I just might have a collision in my naming of various entities that are conceptually in different spaces but which -- due to the nature of the language I'm using -- happen to co-exist in the same namespace. For example, although this contrived example suggests poor imagination in picking names, I think it demonstrates the point. INVENTORYCODE = 5 # in effect one item in a constant "enum" class InventoryCode: '''Might represent something to do with inventory codes... duh''' def myfunc(): inventoryCode = someOtherFunction() In other words, I have a CONSTANT, a Class, and an instance, and if the set of code involved were large enough, these three things might be defined far enough apart that the potential collision wouldn't be as obvious as it is here. More to the point, there might not be any relationship between these things in my mind as I'm programming, and having to deal with an error message from a compiler or, worse, a run time error resulting from this collision would really annoy me. Case sensitivity might not be something we should be deliberately exercising on a daily basis, but there's no good reason (in my opinion) for not having it available to allow one freedom in naming (assuming one is sane and uses consistent convention for the case of things like constants, classes, and instances) without the worry of pesky collisions. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Execution Times
John Machin wrote: > Then post your summarised results back to the newsgroup for the benefit > of all -- there's this vague hope that folk actually read other peoples' > posts before firing off questions :-) +1 QOTW :-) -- http://mail.python.org/mailman/listinfo/python-list
RE: What are OOP's Jargons and Complexities?
[Paul Rubin] > Strong typing means there [are] a lot of variables whose names > are in ALL CAPS. +1 QOTW. =Tony.Meyer -- http://mail.python.org/mailman/listinfo/python-list
Re: What are OOP's Jargons and Complexities?
Roy Smith <[EMAIL PROTECTED]> writes: > I used to have a bunch of comp sci questions I would ask interview victims. > One of them was "what does it mean when a language is strongly typed?" I > once had somebody tell me it meant the language had long variable names, > and thus took a lot of typing. But that's incorrect. Strong typing means there's a lot of variables whose names are in ALL CAPS. -- http://mail.python.org/mailman/listinfo/python-list
Re: What are OOP's Jargons and Complexities?
"Xah Lee" <[EMAIL PROTECTED]> wrote: > Joe: lang x is strongly typed > Dave: you mean statically typed? > John: no no, that's weakly typed. > Mike: actually, it is dynamically typed! I used to have a bunch of comp sci questions I would ask interview victims. One of them was "what does it mean when a language is strongly typed?" I once had somebody tell me it meant the language had long variable names, and thus took a lot of typing. -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
Wow.. Andrew Koenig.. I found your name in many c++ books I read. Never know you are hanging around in python python mailing-list. (or perhaps python newsgroup, whatever it is) Thanks for the explanation. Andrew Koenig wrote: >"Sakesun Roykiattisak" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] > > > >>Does c++ call base class constructor automatically ?? >>If I'm not wrong, in c++ you also have to call base class constructor >>explicitly. >> >> > >In C++, if you don't call a base-class constructor (I am saying "a" rather >than "the" because there might be more than one direct base class), it is >called automatically with no arguments. The only case in which you must >call it explicitly is if it will not accept an empty argument list. > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: What are OOP's Jargons and Complexities?
Joe: lang x is strongly typed Dave: you mean statically typed? John: no no, that's weakly typed. Mike: actually, it is dynamically typed! rely on the morons of the IT industry, every mother fucking one of them, to sing and propagate jargons. See also: http://xahlee.org/UnixResource_dir/writ/jargons.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
"Elliot Temple" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi I have two questions. ... > Also, why aren't there > multiline comments? Would adding them cause a problem of some sort? As a matter of fact, yes. First, consider that as soon as you have multi-line comments, someone is going to request nested multi-line comments. (In other words, the compiler should check that the embedded comment is still correct.) That rapidly leads to madness. Second, multi-line comments aren't really necessary; as someone in the thread commented, a decent editor or IDE will allow adding or removing comments from a block of code easily. Python's philosophy is to only add features when there is a use case that will improve the language significantly, and commenting out a block of code for testing isn't it. (It's also not the world's best practice, but that's another subject.) John Roth > > Thanks, > Elliot > -- http://mail.python.org/mailman/listinfo/python-list
dirrection for simple record keeping app.
Hey there, i have been spending some time learning python. i do enjoy it so. Heres the deal. i need some dirrection advice. i have a friend that wants me to set up a customer database for him. Easy stuff like name, phone number, email address. and current status. he also wants to be able to print this stuff out. Heres the deal. He runs windows xp. how could i write something to help him out ? i thought of glade, since its gtk and gtk can use a windows runtime i also thought of making something web-based and doing this with cgi scripts. but what would be easier to learn using a database like mysql, or writing text files and reading them to retrieve the info. The scripting itself could just be a simple dictionary... so any suggestions? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
Thanks for the link on case sensitivity. I'm curious about the person who found case sensitivity useful though: what is it useful for? The way I find multi-line comments useful is to quickly comment out a block of code while debugging. A good development environment can (mostly) solve that one though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbol Tables
Dave Zhu wrote: > Hello, > > I would like to know more about Python's symbol > tables. How are symbol tables implemented in Python? > Hash tables, lists, or arrays? I would really > appreciate if there is any documentation that you can > provide. Thank you in advance. > > Dave > > > > __ > Discover Yahoo! > Use Yahoo! to plan a weekend, have fun online and more. Check it out! > http://discover.yahoo.com/ Google is your friend: http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLD,GGLD:2004-49,GGLD:en&q=python+symbol+table -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem accessing Python Business Forum
John: > Every time I attempt to look at the Python Business > Forum (www.python-in-business.org), I encounter an error that starts > like this: > ... Laura Creighton responded about this on python-dev: # The machine is at work, and anybody who wants to fix it # is welcome to. The problem is that some people decided # that it would be a good idea to install Zope, and # archtypes, and I don't know what else. When things # broke, none of them had time or inclination to fix it. The # people who do have the desire to fix it, don't know # anything about Zope and have no desire to learn this. # # Right now Jacob and I are too busy with Europython to # worry about the PBF website, given that the PBF # members have shown no desire to fix this. In the # meantime, collaboration between PBF members is working # quite well and we have more than a few shared projects # -- but fixing the website is not one of them. # # If anybody here wants this job, it is all yours. Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: overflowerror!!
Will McGugan wrote: > [EMAIL PROTECTED] wrote: > >> I tried that. Still get an Overflowerror: unsigned long is less than >> minimum. >> > > You'll also need to reserve enough space for the 256 ints. Try this.. > > data = array('L', '\0' * 256*4) > > I don't understand. Why not just do the whole thing simply and cleanly, like this: data = array('L', 256 * [0x]) -- http://mail.python.org/mailman/listinfo/python-list
Re: using timeit for a function in a class
Kent Johnson wrote: > flupke wrote: > >> >> Hi, >> >> i tried to use timeit on a function in a class but it doesn't do what >> i think it should do ie. time :) >> In stead it starts printing line after line of hello time test! >> What am i doing wrong in order to time the f function? > > > Hmm, by default Timer.timeit() calls the function being timed 100 > times. That's a lot of "hello time test" =:-) > > Kent Hehe, thanks Kent. Need to drink more coffee and train the eyes more, a new goal in life :) print t.timeit(1) did the trick. Regards, Benedict -- http://mail.python.org/mailman/listinfo/python-list
Symbol Tables
Hello, I would like to know more about Python's symbol tables. How are symbol tables implemented in Python? Hash tables, lists, or arrays? I would really appreciate if there is any documentation that you can provide. Thank you in advance. Dave __ Discover Yahoo! Use Yahoo! to plan a weekend, have fun online and more. Check it out! http://discover.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
Mike Meyer wrote: > Personally, I think anyone who has two variables whose names differ > only in case should be shot. No, let me extend that - anyone who has > two variables whose names would be pronounced the same should be > shot. I've had to debug such code, and it ain't fun. Here's a pair of targets for you: From "Software Engineering with Modula-2 and Ada", by Wiener & Sincovec, page 84: WITH w^ DO ... Col := column; Row := row; It turns out that 'Row' & 'Col' are module-global variables holding the current cursor position, and 'row' & 'column' are elements of the record to which 'w' points. Here's another corollary for Meyer's Law: Anyone who has two variables the name of one of which is, or could reasonably be understood to be, an abbreviation of the name of the other should be shot. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: using timeit for a function in a class
Fredrik Lundh wrote: > "flupke" wrote: > > >>i tried to use timeit on a function in a class but it doesn't do what i >>think it should do ie. time :) >>In stead it starts printing line after line of hello time test! >>What am i doing wrong in order to time the f function? > > > how do you expect timeit to figure out how long it takes to run your > function without calling the function? > > >>class TimeTest(object): >>def f(self): >>print "hello time test!" > > > > > > ? i think you missed some of the code ... s = """ test = TimeTest() test.f() """ ... So the function is being called (as i said, it prints the hello message). Regards, Benedict -- http://mail.python.org/mailman/listinfo/python-list
Re: overflowerror!!
[EMAIL PROTECTED] wrote: > I tried that. Still get an Overflowerror: unsigned long is less than > minimum. > You'll also need to reserve enough space for the 256 ints. Try this.. data = array('L', '\0' * 256*4) Will -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz" ] ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex: step in for loop
"Luis P. Mendes" <[EMAIL PROTECTED]> writes: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > | so it's > | > | for i in range(8, 14, 1): ... > | > | > For what I've read, for i in range is slower than the other for > construct used by Pyrex: > > for i from iMin <= i < iMax: > > My question had to do with this new expression. How can I introduce a > step there. My bad. I missed the "Pyrex" in the subject line. Sorry, http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Execution Times
Elliot Temple wrote: [copying Elliot's e-mail reply back to the list because it's educational and scarcely private] > > > > On 5/26/05, John Machin <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > > > I am running two functions in a row that do the same thing. > > > > 1. I see no functions here. > > > > You should set out a script like this: > > > > def main(): > > your_code_goes_here() > > > > if __name__ == '__main__': > > main() > > > > for two reasons (a) your code will be referring to locals instead of > > globals; this is faster, which might appeal to you (b) if somebody > > accidentally imports the script, nothing happens. > > Oops, I meant code blocks not functions. Good advice, thanks. > > > 2. The two loops to which you refer do *not* do the same thing; see > later. > > > > > General questions: what platform? what version of Python? how large is > > the file? how much free memory do you have? how many passwords are > > there? what is the average length of a password? > > OS X 10.4.1Python 2.3.5 (I wonder why they bundled an old > version..) The file is 4 megs, about 8000 passwords. I have 375 megs > of RAM free. the passwords are mostly about 5-6 chars long. Huh-uh -- evidently (from what you said later) a *GUESS* on the password size; measurement on the actual file that you were using would have given the answer "Oops, mean = 32, standard dev = 0". > > > > Ignoring the superficial-but-meaningless differences (i vs j, md5 > > [aarrgghh!!] vs m), jo vs join), these two loops differ in the > following > > respects: > > Sorry, I wrote a nicer version of the program with things named well, > but it was only getting the fast time, so I copied it into the old > version of the program and then I had to write join=jo etc to avoid > changing it. Avoid changing what? And did you get the message that doing (in effect) import md5 m = md5.new md5 = m is a horrifyingly dangerous disgusting and ugly stunt? > > > > > (1) 'data' is a copy of 'a' > > (2) the first loop's body is effectively: digest = RHS; LHS = digest > > whereas the 2nd loop's body is: LHS = RHS > > (3) the first loop uses starts[j]+1 whereas the second loop uses > starts[j] > > oops, 3 is because the nicer version created a slightly different index > list. Hey, turns out that matters (see end) > > > Item (1) may affect the timing if file is large compared with available > > memory -- could be 'a' has to be swapped out, and 'data' swapped in. > > > > Item (2) should make the 2nd loop very slightly faster, so we'll ignore > > that :-) > > yeah > > > Item (3) means you are not comparing like with like. It means that the > > 1st loop has less work to do. So this could make an observable > > difference for very short passwords -- but still nothing like 0.14 > > compared with 56. > > > > So, some more questions: > > > > The 56.56 is suspiciously precise -- you ran it a few times and it > > printed exactly 56.56 each time? > > No, it got 55 or 56 something. > > > > > Did you try putting the 2nd loop first [refer to Item (1) above]? > > Yes, that didn't change which was fast. > > > Did you try putting in a switch so that your script runs either 1st > loop > > or 2nd loop but not both? > > No, good idea. OK tried it, and it didn't change how fast > each loop ran. I also changed it so they both work on the same list in > the version with a switch, and that didn't matter. > > > Note that each loop is making its target list > > expand in situ; this may after a while (like inside loop 2) cause the > > memory arena to become so fragmented that swapping will occur. This of > > course can vary wildly depending on the platform; Win95 used to be the > > most usual suspect but you're obviously not running on that. > > Nod > > > Some observations: > > > > (1) 's' is already a string, so ''.join(s[x:y]) is a slow way of doing > > s[x:y] > > Oops! That happened because it used to be ''.join(the_list[x:y]) but > then i realised i could just grab sections of the original string but > didn't fully change it. > > > (2) 'a' ends up as a list of one-byte strings, via a very circuitous > > process: a = array.array('c', s).tolist() > > > > A shorter route would be: a = list(s) > > Oh cool. I looked for a string-to-list function a little, but didn't > find that. I thought I tried that exact one too, but I guess not. Be aware of list comprehensions; when list(s) escaped your scan of the manuals, you could have done this: a = [x for x in s] NOTE: a string is an iterable! (see later) > > > However what's wrong with what you presumably tried out first i.e. a = > > array.array('c', s) ?? It doesn't need the final ''.join() before > > writing to disk, and it takes up less memory. > > The problem was I couldn't put the new passwords in as a single > element. Indeed. It's annoying enough th
Re: Pyrex: step in for loop
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 | so it's | | for i in range(8, 14, 1): ... | | http://enigmail.mozdev.org iD8DBQFClkmlHn4UHCY8rB8RAlUqAKCxSEkEKVIcoshTwmL7GQNK6d/j0wCgoC67 jOhuXQpnDt23SEAM9huKTQA= =8XO0 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
ftplib fails when directory name contains spaces
Hi, ftplib fails to cwd into a directory which contains spaces in it's name.How do i correct this? Regards Manu -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex: step in for loop
"Luis P. Mendes" <[EMAIL PROTECTED]> writes: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi, > > I'm trying to improve speed in a module and substituted the pythonic > 'for in range()' for 'for i from min < i < max:' > > But, I need to define a step for the i variable. How can I do it? > > for example, how do I iterate through 8 to 14 with step 1? guru% pydoc range Help on built-in function range in module __builtin__: range(...) range([start,] stop[, step]) -> list of integers Return a list containing an arithmetic progression of integers. range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0. When step is given, it specifies the increment (or decrement). For example, range(4) returns [0, 1, 2, 3]. The end point is omitted! These are exactly the valid indices for a list of 4 elements. so it's for i in range(8, 14, 1): ... http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: concurrent access to object file
"Frank Abel" <[EMAIL PROTECTED]> writes: > Hi again! > > I will make the question more simple: > > If two call to the "write" method of a file object "occur simultaneously " > is totally sure that the data of each call is writen successive or exist the > posibility of merge data? Youv'e asked this before and failed to get an answer. I think you failed to get an answer because there isn't a definitive one. fileobject.c passes calls to the the write method to the C library fwrite call. How that behaves under simultanious access depends on the library implementation, and that probably depends on the underlying OS. On Unix, that probably depends on how you got the file descriptors the two file objects are using for I/O. > where I can find information about this? Check the C and system library documentation for the platform you're running on. If you want to make your code portable, don't do this. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption with Python?
Christos "TZOTZIOY" Georgiou <[EMAIL PROTECTED]> writes: > That's all. I see you took up the challenge and indirectly replied to > my last question, and in good spirit I say you earned a little respect > from me, at least for standing up to your words. Now I hope no-one > gives a try to your data (for your own sake :) I don't think the challenge was really accepted. The algorithm changed between when you issued the challenge, and when the sensitive data went up. A good algorithm doesn't need to change depending on the data. I agree with the poster who said that the strength of either one of the algorithms is irrelevant, if the keyspace is just 32 bits. -- http://mail.python.org/mailman/listinfo/python-list
Re: staticmethod and classmethod
[Bruno Desthuilliers] > C Gillespie a écrit : > > Does anyone know of any examples on how (& where) to use > > staticmethods and classmethods? > Here's an example from a ldap lib [...] I recently had a use case for class methods while converting a PL/I program to Python: a lot of global declarations, where in many cases, procs could be regrouped around well identified subsets of globals. The idea is to create a class for each related group of globals. The global declarations themselves become class variables of that class, and related procs become class methods meant to act on these class variables. For best clarity and legibility while doing so, one should use all lowercase class names in such cases, and use `self' instead of `cls' for the first formal argument of class methods[1]. Then, one use these classes as if they were each the single instance of a similar class with usual methods. If one later changes his/her mind and wants more usual objects, and not allocated statically (!), merely remove all classmethod declarations, capitalise the first letter of class names, and create one instance per class into the all lowercase name of the class. That's seemingly all. -- [1] I already found out a good while ago, in many other cases unrelated to this one, but notably in metaclasses, that `self' is often (not always) clearer than `cls'. Classes are objects, too! :-) -- François Pinard http://pinard.progiciels-bpi.ca -- http://mail.python.org/mailman/listinfo/python-list
Re: overflowerror!!
I tried that. Still get an Overflowerror: unsigned long is less than minimum. -Ashton -- http://mail.python.org/mailman/listinfo/python-list
Re: Self-modifying Code
Steven D'Aprano a écrit : (snip) > Having said that, here is a good example of self-modifying code: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68429 > > The RingBuffer class dynamically modifies itself once it is full so that > its behaviour changes. > This is nothing more than a pythonic implementation of the state pattern. I would not call this "self-modifying code", since the code itself is not modified. -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
Mike Meyer wrote: > "Elliot Temple" <[EMAIL PROTECTED]> writes: >> Also, why aren't there >>multiline comments? Would adding them cause a problem of some sort? > > Because no one every really asked for them. After all, there are two > formats for multi-line strings, which the interpreter will build and > then discard. There are tools that recognize multi-line strings after > function/method definitions and treat them as function documentation. > > Adding multiline comments probably wouldn't be a problem - you'd just > have to come up with an introductory character sequence that can't > occur in the language (not that that stopped C). But you'd have to get > someone to write the code, then someone with commit privs to decide it > was useful enough to commit. That seems to be a lot of work for very > little gain. Don't we already have multi-line comments in the form of string literals? -- Paul McNett http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Problem accessing Python Business Forum
Every time I attempt to look at the Python Business Forum (www.python-in-business.org), I encounter an error that starts like this: Site Error An error was encountered while publishing this resource. KeyError Sorry, a site error occurred. Traceback (innermost last): Module ZPublisher.Publish, line 150, in publish_module I thought it might be temporary, but I have encountered the same error for a couple of weeks. I know other parts of the Python Business Forum site work since I have been sent links to the European PyCon 2005 for example. Is there another URL for the Python Business Forum that has a site map or something similar? I am guessing someone has had and been given an answer to the problem I am having, but I have not been able to locate it. I did a search of this forum, but almost all references to "Python Business Forum" were in Dr. Dobbs postings. Thanks for your help, John -- http://mail.python.org/mailman/listinfo/python-list
Pyrex: step in for loop
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm trying to improve speed in a module and substituted the pythonic 'for in range()' for 'for i from min < i < max:' But, I need to define a step for the i variable. How can I do it? for example, how do I iterate through 8 to 14 with step 1? Luis -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFClkGTHn4UHCY8rB8RAgZXAJ0XPg9IH0OU329FVX3o14QjNFXuXgCgm+UR O0GpXmDpQr7Y7TgMsmVvZ6s= =zZnm -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption with Python?
On Tue, 24 May 2005 10:16:15 +0200, rumours say that "Anthra Norell" <[EMAIL PROTECTED]> might have written: >Why whack someone over the head who tries to develop an idea of his own. >Such an approach isn't uncommon to earn extra credit in educational >settings. I would never whack someone over the head (WSOTH) who tries to develop an idea of his own, and never will (intentionally at least --I myself like reinventing the wheel once in a while just to make sure my synapses still work). However I do WSOTH for >>I rolled my own for relatively short sequences, like passwords. The key is >>an integer. To decrypt use the negative encryption key. I consider the >>encryption unbreakable, as it is indistinguishable from a random sequence. So, to be clear, my reason was your declaring that "I consider the encryption unbreakable, as it...", and that is why I actually challenged you to either support the unbreakability of your algorithm by supplying sensitive data for you, or back off and simply say "ok guys, my words were a *little* over the top". That's all. I see you took up the challenge and indirectly replied to my last question, and in good spirit I say you earned a little respect from me, at least for standing up to your words. Now I hope no-one gives a try to your data (for your own sake :) -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: overflowerror!!
[EMAIL PROTECTED] wrote: > Hello, > I am trying to fill in a dword value into an array and i get an > overflowerror > > Here's what iam trying to do. > > from array import * > data = array('B', '\0' * 256) > > val = 0x > > for i in range(256): > data[i] = val > > print data > > How do i fill in the val 256 times into the array? 'B' creates bytes, and a byte can only store numbers in the range 0 to 255. Try using 'L' when creating your array. Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz" ] ) -- http://mail.python.org/mailman/listinfo/python-list
overflowerror!!
Hello, I am trying to fill in a dword value into an array and i get an overflowerror Here's what iam trying to do. from array import * data = array('B', '\0' * 256) val = 0x for i in range(256): data[i] = val print data How do i fill in the val 256 times into the array? -Ashton -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
"Elliot Temple" <[EMAIL PROTECTED]> writes: > Hi I have two questions. Could someone explain to me why Python is > case sensitive? I find that annoying. Because it comes from a language background of case sensitive languages (C, shell, etc.). But read what the BDFL has to say about it: http://mail.python.org/pipermail/python-list/2001-July/054788.html > Personally, I think anyone who has two variables whose names differ only in case should be shot. No, let me extend that - anyone who has two variables whose names would be pronounced the same should be shot. I've had to debug such code, and it ain't fun. Variables whose name differs from the class they are instance of only in case is the only allowable exception. And should be used with care. On the same note, anyone who spells a variable name with different cases because the languge is case-insensitive should be shot. I want to be able to use various source analysis tools without having to worry about dealing with two different ascii strings being names for a single variable. Add those two together, and you'll see that *I don't care*. I consider taking advantage of a language being case-sensitive or case-insensitive to be a bad idea, so it doesn't matter what the language does. > Also, why aren't there > multiline comments? Would adding them cause a problem of some sort? Because no one every really asked for them. After all, there are two formats for multi-line strings, which the interpreter will build and then discard. There are tools that recognize multi-line strings after function/method definitions and treat them as function documentation. Adding multiline comments probably wouldn't be a problem - you'd just have to come up with an introductory character sequence that can't occur in the language (not that that stopped C). But you'd have to get someone to write the code, then someone with commit privs to decide it was useful enough to commit. That seems to be a lot of work for very little gain. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
concurrent access to object file
Hi again! I will make the question more simple: If two call to the "write" method of a file object "occur simultaneously " is totally sure that the data of each call is writen successive or exist the posibility of merge data? where I can find information about this? Thank in advance Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
Kent Johnson wrote: > VK wrote: > >>> On Thu, 26 May 2005 14:33:45 +0200, VK <"myname"@example.invalid> >>> declaimed the following in comp.lang.python: >>> >>> Hi, all! In my programm i have to insert a variable from class 2 to class 1 and I get error NameError: global name 'd' is not defined. How do I get access to d.entry.insert() method of class 1 > > >> >> from Tkinter import * >> >> class First: >> def __init__(self): >> self.root = Tk() # create window contents as children to >> root.. >> self.entryframe = Frame(self.root) >> self.entryframe.pack(fill=BOTH,expand=1) >> >> self.entry = Entry(self.entryframe) >> self.entry.pack(side=TOP,expand=1,fill=BOTH) >> self.entry.focus() >> self.entry.bind('',(lambda event: self.fetch())) # >> on enter key >> >> self.button = >> Button(self.entryframe,text="Call",command=self.getvar) >> self.button.pack(side=LEFT,expand=YES,fill=BOTH) >> >> self.root.mainloop() >> >> def fetch(self): >> print 'Input => "%s"' % self.entry.get() # get text form >> entry >> >> def getvar(self,event=0): >> c=Second(self,self.root) >> >> >> >> class Second: >> def __init__(self,parent,s="thing"): >> self.root = Tk() >> self.ent = Entry(self.root) >> self.ent.pack() >> self.btn = Button(self.root,text='Fetch',command=self.fetch) >> self.btn.pack(side=RIGHT) >> def fetch(self): >> text = self.ent.get() # get text form entry in this window >> d.entry.insert(0, text)# must insert in other window >> >> d = First() #First window > > > The problem is that First.__init__() never returns so the instance of > First is never bound to d. Take the line > self.root.mainloop() > out of First.__init__() and and the line > d.root.mainloop() > > at the end of the program and it will work as you expect. > > Kent O, God! It works! Thousend of thanks! By the way, the second window appears not activ, is there an option to make it activ on start? Reg,VK -- http://mail.python.org/mailman/listinfo/python-list
Re: using timeit for a function in a class
flupke wrote: > > Hi, > > i tried to use timeit on a function in a class but it doesn't do what i > think it should do ie. time :) > In stead it starts printing line after line of hello time test! > What am i doing wrong in order to time the f function? Hmm, by default Timer.timeit() calls the function being timed 100 times. That's a lot of "hello time test" =:-) Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: staticmethod and classmethod
C Gillespie a écrit : > Hi, > > Does anyone know of any examples on how (& where) to use staticmethods and > classmethods? > Here's an example from a ldap lib (work in progress, not finished, and all other disclaimers). The class methods are here: # -- # Base class for LDAP Objects # -- class LdapObject(object): """ Base class for LDAP data objects. """ (snip) # -- def query_class(cls): return "(objectClass=%s)" % cls.query_object_class query_class = classmethod(query_class) # -- def query_id(cls, ldap_id): return "(& %s (%s=%s))" % (cls.query_class(), cls.id_attribute, ldap_id) query_id = classmethod(query_id) # -- def query(cls, filters=None): if filters is None: return cls.query_class() else: return cls._decorate_query(filters(cls)) query = classmethod(query) # -- def _decorate_query(cls, query): return "(& %s %s)" % (cls.query_class(), query) _decorate_query = classmethod(_decorate_query) class LdapContact(LdapObject): """ Wraps a MozillaAbPersonObsolete/OpenLDAPperson entry. """ # ldap objectClass(es) object_classes =('OpenLDAPperson', 'MozillaAbPersonObsolete', ) # which one we'll use for queries query_object_class = 'MozillaAbPersonObsolete' id_attribute = 'uid' sort_keys = ('displayName',) (snip) They are used here (LdapItemKlass is supposed to be a subclass of LdapObject, like LdapContact above): # -- # The LdapConnection itself. # -- class LdapConnection(object): (snip) # -- def list_items(self, ldapItemKlass, sort_keys=None, filters=None): items = [ldapItemKlass(self, entry) \ for entry in self._search( \ ldapItemKlass.query(filters, match_op) \ )] if sort_keys is None: sort_keys = ldapItemKlass.sort_keys return self.sort(items, sort_keys) # -- def get_item(self, ldapItemKlass, ldap_id): entry = self._get_item(ldapItemKlass, ldap_id) if entry is not None: entry = ldapItemKlass(self, entry) return entry (snip) And client code may look like this (LdapContact being a subclass of LdapObject): cnx = LdapConnection(...).connect() all_contacts = cnx.list_items(LdapContact) someone = cnx.get_item(LdapContact, 'uid=someone') Since we don't have any instance before running the query, we can't use instance methods... Still, most of the knowledge required to build the appropriate query belongs to the LdapContact (or whatever) class. HTH Bruno -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
VK wrote: >> On Thu, 26 May 2005 14:33:45 +0200, VK <"myname"@example.invalid> >> declaimed the following in comp.lang.python: >> >> >>> Hi, all! >>> >>> In my programm i have to insert a variable from class 2 to class 1 >>> and I get error NameError: global name 'd' is not defined. How do I >>> get access to d.entry.insert() method of class 1 > > from Tkinter import * > > class First: > def __init__(self): > self.root = Tk() # create window contents as children to > root.. > self.entryframe = Frame(self.root) > self.entryframe.pack(fill=BOTH,expand=1) > > self.entry = Entry(self.entryframe) > self.entry.pack(side=TOP,expand=1,fill=BOTH) > self.entry.focus() > self.entry.bind('',(lambda event: self.fetch())) # > on enter key > > self.button = > Button(self.entryframe,text="Call",command=self.getvar) > self.button.pack(side=LEFT,expand=YES,fill=BOTH) > > self.root.mainloop() > > def fetch(self): > print 'Input => "%s"' % self.entry.get() # get text form entry > > def getvar(self,event=0): > c=Second(self,self.root) > > > > class Second: > def __init__(self,parent,s="thing"): > self.root = Tk() > self.ent = Entry(self.root) > self.ent.pack() > self.btn = Button(self.root,text='Fetch',command=self.fetch) > self.btn.pack(side=RIGHT) > def fetch(self): > text = self.ent.get() # get text form entry in this window > d.entry.insert(0, text)# must insert in other window > > d = First() #First window The problem is that First.__init__() never returns so the instance of First is never bound to d. Take the line self.root.mainloop() out of First.__init__() and and the line d.root.mainloop() at the end of the program and it will work as you expect. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Execution Times
hey FYI i found the problem: i accidentally copied an output file for my test data. so all the passwords were exactly 32 chars long. so when replacing them with new 32 char passwords, it went much much faster, I guess because the list kept the same number of chars in it and didn't have to copy lots of data around. -- http://mail.python.org/mailman/listinfo/python-list
Re: "...Learning with Python" ...a property that addition andmultiplication have...
GMane Python wrote: > string repetition can not repeat a value negative times: > 'hello' * -3 is invalid. Well, it's not invalid: py> 'a' * -1 '' py> 'a' * -42 '' but you could definitely say that S * N1 == S * N2 does not imply that N1 == N2 STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: vim configuration for python
In comp.editors DJK <[EMAIL PROTECTED]> wrote: > Does anybody know of any scripts to check python syntax when you type > :make? The problem I had doing this with Python was that the Python interpreter spits out errors in the opposite order from that in which I wanted to traverse them in vim's quickfix error list. I wrote the following compiler file and helper script to work around this. I don't use Python very often and haven't used in it a while, so this still isn't very polished, but you might find it useful anyway. Note also that I did this on a Unix system. - compiler/python.vim -- " Vim compiler file " Compiler: Python " Maintainer: Gary Johnson <[EMAIL PROTECTED]> " Last Change: 2002-06-26 00:27:56 if exists("current_compiler") finish endif let current_compiler = "python" setlocal makeprg=python\ % setlocal shellpipe=2>&1\ \|\ ~/.vim/tools/efm_filter.py\ \|\ tee " Note: efm_filter.py could be rewritten to send its input to stdout " and to write its output to the file given on the command line. This " way the user could see the familiar output from Python while the " quickfix error file received the format the vim can understand. E.g., " " setlocal shellpipe=2>&1\ \|\ ~/.vim/tools/efm_filter.py " " or " " setlocal shellpipe=2>&1\ \|\ tee\ /dev/tty\ \|\ ~/.vim/tools/efm_filter.py setlocal errorformat=\ \ File\ \"%f\"\\,\ line\ %l\\,\ in\ %*[^\\,]\\,\ %m - tools/efm_filter.py -- #!/usr/bin/env python import sys import string errors = sys.stdin.readlines() message = errors.pop()[:-1] errors.reverse() for error in errors: if string.find(error, ' File') == 0: print error[:-1] + ", " + message message = "Traceback" To use these, put them in the indicated directories under ~/.vim and execute ":compiler python". Also see ":help compiler". HTH, Gary -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
Roy Smith a écrit : > bruno modulix <[EMAIL PROTECTED]> wrote: > >>I've always explicitelly used the (implied) 'this' pseudo-pointer in >>Java, C++ etc. The wart is in all those languages that don't makes it >>mandatory IMHO !-) > > > And the correlary wart in Python is that the first argument to a > method is not required to be called "self". Well, I would not call this a wart. Because when it's a class method, naming the fisrt param 'cls' could seem more appropriate !-) > The vast majority of > people use "self", but every once in a great while you run into some > yahoo who feels this is the right place to express his creativity and > call it "this", or "obj", or some other obfuscation. Then every python programmer in its own mind will throw away this code with mimics of disgust, and everything is fine. More seriously, I prefer to have some bozo using this instead of self - which I can easily correct if needed - than having to deal with implicit this in a whole code base... -- http://mail.python.org/mailman/listinfo/python-list
Re: Case Sensitive, Multiline Comments
Hi, A1: because some people find it very useful ? I know I do A2: they exist: """ Regards, Philippe Elliot Temple wrote: > Hi I have two questions. Could someone explain to me why Python is > case sensitive? I find that annoying. Also, why aren't there > multiline comments? Would adding them cause a problem of some sort? > > Thanks, > Elliot -- http://mail.python.org/mailman/listinfo/python-list
Re: Design problem...need some ideas
bump Anyone? I don't need code. Just widgets and a compass for the right direction. -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe problems with win32com [ EnsureDispatch('ADODB.Connection') ]
I'm not positive about this, but when using com you need to force it into the compile. In my applications where I use Excel I use this line: python setup.py py2exe --progid "Excel.Application" You may need to do something similar for the db application. -- http://mail.python.org/mailman/listinfo/python-list
Case Sensitive, Multiline Comments
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline comments? Would adding them cause a problem of some sort? Thanks, Elliot -- http://mail.python.org/mailman/listinfo/python-list
Re: os independent way of seeing if an executable is on the path?
Don wrote: > I wrote this 'which' function for Linux, but I think if you changed the ':' > character, it would work on Windows (I think its a ';' on Windows, but I > can't remember): Why remember when os.pathsep will do it for you. However, for windows you need a bit more: def which(command): win32 = sys.platform == 'win32' if win32: # Case-insesitive file names and file exts for commands try: knownexts = [''] + os.getenv('PATHEXT').split(os.pathsep) except AttributeError: knownexts = [''] else: knownexts = [ext.lower() for ext in knownexts] test = command.lower() tests = set(test + ext for ext in knownexts) else: tests = set([command]) for dirname in os.getenv('PATH').split(os.pathsep): try: files = os.listdir(dirname) except IOError: continue else: for name in files: if name in tests or win32 and name.lower() in tests: yield dirname, name --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: "...Learning with Python" ...a property that addition and multiplication have...
[EMAIL PROTECTED] writes: > question is, "Can you think of a property that addition and > multiplication have that string concatenation and repetition do not?" > > I thought it was the commutative property but ""*3 is > equivalent to 3*"". Any ideas? Um, string concatenation is not commutative. "a"+"b" is not the same as "b"+"a". -- http://mail.python.org/mailman/listinfo/python-list
Re: os independent way of seeing if an executable is on the path?
On Thu, 26 May 2005 11:53:04 -0700, Don <[EMAIL PROTECTED]> wrote: >Steven Bethard wrote: > >> This has probably been answered before, but my Google skills have failed >> me so far... >> >> Is there an os independent way of checking to see if a particular >> executable is on the path? Basically what I want to do is run code like: >> i, o, e = os.popen3(executable_name) >> but I'd like to give an informative error if 'executable_name' doesn't >> refer to an executable on the path. >> >> [snip] >> >> Thanks for the help, >> >> STeVe > >I wrote this 'which' function for Linux, but I think if you changed the ':' >character, it would work on Windows (I think its a ';' on Windows, but I >can't remember): > >def which( command ): >path = os.getenv( 'PATH' ).split( ':' ) >found_path = '' >for p in path: >try: >files = os.listdir( p ) >except: >continue >else: >if command in files: >found_path = p >break > >return found_path > Here's the version that comes with Twisted: import os, sys, imp def which(name, flags=os.X_OK): """Search PATH for executable files with the given name. @type name: C{str} @param name: The name for which to search. @type flags: C{int} @param flags: Arguments to L{os.access}. @rtype: C{list} @param: A list of the full paths to files found, in the order in which they were found. """ result = [] exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep)) for p in os.environ['PATH'].split(os.pathsep): p = os.path.join(p, name) if os.access(p, flags): result.append(p) for e in exts: pext = p + e if os.access(pext, flags): result.append(pext) return result Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: win32clipboard.GetClipboardData() return string with null characters
It appears to me that some applications put extra garbage data into the clipboard. win32clipboard may have faithfully returning all of them. I use this application to show the clipboard content: import win32clipboard, win32con def getWinClipboardText(): win32clipboard.OpenClipboard() d=win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return d print getWinClipboardText().encode('string_escape') For example, copying the Python banner from the windows console gets me this output. Notice the \x00 and garbage characters after that. -- Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32\r\nType "help", "copyright", "credits" or "lic ense" for more information.\x00\n ?? -- Some applications appear to put clean data in the clipboard always: Opera, Putty, Outlook Some applications appear to include \0 and other crap: cmd.exe, powerpoint, EmEditor.exe When I paste, it never appears to be any problem that there maybe garbage characters in the clipboard. Guess most C based program correctly null terminates the string. -- http://mail.python.org/mailman/listinfo/python-list
Re: os independent way of seeing if an executable is on the path?
> > In Windows, I can read the error file, and get something like: > > "'' is not recognized as an internal or external > > command,\noperable program or batch file.\n" > > and I'm sure I could parse this, but this seems fragile, and clearly os > > dependent. http://starship.python.net/crew/tmick/#which I have a 'which' implementation that looks up a command-line program name in the same way that Windows' process launching does at the shell (when on Windows) and in the same way the usual 'which' executable does on Un*x (when on Un*x). Trent -- Trent Mick [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: "...Learning with Python" ...a property that addition andmultiplication have...
The inablility to work with negative values. Addition can do the following: 5 + (-4) read as 5 plus the value negative four. Multiplication can do the following: 5 * (-1) read as 5 times the value negative one. String concatination can not subtract the sub-string 'lo' from 'hello'. 'hello' - 'lo' is invalid. string repetition can not repeat a value negative times: 'hello' * -3 is invalid. 'hello' * 2.75 is also invalid, in that you can not repeat a fractional amount. -Dave (Python Newbie) <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings. > > I'm reading "How to think like a computer scientist: Learning with > Python" and there's a question regarding string operations. The > question is, "Can you think of a property that addition and > multiplication have that string concatenation and repetition do not?" > > I thought it was the commutative property but ""*3 is > equivalent to 3*"". Any ideas? > > Thanks, > > Jeff > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: os independent way of seeing if an executable is on the path?
Steven Bethard wrote: > This has probably been answered before, but my Google skills have failed > me so far... > > Is there an os independent way of checking to see if a particular > executable is on the path? Basically what I want to do is run code like: > i, o, e = os.popen3(executable_name) > but I'd like to give an informative error if 'executable_name' doesn't > refer to an executable on the path. > > The idea is to differentiate between errors generated by not being able > to run the program, and errors generated while running the program. The > former is a probably a configuration error by my user, the second is > probably a logic error in my code (or perhaps an error on the executable > I'm calling). > > In Windows, I can read the error file, and get something like: > "'' is not recognized as an internal or external > command,\noperable program or batch file.\n" > and I'm sure I could parse this, but this seems fragile, and clearly os > dependent. > > It's not crucial that I use os.popen3 as long as I have access to the > input, output and error files. I played around with subprocess for a > while, but couldn't see any way to do this using that module either. > > Thanks for the help, > > STeVe I wrote this 'which' function for Linux, but I think if you changed the ':' character, it would work on Windows (I think its a ';' on Windows, but I can't remember): def which( command ): path = os.getenv( 'PATH' ).split( ':' ) found_path = '' for p in path: try: files = os.listdir( p ) except: continue else: if command in files: found_path = p break return found_path -Don -- http://mail.python.org/mailman/listinfo/python-list
[ANNOUNCE] Twenty-fifth release of PythonCAD now available
I'm pleased to announce the twenty-fifth development release of PythonCAD, a CAD package for open-source software users. As the name implies, PythonCAD is written entirely in Python. The goal of this project is to create a fully scriptable drafting program that will match and eventually exceed features found in commercial CAD software. PythonCAD is released under the GNU Public License (GPL). PythonCAD requires Python 2.2 or newer. The interface is GTK 2.0 based, and uses the PyGTK module for interfacing to GTK. The design of PythonCAD is built around the idea of separating the interface from the back end as much as possible. By doing this, it is hoped that both GNOME and KDE interfaces can be added to PythonCAD through usage of the appropriate Python module. Addition of other PythonCAD interfaces will depend on the availability of a Python module for that particular interface and developer interest and action. The twenty-fifth release consists primarily of bug fixes. The compatibility code for the GTK Action and ActionGroup classes introduced in the previous release had a number of bugs which have been fixed. People running PythonCAD on PyGTK releases prior to 2.4 should find this latest release working correctly due to these fixes. Thanks go to Wilbert Knol for helping identify and test the proposed fixes for this problem. A number of changes to the event handling code also are include in this release. Previously various event handling routines either returned an incorrect value, or returned a value when not needed. This release cleans up many of these issues, making the event handling code easier to follow as well as better conforming to GTK/PyGTK requirements. Various other bug fixes and code enhancements are present in this release as well. A mailing list for the development and use of PythonCAD is available. Visit the following page for information about subscribing and viewing the mailing list archive: http://mail.python.org/mailman/listinfo/pythoncad Visit the PythonCAD web site for more information about what PythonCAD does and aims to be: http://www.pythoncad.org/ Come and join me in developing PythonCAD into a world class drafting program! Art Haas -- Man once surrendering his reason, has no remaining guard against absurdities the most monstrous, and like a ship without rudder, is the sport of every wind. -Thomas Jefferson to James Smith, 1822 -- http://mail.python.org/mailman/listinfo/python-list
Re: Intellisense and the psychology of typing
On 5/26/2005 12:31, [EMAIL PROTECTED] wrote: > 1) Intellisense is really just another crutch that does more harm than > good? To me I found the intellisense in VS for C++ was somewhat helpful in my earliest stage of learning where I had to look up how many args a function had. After a while, I found it more convenient to just keep the VS language and std lib docs open in another window. IOW, it started getting in the way. Maybe at times it can save some keystrokes but I kept finding a pattern of start typing something...down arrow...down arrow...down arrow...down arrow...tab...type args. Even worse is the situation were start typing something...downWhoops hit left arrow...hit end...hit backspace...type last letterdown arrow...etc...tab...etc... How egregious!? No thank you; I already use variable names like "myData" instead of "mD" so extra keystrokes are not that big of a deal :) Still I think calling it a crutch might be a bit extreme. Is a book or documentation a crutch too? > 2) Intellisense is really useful but hard to implement well in IDEs for > dynamic languages? Maybe for some people and yes. There was some recent discussion in this very NG about this WRT vim et al. Cheers, ~Jason -- Posted Via Usenet.com Premium Usenet Newsgroup Services -- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** -- http://www.usenet.com -- http://mail.python.org/mailman/listinfo/python-list
Re: converting jpg to pdf
You use PIL (Python Imaging Library) if you want simple conversion or ReportLab if you want to combine several along with text, etc. -larry Raghul wrote: > Hi friends > Is it possible to convert jpg to pdf in python. I need a > program to convert jpg format file to pdf. Is there any sample or any > library to do that? Pls guide me. > > Thanks in advance > -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 and SSL
rbt <[EMAIL PROTECTED]> writes: > Thanks for the tip... how *does* all of the other Win32 apps handle > SSl w/o installing OpenSSL? Do they bundle it and only use it for > themselves? That seems foolish. Mozilla has its own SSL stack. IE uses one built into wininet, I think. -- http://mail.python.org/mailman/listinfo/python-list
Re: [PATCH] add offset argument to mmap
Christopher Li wrote: > I am surprised to find out the mmap module in python always > mmap from offset 0. So I just hack up some patch to allow it > accept offset arguments. patches posted to the newsgroup are likely to be ignored or forgotten. patches posted to the patch tracker http://sourceforge.net/tracker/?group_id=5470&atid=305470 are a lot more likely to be reviewed and included. -- http://mail.python.org/mailman/listinfo/python-list
Re: File list from listdir or shell?
[EMAIL PROTECTED] wrote: > Unluckily, to capture the stdout I have to redirect it to a file... > I hoped that this could work ... > lF=sys.stdin.readline(os.system("ls -1 *.py")) hint: look up "os.popen" and "subprocess" in the library reference. -- http://mail.python.org/mailman/listinfo/python-list
Re: Store doctest verbose results to a variable
"mitchell" <[EMAIL PROTECTED]> wrote: > Is it possible to store doctest's verbose output to a variable? > > For example: > > import doctest, my_test_module > a = doctest.testmod(my_test_module) > > The contents of 'a' is the tuple of passed and failed results. I tried > passing verbose mode to the testmod function, but 'a' is still a tuple. > > Any help is greatly appreciated. the third example on this page http://effbot.org/librarybook/stringio.htm shows one way to do that. -- http://mail.python.org/mailman/listinfo/python-list
[PATCH] add offset argument to mmap
I am surprised to find out the mmap module in python always mmap from offset 0. So I just hack up some patch to allow it accept offset arguments. So here it is. Chris Add optional offset argument to mmap module. Test on linux with Python 2.4. The windows code is totally untested. Signed-Off-by: Christopher Li <[EMAIL PROTECTED]> Index: Modules/mmapmodule.c === --- Modules.orig/mmapmodule.c 2004-05-19 10:39:08.0 -0400 +++ Modules/mmapmodule.c2005-05-26 10:01:51.0 -0400 @@ -853,14 +853,17 @@ mmap_object *m_obj; PyObject *map_size_obj = NULL; int map_size; + unsigned long offset = 0; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; access_mode access = ACCESS_DEFAULT; char *keywords[] = {"fileno", "length", "flags", "prot", - "access", NULL}; + "access", "offset", + NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords, -&fd, &map_size_obj, &flags, &prot, &access)) + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iiil", keywords, +&fd, &map_size_obj, &flags, &prot, +&access, &offset)) return NULL; map_size = _GetMapSize(map_size_obj); if (map_size < 0) @@ -910,7 +913,7 @@ m_obj->fd = fd; m_obj->data = mmap(NULL, map_size, prot, flags, - fd, 0); + fd, offset); if (m_obj->data == (char *)-1) { m_obj->data = NULL; Py_DECREF(m_obj); @@ -929,6 +932,7 @@ mmap_object *m_obj; PyObject *map_size_obj = NULL; int map_size; + unsigned long offset = 0; char *tagname = ""; DWORD dwErr = 0; int fileno; @@ -939,9 +943,9 @@ "tagname", "access", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zil", keywords, &fileno, &map_size_obj, -&tagname, &access)) { +&tagname, &access, &offset)) { return NULL; } @@ -1040,8 +1044,8 @@ if (m_obj->map_handle != NULL) { m_obj->data = (char *) MapViewOfFile (m_obj->map_handle, dwDesiredAccess, - 0, - 0, + offset>>32, + (unsigned int)offset, 0); if (m_obj->data != NULL) { return ((PyObject *) m_obj); -- http://mail.python.org/mailman/listinfo/python-list
Majordomo results: {Filename?} HELLO
Warning: This message has had one or more attachments removed The command "Warning:" is invalid. Use the "help topics" command to see a list of valid commands. Discarded 3 line(s) of unrecognized text. Valid commands processed: 0 0 succeeded, 0 stalled, and 0 failed. Use the following command: sessioninfo 7c7fbce6ff86a1aaf1eee4f0007353797e927866 to see technical information about this session. This is a message from the MailScanner E-Mail Virus Protection Service The command "This" is invalid. Use the "help topics" command to see a list of valid commands. -- Stopping at signature separator. No more commands will be processed. -- http://mail.python.org/mailman/listinfo/python-list
os independent way of seeing if an executable is on the path?
This has probably been answered before, but my Google skills have failed me so far... Is there an os independent way of checking to see if a particular executable is on the path? Basically what I want to do is run code like: i, o, e = os.popen3(executable_name) but I'd like to give an informative error if 'executable_name' doesn't refer to an executable on the path. The idea is to differentiate between errors generated by not being able to run the program, and errors generated while running the program. The former is a probably a configuration error by my user, the second is probably a logic error in my code (or perhaps an error on the executable I'm calling). In Windows, I can read the error file, and get something like: "'' is not recognized as an internal or external command,\noperable program or batch file.\n" and I'm sure I could parse this, but this seems fragile, and clearly os dependent. It's not crucial that I use os.popen3 as long as I have access to the input, output and error files. I played around with subprocess for a while, but couldn't see any way to do this using that module either. Thanks for the help, STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Intellisense and the psychology of typing
my opinion is that if you find it useful, use it. if you don't then don't... either way, its up to you to decide what's useful and what's not. don't ask us. Try it out yourself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
> On Thu, 26 May 2005 14:33:45 +0200, VK <"myname"@example.invalid> > declaimed the following in comp.lang.python: > > >>Hi, all! >> >>In my programm i have to insert a variable from class 2 to class 1 and I >>get error NameError: global name 'd' is not defined. How do I get access >>to d.entry.insert() method of class 1 >> >>class 1: > >Does Python even allow numeric class names? :-D don't know > > REAL code, stripped to the minimum that duplicates your problem, > is always better than pseudo-code... I thought that is it... > > >>self.entry = Entry(self.entryframe) >>self.entry.pack() >> >>self.button = Button(command = self.callclass2window) >> >>def callclass2window >> c = 2() >> >> >>class 2: >>def ins(self) > > NO : ??? > > >> d.entry.insert(variable) >> >> >>d = 1() > > > What, might I ask, does .insert() /do/ for an Entry() object? That insert text into entry object. > > As far as I can tell, "class 1" is creating some GUI button. > Pressing that button invokes your callclass2window(), which creates a > new "class 2" instance, and then throws it away. Yes, exactly > > Give us code that we can /run/ and we might be able to give you > an answer... I try: from Tkinter import * class First: def __init__(self): self.root = Tk() # create window contents as children to root.. self.entryframe = Frame(self.root) self.entryframe.pack(fill=BOTH,expand=1) self.entry = Entry(self.entryframe) self.entry.pack(side=TOP,expand=1,fill=BOTH) self.entry.focus() self.entry.bind('',(lambda event: self.fetch())) # on enter key self.button = Button(self.entryframe,text="Call",command=self.getvar) self.button.pack(side=LEFT,expand=YES,fill=BOTH) self.root.mainloop() def fetch(self): print 'Input => "%s"' % self.entry.get() # get text form entry def getvar(self,event=0): c=Second(self,self.root) class Second: def __init__(self,parent,s="thing"): self.root = Tk() self.ent = Entry(self.root) self.ent.pack() self.btn = Button(self.root,text='Fetch',command=self.fetch) self.btn.pack(side=RIGHT) def fetch(self): text = self.ent.get() # get text form entry in this window d.entry.insert(0, text)# must insert in other window d = First() #First window -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
On 5/26/05, VK <[EMAIL PROTECTED]> wrote: > That is not real code, only dummy describing the problem We realise that. The problem is that there are problems in your dummy in addition to the real problems, and we can't tell them apart. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Store doctest verbose results to a variable
Is it possible to store doctest's verbose output to a variable? For example: import doctest, my_test_module a = doctest.testmod(my_test_module) The contents of 'a' is the tuple of passed and failed results. I tried passing verbose mode to the testmod function, but 'a' is still a tuple. Any help is greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
> VK wrote: > >>Hi, all! >> >>In my programm i have to insert a variable from class 2 to class 1 and I >>get error NameError: global name 'd' is not defined. > > > Looking at your code snippet, I think you have a lot of other errors > before. > > >>class 1: >> self.entry = Entry(self.entryframe) > > NameError : self is not defined > > etc... > That is not real code, only dummy describing the problem -- http://mail.python.org/mailman/listinfo/python-list
Intellisense and the psychology of typing
Yesterday I typed in some C++ code that called a function with two ints. Intellisense (auto-complete) helpfully told me that the first formal parameter was called "frontLight" and the second "ringLight". It occurred to me that I'm getting some semantic help here on top of the obvious type safety. It seems to me that the existance of this kind of support is tied to the static typing nature of C++. I've always been interested in the psychology behind those heated "static" vs. "dynamic" (quotes to avoid another lengthy discussion about manifest, latent, explicit, ...) typing debates. So I googled "Intellisense static dynamic typing" and tried to get a view of the collective mental landscape of this subject. It appears that the threads that talk about Intellisense soon run dry. I'm wondering if this is because: 1) Intellisense is really just another crutch that does more harm than good? There were a few hardcore defenders of this position but not many. 2) Intellisense is really useful but hard to implement well in IDEs for dynamic languages? Can anyone comment on the status of Intellisense-like tools for dynamic-language IDEs? 3) Users of dynamic languages are always developing/debugging running programs where the current type of a variable is known and hence Intellisense is possible again? My own limited experience with dynamic languages (Ruby) is limited to edit-run cycles. Any opinions? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: Just remember that Python is sexy
Sion Arrowsmith wrote: >>The name index implies it returns something you can use as an index to >>get at the substring. > > Unfortunately, -1 can of course be used as an index. Mind you, it > would be perverse to expect to find the substring at it. > That was my point. The returned index always points at the substring, therefore the function which returns a -1 isn't returning an index. Therefore index must be the one which raises an exception. -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
VK wrote: > Hi, all! > > In my programm i have to insert a variable from class 2 to class 1 and I > get error NameError: global name 'd' is not defined. Looking at your code snippet, I think you have a lot of other errors before. > > class 1: >self.entry = Entry(self.entryframe) NameError : self is not defined etc... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
bruno modulix wrote: >Paul McNett wrote: > > >>Sriek wrote: >> >> >> >(snip) > > >>>Similarly, why do we have to explicitly use the 'self' keyword >>>everytime? >>>This is closer to a wart, IMO, >>> >>> > > > Here's one of the shorter threads discussing 'self'. I remember one long running thread, but can't seem to find it, at the minute http://groups.google.co.uk/group/comp.lang.python/browse_thread/thread/f28dea8d63ac44/a0c80d8b1c92101c?q=python++self+implicit&rnum=1&hl=en#a0c80d8b1c92101c J -- http://mail.python.org/mailman/listinfo/python-list
Re: Access from one class to methode of other class
VK wrote: >> I don't know if your're actually calling the classes '1' and '2', but >> that's a really bad idea! >> >> >>> class 2: >>> def ins(self) >>> d.entry.insert(variable) >> >> >> >> This is probably where you're getting the NameError. d is not defined, >> so calling d.entry will generate an error. >> > > What is d = 1() in my example then? a global variable. > And how do I solve this problem? passing d to the instance of 2 *could* be a solution. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
bruno modulix <[EMAIL PROTECTED]> wrote: > I've always explicitelly used the (implied) 'this' pseudo-pointer in > Java, C++ etc. The wart is in all those languages that don't makes it > mandatory IMHO !-) And the correlary wart in Python is that the first argument to a method is not required to be called "self". The vast majority of people use "self", but every once in a great while you run into some yahoo who feels this is the right place to express his creativity and call it "this", or "obj", or some other obfuscation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python analog of Ruby on Rails?
George Sakkis wrote: > "Christopher J. Bottaro" wrote: > > >>Cool signature, can anyone do a Python one that I can leech? =) >> >>-- C >> > > > Here's the transliteration in python for your address: > > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) > for p in '[EMAIL PROTECTED]'.split('@')])" BTW, here's the proper response to that religious thread that keeps invading this list: python -c 'print sum([ord(c) for c in "HOLYBIBLE"])' I'm Christian and I think it's funny. ;-) Some background: http://scriptures.lds.org/rev/13/16-18#16 http://www.greaterthings.com/Word-Number/666HolyBible.htm Shane -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__() not called automatically
Paul McNett wrote: > Sriek wrote: > (snip) >> Similarly, why do we have to explicitly use the 'self' keyword >> everytime? > > > This is closer to a wart, IMO, I've always explicitelly used the (implied) 'this' pseudo-pointer in Java, C++ etc. The wart is in all those languages that don't makes it mandatory IMHO !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatically populate and submit HTML Forms
Grant Edwards wrote: > On 2005-05-25, rbt <[EMAIL PROTECTED]> wrote: > >>How can I make a python client script connect to a Web server and >>automatically populate form fields and then submit the form? >> >>For example, say I wanted to check and see if 1924 was a leap year... >>how would I populate the 'year' field and then submit it for processing? >>I have no control of the server... just the client script. >> >> >> Enter a year and find out if it's a leap year: >> >> >> >> > > > Just use urllib() and pass the form data to the urlopen() > method. If given data, it will generate a "POST" request > instead of a "GET". Here's a snippet of code from an app of > mine that "fills in a form" and submits it: > > postData = > urllib.urlencode({'submit':'Remove','disp':'M','action':'change_Msgs'}) > > for msgid in msgIDs: > postData += "&msgid="+msgid > > req2 = urllib2.Request("http://mc-s6.postini.com/exec/MsgCtr",postData) > rsp2 = ClientCookie.urlopen(req2) > > In this code I've eyeballed the form and the field names are > hard-wired into the code. If your form doesn't change from one > usage to the next, that's the simplest way to do it. > > In my example I'm using ClientCookie and urllib2 to create/open > the reqeust in two steps because the request seen above won't > work without some cookie values previsouly established in code > that I've snipped. Otherwise all you'd need to do is something > like this: > > urllib.urlopen('http://whatever', > > urllib.urlencode({'field1Name':'value1','field2Name':'value2'})) > Thanks Grant... I found ClientCookie and ClientForm here: http://wwwsearch.sourceforge.net/ Two great Python modules that really simplify this!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python analog of Ruby on Rails?
George Sakkis wrote: > "Christopher J. Bottaro" wrote: > > >>Cool signature, can anyone do a Python one that I can leech? =) >> >>-- C > > > Here's the transliteration in python for your address: > > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) > for p in '[EMAIL PROTECTED]'.split('@')])" Err... Looks like I've seen this before, but where ??? -- bruno desthuilliers ruby -e "print '[EMAIL PROTECTED]'.split('@').collect{|p| p.split('.').collect{|w| w.reverse}.join('.')}.join('@')" python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Python analog of Ruby on Rails?
Christopher J. Bottaro wrote: > bruno modulix wrote: > (snip) > > Cool signature, can anyone do a Python one that I can leech? =) You mean this ?-) python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
SCF Bundle released
Dear all, I am very happy to announce the release of SCFB: a python development toolkit for Smart Cards. SCFB comes with all necessary tools to easily get a Smart Card application running. SCFB also includes the necessary Smart Card and their software interface. SCFB is the tool we use to develop our own Smart Cards solutions. You may find information on SCFB by following the links: www.snakecard.com/html_bundle www.snakecard.com/scfb.pdf Best regards, Philippe Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Improve the performance of a loop
Actually slicing the way you suggested improved it to some extent. I did profile on this and I observed that it reduced the number of calls for __get_item__ and improved the timing to some extent. Which was useful to some extent. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: vim configuration for python
Does anybody know of any scripts to check python syntax when you type :make? -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatically populate and submit HTML Forms
On 2005-05-26, Grant Edwards <[EMAIL PROTECTED]> wrote: >> How can I make a python client script connect to a Web server and >> automatically populate form fields and then submit the form? > Just use urllib() and pass the form data to the urlopen() > method. If given data, it will generate a "POST" request > instead of a "GET". Oops, I forgot. Here's a pointer to the examples in the urllib docs: http://docs.python.org/lib/node478.html -- Grant Edwards grante Yow! This is PLEASANT! at visi.com -- http://mail.python.org/mailman/listinfo/python-list