The following code demonstrates that a collections.defaultdict is
shelve worthy:
import shelve
import collections as c
dd = c.defaultdict(int)
dd["Joe"] = 3
print(dd)
my_shelve = shelve.open('data.shelve')
my_shelve['strike_record'] = dd
my_shelve.close()
my_shelve = shelve.open('data.shelve'
On Feb 10, 7:48 pm, 7stud <7s...@excite.com> wrote:
>
> But I cannot get a class that inherits from collections.defaultdict to
> shelve itself:
>
> import collections as c
> import shelve
>
> class Dog(c.defaultdict):
> def __init__(self):
> super().
On Feb 10, 7:52 pm, 7stud <7s...@excite.com> wrote:
I don't know if this helps, but I notice when I initially do this:
shelve.open('data22')
the file is saved as 'data22.db'. But on subsequent calls to
shelve.open(), if I use the file name 'data22.db&
On Feb 11, 10:56 am, Ian Kelly wrote:
> On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote:
> > class Dog(dict):
>
> > def __missing__(self):
> > return 0
>
> Sorry, that should have been:
>
> class Dog(dict):
>
> def __missing__(self, key):
> return 0
>
> Cheers,
> Ian
Than
http://www.evolt.org/article/OO_programming_the_Python_way/18/449/
-
The last article gives you the absolute basics of using Python. This
time, we'll do the OO side of Python. Yes, Python: a true object-
oriented language with classes, inheritance and all.
Ok, my OO background comes from the
Ron Provost wrote:
> class X( object ):
>fn = None
>@staticmethod
>def callX( n ):
> return X.fn( n )
> Now, the following global stuff represents my higher-level routines:
> def fn_impl( n ): # my callback
>return n + 1
> X.fn = fn_impl # register my callback
> No
On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> suppose i have a free_object list[Sample1, Smaple2]. when create a
> new object sample(*args, **kwds), if free_object_list isn't empty, just
> pop one from free_object_list instead of creating a new instance.
>
> any way to do this
I just noticed that in your code you used pop(0). It's not efficient
to pop an element off the front of a list because after doing so,
every other element in the list has to be moved over to the left one
position. If you pop() an element off the end of the list, then the
first element in the list
On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> suppose i have a free_object list[Sample1, Smaple2]. when create a
> new object sample(*args, **kwds), if free_object_list isn't empty, just
> pop one from free_object_list instead of creating a new instance.
>
> any way to do this
On Jun 3, 12:17 am, 7stud <[EMAIL PROTECTED]> wrote:
> On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > suppose i have a free_object list[Sample1, Smaple2]. when create a
> > new object sample(*args, **kwds), if free_o
On Jun 3, 12:50 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sat, 02 Jun 2007 23:25:49 -0700, 7stud wrote:
> > Oops. This line:
>
> >> temp = object.__new__(Sample, args, kwds)
>
> > should be:
>
> > temp = object.__new__(cls, args, kwd
On Jun 10, 10:37 am, Stef Mientki <[EMAIL PROTECTED]>
wrote:
> hello,
>
> For a simulation at different levels,
> I need different functions with the same name.
> Is that possible ?
>
> I can realize it with a simple switch within each function,
> but that makes the code much less readable:
>
> def
On Jun 10, 11:11 am, 7stud <[EMAIL PROTECTED]> wrote:
> On Jun 10, 10:37 am, Stef Mientki <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > hello,
>
> > For a simulation at different levels,
> > I need different functions with the same name.
> > Is that
On Jun 10, 2:03 pm, Stef Mientki <[EMAIL PROTECTED]>
wrote:
> thanks Francesco and "7stud",
>
> The solution with objects is too difficult,
> because I want to stay very close to the orginal language,
>
Why would you want to duplicate poorly written code?
--
On Jun 13, 2:40 am, james_027 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> class UserDict:
> def __init__(self, dict=None):
> self.data = {}
> if dict is not None: self.update(dict)
>
> I just don't understant this code, as it is not also mention in the
> book. the update is a method of
On Jun 14, 11:21 am, [EMAIL PROTECTED] (John Fisher) wrote:
> Hi Groupies,
>
> I have an Intel Macbook running OS X 10.4.
>
> It came installed with Python 2.3.5. I have since installed MacPython
> with version 2.4.4, cool.
>
> When I open a bash terminal session and type python, it brings up
> ver
On Jun 14, 6:25 pm, Paul McNett <[EMAIL PROTECTED]> wrote:
> John Fisher wrote:
> > Ted <[EMAIL PROTECTED]> wrote:
>
> >> On Jun 14, 1:31 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote:
> >>> John Fisher wrote:
> Hi Groupies,
> I have an Intel Macbook running OS X 10.4.
> It came install
On Jun 15, 11:59 am, "Evan Klitzke" <[EMAIL PROTECTED]> wrote:
> On 6/15/07, Amol <[EMAIL PROTECTED]> wrote:
>
> > Hi, I want to learn Python in less than a month which resources should
> > I use. I prefer to read books . Please give me a list of *recognized*
> > resources. Thank You all
>
> The Ap
> I'm curious, have you tried _Python for Dummies_?
No, I haven't. Unfortunately, I don't ever consider Dummies books.
That type of marketing appeals to certain people and not others. I'm
one of the others. I'll definitely take a look at it the next time
I'm in the bookstore.
>We didn't wait f
On Jun 17, 7:16 am, mark carter <[EMAIL PROTECTED]> wrote:
> David Wahler wrote:
> > On 6/17/07, mark carter <[EMAIL PROTECTED]> wrote:
> >> Anyone else getting these problems?
>
> > Seehttp://www.python.org/dev/peps/pep-0249/(emphasis mine):
>
> >.commit()
>
> OK, I tried that, and I appear to
On Jun 18, 10:07 am, "filox" <[EMAIL PROTECTED]> wrote:
> is there a way to find out the size of an object in Python? e.g., how could
> i get the size of a list or a tuple?
>
> --
> You're never too young to have a Vietnam flashback
You can use the struct module to find the size in bytes:
imp
On Jun 22, 2:24 pm, askel <[EMAIL PROTECTED]> wrote:
> class Dummy:
> def method(self, arg):
> print arg
>
> def method2(self, arg):
> self.method(arg)
>
> Dummy.method2 = method2
> Dummy.method2('Hello, world!')
Traceback (most recent call last):
File "test1.py", line 8, in ?
Dummy.
On Jun 22, 3:23 pm, askel <[EMAIL PROTECTED]> wrote:
> sorry, of course last line should be:
> Dummy().method2('Hello, world!')
..which doesn't meet the op's requirements.
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 23, 11:45 am, walterbyrd <[EMAIL PROTECTED]> wrote:
> On Jun 22, 11:43 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
>
> > Can you help us understand, by showing a use case that would in your
> > estimation be improved by the feature you're describing?
>
> Suppose you are sequentially processi
On Jun 23, 2:13 pm, Stuart <[EMAIL PROTECTED]> wrote:
> With my Python extension module all the function definitions are with
> METH_VARGS. The result being that pydoc, just puts "(...)" for the
> argument list. Can I hand edit this to put the specific variable names
> I want? With optional argumen
On Jun 24, 11:55 am, "Nathan Harmston" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I m playing around with extended euclids algorithm from Knuth. I m
> trying to build a function with a function inside it.
>
> def exteuclid(m,n):
> a,a1,b,b1,c,d = 0,1,1,0,m,n
> def euclid(c,d):
> q = c /d
>
I'm trying to get Apache set up on my system so I can use mod_python.
I installed Apache 2.2.4 according to the following instructions:
http://switch.richard5.net/isp-in-a-box-v2/installing-apache-on-mac-os-x/#comment-30704
and everything seemed to install correctly, but I can't start Apache.
I t
> On Jun 25, 7:23 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm trying to get Apache set up on my system so I can use mod_python.
> > I installed Apache 2.2.4 according to the following instructions:
>
> >http://switch.richard5.net/isp-in-a-bo
Ok. If I try to start Personal Web Sharing while Apache is running,
it says "Web Sharing starting up...", but it never does. Then if I
close the window and restart my imac, my imac boots up with Personal
Web Sharing turned on.
I still can't figure out where the page that says "It works!" is
loc
On Jun 26, 12:52 am, kaens <[EMAIL PROTECTED]> wrote:
> If apache2 works on macs how it does on linux (it should, right?)
> there should be Apache2/sites-enabled and Apache2/sites-available
> directories - the "default" files in these will tell you what pages
> are being served, I believe.
>
There
Well, I'm able to put html pages in /Library/Apache2/htdocs/ and
access them in Safari as I would expect:
http://localhost/test.htm
and I can access the index.html page in that directory:
http://localhost/index.html
and it displays:
It works! Apache 2.2.4
But, if I just use the address http:/
On Jun 26, 1:34 am, 7stud <[EMAIL PROTECTED]> wrote:
> Where is that coming from? Is the original index.html page(before I
> changed it and added "Apache 2.2.4") cached by Safari somehow? That
> doesn't make any sense to me because when I explicitly request
> ind
> Console and the system logs are an invaluable debugging tool on Macs.
> Bet you have some errors there saying why apache couldnt stop/start.
>
What/where is Console and how do I look at the system logs?
--
http://mail.python.org/mailman/listinfo/python-list
I have this program:
mytest.py
--
myinput = raw_input("Enter input: ")
if myinput == "hello":
print "goodbye"
--
and I want to execute it using subprocess.Popen(). I tried the
following but it just hangs:
---
import subprocess
f = open("/Users/me/2testing/d
On Jun 26, 3:00 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote:
> On 6/26/07, 7stud <[EMAIL PROTECTED]> wrote:
>
> > p.stdin.write("hello")
>
> You need to add the linefeed, otherwise your mytest.py process is
> still waiting for you to finish typi
Based on this example and the error:
-
u_str = u"abc\u"
print u_str
UnicodeEncodeError: 'ascii' codec can't encode character u'\u' in
position 3: ordinal not in range(128)
--
it looks like when I try to display the string, the ascii decoder
parses each character in the string and
Here is a program to print out the files in a directory:
---
import os
myfiles = os.listdir("../")
print myfiles
for afile in myfiles:
print afile
if os.path.isfile(afile):
print afile, "___file"
if os.path.isdir(afile):
print afile, "___dir"
print
---
On Jul 1, 3:36 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> 7stud <[EMAIL PROTECTED]> wrote:
> > Here is a program to print out the files in a directory:
>
> > ---
> > import os
>
> > myfiles = os.listdir("../")
> > print myfil
Erik Max Francis wrote:
> 7stud wrote:
>
> > Based on this example and the error:
> >
> > -
> > u_str = u"abc\u"
> > print u_str
> >
> > UnicodeEncodeError: 'ascii' codec can't encode character u'\u' i
Hi,
Thanks for the detailed response.
On Jul 1, 2:14 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > 1) If you print a unicode string:
> >
> > a) str() calls encode(), and encode() tries to convert the unicode
> > string to a regular string. encode() uses the default encoding, which
> > is
On Jul 1, 9:51 pm, 7stud <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks for the detailed response.
>
> On Jul 1, 2:14 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
>
> > > 1) If you print a unicode string:
>
> > > a) str() calls encode()
Hi,
Can someone explain what a broken pipe is? The following produces a
broken pipe error:
--
import subprocess as sub
p = sub.Popen(["ls", "-al", "../"], stdin=sub.PIPE, stdout=sub.PIPE)
print p.stdout.read()
#outputs the files correctly
p.stdin.write("ls\n")
#IOError: [Errno 32] Bro
On Jul 2, 11:32 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Jul 2, 1:12 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > Can someone explain what a broken pipe is? The following produces a
> > broken pipe error:
>
>
Why doesn't the following program write to the file?
driver.py
---
import subprocess as sub
p = sub.Popen(["python", "-u", "test1.py"], stdin=sub.PIPE,
stdout=sub.PIPE)
p.stdin.write("text3")
while True:
pass
---
test1.py:
-
import sys
data = sys.stdin.read()
f = open("a
On Jul 2, 1:58 pm, Bjoern Schliessmann wrote:
> 7stud wrote:
> > Thanks for the response. So are you saying that the only way you
> > can get data out of a pipe is when the subprocess has terminated?
>
> No, not only because Pipes aren't related to processes in any
On Jul 2, 2:03 pm, Bjoern Schliessmann wrote:
> 7stud wrote:
> > Why doesn't the following program write to the file?
> > [...]
> > It just hangs, and then when I hit Ctrl+C and look in the file,
> > the data isn't in there.
>
> Also, the pipe may be
On Jul 2, 2:12 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> a) Who told you pipes should be unbuffered by default, and b) what difference
> does that make anyway?
>
a) The docs.
b) If the pipes were buffered then writing a small amount of data like
"text3" to the pipe would cause the other side
Hardy wrote:
> I experience a problem with append(). This is a part of my code:
>
> for entity in temp:
> md['module']= entity.addr.get('module')
> md['id']=entity.addr.get('id')
> md['type']=entity.addr.get('type')
> #print md
>
The mod_python manual says this under section 2.1 Prerequisites:
--
In order to compile mod_python you will need to have the include files
for both Apache and Python, as well as the Python library installed on
your system. If you installed Python and Apache from source, then you
already have e
On Jul 19, 7:43 pm, Gilles Ganault <[EMAIL PROTECTED]> wrote:
> Hello
>
> I need to write a script to automate fetching data from a web site:
> 1. using the POST method, log on, with login/password saved as cookies
> 2. download page and extract relevent information using regexes
> 3. log off
> 4.
On Jul 19, 11:09 pm, gravey <[EMAIL PROTECTED]> wrote:
> The URL looks like this:
>
> file:///C|/Temp/Google%20Maps/linktothis.htm?lat=45.0&lng=-20.0&zoom=4&type =k
>
> The Javascript gets the URL from the Javascript location object and
> parses it. I'm assuming that the location object has some ki
On Apr 18, 8:50 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> The special methods need to be on the type -- having attributes of those
> names on the instance doesn't help (applies to all special methods in
> the normal, aka newstyle, object model; legacy, aka classic, classes,
> work by slightly
On Apr 18, 10:34 am, [EMAIL PROTECTED] wrote:
> I thought import used relative paths from either the python executable
> or the script being executed. I have a script pulling in code from an
> arbitrary directory. How is this happening?
>
> It's a RHEL 4 environment by the way. I couldn't find a
Here's an example where you are trying to import a function in one of
your .py files--when that .py file is not in the current directory:
import sys
sys.path.append("/Users/me/2testing/dir1/")
#directory that contains the file
import test1 #name of file without .py extension
test1.greet()
--
Hi,
Thanks for the responses.
> 7stud <[EMAIL PROTECTED]> wrote:
> > Can you explain some of the details of why this code fails:
> ---
> class Parrot(object):
> def __iter__(self):
> return self
> def __init__(self):
> self.next = sel
On Apr 18, 11:08 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> EMC ROY wrote:
> > Original Sentence: An apple for you.
> > Present: An apple for you .<.>
> > Desire:An apple for you <.>.
> >>> text = 'An apple for you .<.>'
> >>> import re
> >>> re.sub(r'(\S+)(<[^>]+>)(\s*)'
On Apr 19, 5:37 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> It's nothing to do with the name lookup. Alex mentioned that to remind
> us that the magic "double-under" names are looked up on the type rather
> than the instance...
P.next()
vs.
type(P).next()
Where is the "double-under" name?
On Apr 19, 3:12 pm, 7stud <[EMAIL PROTECTED]> wrote:
> On Apr 19, 5:37 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
>
>
> > It's nothing to do with the name lookup. Alex mentioned that to remind
> > us that the magic "double-under" names are
On Apr 19, 1:38 pm, Tyler <[EMAIL PROTECTED]> wrote:
> Hello All:
>
> I am currently working on a project to create an FEM model for school.
> I was thinking about using wxPython to gather the 12 input variables
> from the user, then, after pressing the "Run" button, the GUI would
> close, and the
[EMAIL PROTECTED] wrote:
>
> However, Python doesn't support pointers
As I understand it, every name in Python is a pointer.
class Gazelle(object):
def __init__(self):
self.x = 0
g_list =[]
for x in range(10):
g_list.append(Gazelle())
for g in g_list:
g.x = 10
print g_list[
On Apr 19, 9:18 pm, Paddy <[EMAIL PROTECTED]> wrote:
>
> # create a list of instances
> gazelles= [ Gazelle() for x in range(5)]
>
Nice. I knew there had to be a way to use a list comprehension, but I
couldn't figure it out.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 20, 8:38 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I'm running Python2.5 with wxPython v2.8.3.0 under WinXP and I cannot
> get the SetDefaultStyle method to work.
>
> I'm trying:
>
> self.output.SetDefaultStyle(wx.TextAttr(wx.RED))
> self.output.AppendText(text)
>
On Apr 21, 2:59 pm, Björn Keil <[EMAIL PROTECTED]> wrote:
> Hello pythons,
>
> I have little problem with understanding conversions in python. I've
> written a little class - nothing much, just to try out Python a little
> - containing the following method:
>
> def __repr__(self):
> """
Martin Drautzburg wrote:
> Is it possible to convert an object into a string that identifies the
> object in a way, so it can later be looked up by this string.
> Technically this should be possible, because things like
>
> <__main__.Foo instance at 0xb7cfb6ac>
>
> say everything about an object.
On Apr 22, 5:07 am, Martin Drautzburg <[EMAIL PROTECTED]>
wrote:
>
> <__main__.Foo instance at 0xb7cfb6ac>
>
> But how can I look up the real object,
> when I only have this string?
>
You can't because that identifies the instance with an address, and
pointers are not part of the python language.
On Apr 22, 7:00 pm, "Sam the Cat" <[EMAIL PROTECTED]> wrote:
> Hey All,
>
> I am writing some COM code in Python to control photoshop. Several
> functions of PS require an "Array" argument. In the examples of VBscript or
> javascript the Array type is used. I have tried what would appear to be t
On Apr 23, 12:26 pm, [EMAIL PROTECTED] wrote:
> I am assuming you are using Tkinter for your front-end GUI. You might
> also take a gander at wxPython. It has an excellent demo you could
> download and it might give you some additional ideas for
> implementation:www.wxpython.org.
>
> Mike
Hi,
I'v
On Apr 23, 4:25 pm, 7stud <[EMAIL PROTECTED]> wrote:
> On Apr 23, 12:26 pm, [EMAIL PROTECTED] wrote:
>
> > I am assuming you are using Tkinter for your front-end GUI. You might
> > also take a gander at wxPython. It has an excellent demo you could
> > download and it
Uhhmm...how are you supposed to close a ShapedWindow(under
Miscellaneous)?
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 23, 11:05 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > On my platform, styling the text doesn't work for single line
> > TextCtrl's(which seems kind of stupid), and on Windows I think you are
> > required to specify wx.TE_RICH2 to style the text. This following
> > code colors the
Hetland (Paperback - 29 Sep
> 2005)http://www.amazon.co.uk/Beginning-Python-Novice-Professional/dp/15905...
>
> WxPython in Action by Noel Rappin and Robin Dunn (Paperback - 30 Mar
> 2006)http://www.amazon.co.uk/WxPython-Action-Noel-Rappin/dp/1932394621/ref...
>
> Kevin
>
> On M
[EMAIL PROTECTED] wrote:
> Annoyances:
>
Every language has annoyances. Python is no exception. Post away.
Anyone that is offended can go drink a Guinness.
> 1. Underscores! What's the deal with that? Especially those double
> underscores. The best answer I read on this is that the double
> und
On Apr 26, 9:08 am, Michael Hoffman <[EMAIL PROTECTED]> wrote:
> 7stud wrote:
> > [EMAIL PROTECTED] wrote:
> >> Annoyances:
>
> > Every language has annoyances. Python is no exception. Post away.
> > Anyone that is offended can go drink a Guinness.
>
On Apr 28, 7:37 am, Bart <[EMAIL PROTECTED]> wrote:
> Hi everyone!
>
> Im using module that gives errors to stderr/stdout (generated by SWIG)
> Problem is that I need to parse this errors/information from module.
>
> os.popen3 looks nice but this executes command not function.
>
> Is there any
> p = subprocess.Popen(["python", "6test.py"],
> stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
The file name is wrong there; it should be:
p = subprocess.Popen(["python", "moduleA.py"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
--
[EMAIL PROTECTED] wrote:
> I want to keep track of the number of different exception happens in
> my python program:
>
> ErrorHash = {}
>
> try:
>
> # come code ...
>
> except Exception, e:
> print e
> errcode = e
>
> if (ErrorHash.has_key(errcode)):
>
On Apr 29, 11:19 am, dmitrey <[EMAIL PROTECTED]> wrote:
>
> callable(lambda-func) returnes False
>
I'm not seeing that. Try this:
f = lambda x: x
print callable(f)
---output:--
True
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 30, 5:53 am, "Nathan Harmston" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I ve being thinking about playing around with bit strings but use in
> some encoding problems I m considering and was trying to decide how to
> implement a bit string class. Is there a library out there for doing
> basic thi
Does sqlite come in a mac version?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
On May 1, 6:43 am, loial <[EMAIL PROTECTED]> wrote:
> OK, I have it working with dictionaries.
>
> However I have another scenerio :
>
> I am reading a file containing records like the following :
>
>
>
>
> ..
> ..
>
> I need to substitute MYVARIABLE with the current value of MYVARIABLE
> in my
On May 1, 5:06 am, Michael <[EMAIL PROTECTED]> wrote:
> Why are functions atomic? (I.e. they are not copied.)
>
> For example, I would like to make a copy of a function so I can change
> the default values:
>
> >>> from copy import copy
> >>> f = lambda x: x
> >>> f.func_defaults = (1,)
> >>> g =
On May 1, 10:38 am, rh0dium <[EMAIL PROTECTED]> wrote:
> Hi Experts!!
>
> I am trying to get the following little snippet to push my data to the
> function func(). What I would expect to happen is it to print out the
> contents of a and loglevel. But it's not working. Can someone please
> help m
On May 1, 4:08 am, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
> > Does sqlite come in a mac version?
>
> The interface (pysqlite) is part of the python 2.5 standard library
> but you need to install sqlite itself separately (as far as I
> remember) fromwww.sqlite.org
>
> Daniel
I'm using python 2
On May 1, 11:06 am, 7stud <[EMAIL PROTECTED]> wrote:
>
> You might consider redefining func() so that you don't have to do the
> unpack--repack...
When you define a function like this:
def func(**keywordargs):
print keywordargs
the function expects to receive arguments
kwargs is not a built in name--it's a made up name used in the
docs.Would you expect this function to work:
def somefunc(x=10, y=20):
print a
The best way to figure out a feature of a programming language that
you don't understand is not in the middle of some complex program.
Instead, yo
On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
> Why does os.path.join('/foo', '/bar') return '/bar' rather than
> '/foo/bar'? That just seems rather counter intuitive.
>
> Elliot
join( path1[, path2[, ...]])
Join one or more path components intelligently. If any component is an
abso
On May 2, 8:14 am, redcic <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I use the csv module of Python to write a file. My code is of the
> form :
>
> cw = csv.writer(open("out.txt", "wb"))
> cw.writerow([1,2,3])
> cw.writerow([10,20,30])
>
> And i get an out.txt file looking like:
> 1,2,3
> 10,20,30
>
On May 1, 6:09 am, Ben Secrest <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 2007-05-01, Daniel Nogradi <[EMAIL PROTECTED]> wrote:
>
> >> Does sqlite come in a mac version?
>
> > The interface (pysqlite) is part of the python 2.5 standard library
> > but you ne
> Did you install Xcode on your Mac?
Yes, Xcode 2.4.
--
http://mail.python.org/mailman/listinfo/python-list
Per the pysqlite installation instructions, this is the test I ran to
confirm that pysqlite installed correctly
>from pysqlite2 import test
>test.test()
and I got output similar to what the docs say should happen:
>ran 101 tests in 0.182s
My python book, "Beginning Python: From Novice to Profes
On May 3, 8:37 am, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
>
> If all tests ran fine then pysqlite can see your sqlite installation.
> How are you importing sqlite? It's usually something like "from
> pysqlite2 import dbapi2 as sqlite" not simply "import sqlite".
>
I just checked the errata fo
On May 3, 7:21 pm, Andy Terrel <[EMAIL PROTECTED]> wrote:
> Okay does anyone know how to decorate class member functions?
>
> The following code gives me an error:
>
> Traceback (most recent call last):
> File "decorators2.py", line 33, in
> s.update()
> File "decorators2.py", line 13, in
On May 4, 3:30 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> Can anyone explain the following:
>
> Python 2.5 (r25:51908, Apr 9 2007, 11:27:23)
> [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> def
> foo():
>
> ... x = 2
>
> A second question is: When can you use += vs .append().
> Are the two always the same?
They are never the same unless you only add one item to the list.
append() will only increase the length of a list by 1.
la = [1,2]
lb = [3, 4, 5]
la += lb
print la
lc = [1,2]
lc.append(lb)
print lc
--outpu
On May 8, 11:05 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> alf <[EMAIL PROTECTED]> wrote:
> > two ways of achieving the same effect
>
> > l+=[n]
>
> > or
>
> > l.append(n)
>
> > so which is more pythonic/faster?
>
> .append - easy to measure, too:
>
> brain:~ alex$ python -mtimeit 'L=range(3);
On May 8, 11:05 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> alf <[EMAIL PROTECTED]> wrote:
> > two ways of achieving the same effect
>
> > l+=[n]
>
> > or
>
> > l.append(n)
>
> > so which is more pythonic/faster?
>
> .append - easy to measure, too:
>
> brain:~ alex$ python -mtimeit 'L=range(3);
> Is there any documentation for the syntax you used with timeit?
This is the syntax the docs describe:
---
Python Reference Library
10.10.1:
When called as a program from the command line, the following form is
used:
python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-h] [statement ...]
---
Then
On May 10, 2:39 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> 7studwrote:
> >> Is there any documentation for the syntax you used with timeit?
>
> > This is the syntax the docs describe:
> [snip
> > python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-h] [statement ...]
> [snip]
> > Then in the exam
On May 15, 12:14 am, Steven Howe <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> > Suppose i have a string stored in variable,how do i remove the
> > space between them,like if i have the name:
> > "USDT request" in a variable.i need "USDTrequest",without any space .
> >
Not "Learning Python: From Novice to Professional". I've looked at
"Learning Python 2nd Ed." to use as a reference for all the blunders
in the first book I mentioned, and it's a lot better--plus it has
exercises at the end of each chapter.
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 519 matches
Mail list logo