This week I was slightly surprised by a behaviour that I've not
considered before. I've long used
for i, x in enumerate(seq):
# do stuff
as a standard looping-with-index construct. In Python for loops don't
create a scope, so the loop variables are available afterward. I've
sometimes used this
Last week I was surprised to discover that there are Unicode characters that
aren't valid in an XML document. That is regardless of escaping (e.g. �)
and unicode encoding (e.g. UTF-8) - not every Unicode string can be stored in
XML. The valid characters are (as of XML 1.0) #x9 | #xA | #xD | [#x2
On Apr 11, 9:52 pm, cerr wrote:
> Hi,
>
> I want to install some python driver on my system that requires trac.util
> (from Image.py) but I can't find that anywhere, any suggestions, anyone?
>
> Thank you very much, any help is appreciated!
>
> Error:
> File "/root/weewx/bin/Image.py", line 32, i
On Apr 19, 9:18 pm, Page3D wrote:
> Hi, I am trying to connect and access data in a *.sdf file on Win7
> system using Python 2.7. I have three questions:
>
> 1. What python module should I use? I have looked at sqlite3 and
> pyodbc. However, I can seem to get the connection to the database file
>
On Feb 28, 6:53 pm, monkeys paw wrote:
> I'm trying to subclass urllib2 in order to mask the
> version attribute. Here's what i'm using:
>
> import urllib2
>
> class myURL(urllib2):
> def __init__(self):
> urllib2.__init__(self)
> self.version = 'firefox'
>
> I get this>
> T
On the English version of http://python.org I'm seeing 下载 as a menu
item between Download and Community. AFAICT it's Simplified Chinese
for 'download'. Is it's appearance intentional, or a leak through from
a translation of the entire page?
Regards, Alex
PS Tested with 10.0.648.114 (75702) and Fi
On Mar 9, 6:12 pm, "Aaron Gray" wrote:
> On Windows I have installed Python 3.2 and PyOpenGL-3.0.1 and am getting the
> following error :-
>
> File "c:\Python32\lib\site-packages\OpenGL\platform\win32.py", line 13
> except OSError, err:
> ^
>
> It works okay on my Linux m
On Mar 22, 2:06 pm, Bradley Hintze
wrote:
> I just started with argparse. I want to simply check the extension of
> the file that the user passes to the program. I get a ''file' object
> has no attribute 'rfind'' error when I use
> os.path.splitext(args.infile). Here is my code.
>
> import argpar
On Mar 22, 2:06 pm, Bradley Hintze
wrote:
> Hi,
>
> I just started with argparse. I want to simply check the extension of
> the file that the user passes to the program. I get a ''file' object
> has no attribute 'rfind'' error when I use
> os.path.splitext(args.infile).
Addendum, some file object
On Mar 23, 1:33 am, monkeys paw wrote:
> When i open a file in python, and then print the
> contents line by line, the printout has an extra blank
> line between each printed line (shown below):
>
> >>> f=open('authors.py')
> >>> i=0
> >>> for line in f:
> print(line)
> i=i+1
>
On Mar 23, 3:20 pm, T wrote:
> Thanks! argparse is definitely what I need..unfortunately I'm running
> 2.6 now, so I'll need to upgrade to 2.7 and hope that none of my other
> scripts break.
Argparse was a third-party module before it became part of the std-
lib. You may find it easier to use th
(Direct reply to me, reposted on Jame's behalf)
Hi Alex,
On Mon, May 9, 2011 at 3:21 PM, Alex Willmer
wrote:
> On May 9, 8:10 pm, James Wright wrote:
>> Hello Ian,
>>
>> It does indeed to seem that way. However the script works just fine
>> on other ma
When reporting file sizes to the user, it's nice to print '16.1 MB',
rather than '16123270 B'. This is the behaviour the command 'df -h'
implements. There's no python function that I could find to perform this
formatting , so I've taken a stab at it:
import math
def human_readable(n, suffix='B', p
I'm trying to track down the name of a file format and python module,
that was featured in the Daily Python URL some time in the last month or
two.
The format was ASCII with a multiline header defining types for the
comma seperated column data below. It may have had the capability to
store multipl
On Fri, 2005-10-07 at 18:56 +0200, Fredrik Lundh wrote:
> Alex Willmer wrote:
>
> > I'm trying to track down the name of a file format and python module,
> > that was featured in the Daily Python URL some time in the last month or
> > two.
>
> http://www.netpro
On Thu, 2005-10-06 at 07:44 -0800, EP wrote:
> Was it something like ARFF? http://www.cs.waikato.ac.nz/~ml/weka/arff.html
Yes that was it thankyou. Although it would seem there isn't a general
python module, rather a Cookbook script to perform conversion to SQL. I
must have confused ARFF with HDF
A challenge, just for fun. Can you speed up this function?
import string
charset = set(string.ascii_letters + string.digits + '@_-')
byteseq = [chr(i) for i in xrange(256)]
bytemap = {byte: byte if byte in charset else '+' + byte.encode('hex')
for byte in byteseq}
def plus_encode(s):
On Monday, 18 August 2014 21:16:26 UTC+1, Terry Reedy wrote:
> On 8/18/2014 3:16 PM, Alex Willmer wrote:
> > A challenge, just for fun. Can you speed up this function?
>
> You should give a specification here, with examples. You should perhaps
Sorry, the (informal) spec w
Hello,
I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small inte
On Mar 15, 4:06 am, John Nagle wrote:
> Is this available as a paper?
>
> John Nagle
It doesn't wppear to be, slides are here:
http://us.pycon.org/2010/conference/schedule/event/12/
Alex
--
http://mail.python.org/mailman/listinfo/python-list
EuroPython 2010 - 17th to 24th July 2010
EuroPython is a conference for the Python programming language
community, including the Django, Zope and Plone communities. It is
aimed at everyone in the Python community, of all skill levels, both
users and program
On Apr 2, 11:12 am, Thomas Heller wrote:
> Maybe I'm just lazy, but what is the fastest way to convert a string
> into a tuple containing character sequences and integer numbers, like this:
>
> 'si_pos_99_rep_1_0.ita' -> ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita')
>
This is very probably not the
On Dec 7, 9:03 pm, utabintarbo wrote:
> I am using tempfile.mkdtemp() to create a working directory on a
> remote *nix system through a Samba share. When I use this on a Windows
> box, it works, and I have full access to the created dir. When used on
> a Linux box (through the same Samba share), t
On Dec 8, 6:26 pm, Christian Heimes wrote:
> There isn't a way to limit access to a single process. mkdtemp creates
> the directory with mode 0700 and thus limits it to the (effective) user
> of the current process. Any process of the same user is able to access
> the directory.
>
> Christian
Qui
On Dec 27, 6:47 am, "Mark Tolonen" wrote:
> "gintare" wrote in message
> > In file i find 'hyv\xe4' instead of hyv .
>
> When you open a file with codecs.open(), it expects Unicode strings to be
> written to the file. Don't encode them again. Also, .writelines() expects
> a list of strings. Us
On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote:
> The grouper-way looks nice, but I tried it and it didn't work:
>
> from itertools import *
> ...
> d = dict(grouper(2, l))
>
> NameError: name 'grouper' is not defined
>
> I use Python 2.7. Should it work with this version?
No. As Ian said g
On Sunday, January 2, 2011 5:43:38 PM UTC, gervaz wrote:
> Sorry, but it does not work
>
> >>> def prg3(l):
> ... return "\n".join([x for x in l if x])
> ...
> >>> prg3(t)
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 2, in prg3
> TypeError: sequence item 0: e
On Sunday, January 2, 2011 6:40:45 PM UTC, catalinf...@gmail.com wrote:
> I install Python 2.7 on Windows XP.
> I try use :
>
> import win32service
> import win32serviceutil
>
> But I got that error :
>
> ImportError: No module named win32service
> Where is this module ?
It's part of the pywin3
I've created a spreadsheet that compares the built ins, features and modules of
the CPython releases so far. For instance it shows:
- basestring was first introduced at version 2.3 then removed in version 3.0
- List comprehensions (PEP 202) were introduced at version 2.0.
- apply() was a built in
On Tuesday, January 4, 2011 12:54:24 AM UTC, Malcolm wrote:
> Alex,
>
> I think this type of documentation is incredibly useful!
Thank you.
> Is there some type of key which explains symbols like !, *, f, etc?
There is a key, it's the second tab from the end, '!' wasn't documented and I
forgot
Thank you Antoine, I've fixed those errors. Going by the docs, I have VMSError
down as first introduced in Python 2.5.
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 4, 8:20 pm, Google Poster wrote:
> Can any of you nice folks post a snippet of how to perform a listing
> of the current directory and save it in a string?
>
> Something like this:
>
> $ setenv FILES = `ls`
>
> Bonus: Let's say that I want to convert the names of the files to
> lowercase? A
On Jan 11, 8:53 pm, Jeremy wrote:
> I have a file that has unicode escape sequences, i.e.,
>
> J\u00e9r\u00f4me
>
> and I want to replace all of them in a file and write the results to a new
> file. The simple script I've created is copied below. However, I am getting
> the following error:
>
On Jan 11, 10:40 pm, "W. Martin Borgert" wrote:
> Hi,
>
> naively, I thought the following code:
>
> #!/usr/bin/env python2.6
> # -*- coding: utf-8 -*-
> import codecs
> d = { u'key': u'我爱中国人' }
> if __name__ == "__main__":
> with codecs.open("ilike.txt", "w", "utf-8") as f:
> print >>
On Jan 21, 10:39 am, sl33k_ wrote:
> What is namespace? And what is built-in namespace?
A namespace is a container for names, like a directory is a container
for files. Names are the labels we use to refer to python objects
(e.g. int, bool, sys), and each Python object - particularly modules
and
On Feb 15, 10:09 am, Wojciech Muła
wrote:
> import re
>
> s = 'xxaabbddee'
> m = re.compile("(..)")
> s1 = m.sub("\\1:", s)[:-1]
One can modify this slightly:
s = 'xxaabbddee'
m = re.compile('..')
s1 = ':'.join(m.findall(s))
Depending on one's taste this could be clearer. The more general
answe
The EuroPython 2010 call for papers closes this Friday on 30th April.
We've already had many submissions covering Python 3, Python 2.7,
IronPython, Game Programming, Testing, Behavior Driven Development,
NoSQL, Accessiblilty and others.
We still are looking for talks and tutorials on Django, PyPy,
On Aug 3, 11:21 am, loial wrote:
> In a unix shell script I can do something like this to look in a
> directory and get the name of a file or files into a variable :
>
> MYFILE=`ls /home/mydir/JOHN*.xml`
>
> Can I do this in one line in python?
Depends if you count imports.
import glob
my_files
On Aug 4, 2:35 pm, vsoler wrote:
> Hi all,
>
> I just installed python 3.1.2 where I used to have python 2.6.4. I'm
> working on Win7.
>
> The IDLE GUI works, but I get the following message when trying to
> open *.py files written for py 2.6
>
> The Application cannot locate win32ui.pyd (
On Aug 4, 5:19 pm, vsoler wrote:
> On Aug 4, 5:41 pm, Alex Willmer wrote:
>
>
>
>
>
> > On Aug 4, 2:35 pm, vsoler wrote:
>
> > > Hi all,
>
> > > I just installed python 3.1.2 where I used to have python 2.6.4. I'm
> > > workin
On Aug 7, 4:48 pm, Peng Yu wrote:
> The problem is that I don't know how to capture pattern that repeat
> itself (like 'a' and 'xy' in the example). I could use 'test\((\w+)
> (\w+)\)(\w) (\w)', but it will capture something like 'test(a b)x y',
> which I don't want to.
>
> I'm wondering if there
On Aug 7, 5:26 pm, GZ wrote:
> I am wondering if there is a module that can persist a stream of
> objects without having to load everything into memory. (For this
> reason, I think Pickle is out, too, because it needs everything to be
> in memory.)
>From the pickle docs it looks like you could do
On Aug 16, 1:07 am, Steven D'Aprano wrote:
> You're passing re.IGNORECASE (which happens to equal 2) as a count
> argument, not as a flag. Try this instead:
>
> >>> re.sub(r"python\d\d" + '(?i)', "Python27", t)
> 'Python27'
Basically right, but in-line flags must be placed at the start of a
patte
On Aug 16, 12:23 pm, Steven D'Aprano wrote:
> On Sun, 15 Aug 2010 17:36:07 -0700, Alex Willmer wrote:
> > On Aug 16, 1:07 am, Steven D'Aprano > cybersource.com.au> wrote:
> >> You're passing re.IGNORECASE (which happens to equal 2) as a count
> &g
On Aug 16, 1:46 pm, Alex Willmer wrote:
> "Note that the (?x) flag changes how the expression is parsed. It
> should be used first in the expression string, or after one or more
> whitespace characters. If there are non-whitespace characters before
> the flag, the results are u
On Aug 24, 5:33 pm, richie05 bal wrote:
> i am starting to learn python and I am stuck with query I want to
> generate with python
> File looks something like this
> TRACE: AddNewBookD {bookId 20, noofBooks 6576, authorId 41,
> publishingCompanyId 7}
> TRACE: AddNewBookD {bookId 21, noofBooks 6577
On Aug 24, 9:45 pm, m_ahlenius wrote:
>
> whereas this fails:
> myStrA = 'Sun Aug 22 19:03:06 PDT'
> gTimeA = strptime( myStrA, '%a %b %d %H:%M:%S %Z')
> print "gTimeA = ",gTimeA
>
> ValueError: time data 'Sun Aug 22 19:03:06 PDT' does not match format
> '%a %b %d %H:%M:%S %Z'
Support for the %Z
On Aug 25, 8:48 am, Lawrence D'Oliveiro wrote:
> In message
> <45faa241-620e-42c7-b524-949936f63...@f6g2000yqa.googlegroups.com>, Alex
>
> Willmer wrote:
> > Dateutil has it's own timezone database ...
>
> I hate code which doesn’t just use /usr/share/zo
gular expression module, to replace re.',
author='Matthew Barnett',
author_email='pyt...@mrabarnett.nospam.plus.com', # Obsfucated
url='http://bugs.python.org/issue2636',
py_modules = ['regex'],
ext_modules=[Extension('_regex', ['_regex.c'])],
)
Sincerely, Alex Willmer
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 3, 10:35 am, "jc.lopes" wrote:
> Does anyone knows what is the proper way to submit a bug report to
> pythonware PIL?
>
> thanks
> JC Lopes
The Python Image SIG list http://mail.python.org/mailman/listinfo/image-sig
"Free Support: If you don't have a support contract, please send your
que
Your code works (assuming digits gets populated fully), but it's the
absolute bare minimum that would.
To be brutally honest it's:
- unpythonic - you've not used the core features of Python at all,
such as for loops over a sequence
- poorly formatted - Please read the python style guide and follo
On Sep 19, 12:20 pm, Lawrence D'Oliveiro wrote:
> In message
> , Alex
>
> Willmer wrote:
> > # NB Constants are by convention ALL_CAPS
>
> SAYS_WHO?
Says PEP 8:
Constants
Constants are usually declared on a module level and written in
all
cap
On Sep 29, 12:38 pm, Hrvoje Niksic wrote:
> Tracubik writes:
> > Hi all,
> > I'm studying PyGTK tutorial and i've found this strange form:
>
> > button = gtk.Button(("False,", "True,")[fill==True])
>
> > the label of button is True if fill==True, is False otherwise.
>
> The tutorial likely predat
On Oct 5, 7:41 am, Pascal Polleunus wrote:
> On 05/10/10 00:11, Diez B. Roggisch wrote:
> > Install the python-dev-package. It contains the Python.h file, which the
> > above error message pretty clearly says. Usually, it's a good idea to
> > search package descriptions of debian/ubuntu packages f
On Oct 25, 11:07 am, kj wrote:
> In "The Zen of Python", one of the "maxims" is "flat is better than
> nested"? Why? Can anyone give me a concrete example that illustrates
> this point?
I take this as a reference to the layout of the Python standard
library and other packages i.e. it's better t
On Oct 25, 2:56 pm, Robin Becker wrote:
> On 25/10/2010 11:07, kj wrote:
>
> > In "The Zen of Python", one of the "maxims" is "flat is better than
> > nested"? Why? Can anyone give me a concrete example that illustrates
> > this point?
>
> ...
> I believe that the following illustrates the n
On Oct 28, 11:24 am, Alex wrote:
> hi there, I keep getting the message in the Topic field above.
>
> Here's my code:
>
> self.click2=Button(root,text="Click Me").grid(column=4,row=10)
> self.click2.bind("",self.pop2pop)
>From reading the Tkinter docs grid doesn't itself return a control. So
I th
On Oct 30, 7:16 pm, brad...@hotmail.com wrote:
> I was thinking of recommending this to a friend but what do you all think?
>
I think
1. Python is a great language, and a good starting point for many
people.
2. You really haven't given us much to go on.
Regards, Alex
--
http://mail.python.org/
58 matches
Mail list logo