On Fri, 20 Oct 2006 09:04:07 +1000, Steven D'Aprano wrote:
> I agree -- the reversed() function appears to be an obvious case of purity
> overriding practicality :(
>
str(reversed("some string"))
> ''
repr(reversed("some string"))
> ''
This doesn't seem particularly "pure" to me, either
On Mon, 26 Jun 2006 10:47:58 -0700, [EMAIL PROTECTED] wrote:
> whats the difference between raw input and input?
'input' is used to ask the user to input a python expression, which is
then run, and 'input' returns the result of executing that expression. For
example:
(define a function which pri
On Mon, 26 Jun 2006 19:40:52 -0700, digitalorganics wrote:
> A misuse of inheritance eh? Inheritance, like other language features,
> is merely a tool. I happen to be using this tool to have my virtual
> persons change roles at different points in their lifetime, as many
> real people tend to do. T
On Mon, 11 Dec 2006 23:24:07 -0500, Ken Tilton wrote:
> Also, Python does not support a functional style of programming so the
> line is the only meaningful textual entity. In this sense the
> primitiveness of Python makes editing easier.
Why do you say that? Wouldn't a block in python be a "mea
On Sun, 10 Dec 2006 03:18:07 -0500, Bill Atkins wrote:
> We're not counting lines here, you goon. We're talking about how
> expressive constructs are and how closely they match your concept of
> what you want to do. The conditional example is lower-level; you're
> talking to the interpreter inste
Klaus Alexander Seistrup wrote:
> Or os.makedirs():
Although that may or may not do what the OP wants. I was assuming she
was trying to produce a directory structure like:
/dir/C/
/dir/ASM/
/dir/Python/
os.makedirs() produces a directory hierarchy, like:
/dir/C/ASM/Python/
--
http://mail.pyth
Haibao Tang wrote:
> Is it possible to substitue all '1.1' to some value else without using
> re.
You could try:
import sys
values = sys.stdin.readline().split()
while values:
results = []
for value in values:
if value != '1.1':
results.append(value)
else:
Nicola Musatti wrote:
> I don't think this is all there is to it. Even though a class such as
> Image might not have a sensible default, initial state it still might
> not be reasonable to burden it with the ability to collect the
> information needed to reach such an initial state. To put it it an
Frank Potter wrote:
> Does google supply some webservice to programmers? I did see
Googling for "google api" gets you to:
http://www.google.com/apis/
It appears to be a SOAP API, which you can access with python, but I
think you'll need a third-party library. Googling for "python soap"
gets you:
kpp9c wrote:
> Namely i have organized a bunch of folders that have soundfiles in them
> and would like Python to slurp up all the .aif/.aiff (or .wav whatever)
> files in a given set of directories. My friend hacked up this is perl:
>
> $files = `ls /snd/Public/*.aiff`;
You could use posix.popen
Paul Rubin wrote:
> Hmm, I also see the PEP doesn't specify what's supposed to happen with
>
> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
> Solar_system = enum('sun', 'mercury', 'venus', 'earth',) # etc.
> print Weekdays.sun == Solar_system.sun
>
> so that's another sho
On Thu, 24 May 2007 20:03:29 +1000, Richard Jones wrote:
> Hoop-jumping implemented to prevent just this kind of direct linking (and
> thus not saving of the PDF to local disk to view, and thus increasing the
> load on the server).
I'm not sure I see the connection - if you're serving something as
On Sun, 22 Jul 2007 21:13:02 +0200, Peter Kleiweg wrote:
> Here is another "space":
>
> >>> u'\uFEFF'.isspace()
> False
>
> isspace() is inconsistent
Well, U+00A0 is in the category "Separator, Space" while U+FEFF is in the
category "Other, Format", so it doesn't seem unreasonable that one i
On Mon, 20 Aug 2007 00:02:47 -0700, Frank Millman wrote:
> When responding to the POST data received, it sends a 301 response, no
> headers, and then the html page.
[...]
> According to the notes, "You don't have to know much about the HTTP
> protocol at all. Except some basic that when the client
On Tue, 21 Aug 2007 21:23:25 -0300, Ricardo Aráoz wrote:
> Do you know if for in-house development a GPL license applies? (Qt4
> and/or Eric4).
(I'm not sure if I've understood your question right)
If you distribute an app that _uses_ PyQT, you have to comply with the GPL
(or buy a license
On Wed, 18 Apr 2007 15:39:22 +1000, Steven D'Aprano wrote:
> I thought that an iterator was any object that follows the iterator
> protocol, that is, it has a next() method and an __iter__() method.
...
> class Parrot(object):
...
> def __init__(self):
> self.next = self._next()
self.n
On Thu, 13 Sep 2007 23:49:32 -0400, Amer Neely wrote:
> In trying to track down why this script would not run on my host, it has
> to come to light that Python is installed, however the Apache module is
> not. So, short story is - I was flogging a dead horse.
Which Apache module? You don't need an
On Sat, 15 Sep 2007 19:34:45 +0300, Konstantinos Pachopoulos wrote:
> Hi,
> i have the following string s and the following code, which doesn't
> successfully remove the "\", but sucessfully removes the "\\".
There is no \\ in the string; there's one \ , which gets succesfully
removed.
> >>> s=
On Tue, 20 Feb 2007 10:46:31 -0800, Beliavsky wrote:
> I think the C and C++ committees also take backwards compatibility
> seriously, in part because they know
> that working programmers will ignore them if they break too much old
> code.
While that's true, C++ compiler vendors, for example, take
On Wed, 21 Nov 2007 17:06:15 -0800, braver wrote:
> Why do I have to count sizes of lines read and compare it to some
> filesize or do other weird tricks just to see, in a way not changing my
> input stream, whether it's at the, well, EOF?
Because you can't, generally, tell whether or not a stream
On Sat, 01 Dec 2007 19:02:41 -0800, Daniel Fetchinson wrote:
> The reason I need this is that my current best strategy to avoid ads in
> web pages is putting all ad server names into /etc/hosts and stick my
> local ip number next to them (127.0.0.1) so every ad request goes to my
> machine. I run a
On Sat, 08 Dec 2007 11:23:57 -0800, MonkeeSage wrote:
>> > The equivalent python idiom is something like:
>>
>> > class A:
>> > __a = "foo"
>> > def __init__(self):
>> > self.a = A.__a
[...]
>> > Which roughly translates to this in ruby:
>>
>> > class A
>> > attr_accessor :a
>> > def in
On Sun, 09 Dec 2007 11:58:05 -0800, MonkeeSage wrote:
> class A
> attr_accessor :a # == self.a,
># accessible to instances of A
> def initialize
> @a = "foo" # A.__a
># only accessible from class scope of A
> end
> end
>
> Once again, there is no such
On Sun, 16 Dec 2007 18:13:47 -0800, [EMAIL PROTECTED] wrote:
> I am learning python, having learnt most of my object orientation with
> java, and decided to port some of my geometry classes over. I haven't
> used immutability in python before, so thought this would be an
> interesting chance to lea
[EMAIL PROTECTED] wrote:
> I see that Python is missing "interfaces". The concept of an interface
> is a key to good programming design in Java, but I've read that they
> aren't really necessary in Python. I am wondering what technique I can
> use in Python to get the same benefits to a program de
Jonathan Daugherty wrote:
> Except when you need to handle exceptions when those methods don't
> exist. I think interfaces can definitely be useful.
I think I see what you mean, but that's an odd way to put it.
Typically, you aren't going to handle the exceptions produced by type
errors. Of cours
On Fri, 28 Apr 2006 14:27:00 -0700, nikie wrote:
> Steven Bethard wrote:
>
>> >>> L = ['C', 'A', 'D', 'B']
>> >>> positions = dict((item, i) for i, item in enumerate(L))
Do you need the generator expression here? dict(enumerate(L)) should be
equivalent, no?
> Isn't this bound to be less effici
On Fri, 28 Apr 2006 16:39:33 -0700, nikie wrote:
> I V wrote:
>> Do you need the generator expression here? dict(enumerate(L)) should be
>> equivalent, no?
>
> I think the generator is needed to swap the item and the index.
> dict(enumerate(L)) would yield a dict like {
On Fri, 05 May 2006 17:26:26 -0700, Xah Lee wrote:
> Regarding the lambda in Python situation... conceivably you are right
> that Python lambda is perhaps at best left as it is crippled, or even
> eliminated. However, this is what i want: I want Python literatures,
> and also in Wikipedia, to cease
On Sat, 06 May 2006 21:19:58 -0400, Bill Atkins wrote:
> There are also cases where a function is so trivial that the simplest
> way to describe it is with its source code, where giving it a name and
> putting it at the beginning of a function is just distracting and
> time-consuming. E.g.:
>
>
On Sat, 06 May 2006 23:05:59 -0700, Alex Martelli wrote:
> Tomasz Zielonka <[EMAIL PROTECTED]> wrote:
>...
>> higher level languages. There are useful programming techniques, like
>> monadic programming, that are infeasible without anonymous functions.
>> Anonymous functions really add some pow
On Sun, 07 May 2006 16:21:01 -0700, [EMAIL PROTECTED] wrote:
> So, if this is right, I need to put the .py file to be imported inside
> sys.path!! And the relative path will be usedto find the module.
>
> Can I __import__ providing the absolute path?
>>> import sys
>>> print sys.path
['', '/usr/l
On Mon, 08 May 2006 00:44:39 -0700, micklee74 wrote:
> i have a list with contents like this
> alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG',
> 'sdfsdgffdgfdg' ]
>
> how can i "convert" this list into a dictionary such that
>
> dictionary = { '>QWER':'askfhs' , '>REWR' : 'sfsdf' , '>FGD
On Wed, 23 Jan 2008 19:41:17 -0800, Yansky wrote:
> Hi, I'm having a lot of problems getting any Python scripts to run on my
> website. I have put them in the cgi-bin directory and chmodded both the
> directory and files to 755. But when I try to access the script, I get a
> 404 error: http://forbo
On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote:
> Yes, it is true that %s already support unicode, and I did not
> contradict that. But it counts the number of bytes instead of
> characters, and makes things like %-20s out of alignment. If you don't
> understand my assertion, please don't argu
On Sun, 03 Feb 2008 21:31:44 -0800, 7stud wrote:
> On Feb 3, 10:28 pm, 7stud <[EMAIL PROTECTED]> wrote:
>> From the docs:
>>
>> issubclass(class, classinfo)
>> Return true if class is a subclass (direct or indirect) of classinfo.
>
>
> print issubclass(Dog, object) #True
So Dog is a subclass o
On Mon, 11 Feb 2008 14:07:49 -0800, Erik Max Francis wrote:
> experience. The notion of impetus -- where an object throw moves in a
> straight line until it runs out of impetus, then falls straight down --
> is clearly contrary to everyday experience of watching two people throw
> a ball back and
On Fri, 29 Feb 2008 08:18:54 -0800, baku wrote:
> return s == s.upper()
A couple of people in this thread have used this to test for an upper
case string. Is there a reason to prefer it to s.isupper() ?
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 09 Mar 2008 01:57:38 -0800, Vince wrote:
> Well, that suits me. The most unnatural thing about Python was adapting
> to the idea of just letting unreleased resources go jogging off
> wherever. :)
Yes, that's a bad habit that garbage collection can encourage. GC is good
for managing memory
On Sat, 06 Dec 2008 16:34:56 -0800, Erik Max Francis wrote:
> `$` as a shortcut for self, on the other hand, gives absolutely no
> mnemonic indication what it stands for, and users would be simply left
> guessing.
However, $ is sometimes used as an alternative way of writing S̸ (I've
attempted to
On Mon, 08 Dec 2008 13:42:00 -0500, r0g wrote:
> Robocop wrote:
>> However i'm having several problems. I know that playskool regular
>> expression i wrote above will only parse every 50 characters, and will
>> blindly cut words in half if the parsed string doesn't end with a
>> whitespace. I'm r
On Sun, 14 Dec 2008 21:08:33 -0800, James Stroud wrote:
> Yes. I think it was the British who decided that the apostrophe rule for
> "it" would be reversed from normal usage relative to just about every
> other noun. I'm not sure the purpose--maybe it was to give compulsive
> proofreaders a raison
On Wed, 18 Mar 2009 21:30:59 -0700, gaeasiankom wrote:
> What actually I'm try to do is :
>
> I'm having a Login page which developed in HTML. When I click on the
> "Login" button I want the page to validate (at datastore of google app)
> using python and redirect to other HTML page. As what I un
On Fri, 20 Mar 2009 07:03:35 -0700, Sreejith K wrote:
> I'm using the above codes in a pthon-fuse's file class's read function.
> The offset and length are 0 and 4096 respectively for my test inputs.
> When I open a file and read the 4096 bytes from offset, only a few lines
> are printed, not the w
On Thu, 23 Apr 2009 02:16:07 +, Steven D'Aprano wrote:
> I'm leaning towards this being a bug in the json module. Unless somebody
> can point me at a credible source that sessionstore.js isn't JSON, I
> will report this as a bug.
I'm just another random guy on the internet, but I'm pretty sure
On Thu, 21 May 2009 02:31:29 +, Steven D'Aprano wrote:
> So the problem isn't directly with getmembers, but with the predicate
> functions you have passed to it (inspect.isfunction and inspect.method).
> Try inspect.ismethoddescriptor instead.
Or perhaps callable ? callable({}.get) and callabl
On Mon, 12 May 2008 16:39:25 -0700, Dave Parker wrote:
> I've read that one of the design goals of Python was to create an easy-
> to-use English-like language. That's also one of the design goals of
> Flaming Thunder at http://www.flamingthunder.com/ , which has proven
> easy enough for even el
On Wed, 14 May 2008 00:38:44 +0200, Christian Heimes wrote:
> Eric Anderson schrieb:
>> Seems like unnecessary code but obviously I know nothing about Python.
>
> Correct, the truth example isn't a good example. "if argv" is better.
I hadn't heard of operator.truth before. Does it do anything dif
On Thu, 22 May 2008 19:35:50 -0700, Charles Hixson wrote:
> Although when comparing Candygram with Erlang it's worth noting that
> Candygram is bound to one processor, where Erlang can operate on
> multiple processors. (I'd been planning on using Candygram for a project
> at one point, but this mad
On Fri, 23 May 2008 00:12:35 -0700, Marc Oldenhof wrote:
> It seems that Python calls numpy's "all" instead of the standard one, is
> that right? If so, how can I call the standard "all" after the numpy
> import? ["import numpy" is not a desirable option, I use a lot of math
> in my progs]
I think
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
> I try to get a set of lambda functions that allows me executing each
> function code exactly once. Therefore, I would like to modify the set
> function to compare the func_code properties (or the lambda functions to
> use this property for c
On Sun, 25 May 2008 13:05:31 -0300, Gabriel Genellina wrote:
> Use a list, and the bisect module to keep it sorted:
That's worth doing if you need the data to be sorted after each insert.
If the OP just needs the data to be sorted at the end, using a data
structure with fast inserts (like a set)
On Sun, 25 May 2008 15:49:16 -0700, notnorwegian wrote:
> i meant like set[pos], not iterate but access a specific position in the
> set.
If you need to access arbitrary elements, use a list instead of a set
(but you'll get slower inserts). OTOH, if you just need to be able to get
the next item
On Sun, 25 May 2008 18:42:06 -0700, notnorwegian wrote:
> def scrapeSites(startAddress):
> site = startAddress
> sites = set()
> iterator = iter(sites)
> pos = 0
> while pos < 10:#len(sites):
> newsites = scrapeSite(site)
> joinSets(sites, newsites)
You change t
On Sun, 25 May 2008 21:41:09 -0400, Jerry Stuckle wrote:
> The the good programmers are able to adapt to the language and make the
> most of whatever language they're using. The result is good code. OTOH,
> poor programmers I have known have found all kinds of excuses - from the
> language itself
On Fri, 13 Jun 2008 22:10:51 +0100, Ognjen Bezanov wrote:
> I am building an application using WxWidgets, and its job is to manage
> HTML data in a database. Now I need essentially a HTML editor that I can
> embed into my program, that will parse the HTML and allow the user to
> edit it.
How about
On Thu, 17 Jul 2008 15:08:17 -0700, castironpi wrote:
> The Python disassembly is baffling though.
>
y= 3
dis.dis('x=y+1')
You can't disassemble strings of python source (well, you can, but, as
you've seen, the results are not meaningful). You need to compile the
source first:
>>> co
On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote:
> use some sort of data-structure (maybe
> nested dictionaries or a custom class) and store the pickled
> data-structure in a single row in the database (then unpickle the data
> and query in memory).
Why would you want to do this? I don't see what
John Salerno wrote:
> How does the __init__ file help if you are still individually importing
> class1 and class2 in each other module of your program?
Felipe's example is a little confusing because he uses the same name
for the module and the class. Here's another example:
--- package/class1.py
dongdong wrote:
> using web browser can get page's content formally, but when use
> urllib2.open("http://tech.163.com/2004w11/12732/2004w11_1100059465339.html";).read()
>
> the result is
>
> CONTENT="0;URL=http://tech.163.com/04/1110/12/14QUR2BR0009159H.html";>
This line here instructs the browse
Sullivan WxPyQtKinter wrote:
> 1. Are there any method (in python of course) to redirect to a web page
> without causing a "Back" button trap(ie, when user click the back
> button on their web browser, they are redirect to their current page,
> while their hope is probably to go back to the last pa
Bror Johansson wrote:
> Is there a good and general way to test an instance-object obj for having a
> class belonging to a certain "sub-tree" of the hierarchy with a common
> parent class C?
If I understand you correctly, isinstance ought to do the job:
class A(object):
pass
class B(A):
Sullivan WxPyQtKinter wrote:
> As you said, There is no solution? I mean, tracing a real session
> without using tricks like hidden field and cookies in CGI script?
As people have said, this isn't a limitation of python, it's a feature
of HTTP. You might want to consider whether you actually n
John Salerno wrote:
> The printable value of node1 is 1, node2 is 2 and node 3 is 3.
>
> node1.next is node2, node2.next is node3 and node3.next is None.
>
> This might be painfully obvious, but I don't understand when the print
> statement is getting called. If you call printBackward with node1, t
Kun wrote:
> This works fine but instead of typing in a 'body', i would like the
> initial python program to just send a string as the body of the email.
> now normally i'd just set the msg in the mail.py file equal to the
> string, however, i do not know how to link a string from another python
>
Kun wrote:
> mail currently gets the body from an input box.
>
> this is where mail.py gets invoked:
OK, I'm a bit confused. Where is the "initial python program" in all
this? You seem to have an one python program (mail.py) and an HTML
form. As it stands, I don't see why you can't change mail.py
On Sat, 17 Oct 2009 18:54:10 +0200, Diez B. Roggisch wrote:
> This is wierd. I looked at the site in FireFox - and it was displayed
> correctly, including umlauts. Bringing up the info-dialog claims the
> page is UTF-8, the XML itself says so as well (implicit, through the
> missing declaration of
On Sat, 17 Oct 2009 21:24:59 +0330, Arian Kuschki wrote:
> I just checked and I see the following in the headers: Content-Type
> text/xml; charset=UTF-8
>
> Where does it say ISO-8859-1?
In the headers returned via urllib (and via wget). But checking in
Firefox, it does indeed specify UTF-8 in t
On Thu, 11 Feb 2010 07:37:35 +0100, Alf P. Steinbach wrote:
> * Steven D'Aprano:
>> s = [1]
>> t = s # Binds the name t to the object bound to the name s.
>> t[0] = 2 # Changes the object bound to the name t print(s) #
>> Checks the object via the original name.
>>
>> Notice that
On Sat, 20 Feb 2010 08:12:01 -0800, lallous wrote:
> How can I do something similar to pure virtual functions in C++ ?
>From what you want, it seems like you want cb() to not be called if it
isn't implemented in the derived class; this isn't really what pure
virtual functions in C++ do - pure vi
On Thu, 25 Mar 2010 15:00:35 -0700, Michel wrote:
> I'm trying to dynamically create a class. What I need is to define a
> class, add methods to it and later instantiate this class. Methods need
> to be bound to the instance though, and that's my problem. Here is what
> I have so far:
I'm not enti
On Fri, 26 Mar 2010 08:54:11 -0700, Michel wrote:
> I want to add a method to a class such that it can be invoked on
> specifics instances.
> You solution works (as well as Patrick's one), thanks ! I still have a
> question though. If I print the type of the self object I get when my
> method is
>
On Wed, 02 Jun 2010 05:17:11 -0700, B.V. wrote:
> But trying to be open to other languages, the server implements also an
> XMLRPC interface (and also a JSONRPC-like interface). That's the key
> point: Decimal is python specific. So in an application, you can't rely
> on the value received from a c
On Fri, 12 Jun 2009 22:02:53 -0700, Andrew Savige wrote:
> Notice that this code uses Perl's lexical scope to hide the
> %private_hash variable, but not the public_fn() function.
You might try:
def public_fn(param):
private_hash = publicfn.private_hash
return private_hash[param]
On Mon, 15 Jun 2009 15:29:34 +0200, Tobias Weber wrote:
> Despite the confusion all those are useable, but I ran into the problem
> that I can't register a @classmethod because weakref doesn't like them.
What do you mean by weakref not liking class methods? This seems to work
OK on python 2.6
cl
On Fri, 10 Jul 2009 16:27:12 -0400, Terry Reedy wrote:
> a bug, bug a limitation due to using limited-range numbers. If one uses
> residue classes instead of integers, and makes no adjustment, I consider
> it wrong to blame Bentley.
But it was Bentley himself who used the C int type, so it hardly
On Mon, 20 Jul 2009 21:53:59 -0400, Esmail wrote:
> In general I would agree with you, but in my specific case I want so
> store some additional meta-data with each function, such as the valid
> range for input values, where the max or minimum are located, the
> name/source for the function etc. I
On Thu, 30 Jul 2009 17:57:48 -0400, Luis Zarrabeitia wrote:
> As I understood the question, it was "was wrong in 'for var in
> container' in comparison with ruby's container.each?"
>
> What's the (semantic) difference between
>
> for localVar in container:
> block
>
> and
>
> container.each
On Fri, 07 Aug 2009 12:57:11 -0700, alex23 wrote:
> John Nagle wrote:
>> Feedparser hasn't been updated since 2007. Does this mean Feedparser is
>> dead?
>
> Wouldn't you be better served asking this on the feedparser bug tracker?
>
> http://code.google.com/p/feedparser/issues/list
But if the p
On Mon, 07 Sep 2009 19:22:17 -0700, ganesh wrote:
> My application is a TCP server having multiple client connectons. C++
> PTHREADS are for each connected socket and the message received on the
> socket is evaluated by python functions. If I use only one process level
Do you have to use threads?
80 matches
Mail list logo