Re: pdb question

2006-11-26 Thread Fredrik Lundh
tac-tics wrote: > In the Python debugger (pdb), how do you designate breakpoints at the > start of methods? > I've tried: > break methodName > break class.methodName > break object.methodName > > but none of these seem to work. What is the trick? define "seem to work". the "className.methodName

Re: acessing to the raw data of an email message

2006-11-26 Thread Fredrik Lundh
Jiba wrote: > Does anyone have an idea ? I think it would be nice to let the > parser add the raw message data in the Message object. since you're the one passing the raw data to the email parser, maybe you could store it somewhere yourself? -- http://mail.python.org/mailman/listinfo/python

Re: Inheritance from builtin list and override of methods.

2006-11-26 Thread Fredrik Lundh
Michalis Giannakidis wrote: > Could someone please explain the reasoning/behabiour of these? in general, methods on C objects are implemented in terms of operations on the internal data structures, not in terms of a subset of the methods already provided by the object. -- http://mail.python

Re: Dynamic function execution

2006-11-26 Thread Fredrik Lundh
Cameron Laird wrote: > ? Or am I missing the point that a better example of what > Mr. Wu really wants is > > def func(seconds = None, minutes = None, hours = None): > print seconds > print minutes > print hours > > dimension = "minutes" > func(**{dimension: 30}) I ass

Re: who is maintainer of xml-rpc module?

2006-11-26 Thread Fredrik Lundh
Mark Harrison wrote: > So, I've made a couple of small but useful additions to > the xml-rpc package. Is there an assigned maintainer > of the package I should communicate with? post your patch here: http://sourceforge.net/tracker/?group_id=5470&atid=305470 -- http://mail.python.org/mailman

Re: Simple threading

2006-11-25 Thread Fredrik Lundh
Grant Edwards wrote: > That depends on the type of the global and how they're used. > Re-binding a name is always an atomic operation. Modifying > many mutable objects is atomic. footnote: for more on this topic, see this FAQ entry: http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-ar

Re: my small hashlib - using pythons hash-functions

2006-11-25 Thread Fredrik Lundh
Mathias Panzenboeck wrote: > But the question is: *IS* this derived work? I mean, it's not copied code. > It's the same hashing-logic, which I learned by watching pythons code. given that it's only a few lines of code, and there's hardly any other way to write those lines if you want to implemen

Re: The Python Papers Edition One

2006-11-25 Thread Fredrik Lundh
Noah Slater wrote: > Which is more important to the Python comunity... the community definitely don't need more random usenet posters who's only contribution is to complain whenever someone tries to do some- thing. this thread is an embarrassment for the Python community; you should all be ash

Re: Dynamic function execution

2006-11-25 Thread Fredrik Lundh
Andy Wu wrote: > def func(seconds = None, minutes = None, hours = None): > ... > > In my program I can get a string object('seconds', 'minutes', 'hours') > to specify which parameter to use, the problem is I don't know how to > call the function. > > Say I have a string 'minutes' and a integ

Re: Importing module of data dicts and constants

2006-11-25 Thread Fredrik Lundh
Nathan Harmston wrote: > I ve got a single module which I m using to contain a lot of > dictionaries, constants, general information, which are used by > various other modules. However I can't seem to access them: > > in data.py > _SEQTYPE_DNA = 0 > _SEQTYPE_RNA = 1 > _SEQTYPE_PROT = 2 > _seqTy

Re: Inheritance and recursion problem

2006-11-25 Thread Fredrik Lundh
Spiro wrote: > XWindow have all drawing functionality and Windows[] object which holds > all child windows. > > Function Draw looks like this: > def Draw(self): > self.Back.blit > for wnd in self.Windows: > wnd.Draw(OffsetX, OffsetY) > > Now in main module i make objec

Re: The Python Papers Edition One

2006-11-25 Thread Fredrik Lundh
Tennessee Leeuwenburg wrote: > If anyone has any good ideas for how to cope as a publisher with these > difficulties, I'm all ears. has any of the format zealots posting to this thread actually volunteered to produce any material for your publication? if not, I suggest ignoring them. any bozo

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Fredrik Lundh
Jim wrote: > Application abc is designed as a complete module. The user is to > script their own functions to work with application abc. so use execfile() with a prepared namespace: namespace = { ...stuff to export to the module ... } execfile("directory/module.py", namespace) --

Re: Abelson and Python

2006-11-24 Thread Fredrik Lundh
Chris Mellon wrote; > Now, writing a compiler/interpreter from the ground up is a more > valuable experience, but does it really matter if the language is the > same one you wrote the compiler in? It gets harder the more > complicated the syntax and semantics of the language are, but, say, > pytho

Re: Pimping the 'cgi' module

2006-11-24 Thread Fredrik Lundh
Christoph Haas wrote: >> well, note, for that they have named it Ruby-On-Rails, so its still the >> language - leveraged. While it is Zope/Django/Ego-on-Python ... ? > > If by that you mean that neither Zope nor Django are exactly pythonic I > think I concur. Django is highly Pythonic (it's pure

Re: Local variables persist in functions?

2006-11-24 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > chunks = _chunkify( list, size ) # _curList keeps its previous value! > chunks = _chunkify( list, size, list() )# this works as expected > > Considering the default value of _curList, these statements should be > identical. Any pointers? http://effbot.org/pyfaq

Re: beginner question about range with list and list

2006-11-23 Thread Fredrik Lundh
erik gartz wrote: > I'm new to python and I'm having difficulty understanding the following > code. Why doesn't the variable a contain [[{}, {'x': 0}, {}], [{}, > {'x': 1}, {}]] instead. Doesn't {} allocate new memory for the > dictionary each time? each time it's *executed*, yes. [{}]*3 doesn'

Re: Access to variable from external imported module

2006-11-23 Thread Fredrik Lundh
GinTon wrote: > Thanks Robert, the best solution is get all local variables, else is > impossible access to them. if you don't want them to be local, why are you using local variables? (have you read the Python tutorial?) -- http://mail.python.org/mailman/listinfo/python-list

Re: Access to variable from external imported module

2006-11-23 Thread Fredrik Lundh
GinTon wrote: > How to access to a variable (that value is not returned) from a module > imported? > And the variable is set at the module-level. import module print module.variable (have you read the Python tutorial?) -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand Python objects

2006-11-23 Thread Fredrik Lundh
Bruno Desthuilliers wrote: > Don't see it as a religious point please, but I fail to understand why > you seem so in love with old-style classes ? new-style classes are the > "official" Python object model since 2.2 (which is a few years ago now), > and the last mandatory use of them (exception

Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Fredrik Lundh
Brian Quinlan wrote: >> 4) [] and {} always create a new object every time they're evaluated. > > Not quite. The empty tuple is cached: > > >>> a = () > >>> b = () > >>> a is b > True () isn't [] or {}, though. time to switch to a bigger font? ;-) -- http://mail.python.org/mailman/listi

Re: ImportError: No module named getopt

2006-11-23 Thread Fredrik Lundh
"prashant" wrote: > I am actually using Cygwin to run a python script. > I have python 2.5 installed. But when i ran the command mentioned by > you... I see that it is looking in the wrong directories... how can i > change these look up directories? is PYTHONHOME perhaps set to the wrong thing?

Re: select() on WinXP

2006-11-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I'm running Python 2.5 on Windows XP. When I try to do this: > > [code] > import select > select.select([], [], []) > [/code] > > I get this: > > [output] > Traceback (most recent call last): > File "C:/Documents and Settings/Grebekel/Desktop/s.py", line 2, in > >s

Re: ImportError: No module named getopt

2006-11-23 Thread Fredrik Lundh
"prashant" wrote: >I am running a python script which has the line > > import getopt, sys, os, re, string > > And i get the error > > ImportError: No module named getopt > > Could you please point out a possible solution for this? looks like a broken installation. try running the script as

Re: non blocking "i o", The deep freeze.

2006-11-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > The whole thing works pretty well, a part from every so offen completely > randomly the 3 machines seem to freeze (or to put in the terms of our sys > admin it trashes them). thrashing? that usually means that a process uses too much memory, thus causing the system to

Re: "10, 20, 30" to [10, 20, 30]

2006-11-23 Thread Fredrik Lundh
Tim Williams wrote: >> It is a dangerous solution if your data is coming from an untrusted source. >> >> >>> s = "10, 20, 30" >> >>> L = [x.strip() for x in s.split(',')] >> >>> L >> ['10', '20', '30'] >> >>> L = [int(x) for x in L] >> >>> L >> [10, 20, 30] >> >> Or, as a one liner: [int(x.strip(

Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Fredrik Lundh
Tor Erik Soenvisen wrote: > I've seen code like this: > > if type([]) is list: >print 'Is list' > > which seem to work. And also I've seen "var is None", as you mention. None is guaranteed to be a singleton: http://effbot.org/pyref/type-none.htm Why "is" works for type objects should be

Re: How do I separate my parameters with spawnv

2006-11-23 Thread Fredrik Lundh
Fabio Chelly wrote: > But when I try to use os.spawnv to excute it from my python code, it > doesn't work at all. Here is my code: > > exe = "c:\\curl.exe" > f = "c:\\upload.txt" > logon = "login:pwd" > url = "ftp://ftp-myurl"; > import os > os.spawnv(os.P_WAIT, exe, ["-T", f, "-u", logon, url,

Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Fredrik Lundh
> distinct identifies don't trust your spellchucker. -- http://mail.python.org/mailman/listinfo/python-list

Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Fredrik Lundh
Tor Erik Soenvisen wrote: > (len(['']) is 1) == (len(['']) == 1) => True > > Is this the case for all numbers? I'm not sure what you're asking here, but if you digest the following facts, maybe you can answer it yourself: 1) all objects that exist at the same time have distinct identifies, and

Re: How do I find possible matches using regular expression?

2006-11-23 Thread Fredrik Lundh
Andy wrote: > The problem is the input will be much more complex than the example, it > could be something like "30 minutes later" where any string starting > with a number is a possible match. so if I type "1", are you going to suggest all possible numbers that start with that digit? doesn't st

Re: Finding the carret position in a regular expression

2006-11-23 Thread Fredrik Lundh
Tool69 wrote: > supposed I've got the following text : > > mytext = "for in :" > > with the following simple pattern : pattern = "<[a-z]+>" > > I use re.findall(pattern, mytext) wich returns : > ['',''] > > Now, I want my prog to return the positions of the returned list > elements, ie : > w

Re: utf - string translation

2006-11-23 Thread Fredrik Lundh
Klaas wrote: > It's not too hard to imagine an accentual difference, eg: especially in languages where certain combinations really are distinct letters, not just letters with accents or silly marks. I have a Swedish children's book somewhere, in which some characters are harassed by a big ugly

Re: Abelson and Python

2006-11-23 Thread Fredrik Lundh
markscottwright wrote: > If it were that easy, the PyPy guys would be done by now. if the PyPy guys had focused on writing a Python interpreter in Python, they'd been done by now. -- http://mail.python.org/mailman/listinfo/python-list

Re: utf - string translation

2006-11-22 Thread Fredrik Lundh
hg wrote: > How would you handle the string.maketrans then ? maketrans works on bytes, not characters. what makes you think that you can use maketrans if you haven't gotten the slightest idea what's in the string? if you want to get rid of accents in a Unicode string, you can do the approach

Re: utf - string translation

2006-11-22 Thread Fredrik Lundh
hg wrote: > We noticed that len('à') != len('a') sounds odd. >>> len('à') == len('a') True are you perhaps using an UTF-8 editor? to keep your sanity, no matter what editor you're using, I recommend adding a coding directive to the source file, and using *only* Unicode string literals for n

Re: KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Lundh
Fredrik Tolf wrote: > So how does it work? Does my code get to return Py_FALSE, and the > interpreter ignores it, seeing that an exception is set? Is a non-local > exit performed right over my call stack (in which case my next question > would be how to clean up resources being used from my C code

Re: file backup in windows

2006-11-22 Thread Fredrik Lundh
"MC" wrote: > " are your friend. to be precise, list2cmdline is your friend. see discussion and examples here: http://effbot.org/pyfaq/why-can-t-raw-strings-r-strings-end-with-a-backslash.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: What's going on here?

2006-11-22 Thread Fredrik Lundh
Dale Strickland-Clark wrote: > Why can't I assign to attributes of an instance of object? it doesn't have any attribute storage. -- http://mail.python.org/mailman/listinfo/python-list

Re: file backup in windows

2006-11-22 Thread Fredrik Lundh
k.i.n.g. wrote: > how can i make the following code work, I have probelm with filepath > declaration. http://effbot.org/pyfaq/tutor-i-need-help-im-getting-an-error-in-my-program-what-should-i-do -- http://mail.python.org/mailman/listinfo/python-list

Re: How to sort list

2006-11-22 Thread Fredrik Lundh
Klaus Alexander Seistrup wrote: > Decorate-sort-undecorate? > > #v+ > > array = [] > > for addr in Emails: > (user, domain) = addr.split('@') > array.append((domain, user, addr)) > # end for > > array.sort() > > SortedEmails = [addr for (user, domain, addr) in array] > > #v- note that D

Re: Parsing/Splitting Line

2006-11-22 Thread Fredrik Lundh
Noah Rawlins wrote: > I'm a nut for regular expressions and obfuscation... > > import re > def splitline(line, size=4): > return re.findall(r'.{%d}' % size, line) > > >>> splitline("helloiamsuperman") > ['hell', 'oiam', 'supe', 'rman'] there are laws against such use of regular expressio

Re: Trying to understand Python objects

2006-11-22 Thread Fredrik Lundh
walterbyrd wrote: > 1) Can attributes can added just anywhere? I create an object called > point, then I can add attributes any time, and at any place in the > program? in general, yes, but that should be done sparingly. > 2) Are classes typically created like this: > > class Point: > pass >

Re: Misleading IOerror when opening a non-existent file for append?

2006-11-21 Thread Fredrik Lundh
jkn wrote: > This 'invalid mode: a' error message seems weird to me. Is this a bug > or am I missimg something? It depends on the underlying implementation of fopen(), which, on some platforms, doesn't set the right error code for bad mode strings. Python uses some simple heuristics to try to g

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Fredrik Lundh
Ben Finney wrote: > Really? Where does Python guarantee that the left side *must* be > evaluated before the right side of a comparison? in the language reference: http://docs.python.org/ref/evalorder.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Caution newbie question: python window to stay open ?

2006-11-21 Thread Fredrik Lundh
mkengel wrote: > Problem: Python window closes immediately after executing a *.py file > (e.g. containing a "print..." command. > What do I have to do to keep it open to see the results ? Simple scripts that print to a console, or read from it, works best if you run them from a standard Command

Re: re.match -- not greedy?

2006-11-21 Thread Fredrik Lundh
EXI-Andrews, Jack wrote: > > that's a misunderstanding of what a regular expression is, though: > > conceptually, a RE describes a set of strings, and the RE engine is > > designed to answer the question "does this string belong to this > > set". > if that's so, what is the point of +? and *

Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

2006-11-19 Thread Fredrik Lundh
gabor wrote: > yes, sure... but then.. it's possible to implement it also on top of an > raise-when-error version :) not necessarily if raise-when-error means raise-error-in-os-listdir. -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree: namespace declaration in each element?

2006-11-19 Thread Fredrik Lundh
cyberco wrote: > OK, that's what I was already doing. Thanks. > Will the standard serializer in 1.3 support default namespaces? that's the plan. I've been working on a more modular XML writer, which will make it easier to tweak the output in various ways, without having to write everything fro

Re: Reloading after from adder import * ????

2006-11-19 Thread Fredrik Lundh
Seymour wrote: > I just made some typos and was wondering if there was an easier > way to clear the Python namespace at the interactive prompt rather than > shutting Komodo down and restarting (really brute force). most IDE's have a "reset interactive mode" command (it's ctrl-F6 in IDLE, for ex

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Fredrik Lundh
John Henry wrote: > Oops! for cases like this, writing "[" + re.escape(charset) + "]" is usually a good way to avoid repeated oops:ing. > newString= re.split("[; ()\[\]", result) >>> newString= re.split("[; ()\[\]", result) Traceback (most recent call last): ... sre_constants.er

Re: A little confuse

2006-11-19 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > When I run this code in the pdb it works. > accountNbr = 1 > for testLine in ftest.readlines(): > acct = testLine[1:2] #there account number > if accountNbr == int(acct): > accountNbr = accountNbr + 1 > > When I run without the

Re: lxml/ElementTree and .tail

2006-11-19 Thread Fredrik Lundh
Uche Ogbuji wrote: > The fact that the XML Infoset is hardly used outside W3C XML Schema, > and that the XPath data model is far more common, and for the bystanders, it should be noted that the Infoset is pretty much the same thing as the XPath data model; it's mostly just that the specificatio

Re: lxml/ElementTree and .tail

2006-11-19 Thread Fredrik Lundh
Uche Ogbuji wrote: > The fact that the XML Infoset is hardly used outside W3C XML Schema, > and that the XPath data model is far more common, and that focus on > the serialization is even more common than that is a matter of > everyday practicality. everyday interoperability problems, that is

Re: ElementTree: namespace declaration in each element?

2006-11-19 Thread Fredrik Lundh
cyberco wrote: > Unfortunately the client that needs to consume this XML can't handle > the 'ns0:' part of each tag. > Is there a way to output XML similar to the input? written by a "it's the bytes, not the data" guy, obviously ;-) the standard serializer in 1.2 doesn't support default namesp

Re: syntax error in sum(). Please explicate.

2006-11-19 Thread Fredrik Lundh
Bjoern Schliessmann wrote: > Are generator comprehensions and generator expressions the same? the documentation uses the word "expression", not comprehension. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Fredrik Lundh
ronrsr wrote: > I'm trying to break up the result tuple into keyword phrases. The > keyword phrases are separated by a ; -- the split function is not > working the way I believe it should be. >>> help(str.split) split(...) S.split([sep [,maxsplit]]) -> list of strings Return a lis

Re: MAKE GOOD MONEY BY INTERNET

2006-11-18 Thread Fredrik Lundh
John Bokma wrote: > dumbfuck Is there no way to filter this kind of junk, short of going to a moderated list? -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml/ElementTree and .tail

2006-11-18 Thread Fredrik Lundh
Chas Emerick wrote: > Further, the fact that ET/lxml works the way that it does makes me > think that there may be some other landmines in the underlying model > that we might not have discovered until some days, weeks, etc., had > passed so the real reason you posted your original post was

Re: Python v PHP for web, and restarting Apache?

2006-11-18 Thread Fredrik Lundh
walterbyrd wrote: >> Python is much better suited to writing and mainting large web >> applications though. > > I have to ask: why is that? modularity, modularity, and modularity. -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml/ElementTree and .tail

2006-11-18 Thread Fredrik Lundh
Chas Emerick wrote: >> and keep patting our- >> selves on the back, while the rest of the world is busy routing around >> us, switching to well-understood XML subsets or other serialization >> formats, simpler and more flexible data models, simpler API:s, and >> more robust code. and Python ;-) >

Re: Having trouble converting popen2 to subprocess

2006-11-18 Thread Fredrik Lundh
Daniel Klein wrote: > Now here is my attempt to use the 'subprocess' module : > > from subprocess import * > p = Popen(r'c:\home\hw.exe', bufsize=-1, stdin=PIPE, stdout=PIPE, > universal_newlines=True) > fin = p.stdin p.stdin is the *other* process' stdin. if you want to read things it prints,

Re: installing modules

2006-11-18 Thread Fredrik Lundh
kilnhead wrote: > I am sure this has been asked a gazillion times, but here it is again. > When installing something like pyRTF, I extract the zip file to a > folder called pyRTFtemp, and then run "setup.py install" in that > folder. After that, can I get rid of the pyRTFtemp folder in general,

Re: lxml/ElementTree and .tail

2006-11-18 Thread Fredrik Lundh
Paul McGuire wrote: > maybe time to switch to decaf... :) do you disagree with my characterization of the state of the XML universe? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I speed this function up?

2006-11-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Generally, don't create objects, don't perform repeated operations. In > this case, batch up I/O. > >> def write_data1(out, data): >> for i in data: >> if i[0] is 'ELEMENT': >> out.write("%s %06d " % (i[0], i[1])) >> for j in i[2

Re: basic python questions

2006-11-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I have a simple assignment for school but am unsure where to go. The > assignment is to read in a text file, split out the words and say which > line each word appears in alphabetical order. I have the basic outline > of the program done which is: looks like an excellen

Re: lxml/ElementTree and .tail

2006-11-18 Thread Fredrik Lundh
Uche Ogbuji wrote: > I certainly have never liked the aspects of the ElementTree API under > present discussion. But that's not as important as the fact that I > think the above statement is misleading. There has always been a > battle in XML between the people who think the serialization is > p

Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

2006-11-17 Thread Fredrik Lundh
Martin v. Löwis wrote: >> How about returning two lists, first list contains unicode names, the >> second list contains undecodable names: >> >> files, troublesome = os.listdir(separate_errors=True) >> >> and make separate_errors=True by default in python 3.0 ? > > That would be quite an incompat

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Terry Reedy wrote: > This is far more accurate than any measured latitude could be. you're saying that we don't measure geographical positions on an atomic scale? ;-) (it's too late for serious calculations, but I'd guess we're talking Ångströms here, right?) -- http://mail.python.org/mail

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Michael B. Trausch wrote: > Sure, I do. Let's say that I want to work with the latitude > 33.6907570. In Python, that number can not be stored exactly without > the aid of decimal.Decimal(). > > >>> 33.6907570 > 33.6907568 > >>> > > As you can see, it loses accuracy after the 6th d

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Michael B. Trausch wrote: > I don't have (so far as I know) a 64-bit float available to me. as mentioned in the documentation, Python's "float" datatype is implemented C doubles, which is 64-bit IEEE on all major platforms. > Some of the lat/long pairs that I have used seem to come out fine, bu

Re: remove a list from a list

2006-11-17 Thread Fredrik Lundh
Fredrik Lundh wrote: >> What is a *nice* way of doing it? > > r = [i for i in e if i not in l] and swap l and e, add a few calls to lower, and start using better variable names in the future. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to print pdf with python on a inkjet printer.

2006-11-17 Thread Fredrik Lundh
krishnakant Mane wrote: > I can't figure out where is the win32api module in my system. > I think I need to download it. > I tried to search but did not find it. googling for "python win32api" gives you: http://sourceforge.net/project/showfiles.php?group_id=78018 among the first few hits.

Re: remove a list from a list

2006-11-17 Thread Fredrik Lundh
Rares Vernica wrote: > I have the following problem: > > I have a list like >e = ['a', 'b', 'e'] > and another list like >l = ['A', 'a', 'c', 'D', 'E'] > I would like to remove from l all the elements that appear in e > case-insensitive. That is, the result would be >r = ['c', 'D'] >

Re: Heap Memory

2006-11-17 Thread Fredrik Lundh
Gregory Piñero wrote: > How does Python use memory on a 64 bit OS? Is there a lot more > available to it by default? as we've already said a couple of hundred times in this thread, Python uses *all* the memory it can get from the operating system. no more, no less. (the link I posted yesterd

Re: Slicing / subsetting list in arbitrary fashion

2006-11-17 Thread Fredrik Lundh
Gregg Lind wrote: > One difficulty I am having with using Python for scientific computing is > that I cannot figure out good ways to get arbitrary (unpatterned?) slices. > In Python, solutions I have found for these tasks are: > > [vals[ii] for ii in wanted]# task 1 > > [a[1] for in zip

Re: Python list Limit

2006-11-17 Thread Fredrik Lundh
Bugra Cakir wrote: > What is the size limit of list data type in Python ? there is no limit, beyond the size of a pointer, and the limitations put on your program by the operating system. > I've found an MemoryError while extending a list with > > samplelist.extend("tail") when the list is resi

Re: How to pass an argument to a python program open in IDLE?

2006-11-17 Thread Fredrik Lundh
"TonyHa" wrote: > My problem is this: When I start IDLE GUI, then I open my script with > the edit window. (i.e. > File -> open). I run my script under the edit window using run -> run > module or F5. But IDLE does not allow me to input the argument to my > script, i.e. IDLE runs without prompting

Re: What python modules are available?

2006-11-17 Thread Fredrik Lundh
Why Tea wrote: > How do I find out what python modules are installed on a Solaris > platform? ask the person who did the installation? or run this script: http://svn.effbot.python-hosting.com/pydotorg/listmodules/listmodules.py > I tried to import numarray, but python couldn't find it. numarr

Re: Understanding Python Source Code - where to start?

2006-11-17 Thread Fredrik Lundh
Thomas Ploch wrote: > I am thinking about reading and understanding the Source Code > of Python, but where would it be best to start? Possibly > someone can give me a little hint. I am getting into > socketmodule.c a little bit at the moment, but thats not > what I want. http://effbot.org/pyf

Re: how to print pdf with python on a inkjet printer.

2006-11-17 Thread Fredrik Lundh
krishnakant Mane wrote: > double wow! as it is my customer wants me to print to the default printer. > can you please help me with the command for rendering the pdf to the > printer with acrobat using python? see: http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html or possibly:

Re: A question on Encoding and Decoding.

2006-11-17 Thread Fredrik Lundh
Johan von Boisman wrote: > Is there ever a reason _not_ to exclusively use the unicode stringtype > throughout your Python program? speed and memory use. in 2.5, the unicode datatype is almost often as fast as the string type at the algorithm level, but it's still limited by memory bandwidth

Re: Bitwise operators. Differences from javascript and PHP.

2006-11-17 Thread Fredrik Lundh
John Machin wrote: > http://theopensourcery.com/phplogic.htm > > "In effect the bitwise operations [words "can be" omitted, I presume] "can only be", more likely. > safely applied to integer variables - their effect on booleans, > float/double or string variables can be predicted but are not re

Re: C extensions and memory leakage

2006-11-17 Thread Fredrik Lundh
Sheldon wrote: > I am very new at this C extensions in Python so my term wrapper was > probably a misnomer. Perhaps glue is better or the interface that > allows the exchange of data between Python and C. > Yes, I am using python objects in my C extension. > Tell me where I can find out more about

Re: Bitwise operators. Differences from javascript and PHP.

2006-11-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I can't understand a little thing in bitwise operations. > > In PHP and Javascript > 4653896912>>13 = -212992 > > In Python and Ruby > 4653896912>>13 = 568102 > > In Python and Ruby - it's ok. I understand. > But i need to get in Python same value as in PHP and Javasc

Re: Secure Python

2006-11-17 Thread Fredrik Lundh
Stephan Kuhagen wrote: > Never heard about it, maybe it's worth a look for the OP. $ more Misc/HISTORY ... What's New in Python 2.3 alpha 2? = *Release date: 19-Feb-2003* ... - Bastion.py and rexec.py are disabled. These modules are not safe

Re: determining the bounds of a tuple returned from a database

2006-11-17 Thread Fredrik Lundh
ronrsr wrote: > very sorry, that was my error - len(result[0]) and len(result[1]) both > return 1 -- > > i think I'm misunderstanding what len() does - to me they appear to > have 2 or 3 elements, or at least be composed of a string of some > length. from python's perspective, the data structure

Re: Yield

2006-11-17 Thread Fredrik Lundh
Danny Colligan wrote: > Carsten mentioned that generators are more memory-efficient to use when > dealing with large numbers of objects. Is this the main advantage of > using generators? Also, in what other novel ways are generators used > that are clearly superior to alternatives? the main adv

Re: popen(1-4) as a seperate process

2006-11-16 Thread Fredrik Lundh
Astan Chee wrote: > Yes, that is true. But everytime I run a os.popen() it executes as a > child process of the current running one. How do I launch as a seperate > process? what's your definition of "separate process", and how is that different from a child process? (all processes created by

Re: problem with defining a global class instance

2006-11-16 Thread Fredrik Lundh
sharath B N wrote: > def generate (... ,,...) > > " in this function i define the global variables " > global stock,stockManager, manager etc. > > > class Manager > ... > ... > ... > def create_stockManager(..) > """ this is a method in class manager""" > stockManager = StockManager( name

Re: Python v PHP: fair comparison?

2006-11-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Huh? I've been doing paid python web work since 2000. I'm fairly sure > that Yahoo! groups predates that by a while http://en.wikipedia.org/wiki/EGroups -- http://mail.python.org/mailman/listinfo/python-list

Re: popen(1-4) as a seperate process

2006-11-16 Thread Fredrik Lundh
Astan Chee wrote: > Im trying to popen (or more specifically os.popen4() ) from wxPython. > I've read the documentation on popen and it says I can do a popen as a > seperate process or popen not as a child process where does it say that? afaik, the whole point of the popen API is to run an ex

Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

2006-11-16 Thread Fredrik Lundh
gabor wrote: > get an Unicode-exception, as everywhere else. you see, exceptions are > ok, i can deal with them. > p.s: one additional note. if you code expects os.listdir to return > unicode, that usually means that all your code uses unicode strings. > which in turn means, that those filenam

Re: determining the bounds of a tuple returned from a database

2006-11-16 Thread Fredrik Lundh
ronrsr wrote: > it looks like the len() function is the one I want. > > for: len(result) - i get 248, > > but for len(result[0]) or len(result[1]) i always get 0. that's a bit surprising, because both items are tuples that contain exactly one item: >> (('Agricultural subsidies; Foreign aid

Re: Heap Memory

2006-11-16 Thread Fredrik Lundh
Gregory Piñero wrote: > This computer it was running on has 2GB of RAM and 6GB of virtual > memory so I really doubt I had used up all of that memory. I didn't > watch it the whole time so I can't be sure though. Any ideas what > could have been going on there? bogus configuration? http:/

Re: Python v PHP: fair comparison?

2006-11-16 Thread Fredrik Lundh
Tim Chase wrote: > I can't say I've come across any hosting places that serve up PHP > for $10/yr either...the closest I've found is about $3.50/mo > (which also provides Python CGI). https://www.nearlyfreespeech.net/about/faq.php#Average -- http://mail.python.org/mailman/listinfo/python-li

Re: Heap Memory

2006-11-16 Thread Fredrik Lundh
Gregory Piñero wrote: >> I have a question. How can we increase heap memory or total memory Python >> interpreter >> will use in order to avoid memory problems ? > > I've wondered the same thing myself. Even if it turns out it's just > not possible I hope you get an answer. > > My completely ar

Re: Has anyone generated Open Office Calc XML files from python

2006-11-16 Thread Fredrik Lundh
vj wrote: > I have a program which generates xml files for excel but these files > are not recognized by open office calc. I looked at the OO uno library, > but it seems like an over kill. this could be a start: http://ooopy.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/py

Re: Will subprocess eventually deprecate popen2 ?

2006-11-16 Thread Fredrik Lundh
Daniel Klein wrote: >I have a few Python programs that use popen2, and they work quite > nicely and dependably, so I don't really have any reason to change > them to use the new subprocess module...unless of course there any > future plans to deprecate popen2. definitely not in the 2.X series. a

Re: ini files and plugins

2006-11-16 Thread Fredrik Lundh
"tool69" wrote: > 1 - create a sort of ini file where I can put the user configuration > that will load itself on the application startup ; http://docs.python.org/lib/module-ConfigParser.html ? > 2 - a simple plugin system with python files ( maybe to add new > langages, etc.) ; http://effbot

<    5   6   7   8   9   10   11   12   13   14   >