Hello,
I wrote a script that does some time measurements. It uses
time.perf_counter() from Python 3 which works very well. Now I need to
backport it to python 2.
Docs say that time.clock() is way to go:
time.clock()
On Unix, return the current processor time as a floating point number
express
Hello,
I have that piece of code:
def _split_block(self, block):
cre = [re.compile(r, flags = re.MULTILINE) for r in self.regexps]
block = "".join(block)
print(block)
print("---")
for regexp in cre:
match = regexp.match(block
Hello,
Is there a way I can extract the named groups from a regular expression?
e.g. given "(?P\d)" I want to get something like ["testgrp"].
OR
Can I make the match object to return default values for named groups, even
if no match was produced?
Thanks,
Florian
--
https://mail.python.org/m
Hello,
I have a format string like:
print "{:10} {:25} = {:6} ({})".format(mod, name, value, description)
description can be None. In this case I want to print an empty string (which
can be achieved by replacing it with 'description or ""') and I want to omit
the brackets. Is there a way to
Am Dienstag, 14. Januar 2014, 17:00:48 schrieb MRAB:
> On 2014-01-14 16:37, Florian Lindner wrote:
> > Hello!
> >
> > I'm using python 3.2.3 on debian wheezy. My script is called from my mail
> > delivery agent (MDA) maildrop (like procmail) through it's x
Hello!
I'm using python 3.2.3 on debian wheezy. My script is called from my mail
delivery agent (MDA) maildrop (like procmail) through it's xfilter directive.
Script works fine when used interactively, e.g. ./script.py < testmail but when
called from maildrop it's producing an infamous UnicodeD
Hello,
I use argparse from Python 3.3.3 with a custom action that normalizes path
arguments:
http://docs.python.org/3/library/argparse.html#action
def norm_path(*parts):
""" Returns the normalized, absolute, expanded and joined path, assembled
of all parts. """
parts = [ str(p) for p i
Am Donnerstag, 9. Januar 2014, 00:26:15 schrieb Chris Angelico:
> On Thu, Jan 9, 2014 at 12:14 AM, Florian Lindner wrote:
> > I've written some tiny script using Python 3 and it used to work perfectly.
> > Then I realized it needs to run on my Debian Stable server too, wh
Hello!
I've written some tiny script using Python 3 and it used to work perfectly.
Then I realized it needs to run on my Debian Stable server too, which offers
only Python 2. Ok, most backporting was a matter of minutes, but I'm becoming
desperate on some Unicode error...
i use scikit-learn to
Hello,
I want to use some machine learning stuff on mail messages. First step is get
some flattened text from a mail message, python's email package does not work
as automatically as I wish. Right now I have:
> def mail_preprocessor(str):
> msg = email.message_from_string(str)
> msg_bod
Am Dienstag, 15. Oktober 2013, 13:18:17 schrieb Michael Speer:
> > "/usr/sbin/ftpasswd" "--hash"
>
> You're missing a comma, and python automatically concatenates adjacent
> strings.
Damn!
Thanks!
>
> On Tue, Oct 15, 2013 at 1:13 PM, Florian L
Hello,
I have a 3rd party perl script:
head -n 1 /usr/sbin/ftpasswd
#!/usr/bin/perl
I want to write data to stdin and read from stdout:
proc = Popen( ["/usr/bin/perl", "/usr/sbin/ftpasswd" "--hash", "--stdin"],
stdout=PIPE, stdin=PIPE)
output, input = proc.communicate(pwd)
return output.stri
Hello,
I have a:
class C:
def __init__(self):
d = dict_like_object_created_somewhere_else()
def some_other_methods(self):
pass
class C should behave like a it was the dict d. So I could do:
c = C()
print c["key"]
print len(c)
but also
c.some_other_method()
How can I achieve
Hello,
I have a class method that executes a subprocess. There are two loggers in the
class, self.logger for general logging and proclog for process output (stdout
& stderr) logging which should go to stdout and a file:
def start_process(self, command, no_shlex=False, raise_excpt=True,
Hello,
I plan to use the etree.ElementTree XML parser to parse a config file
in which the order of the elements matter, e.g.:
is not equal to:
I have found different answers to the question if order matters in XML
documents. So my question here: Does it matters (and is more or less
guare
Hello,
I have a (rather small, memory consumption is not an issue) XML document. The
application is still at the planning stage, so none of the XML parsers from
the stdlib is choosen yet.
I want to cut out an XML subtree like that:
Now I want to get the subB note inclu
Hello,
I configure my logging on application startup like that:
logging.basicConfig(level = logging.DEBUG, format=FORMAT, filename = logfile)
ch = logging.StreamHandler()
ch.setFormatter(logging.Formatter(FORMAT))
logging.getLogger().addHandler(ch)
In one module of my application I want a logge
Hello,
how can I achieve a behavior like tee in Python?
* execute an application
* leave the output to stdout and stderr untouched
* but capture both and save it to a file (resp. file-like object)
I have this code
proc = subprocess.Popen(shlex.split(cmd), stdout = subprocess.PIPE,
stderr=subpro
Steven D'Aprano wrote:
> On Sun, 11 Nov 2007 11:22:19 +0100, Florian Lindner wrote:
>
>> Hello,
>> I have a piece of code like that:
>>
>> for row in resultSet:
>> logs += "/home/%s/%s/log/access.log \n" % (row[1], row[0])
>>
Hello,
I have a piece of code like that:
for row in resultSet:
logs += "/home/%s/%s/log/access.log \n" % (row[1], row[0])
logs += "/home/%s/%s/log/error.log \n" % (row[1], row[0]) # <--
Now I want to avoid the newline at the last iteration and only at the second
line.
How to d
Marc 'BlackJack' Rintsch wrote:
> On Sat, 10 Nov 2007 09:45:47 -0800, rishiyoor wrote:
>
>> I need help coding my flowchart. The C's are conditions, the S's are
>> statements. The statements do not affect the conditions except for S5
>> which is an increment for C0. The left is True, and the righ
On 18 Okt., 22:08, Paul McNett <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Oct 19, 7:32 am, Florian Lindner <[EMAIL PROTECTED]> wrote:
> >> Hello,
> >> I have a string:
>
> >> INSERT INTO mailboxes (`name`, `login`, `home`, `mail
Hello,
I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:
ret = cursor.execute(sql, paras)
paras is:
('flindner', '[EMAIL PROTECTED]', '/home/flindner/', '/home
[EMAIL PROTECTED] wrote:
> On Oct 12, 2:55 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
>> Hello,
>> is there a function in the Python stdlib to test if a string is a valid
>> email address?
>>
>> Thanks,
>>
>> florian
>
> What do you m
Larry Bates wrote:
> Florian Lindner wrote:
>> Hello,
>> I have a little problem with the global statement.
>>
>> def executeSQL(sql, *args):
>> try:
>> import pdb; pdb.set_trace()
>> cursor = db.cursor() # db is .
>>
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?
Thanks,
florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I have a little problem with the global statement.
def executeSQL(sql, *args):
try:
import pdb; pdb.set_trace()
cursor = db.cursor() # db is .
[...]
except:
print "Problem contacting MySQL database. Please contact root."
sys.exit(-1)
db =
Carsten Haese wrote:
> On Fri, 2007-10-12 at 13:12 +0200, Florian Lindner wrote:
>> Carsten Haese wrote:
>> > sql = "INSERT INTO "+DOMAIN_TABLE+"("+DOMAIN_FIELD+") VALUES (%s)"
>> > executeSQL(sql, domainname)
>>
>> Ok, I under
Carsten Haese wrote:
> On Thu, 2007-10-11 at 15:14 +0200, Florian Lindner wrote:
>> Hello,
>> I have a function that executes a SQL statement with MySQLdb:
>>
>> def executeSQL(sql, *args):
>> print sql % args
>> cursor = conn.c
Hello,
can I determine somehow if the iteration on a list of values is the last
iteration?
Example:
for i in [1, 2, 3]:
if last_iteration:
print i*i
else:
print i
that would print
1
2
9
Can this be acomplished somehow?
Thanks,
Florian
--
http://mail.python.org/mailman/lis
Hello,
I have a function that executes a SQL statement with MySQLdb:
def executeSQL(sql, *args):
print sql % args
cursor = conn.cursor()
cursor.execute(sql, args)
cursor.close()
it's called like that:
sql = "INSERT INTO %s (%s) VALUES (%s)"
executeSQL(sql, DOMAIN_TABLE,
Hello,
some time ago I've heard about proposals to introduce the concecpt of
interfaces into Python. I found this old and rejected PEP about that:
http://www.python.org/dev/peps/pep-0245/
What is the current status of that?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I have a struct_time and a datetime object and need compare them. Is there
any function that converts either of these two to another?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> On Apr 2, 10:20 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
>> Some of the question I have but found answered nowhere:
>>
>> I have a feedparser object that was created from a string. How can I
>> trigger a update (from a new string
[EMAIL PROTECTED] wrote:
> On Apr 2, 7:22 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
>> Hello,
>> I'm looking for python RSS feed parser library.
>> Feedparserhttp://feedparser.org/does not seem to maintained anymore.
>>
>> What alternatives ar
Hello,
I'm looking for python RSS feed parser library. Feedparser
http://feedparser.org/ does not seem to maintained anymore.
What alternatives are recommendable?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I have a function from a library thast expects a file object as argument.
How can I manage to give the function a string resp. have the text it would
have written to file object as a string?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I'm looking for a python library that creates a RSS and/or Atom feed. E.g. I
give a list like that:
[
[title1, short desc1, author1],
[title2, short desc2, author2],
]
and the library creates a valid feed XML file. (return as a string)
Thanks,
Florian
--
http://mail.python.org/mailma
Hello,
does python have static variables? I mean function-local variables that keep
their state between invocations of the function.
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> that will break horribly in windows, remenber it install all it's crap
> in c:\Program Files
Why should this break? If you split at the \n character?
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I try to call the superclass of the ConfigParser object:
class CustomizedConfParser(ConfigParser.SafeConfigParser):
def get(self, section, attribute):
try:
return super(CustomizedConfParser, self).get(section, attribute)
# [...]
but that gives only
ret
Hello,
how can I get all subdirectories of a given directories? os.listdir() gives
me all entries and I've found no way to tell if an object is a file or a
directory.
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
http://docs.python.org/lib/module-ConfigParser.html writes:
"with continuations in the style of RFC 822; "
what is meant with these continuations?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Alexis Roda wrote:
> Florian Lindner escribió:
>> I think the best solution would be to use a seperation character:
>>
>> dir="/home/florian, /home/john, home/whoever"
>
> RCS uses , in filenames
A kommata (,) is a valid character in path names. Ok, you
Hello,
since ConfigParser does not seem to support multiple times the same option
name, like:
dir="/home/florian"
dir="/home/john"
dir="/home/whoever"
(only the last one is read in)
I wonder what the best way to work around this.
I think the best solution would be to use a seperation character:
Hello,
how can I get the path of a class. I managed to do it with
c.__module__ + "." + c.__name__
but I'm sure there is a better way.
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
benz wrote:
PYTHON_IDE={
> 'spe' : 'http://spe.pycs.net/',
> 'eric3' : 'http://www.die-offenbachs.de/detlev/eric3.html',
> 'drpython' : 'http://drpython.sourceforge.net/'}
I've tried out eric3 and it looks promising. However, I have one problem. I
open a file which is part of Zope and set a b
Hello,
in order to understand python code from a larger project (Zope 3) I'm
looking for a tool that helps me with that. It should also help
What (graphical) application running on Linux can you recommend?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
is there a python lib (preferably in the std lib) to monitor a directory for
changes (adding / deleting files) for Linux 2.6?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Florian Lindner wrote:
> Hello,
> I've been using Python a lot for scripting (mainly scripts for server
> administration / DB access). All these scripts were shell based.
>
> Now I'm considering using Python (with mod_python on Apache 2) for a web
> project, ju
Hello,
I've been using Python a lot for scripting (mainly scripts for server
administration / DB access). All these scripts were shell based.
Now I'm considering using Python (with mod_python on Apache 2) for a web
project, just how I've used PHP in some smaller Projects before ()..
How suitable
Hello,
I try to compute SHA hashes for different files:
for root, dirs, files in os.walk(sys.argv[1]):
for file in files:
path = os.path.join(root, file)
print path
f = open(path)
sha = sha.new(f.read())
sha.update(f.read())
print sha.hexdigest
Hello,
IIRC there is a directory traverser for walking recursively through
subdirectories in the standard library. But I can't remember the name and
was unable to find in the docs.
Anyone can point me to it?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Peter Hansen wrote:
> Florian Lindner wrote:
>> Peter Hansen wrote:
>>>[Zope] doesn't include
>>>database interfaces other than to its own ZODB.
>>
>> That's not correct. Zope2 includes DB interfaces to MySQL, PostGre, ODBC
>> and many oth
Peter Hansen wrote:
> godwin wrote:
>> I wanna thank Martin for helping out with my ignorance concerning
>> execution of stored procedure with python. Now i have decided to write
>> a web app that googles into my companies proprietary database.
>
> Just checking... do you really mean "googl
Hello,
is there in python a kind of dictionary that supports key - key pairs?
I need a dictionary in which I can access a certain element using two
different keys, both unique.
For example:
I've a dictionary with strings and times. Sometimes I have the string and I
want to have the time, other ti
Hello,
I am building a object cache in python, The cache has a maximum size and the
items have expiration dates.
At the moment I'm doing like that:
cache = {} # create dictionary
cache[ID] = (object, timestamp) # Save a tuple with the object itself and a
timestamp (from datetime.datetime.now()) u
Hello,
I want to know if a certain duration is over.
I try it like this with timedelta objects:
d = datetime.timedelta(minutes = 2)
t = time.gmtime()
print (t + d < time.gmtime())
gives:
TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and
'time.struct_time'
How to do that rig
Hello,
is there a function to escape spaces and other characters in string for
using them as a argument to unix command? In this case rsync
(http://samba.anu.edu.au/rsync/FAQ.html#10)
Thx,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Richie Hindle wrote:
>
> [Florian]
>> You mean that csv.reader can't work with unicode as the delimiter
>> parameter?
>
> Exactly. http://www.python.org/doc/2.3.5/lib/module-csv.html says:
>
> "Note: This version of the csv module doesn't support Unicode input. Also,
> there are currently some
Richie Hindle wrote:
>
> [Florian]
>> I've one problem using the csv module.
>> The code:
>>
>> self.reader = csv.reader(f, delimiter = ",")
>>
>> works perfectly. But when I use a variable for delimiter:
>>
>> self.reader = csv.reader(f, delimiter = Adelimiter)
>>
>> I get th
Hello,
I've one problem using the csv module.
The code:
self.reader = csv.reader(f, delimiter = ",")
works perfectly. But when I use a variable for delimiter:
self.reader = csv.reader(f, delimiter = Adelimiter)
I get the traceback:
File "/home/florian/visualizer/ConfigReader.
Hello,
I've the traceback:
Traceback (most recent call last):
File "visualizer.py", line 8, in ?
main()
File "visualizer.py", line 5, in main
g = GraphCreator(f)
File "/home/florian/visualizer/GraphCreator.py", line 13, in __init__
self.conf = ConfigReader(config)
File "/home/f
Hello,
when I'm iterating through a list with:
for x in list:
how can I get the number of the current iteration?
Thx,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
how can I give an arbitrary number of options in a automated way to a
function?
Example.
I've the list A =
[
1
2
3
...
]
Now I want to give this list to a function so that it is the same for
function like:
f(1, 2, 3, ...)
How can I do that?
Thanks,
Flor
Hello,
I'm using the PyXML Package.
My XML document looks like that:
/home/florian/visualizer/testdata.csv
print sourceNode.getElementsByTagName("filename")[0]
print sourceNode.getElementsByTagName("filename")[0].nodeValue()
gives:
Traceback (most recen
Maniac wrote:
> Florian Lindner wrote:
>
>>Traceback (most recent call last):
>> File "ConfigReader.py", line 40, in ?
>>c = ConfigReader(f)
>> File "ConfigReader.py", line 32, in __init__
>>print sourceNode.getElementsByTagName(&
Hello,
I'm looking for libraries to create graphs. I'm not talking about plotting a
function like f(x)=x^2 just plotting a couple of values into a short, maybe
interpolating them. Output should be something like JPEG.
Thx,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I've read the chapter in the Python documentation, but I'm interested in a a
more in-depth comparision. Especially regarding how pythonic it is and how
well it performs and looks under Windows.
I've some C++ experiences with Qt, so I'm very interested to have PyQt
compared to wxWindows and T
Paul Rubin wrote:
> Florian Lindner <[EMAIL PROTECTED]> writes:
>> I have a script which is readable and executable by a user, but not
>> writable.
>> The users executes the scripts, it reads in a value and based on this
>> value it computes a result and stores
Hello,
given the following situation:
I have a script which is readable and executable by a user, but not
writable.
The users executes the scripts, it reads in a value and based on this value
it computes a result and stores it in a variable.
Can the user read out the value of this variable? If yes
Serge Orlov wrote:
> Florian Lindner wrote:
>> Paul Rubin wrote:
>>
>>> - sort of similar: have a separate process running that knows the
>>> password (administrator enters it at startup time). That process
>>> listens on a unix socket and checks
Paul Rubin wrote:
> Florian Lindner <[EMAIL PROTECTED]> writes:
>> I've a scripts that allows limited manipulation of a database to users.
>> This script of course needs to save a password for the database
>> connection. The users, on the other hand need read perm
Esben Pedersen wrote:
> Florian Lindner wrote:
>> Hello,
>> I've a scripts that allows limited manipulation of a database to users.
>> This script of course needs to save a password for the database
>> connection. The users, on the other hand need read permiss
Peter Hansen wrote:
> Florian Lindner wrote:
>> I've a scripts that allows limited manipulation of a database to users.
>> This script of course needs to save a password for the database
>> connection. The users, on the other hand need read permission on the
>> s
Hello,
I've a scripts that allows limited manipulation of a database to users. This
script of course needs to save a password for the database connection. The
users, on the other hand need read permission on the script in order to
execute it but should not be able to read out the password.
What is
Hello,
how can I mark a attribute of a class as read-only (for non classmembers)?
Yes, stupid question, but the docu gave me no help.
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
what is a good python library for parsing of RSS and/or Atom feeds. It
should be able to handle most of the common protocols.
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
AFAIK python has a generic API for database access which adapters are
supposed to implement. How can I found API documentation on the API?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard schrieb:
Christopher J. Bottaro wrote:
Why don't this code work?
import PRI
class Poscdnld_PYIO(PRI.BasicBatch):
def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)
x = Poscdnld_PYIO()
I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
Hello,
which free forums, based on mod_python and MySQL are around there?
Something like phpBB...
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I've two files in my package.
In the first file I want to inport a class which is declared in the
second file. How can do that without stating the absolute path to the
file, just the relative one?
Thanks,
Florian
--
http://mail.python.org/mailman/listinfo/python-list
82 matches
Mail list logo