Chris Angelico wrote:
> On Tue, Mar 18, 2014 at 11:32 AM, Mok-Kong Shen
> wrote:
>> Is there a way to force a certain ordering of the printout or else
>> somehow manage to get at least a certain stable ordering of the
>> printout (i.e. input and output are identical)?
>
> Yes; instead of simply
Carlos Nepomuceno wrote:
>
>> From: usenetm...@solar-empire.de
> [...]
>> Not in Python3.x
> decks = 6
> list(range(13 * 4 * decks)) == range(13 * 4 * decks)
>> False
>
> What does "list(range(13 * 4 * decks))" returns in Python 3?
Carlos Nepomuceno wrote:
>
>> Date: Sun, 26 May 2013 10:52:14 -0700
>> Subject: Cutting a deck of cards
>> From: rvinc...@gmail.com
>> To: python-list@python.org
>>
>> Suppose I have a deck of cards, and I shuffle them
>>
>> import random
>> cards = []
>> d
Mark Lawrence wrote:
> On 26/05/2013 04:55, cdorm...@gmail.com wrote:
>> This is a small little Project that I have started. Its a light
>> little Web Server (HTTPd) coded in python. Requirements: Python 2.7
>> =< And Linux / BSD. I believe this could work in a CLI Emulator in
>> windows too.
>> W
Terry Reedy wrote:
> On 2/12/2013 7:47 AM, Fayaz Yusuf Khan wrote:
>> dcomp = zlib.decompressobj(16+zlib.MAX_WBITS)
>
> Since zlib.MAX_WBITS is the largest value that should be passed (15),
> adding 16 makes no sense. Since it is also the default, there is also no
> point in providing it explic
Greg Donald wrote:
> On Mon, Dec 10, 2012 at 10:34:31PM -0700, Michael Torrie wrote:
>> I use a module I got from pypi called dateutil. It has a nice submodule
>> called parser that can handle a variety of date formats with good
>> accuracy. Not sure how it works, but it handles all the common A
Helmut Jarausch wrote:
> I have a machine with a non-UTF8 local.
> I can't figure out how to make numpy.genfromtxt work
[...]
> #!/usr/bin/python3
> import numpy as np
> import io
> import sys
>
> inpstream = io.open(sys.stdin.fileno(), "r", encoding='latin1')
>
> data = np.genfromtxt(inpstream)
Steven D'Aprano wrote:
> On Fri, 13 Jan 2012 06:14:50 -0800, mike wrote:
>> pysibelius is a lib that we use.
>>
>> I am not sure that is the problem since the python program works on SuSE
>> but not on RH server. And AFAIK
>> the only difference ( well that I can see) is the OpenSSL version.
>
>
Saqib Ali wrote:
> I'm using this decorator to implement singleton class in python:
>
> http://stackoverflow.com/posts/7346105/revisions
>
> The strategy described above works if and only if the Singleton is
> declared and defined in the same file. If it is defined in a different
> file and I im
Roy Smith wrote:
> I'm trying to use a custom version of mongoengine. I cloned the git
> repo and put the directory on my PYTHONPATH, but python is still
> importing the system's installed version. Looking at sys.path, it's
> obvious why:
>
> $ echo $PYTHONPATH
> /home/roy/songza:/home/roy/
Makoto Kuwata wrote:
> Is it possible to specify PREFIX directory for pip command by
> environment variable?
>
> I found that 'pip install --install-option=--prefix=PREFIX' works well,
> but I don't want to specify '--install-option=--prefix=PREFIX' every time.
> I prefer to specify it by environ
Yingjie Lin wrote:
> Hi Python users,
>
> I have two lists:
>
> li1 = ['a', 'b']
> li2 = ['1', '2']
>
> and I wish to obtain a list like this
>
> li3 = ['a1', 'a2', 'b1', 'b2']
>
> Is there a handy and efficient function to do this, especially when
> li1 and li2 are long lists.
Depending on
Daniel Kluev wrote:
> test.py:
>
> from threading import Thread
> class X(object):
>pass
> obj = X()
> obj.x = 0
>
> def f(*args):
> for i in range(1):
> obj.x += 1
>
> threads = []
> for i in range(100):
>t = Thread(target=f)
>threads.append(t)
>t.start()
>
> for t
Dan Stromberg wrote:
> I've got a couple of programs that read filenames from stdin, and then
> open those files and do things with them. These programs sort of do
> the *ix xargs thing, without requiring xargs.
>
> In Python 2, these work well. Irrespective of how filenames are
> encoded, thin
Neal Becker wrote:
> Any idea what this could be about?
>
> Traceback (most recent call last):
> File "run-tests-1004.py", line 48, in
>results = pool.map (run_test, cases)
> File "/usr/lib64/python2.7/multiprocessing/pool.py", line 199, in map
>return self.map_async(func, iterable
eliben <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I want to be able to do something like this:
>
> Employee = Struct(name, salary)
>
> And then:
>
> john = Employee('john doe', 34000)
> print john.salary
>
> Basically, Employee = Struct(name, salary) should be equivalent to:
>
> class Employee(o
Robert LaMarca <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using numpy and wish to create very large arrays. My system is
> AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a
> 15 GB swap drive.
>
> The command I have been trying to use is;
> g=numpy.ones([1000,1000,1000],
Alex Marandon <[EMAIL PROTECTED]> wrote:
> Alexnb wrote:
>> I am wondering, is there a simple way to test for Internet connection? If
>> not, what is the hard way :p
>
> Trying to fetch the homepage from a few major websites (Yahoo, Google,
> etc.)? If all of them are failing, it's very likely th
ssecorp <[EMAIL PROTECTED]> asked:
> Why is this blowing the stack, thought it was tail-recursive...
Because python does no tail-call optimization.
Ciao
Marc
--
http://mail.python.org/mailman/listinfo/python-list
Joel Koltner <[EMAIL PROTECTED]> wrote:
> Is there an easy way to get a list comprehension to produce a flat
> list of, say, [x,2*x] for each input argument?
>
> E.g., I'd like to do something like:
>
> [ [x,2*x] for x in range(4) ]
>
> ...and receive
>
> [ 0,0,1,2,2,4,3,6]
>
> ...but of cours
Mark Dickinson <[EMAIL PROTECTED]> wrote:
> On SuSE 10.2/Xeon there seems to be a rounding bug for
> floating-point addition:
>
> [EMAIL PROTECTED]:~> python
> Python 2.5 (r25:51908, May 25 2007, 16:14:04)
> [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
> Type "help", "copyright", "cred
Matt Porter <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I'm trying to compress a string.
> E.g:
> "BBBC" -> "ABC"
You mean like this?
>>> ''.join(c for c, _ in itertools.groupby("BBBCAADCASS"))
'ABCADCAS'
HTH
Marc
--
http://mail.python.org/mailman/listinfo/python-list
globalrev <[EMAIL PROTECTED]> wrote:
> class Foo(object):
>def Hello(self):
>print "hi"
>
> object is purple, ie some sort of reserved word.
>
> why is self in black(ie a normal word) when it has special powers.
Because `self` is just a name. Using `self` is a convention,
Alexander Schmolck <[EMAIL PROTECTED]> wrote:
> Gary Herron <[EMAIL PROTECTED]> writes:
>
>> But... It's not!
>>
>> A simple test shows that. I've attached a tiny test program that
>> shows this extremely clearly. Please run it and watch it fail.
>
> In [7]: run ~/tmp/t.py
> final count: 200
JYA <[EMAIL PROTECTED]> wrote:
>for y in x.getElementsByTagName('display-name'):
>elem.appendChild(y)
Like Gabriel wrote, nodes can only have one parent. Use
elem.appendChild(y.cloneNode(True))
instead. Or y.cloneNode(False), if you want a shallow copy (i
Alex9968 <[EMAIL PROTECTED]> wrote:
> Can I get sequence of all strings that can match a given regular
> expression? For example, for expression '(a|b)|(x|y)' it would be ['ax',
> 'ay', 'bx', 'by']
>
> It would be useful for example to pass these strings to a search engine
> not supporting RegE
sturlamolden <[EMAIL PROTECTED]> wrote:
> On 18 Mar, 00:58, Jeff Schwab <[EMAIL PROTECTED]> wrote:
>
>> def make_slope(distance, parts):
>> if parts == 0:
>> return []
>>
>> q, r = divmod(distance, parts)
>>
>> if r and parts % r:
>> q += 1
>>
>> return [q] +
Tom Stambaugh <[EMAIL PROTECTED]> wrote:
>> Somehow I don't get what you are after. The ' doesn't have to be escaped
>> at all if " are used to delimit the string. If ' are used as delimiters
>> then \' is a correct escaping. What is the problem with that!?
>
> If I delimit the string with doub
[EMAIL PROTECTED] wrote:
> I have a linux box with multiple ip addresses. I want to make my
> python client connect from one of the ip addresses. Here is my code,
> no matter what valid information I put in the bind it always comes
> from the default ip address on the server. Am I doing something w
jefm <[EMAIL PROTECTED]> wrote:
> How can I print the unicode box drawing characters in python:
>
>
> print u'\u2500'
> print u'\u2501'
> print u'\u2502'
> print u'\u2503'
> print u'\u2504'
>
> Traceback (most recent call last):
> File "\test.py", line 3, in ?
>print u'\u2500'
> File "C:\P
BlueBird <[EMAIL PROTECTED]> wrote:
> On Dec 2, 4:27 pm, BlueBird <[EMAIL PROTECTED]> wrote:
>> On Nov 26, 5:07 pm, "Sergio Correia" <[EMAIL PROTECTED]> wrote:
>>
>> >Bluebird:
>>
>> > If you are using python 2.5, relative imports are no longer an
>> > issue:http://docs.python.org/whatsnew/pep-328.
Joshua Kugler <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
>> i tried a couple python json libraries. i used simplejson on the
>> server and was using cjson on the client, but i ran into this issue.
>> i'm now using simplejson on both sides, but i'm still interested in
>> this issue. d
gt;
> http://www.naco.faa.gov/digital_tpp_search.asp?fldIdent=ksfo&fld_ident_type=ICAO&ver=0711&bnSubmit=Complete+Search
>
>
>
> Marc Christiansen <[EMAIL PROTECTED]> wrote:
>
>> The problem is this line:
>>
>>
>> Which is wrong. The content is
Frank Stutzman <[EMAIL PROTECTED]> wrote:
> I've got a simple script that looks like (watch the wrap):
> ---
> import BeautifulSoup,urllib
>
> ifile = urllib.urlopen("http://www.naco.faa.gov/digital_tpp_search.asp?fldId
> ent=klax&fld_ident_type=ICAO
Vladimir Rusinov <[EMAIL PROTECTED]> wrote:
> I'm using beautiful soup html parser, and I need to get all ' class=g>...' tags.
> It can be done by:
>
> import BeautifulSoup as BSoup
from BeautifulSoup import BeautifulSoup as BSoup
>
> ...
>
> soup = BSoup(page)
> for div in soup.findAll('div',
Fantus <[EMAIL PROTECTED]> wrote:
> Hello
>
> I am doing a small research and I found this:
>
> http://www.freedom-to-tinker.com/tinyp2p.html
[...]
> Now when I try to run a client using following command:
>
> > python tinyp2p.py haslo client http://10.10.10.1:2233 koniki
>
> it gives me some s
Casey <[EMAIL PROTECTED]> wrote:
> I would recommend the OP try this:
>
> run the (I)python shell and try the following:
>
a = [x for x in "abcdefg"]
a
> ['a','b','c','d','e','f','g']
"c" in a
> True
"c" in a == True
> False
("c" in a) == True
> True
>
> The reason your
[EMAIL PROTECTED] wrote:
> I've been searching to find a way to force this delete to work even if
> the directory isn't empty. I've had no luck thus far. Anyone know
> what that would be?
Answering your immediate question: you can't force os.removedirs to
delete non-empty dirs.
But shutil.rmtree
Adam Hupp <[EMAIL PROTECTED]> wrote:
> I've noticed some unexpected behavior with __builtins__ during module
> import. It seems that during module import __builtins__ is a dict
> but at all other times it is a module.
>
> For example, if the file testmod.py has these contents:
>
> print type(__
Peter Otten <[EMAIL PROTECTED]> wrote:
> Marc Christiansen wrote:
>
>> Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>>> En Tue, 12 Jun 2007 05:46:25 -0300, <[EMAIL PROTECTED]> escribió:
>>>
>>>> On 6 12 , 3 16 , ici <[EMAIL PROTEC
Jeff Rollin <[EMAIL PROTECTED]> wrote:
> I'm working with the Python Tutorial "Byte of Python" at swaroopch.info.
>
> I have created the attached file, but when I execute:
>
> % objvar.py
>
> I get the error message:
>
> (Initializing Calamity Jane)
> Traceback (most recent call last):
> File
Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> En Tue, 12 Jun 2007 05:46:25 -0300, <[EMAIL PROTECTED]> escribió:
>
>> On 6 12 , 3 16 , ici <[EMAIL PROTECTED]> wrote:
>>> On Jun 12, 10:10 am, <[EMAIL PROTECTED]> wrote:
>>>
>>> > How could I format the float number like this: (keep
Ivan Voras <[EMAIL PROTECTED]> scribis:
> While using PyGTK, I want to try and define signal handlers
> automagically, without explicitly writing the long dictionary (i.e. I
> want to use signal_autoconnect()).
>
> To do this, I need something that will inspect the current "self" and
> return a di
James T. Dennis <[EMAIL PROTECTED]> scribis:
> In fact I realized, after reading through tempfile.py in /usr/lib/...
> that the following also doesn't "work" like I'd expect:
>
># foo.py
>tst = "foo"
>def getTst(arg):
If I change this line:
>return "foo-%s"
Timothy Smith <[EMAIL PROTECTED]> wrote:
> i want to trunkate 199.999 to 199.99
> getcontext.prec = 2 isn't what i'm after either, all that does is E's
> the value.
> do i really have to use floats to do this?
You could try this (from a script I use for my phone bill):
from decimal import Decima
Michael Spencer <[EMAIL PROTECTED]> wrote:
Nice. When you replace None by an object(), you have no restriction on
the elements any more:
> Here's something to work with:
>
> class OrdSet(object):
> def __init__(self, iterable):
> """Build an ordered, unique collection of hashable ite
Miki Tebeka <[EMAIL PROTECTED]> wrote:
> Hello Nemesis,
>
>> Hi all, I'm trying to write a multiplatform function that tries to
>> return the actual user home directory.
>> ...
> What's wrong with:
>from user import home
> which does about what your code does.
Except it also execfile()s $HOME
[EMAIL PROTECTED] wrote:
> Nick Coghlan <[EMAIL PROTECTED]> wrote:
>> Hmm, when the second argument is omitted, the system call looks like:
>>
>> getservbyname("daytime", NULL);
>>
>> Based on "man getservbyname" on my Linux PC, that should give
>> the behaviour we
>> want - any protocol will ma
Riko Wichmann <[EMAIL PROTECTED]> wrote:
>>>Tried that already. At least, I hope I guessed at least one of the
>>>possible identifiers correct: MSIE6.0, MSIE 6.0, MSIE/6.0
>>
>>
>> When my opera is set to identify as MSIE, it sends
>> "Mozilla/4.0 (compatible; MSIE 6.0; X11; Linux i686) Opera 7
Riko Wichmann <[EMAIL PROTECTED]> wrote:
> Jonathan Ellis wrote:
>>
>> Sounds like your first step should be to identify yourself as IE.
>>
>> opener = urllib2.build_opener(...)
>> opener.addheaders = [("User-Agent", "whatever IE calls itself these
>> days")]
>>
>> -Jonathan
>>
>
> Tried that
50 matches
Mail list logo