Re: regex search with a space as the fist character

2009-09-17 Thread Diez B. Roggisch
Daniel Santos schrieb: Hello, print re.compile('u ').search(" u box2", 1) <_sre.SRE_Match object at 0x7ff1d918> print re.compile(' u ').search(" u box2", 1) None Why ? because you start searching at the offset 1, which means you try to find " u " in "u box2" - and that's not found. Di

Re: Shebang line problems and python

2009-09-17 Thread Diez B. Roggisch
Blaine schrieb: Hello, Scripts that have "#!/usr/bin/python" at the top do not parse correctly. Bash treats scripts with that shebang as if they are bash scripts. E.g.: bla...@attila ~/apps/rs-mu $ /usr/sbin/env-update /usr/sbin/env-update: line 6: import: command not found /usr/sbin/env-update

Re: How do I begin debugging a python memory leak?

2009-09-16 Thread Diez B. Roggisch
Matthew Wilson schrieb: I have a web app based on TurboGears 1.0. In the last few days, as traffic and usage has picked up, I noticed that the app went from using 4% of my total memory all the way up to 50%. I suspect I'm loading data from the database and somehow preventing garbage collection.

Re: Application Packages

2009-09-15 Thread Diez B. Roggisch
Dj Gilcrease schrieb: Say I have an application that lives in /usr/local/myapp it comes with some default plugins that live in /usr/local/myapp/plugins and I allow users to have plugins that would live in ~/myapp/plugins Is there a way to map ~/myapp to a user package so I could do "from user.pl

Re: How to improve this code?

2009-09-14 Thread Diez B. Roggisch
Oltmans schrieb: Hello, Is there someway I can improve the following code(pythonically)? (Copying from IDLE) match=[1,2,3,4,5] def elementsPresent(aList): result=False if not aList: return False for e in aList: if e in match:

Re: Problem with the inclusion of new files like lxml, django, numpy, etc.

2009-09-11 Thread Diez B. Roggisch
joy99 schrieb: Dear Group, I am trying to download the following files, a) lxml, b) numpy, c) scipy, and d) django. I am trying to include them in C\python26\Lib But they are giving error report, as I am trying to use them by importing. What is an "error report"? Unless you get more specific

Re: How can I use my modules here?

2009-09-11 Thread Diez B. Roggisch
Chris Rebert wrote: > On Fri, Sep 11, 2009 at 2:24 AM, Kermit Mei wrote: >> Hello community! >> >> I write a modules for testing, and my code is like this(under Linux): >> >> >> $ tree >> . >> |-- MyTestModules >> | |-- Test1.py >> | |-- Test2.py >> | `-- __init__.py >> `-- main.py >> >> 1 direct

Re: Execution order

2009-09-11 Thread Diez B. Roggisch
DarkBlue wrote: > Here is some code from a pyqt4.5.4 application on python 2.6 > > def findData(self): > > self.ui.label.setText('Processing... ') > > # here we do something which takes a few seconds > self.refreshGrid() > > > > The problem is that the text in the self.ui.

Re: Download and save a picture - urllib

2009-09-10 Thread Diez B. Roggisch
mattia wrote: > Hi all, in order to download an image. In order to correctly retrieve the > image I need to set the referer and handle cookies. > > opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler > (), urllib.request.HTTPCookieProcessor()) > urllib.request.install_opener(o

Re: How to create an array which can be used also as a dictionary

2009-09-10 Thread Diez B. Roggisch
Hans Müller wrote: > Hello, > > I have a lot of items having a name and a given sequence. > > To access these items fast in a sequence order they should be used as > a list, but to be fetched fast by name they also should be in a > dictionary. > > Code could be something like this. > > class i

Re: PYTHONPATH issue with sibling package names

2009-09-10 Thread Diez B. Roggisch
Stuart Moffatt wrote: > Environment: Eclipse 3.4.2, Windows XP Pro SP2, Pydev 1.4.4, python > 2.6 > > When I work in eclipse with java, I like to break up my client and > server packages, like this: > > client-project/src/org/me/client > > server-project/src/org/me/api > server-project/src/org/

Re: lxml question

2009-09-10 Thread Diez B. Roggisch
mattia wrote: > I would like to click on an image in a web page that I retrieve using > urllib in order to trigger an event. > Here is the piece of code with the image that I want to click: > onclick="return checkPhoneField(document.contactFrm, 'mobile');" > alt="sms" src="images/button_sms.bmp"

Re: Less APIs or more encapsulation?

2009-09-09 Thread Diez B. Roggisch
一首诗 wrote: > 2 class, B contains C. When user want to use some service of C, > there are two choice: > > First, more encapsulation: > > = > class B: > def newMethod(self): > self.c.newMethod() > > class C: > def newMethod(self): > > #do some

Re: Open Position: Software/System Engineer....Python....

2009-09-09 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > James wrote: > >> Hello All >> I do not know if this is the correct forum. I am looking for a >> Software/System Engineer with Python experience in the Cleveland, OH >> area. The skill set looks like this: >> >> Skills/Qua

Re: Open Position: Software/System Engineer....Python....

2009-09-09 Thread Diez B. Roggisch
James wrote: > Hello All > I do not know if this is the correct forum. I am looking for a > Software/System Engineer with Python experience in the Cleveland, OH > area. The skill set looks like this: > > Skills/Qualifications: > • Working in a dynamic, self motivated environment with minima

Re: [Tkinter] messed callbacks

2009-09-09 Thread Diez B. Roggisch
Giacomo Boffi wrote: > i have this test program (that i already posted on it.comp.lang.python) > > [ test.py ] > from Tkinter import * > > def output(s): > print s > > def doit(fr,lst): > for c1,c2 in zip(lst[::2], lst[1::2]): > subframe=Frame(fr) > Label(subframe,text=c1+' <->

Re: Modifying a row in a textfile

2009-09-08 Thread Diez B. Roggisch
Olli Virta wrote: > Hi! > > I got a textfile made out of database records. Is there an easy way to > modify rows in that file in case you have to take away some items here > and there from each rows. for line in inf.readlines(): if matches_criteria(line): line = modify_line(line)

Re: Smallest float different from 0.0?

2009-09-07 Thread Diez B. Roggisch
Paul McGuire wrote: > On Sep 7, 9:47 am, kj wrote: >> Is there some standardized way (e.g. some "official" module of such >> limit constants) to get the smallest positive float that Python >> will regard as distinct from 0.0? >> >> TIA! >> >> kj > > You could find it for yourself: > for i

Re: How to download directly to a file?

2009-09-04 Thread Diez B. Roggisch
kj schrieb: I want to send a POST request and have the returned content put directly into a file. Is there a way to do this easily in Python? I've been looking at the documentation for urllib2, but I can't see a direct way to do this, other than saving the returned contents to an in-memory varia

Re: Python SSH interface

2009-09-04 Thread Diez B. Roggisch
Mag Gam wrote: > Is there something similar to NetSSH > (http://search.cpan.org/dist/Net-SSH-Perl/) for python? Google dead today? From the > 3.000.000 answers for python + ssh, I suggest paramiko, but there are more options. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: website feedback to where?

2009-09-02 Thread Diez B. Roggisch
MRAB schrieb: Diez B. Roggisch wrote: rogerdpack schrieb: On Sep 2, 12:30 pm, Terry Reedy wrote: rogerdpack wrote: on this page http://docs.python.org/3.1/tutorial/introduction.html some of the "text" examples are [incorrectly] color formatted. I did not see any problems with

Re: website feedback to where?

2009-09-02 Thread Diez B. Roggisch
rogerdpack schrieb: On Sep 2, 12:30 pm, Terry Reedy wrote: rogerdpack wrote: on this page http://docs.python.org/3.1/tutorial/introduction.html some of the "text" examples are [incorrectly] color formatted. I did not see any problems with my browser (FF3.5), so please be more specific. sear

Re: executable path finding

2009-08-31 Thread Diez B. Roggisch
koranthala wrote: > Hi, > I am creating a python application using py2exe. I am facing a > problem which I am not sure how to solve. > The application contains many other files associated with it - > like icons, config files etc. The executable can be in any directory. > If the user create

Re: starting a client remotely

2009-08-31 Thread Diez B. Roggisch
jacopo wrote: > thank you Diez, > unfortunatelly I am on Windows NT. > Did you use SSH in a python script? Via subprocess, yes. Paramiko would be a way, too. > Isn't multiprocessing.managers already doing something like Pyro? I never used it, so I don't know - but it appears to be, yes. Doesn't

Re: starting a client remotely

2009-08-31 Thread Diez B. Roggisch
jacopo wrote: > I am playing with multiprocessing and I would like to have a python > script on one machine which initialize my whole system, in other > words, this script should start the server (a python script) on my > local machine and the clients (python scripts) on the other machines > in my

Re: initilize a memory zone in python

2009-08-31 Thread Diez B. Roggisch
Mug schrieb: On Aug 30, 8:58 pm, "Diez B. Roggisch" wrote: Mug schrieb: hello, i'm new in python, i used to program in C, i have a small problem, i tryed to do some serial port things manipulation with python. i have something like: import sys,termios fd = sys.stdin.fil

Re: initilize a memory zone in python

2009-08-30 Thread Diez B. Roggisch
Mug schrieb: hello, i'm new in python, i used to program in C, i have a small problem, i tryed to do some serial port things manipulation with python. i have something like: import sys,termios fd = sys.stdin.fileno() term_conf=termios.tcgetattr(fd); now i want to modify the actuall values in t

Re: How to install setuptools...egg?

2009-08-30 Thread Diez B . Roggisch
Rolf wrote: > Hi, > > I would like to install setuptools for Python2.6 on Windows. > Unfortunately I could only find setuptools-0.6c9-py2.6.egg but no > *.exe > for Python2.6. And as far as I understand I need setuptools to install > a > Python egg. I would be very appreciative for any help.

Re: Combining C and Python programs

2009-08-29 Thread Diez B. Roggisch
Sortie schrieb: I want to write a program that will use ode for the physics simulation, whose python bindings are outdated. So I'm writing the physics engine in C and want to write the drawing code in Python. What will be the best way of making those two programs work together? THe physics eng

Re: comparison on list yields surprising result

2009-08-28 Thread Diez B. Roggisch
Dr. Phillip M. Feldman schrieb: In [21]: x Out[21]: [1, 2, 3, 5] In [22]: x>6 Out[22]: True Is this a bug? In python2.x, it's the defined behavior - all types are somhow comparable. The comparison is stable (all lists compare larger to all ints), but of course this by no means well-defined.

Re: comparison on list yields surprising result

2009-08-28 Thread Diez B. Roggisch
Dr. Phillip M. Feldman schrieb: In [21]: x Out[21]: [1, 2, 3, 5] In [22]: x>6 Out[22]: True Is this a bug? In python2.x, it's the defined behavior - all types are somhow comparable. The comparison is stable (all lists compare larger to all ints), but of course this by no means well-defined.

Re: Algorithms as objects?

2009-08-28 Thread Diez B. Roggisch
Kreso schrieb: I am writing an application that essentially calculates set of numbers, say N1, N2, ..., where they can be calculated by several different algorithms. (One should be able to choose the algorithm at run time.) In each algorithm one starts from a set of functions, say f1, f2, ...,

Re: ubuntu dist-packages

2009-08-27 Thread Diez B. Roggisch
Paul Boddie wrote: > On 26 Aug, 17:48, Jorgen Grahn wrote: >> >> Well, if you are thinking about Debian Linux, it's not as much >> "ripping out" as "splitting into a separate package with a non-obvious >> name". Annoying at times, but hardly an atrocity. > > Indeed. Having seen two packages toda

Re: How to exclude "import"s from PyDoc

2009-08-26 Thread Diez B. Roggisch
Matt Bellis schrieb: Hi all, I tried PyDoc today for documentation for a small project on which I'm working. I have a class, foo, in foo.py. However, at the beginning of the file I "from math import *". When I use PyDoc, it's pulling in all the math functions ---snip--- . . . FUNCTION

Re: Object's nesting scope

2009-08-26 Thread Diez B. Roggisch
zaur wrote: > Hi folk! > > What do you think about idea of "object's nesting scope" in python? > > Let's imaging this feature, for example, in this syntax: > > obj=: > > > or > > : > > > That's means that result object of evaluation is used as > nested scope for evaluation. > >

Re: ubuntu dist-packages

2009-08-26 Thread Diez B. Roggisch
Robin Becker wrote: > I was surprised a couple of days ago when trying to assist a colleage with > his python setup on a ubuntu 9.04 system. > > We built our c-extensions and manually copied them into place, but > site-packages wasn't there. It seems that ubuntu now wants stuff to go > into lib/p

Re: Python, qt, and lgpl

2009-08-26 Thread Diez B. Roggisch
sturlamolden schrieb: On 25 Aug, 21:45, Terry Reedy wrote: Will be good news if realized. Good news for everyone except Riverbank. And only if LGPL is something you can live with. Some projects require more liberal licenses. Or is there a commercial license available, too? Diez --

Re: PyObject_CallFunction and writable memory

2009-08-26 Thread Diez B. Roggisch
Christopher Nebergall schrieb: I'm working a patch to a hex editor (frhed) written in c++ so it can load python scripts. Internally the c++ code has a unsigned char * of possibly serveral hundred megs which I want to send into the python code to modify.What is the best way to send the unsigne

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-26 Thread Diez B. Roggisch
Evan Driscoll schrieb: On Aug 25, 3:47 pm, Evan Driscoll wrote: So here is my simplified version that only works for globals: So I think this works if (1) you only use changed_value in the same module as it's defined in (otherwise it picks up the globals from the module it's defined in, which

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Diez B. Roggisch
Evan Driscoll schrieb: On Aug 25, 2:33 pm, Evan Driscoll wrote: I want to make a context manager that will temporarily change the value of a variable within the scope of a 'with' that uses it. This is inspired by a C++ RAII object I've used in a few projects. Ideally, what I want is something l

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Diez B. Roggisch
Evan Driscoll schrieb: (If you don't want to read the following, note that you can answer my question by writing a swap function.) I want to make a context manager that will temporarily change the value of a variable within the scope of a 'with' that uses it. This is inspired by a C++ RAII objec

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
John Posner schrieb: Diez said: Classes are not scopes. So the above doesn't work because name resolution inside functions/methods looks for local variables first, then for the *global* scope. There is no class-scope-lookup. But http://docs.python.org/tutorial/classes.html says, in Section

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
Jean-Michel Pichavant wrote: > Diez B. Roggisch wrote >> Classes are not scopes. >> >> > Too bad, could have been handy. Nope. Because then a lot of people would write something like this: class Foo(object): def bar(self): bar() # note the missing self.

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
kj wrote: > > > > I have many years of programming experience, and a few languages, > under my belt, but still Python scoping rules remain mysterious to > me. (In fact, Python's scoping behavior is the main reason I gave > up several earlier attempts to learn Python.) > > Here's a toy example

Re: unexpected token `;'

2009-08-25 Thread Diez B. Roggisch
bbarb...@inescporto.pt wrote: > Hello to all! > > I am struggling with a script in python for a while now, and decided > to look for some help. I am running a code that takes commands from > Marsyas(open source for Music analysis). > > #!/Library/Frameworks/Python.framework/Versions/2.6/bin/pyth

Re: Distutils evil voodoo: install into a package

2009-08-24 Thread Diez B. Roggisch
Pavel Panchekha schrieb: Before you flame me, I know that what I'm trying to do is beyond evil. But I nonetheless want to do it. Feel free to rant if you must. :) I have a package that I want to install into another package. For example, I have the packages pya and pyb. pya is guaranteed to be i

Re: Graph library recommendations for large graphs

2009-08-24 Thread Diez B. Roggisch
VanL schrieb: I am working on a project that will require building and querying large graph objects (initially 8M nodes, 30-40M edges; eventually 40M nodes, 100M edges). NetworkX seems to be the most popular, but I am concerned that a dict representation for nodes would use too much memory -- m

Re: Web Services examples using "raw" xml?

2009-08-24 Thread Diez B. Roggisch
John Gordon schrieb: I'm developing a program that will use web services, which I have never used before. There are several tutorials out there that advise you to get the WSDL and then call a method (such as wsdl2py) that inspects the wsdl and automagically generates the python classes and metho

Re: P3 weird sys.stdout.write()

2009-08-24 Thread Diez B. Roggisch
Jerzy Jalocha N wrote: > I've stumbled upon the following in Python 3: > > Python 3.0.1+ (r301:69556, Apr 15 2009, 15:59:22) > [GCC 4.3.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import sys sys.stdout.write("") > 0 sys.stdout.write("someth

Re: Python and JMS

2009-08-24 Thread Diez B. Roggisch
osky wrote: > Hi all, > > I would like to make a JMS client connection from Python to Progress > Sonic ESB (JMS message provider similar to WebSphere MQ or Active > MQ). > > What would be the best way to implement that within Python 2.6 ? > Any ideas ? I just recently learned about JCC - a Java

Re: Conditionally skipping the contents of a with-statement

2009-08-21 Thread Diez B. Roggisch
tsuraan schrieb: I'd like to write a Fork class to wrap os.fork that allows something like this: with Fork(): # to child stuff, end of block will automatically os._exit() # parent stuff goes here This would require (I think) that the __enter__ method of my Fork class to be able to return a va

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: Simon Forman schrieb: On Aug 18, 7:33 pm, Allan wrote: Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Simon Forman schrieb: On Aug 18, 7:33 pm, Allan wrote: Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it in a text file and I am so lost. Can an

Re: Python and PHP encryption/decryption

2009-08-19 Thread Diez B. Roggisch
Jean-Claude Neveu schrieb: I'm looking for a recommendation about encryption/decryption packages for Python. I'm working on a project that will require me to store some values in a database in encrypted format. I'll be storing them from a PHP script and retrieving them (decrypting them) using

Re: Dictionary from a list

2009-08-19 Thread Diez B. Roggisch
iu2 schrieb: Hi all, I need to create a dictionary out of a list. Given the list [1, 2, 3, 4, 5, 6] I need the dictionary: {1:2, 3:4, 5:6} dict(zip(l[::2], l[1::2])) Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between 2 arrays

2009-08-19 Thread Diez B. Roggisch
baalu aanand wrote: > On Aug 19, 1:48 pm, Pierre wrote: >> Hello, >> >> I would like to know how to find the difference (set operation) >> between 2 arrays : >> >> a = array([1,2, 3,2,5,2]) >> b = array([1,2]) >> I want a - b = [3,5] >> >> Well, the equivalence of setdiff in matlab... >> >> I tho

Re: Code formatting question: conditional expression

2009-08-19 Thread Diez B. Roggisch
> BTW, from the (admittedly few) responses to my original post, it seems > there's some sentiment that "conditional expressions" are a non-Pythonic > misfeature. Interesting ... No. I love them. But not if they are so large that they stretch over several lines (or to many columns). foo = bar if

Re: can't retrieve data from pyxml

2009-08-19 Thread Diez B. Roggisch
Sakib schrieb: well, i need to retrive data from the following line of xml. i need the Caption and the type data. is any one out there help me doing that? That's not XML. It lacks namespace-declarations. So no XML-parser will (or should) grok it. Also, to get help here it's better t

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Piet van Oostrum wrote: >> Allan (A) wrote: > >>A> Hi! I'm fairly new to Python. I understand the basics basics but I'm >>A> been trying to write a simple python code that will let me read input >>A> data (such as mouse movement) from my USB port and write it in a text >>A> file and I am so

Re: Help with libxml2dom

2009-08-19 Thread Diez B. Roggisch
Nuno Santos wrote: > I have just started using libxml2dom to read html files and I have some > questions I hope you guys can answer me. > > The page I am working on (teste.htm): > > > > Title > > > > > > > > > > >

Re: difference between 2 arrays

2009-08-19 Thread Diez B. Roggisch
Pierre wrote: > Hello, > > I would like to know how to find the difference (set operation) > between 2 arrays : > > a = array([1,2, 3,2,5,2]) > b = array([1,2]) > I want a - b = [3,5] > > Well, the equivalence of setdiff in matlab... > > I thought a.difference(b) could work, but no : Attribute

Re: recording input from USB port and write to text file

2009-08-19 Thread Diez B. Roggisch
Allan schrieb: Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it in a text file and I am so lost. Can anyone help or direct me to some resources?

Re: How to create functors?

2009-08-18 Thread Diez B. Roggisch
The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: funcs = [] for i in xrange(10): def f(i=i): print i funcs.append(f) for f in funcs:

Re: Editing a wiki

2009-08-18 Thread Diez B. Roggisch
KillSwitch schrieb: Hey guys, Is it possible to edit a wiki page with python, including logging in to edit the page, and inserting text into the edit box, etc. I was thinking maybe python would be the language to do this in, because I have to iterate through every line in a text file and gather i

Re: Start-up program

2009-08-18 Thread Diez B. Roggisch
Virgil Stokes wrote: > How difficult is to create a program that will be executed when Windows > Vista is started? As Windows Calendar does, for example. > > I am actually more interested in the Python tools that might be used for > this task. I hope that this question is not inappropriate for th

Re: Code formatting question: conditional expression

2009-08-18 Thread Diez B. Roggisch
John Posner wrote: > While refactoring some code, I ran across an opportunity to use a > conditional expression. Original: > > if total > P.BASE: > excessblk = Block(total - P.BASE, srccol, > carry_button_suppress=True) > else: > excessblk = None > > Is there any consensus

Re: Strongly typed list

2009-08-18 Thread Diez B. Roggisch
هاني الموصلي wrote: > I think i found a good managable solution. Actually it is trivial but > may help (I used it now). > When i wnat to access the list then i assign the object which i want > to access to a variable ex: > 1)x=AutomataBranch() > 2)x=self.cfgAutomata[i] > > The first line is used

Re: Changing Python Opcodes

2009-08-18 Thread Diez B. Roggisch
Sreejith K wrote: > On Aug 18, 12:19 pm, "Diez B. Roggisch" wrote: > >> Did you try installing the egg *without* pyc-files in there? Because >> naturally those shouldn't work. They shouldn't crash the interpreter >> either, but then again - you *

Re: Strongly typed list

2009-08-18 Thread Diez B. Roggisch
هاني الموصلي schrieb: Please could you lead me to a way or a good IDE that makes developing huge projects in python more easier than what i found.Now i am using eclips. Actually it is very hard to remember all my classes methods and attributes or copy and paste them each time. Thanks very much fo

Re: Changing Python Opcodes

2009-08-18 Thread Diez B. Roggisch
Sreejith K schrieb: Hi, I know this is not the best way to do it. But I have to do it at least to make it *hard* to decompile the python bytecode. I want to distribute a software written in Python without the source. So I compiled Python from source changing some opcode values (Taking care of H

Re: sub-list extraction, logical indexation

2009-08-17 Thread Diez B. Roggisch
Pierre wrote: > Hello Everyone, > > I would like to know if it is possible to extract a sub-list from a > list ? > > typically if : > > L =[[1, 2, 3],[4, 5, 6],[3] ] > > How to extract easily the elements 0 and 2 of L in order to get : > > L2 =[[1, 2, 3],[3] ] > > Moreover, I would like to k

Re: XPath support?

2009-08-16 Thread Diez B. Roggisch
kj schrieb: I'm looking for a XML parser that produces an object with full XPath support. What I've been using up to now, xml.etree.ElementTree, fails to support Xpath predicates, as in "sp...@eggs='3']/ham". What I'm trying to do is to read-in a large XML string, and parse it into an object fr

Re: callable virtual method

2009-08-14 Thread Diez B. Roggisch
Jean-Michel Pichavant schrieb: MRAB wrote: Jean-Michel Pichavant wrote: Hi fellows, Does anyone know a way to write virtual methods (in one virtual class) that will raise an exception only if called without being overridden ? Currently in the virtual method I'm checking that the class of the

Re: Why does my ftp script quit after couple of hours?

2009-08-14 Thread Diez B. Roggisch
kk schrieb: Hi Diez Thanks for your insight. The reason I chose the awkward method to parse the ip digits is that I was not familiar with the regex module and the Dyndns Ip page is pretty simple page. I guess it is time to learn more about the Re module. As far as robustness, I agree with your

Re: Why does my ftp script quit after couple of hours?

2009-08-14 Thread Diez B. Roggisch
kk schrieb: Hi This way the first time I did something with ftp stuff. I think that generally it works but it stops working(quits or disappears) after couple of hours of running. This was a personal test-trial script for my own needs which was to get my dynamic ip and broadcast to a client(I hav

Re: callable virtual method

2009-08-14 Thread Diez B. Roggisch
Jean-Michel Pichavant schrieb: Hi fellows, Does anyone know a way to write virtual methods (in one virtual class) that will raise an exception only if called without being overridden ? Currently in the virtual method I'm checking that the class of the instance calling the method has defined th

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-14 Thread Diez B. Roggisch
Hendrik van Rooyen schrieb: On Friday 14 August 2009 14:13:46 greg wrote: You can't read and write with the same stdio file object at the same time. Odd things tend to happen if you try. You need to open *two* file objects, one for reading and one for writing: fr = open("/dev/ttyS0","rb",0

Re: implementing descriptors

2009-08-14 Thread Diez B. Roggisch
dippim schrieb: On Aug 14, 5:45 am, Jean-Michel Pichavant wrote: Emile van Sebille wrote: On 8/13/2009 3:17 PM dippim said... I am new to Python and I have a question about descriptors. If I have a class as written below, is there a way to use descriptors to be certain that the datetime in s

Re: get the pause status from amarok 2.1

2009-08-14 Thread Diez B. Roggisch
Sleepy Cabbage schrieb: As the title says, I'm trying to find a way to get the pause status from amarok 2.1. I'm running kubuntu 9.04 with kde 4.2.2, python 2.6.2. Thanks in advance. Not at my linux-system right now, but dcop and the respective python-module should help. Diez -- http://ma

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-14 Thread Diez B. Roggisch
Hendrik van Rooyen schrieb: In the past, on this group, I have made statements that said that on Linux, the serial port handling somehow does not allow transmitting and receiving at the same time, and nobody contradicted me. I am running into the self same issue again. What I normally do is

Re: resume upload wsgi script

2009-08-13 Thread Diez B. Roggisch
gert schrieb: On Aug 10, 10:39 am, "Diez B. Roggisch" wrote: 250KB :) So why do you bother? Its just HTTP1.1 has everything for making ftp like file transfers possible. When I write it to a file then I am back at square one because I still need to load it completely to get it i

Re: Frustrated with scopes

2009-08-12 Thread Diez B. Roggisch
andrew cooke wrote: > On Aug 12, 7:49 am, andrew cooke wrote: >> On Aug 12, 1:51 am, James Stroud >> wrote: >> >> >> >> > andrew cooke wrote: >> > > Is there a way to make this work (currently scope and join are >> > > undefined at runtime when the inner class attributes are defined): >> >> > >

Re: Problem when fetching page using urllib2.urlopen

2009-08-11 Thread Diez B. Roggisch
dorzey wrote: > "geturl - this returns the real URL of the page fetched. This is > useful because urlopen (or the opener object used) may have followed a > redirect. The URL of the page fetched may not be the same as the URL > requested." from > http://www.voidspace.org.uk/python/articles/urllib2.

Re: for key, value in dict.() - how to get? (which func)

2009-08-11 Thread Diez B. Roggisch
dmitrey schrieb: Yes, thank you, items() is the correct approach, on the other hand I have already get rid of the cycle. Most certainly items() is *not* the correct approach if you are concerned so much with performance, because items() first creates a list of key/value-pairs, where iteritems

Re: create shell history with python

2009-08-11 Thread Diez B. Roggisch
Joel Juvenal Rivera Rivera schrieb: I been thinking how to make a 'bash like history shell' in python, i don't know if with stdin and stdout i can accomplish this or do i need something like curses and stuff like that, anyway im start to figure this out. Does any body has try this? or have any in

Re: ElementTree - Howto access text within XML tag element...

2009-08-11 Thread Diez B. Roggisch
cmalmqui schrieb: On Aug 11, 9:51 am, "Diez B. Roggisch" wrote: cmalmqui schrieb: Hi, I am writing on a small XML parser and are currently stuck as I am not able to get the whole element name in ElementTree. Please see the below example where "print root[0][0]" returns

Re: UML for Python or some other Graphical Notation Language

2009-08-11 Thread Diez B. Roggisch
llothar wrote: > This is more an academic question right now but was there ever some > work in progress how UML could be made better for Python or script > languages in general. > > It is so extremely deep interwoven with Java/C++ language > implementations that there are a lot of modified notiat

Re: ElementTree - Howto access text within XML tag element...

2009-08-11 Thread Diez B. Roggisch
cmalmqui schrieb: Hi, I am writing on a small XML parser and are currently stuck as I am not able to get the whole element name in ElementTree. Please see the below example where "print root[0][0]" returns "" Is there a way to get hold of the "Running" string in the tag using elementTree?

Re: variable & scoping question.

2009-08-10 Thread Diez B. Roggisch
Cornelius Keller wrote: > Hi, > > I'm a quite fresh python programmer, (6 Month python experience). > Today I found something I absolotly don'nt understand: > > given the following function: > > def test_effect(class_id=None,class_ids=[]): >     if class_id is not None: >         if class_id no

Re: Cython + setuptools not working with .pyx,only with .c-files

2009-08-10 Thread Diez B. Roggisch
Stefan Behnel wrote: > Diez B. Roggisch wrote: >> I'm trying to build a Cython-extension as Egg. >> >> However, this doesn't work - I can either use distutils to build the >> extension, creating a myextension.c-file on the way. >> >> If th

Re: resume upload wsgi script

2009-08-10 Thread Diez B. Roggisch
250KB :) So why do you bother? Its just HTTP1.1 has everything for making ftp like file transfers possible. When I write it to a file then I am back at square one because I still need to load it completely to get it into a blob. Well, the blob is nothing but datat in the file-system. If you

Re: Monkeypatching an object to become callable

2009-08-09 Thread Diez B. Roggisch
Nikolaus Rath schrieb: Hi, I want to monkeypatch an object so that it becomes callable, although originally it is not meant to be. (Yes, I think I do have a good reason to do so). But simply adding a __call__ attribute to the object apparently isn't enough, and I do not want to touch the class

Re: resume upload wsgi script

2009-08-09 Thread Diez B. Roggisch
gert schrieb: On Aug 9, 4:42 pm, "Diez B. Roggisch" wrote: gert schrieb: On Aug 9, 3:17 pm, "Diez B. Roggisch" wrote: gert schrieb: I working on a resume upload script and encountered the following problems sql: Could not decode to UTF-8 column 'SUBSTR(picture,?

Re: resume upload wsgi script

2009-08-09 Thread Diez B. Roggisch
gert schrieb: On Aug 9, 3:17 pm, "Diez B. Roggisch" wrote: gert schrieb: I working on a resume upload script and encountered the following problems sql: Could not decode to UTF-8 column 'SUBSTR(picture,?)' with text '\ufffd\ufff d\ufffd\ufffd↑!ExifEf1gL

Re: resume upload wsgi script

2009-08-09 Thread Diez B. Roggisch
gert schrieb: I working on a resume upload script and encountered the following problems sql: Could not decode to UTF-8 column 'SUBSTR(picture,?)' with text '\ufffd\ufff d\ufffd\ufffd↑!ExifEf1gL6KM7Ij5ae0gL6KM7cH2cH2GI3 Content-Disposition: form-data; name="Filename" You are treati

Re: is it possible to overload operator "^"?

2009-08-08 Thread Diez B. Roggisch
dmitrey schrieb: the operator precedence will seem wrong So, are there any ways to change operator precedence (for my class)? No. Those are built-in. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: is it possible to overload operator "^"?

2009-08-08 Thread Diez B. Roggisch
dmitrey schrieb: hi all, is it possible to overload operator "^"? (AFAIK __pow__ overloads ** instead of ^) Thank you in advance, D. Did you read the link I gave you for your last question? It shows __xor__ as special method. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax checker in python

2009-08-07 Thread Diez B. Roggisch
horos11 schrieb: ps - I just realized that it isn't enough to do: python -c 'import /path/to/script' since that actually executes any statement inside of the script (wheras all I want to do is check syntax) So - let me reprhase that - exactly how can you do a syntax check in python? Something

Re: how to overload operator "< <" (a < x < b)?

2009-08-07 Thread Diez B. Roggisch
alex23 schrieb: On Aug 7, 10:50 pm, Benjamin Kaplan wrote: That isn't an operator at all. Python does not support compound comparisons like that. You have to do "a > b and b > c". You know, it costs nothing to open up a python interpreter and check your certainty: x = 10 1 < x < 20 True T

Re: Bug or feature: double strings as one

2009-08-07 Thread Diez B. Roggisch
durumdara schrieb: Hi! I found an interesting thing in Python. Today one of my "def"s got wrong result. When I checked the code I saw that I miss a "," from the list. l = ['ó' 'Ó'] Interesting, that Python handle them as one string. print ['ó' 'Ó'] ['\xf3\xd3'] I wanna ask that is a bug or

<    1   2   3   4   5   6   7   8   9   10   >