Re: pyflakes best practices?

2014-05-29 Thread Roy Smith
In article , Mark Lawrence wrote: > On 30/05/2014 01:13, Roy Smith wrote: > > We've recently started using pyflakes. The results seem to be similar > > to most tools of this genre. It found a few real problems. It > > generated a lot of noise about things which

Re: Python 3 is killing Python

2014-06-02 Thread Roy Smith
In article <538ca310$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: > > > On Jun 1, 2014 12:11 PM, wrote: > > > >> At least Py2 does not crash when using non ascii (eg sticking with > >> cp1252). > >> > >> I just noti

Re: Benefits of asyncio

2014-06-02 Thread Roy Smith
In article , Terry Reedy wrote: > asyncio lets you write platform independent code while it makes good use > of the asynchronous i/o available on each particular system. Async-i/o > is one area where Windows has made advances over posix. But the models > are different, and if one uses Windows

Re: Benefits of asyncio

2014-06-03 Thread Roy Smith
In article <87ha42uos2@elektro.pacujo.net>, Marko Rauhamaa wrote: > Chris Angelico : > > > I don't see how Marko's assertion that event-driven asynchronous > > programming is a breath of fresh air compared with multithreading. The > > only way multithreading can possibly be more complicated

Re: multiprocess (and paramiko)

2014-06-03 Thread Roy Smith
In article <3c0be3a7-9d2d-4530-958b-13be97db3...@googlegroups.com>, mennis wrote: > Here I have a simple multiprocessing class that when initializes takes a > connected SSHClient instance and a command to run on the associated host in a > new channel. ChrisA has already answered your question

Re: Unicode and Python - how often do you index strings?

2014-06-03 Thread Roy Smith
In article , Chris Angelico wrote: > A current discussion regarding Python's Unicode support centres (or > centers, depending on how close you are to the cent[er]{2} of the > universe) Um, you mean cent(er|re), don't you? The pattern you wrote also matches centee and centrr. > around one cri

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-04 Thread Roy Smith
In article , Chris Angelico wrote: > You can't ignore those. You might be able to say "Well, my program > will run slower if you throw these at it", but if you're going down > that route, you probably want the full FSR and the advantages it > confers on ASCII and Latin-1 strings. Binding your pr

Re: PEP8 revised: max line lengths

2013-08-01 Thread Roy Smith
In article , Terry Reedy wrote: > Newly revised this morning: > http://www.python.org/dev/peps/pep-0008/#maximum-line-length > summary: > 72 for text block (comments, triple-quoted strings) > 79 for normal code > 99 for code that is really more readable with extra And the people did rejoice and

Re: PEP8 revised: max line lengths

2013-08-03 Thread Roy Smith
In article , Chris Angelico wrote: > Sorry. Term I should have used is "base SI unit". Instead of using the > cm, use the m. Or go three orders of magnitude at a time to the km or > the mm. Or, go digital, and use Kim (kibimeters). -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing matching items from a list?

2013-08-03 Thread Roy Smith
In article <6c0bdea5-23bd-4854-8016-4bf0af3b7...@googlegroups.com>, kevin4f...@gmail.com wrote: > let's say there is a list: > > pHands[0] = ['ad', 'ac', 'as', 'ah', '7d', '8s', '9d', 'td', 'js', 'jd'] I assume this is a card game, and these are cards (ad = Ace of Diamonds, etc). > I'm trying

Re: Removing matching items from a list?

2013-08-03 Thread Roy Smith
In article <51fd8635$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > 2) Then go through those initial letters, and pick out the ones equal to > 4 (or should that be "four or more"?). Assuming my earlier hunch is correct about these being cards in a deck, and the a's bein

Re: PEP8 revised: max line lengths

2013-08-04 Thread Roy Smith
In article , wxjmfa...@gmail.com wrote: > I have always found, computer scientists are funny scientists. I have always found that sciences which contain the word "science" in their name tend to not be very scientific. Biology, Chemistry, Physics, those are real sciences. Computer Science, So

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Roy Smith
In article <07f6b1c7-069d-458b-a9fe-ff30c09f2...@googlegroups.com>, matt.doolittl...@gmail.com wrote: > self.logfile.write('%s\t'%(str(time( > [...] > 1375588774.89 > [...] > Why is it only giving me the centisecond precision? the docs say i should > get microsecond precision When citing d

Re: PEP8 revised: max line lengths

2013-08-04 Thread Roy Smith
In article , Chris Angelico wrote: > programmers, like engineers, have to deal with the > possibility (or certainty) of idiots using their products. As a programmer, I'm OK with the idea that idiots are using my programs. What bothers me more is when, as a user of a program, I have to deal w

Re: outputting time in microseconds or milliseconds

2013-08-08 Thread Roy Smith
In article , Skip Montanaro wrote: > When Tim Peters wrote datetime, the world became a better > place. Lots of languages and databases have things called datetimes. It's easy to be lulled into thinking that they're all the same, but they're not. They all have slightly different ranges an

Re: PEP 450 Adding a statistics module to Python

2013-08-10 Thread Roy Smith
In article , Skip Montanaro wrote: > Given that installing numpy or scipy is generally no more difficult > that executing "pip install (scipy|numpy)" I'm not really feeling the > need for a battery here... I just tried installing numpy in a fresh virtualenv on an Ubuntu Precise box. I ran "pi

Re: PEP 450 Adding a statistics module to Python

2013-08-10 Thread Roy Smith
Skip Montanaro wrote: > >> installing numpy or scipy is generally no more difficult > >> that executing "pip install (scipy|numpy)" I described the problems I had trying to follow that advice. In article , Oscar Benjamin wrote: > You should use apt-get for numpy/scipy on Ubuntu. Although > un

Re: Python Basic Doubt

2013-08-10 Thread Roy Smith
In article , Krishnan Shankar wrote: > Hi Fellow Python Friends, > > I am new to Python and recently subscribed to the mailing list.I have a > doubt regarding the basics of Python. Please help me in understanding the > below concept. > > So doubt is on variables and their contained value. > >

Re: The meaning of "doubt", was Re: Python Basic Doubt

2013-08-10 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > Quoting http://en.wikipedia.org/wiki/Indian_English > > """ > doubt = question or query; e.g. one would say, 'I have a doubt' when one > wishes to ask a question. > """ > > I'd say if Brits can cope (hard as it may be) with the American vari

Re: How many times does unittest run each test?

2013-08-10 Thread Roy Smith
In article , Josh English wrote: > I am working on a library, and adding one feature broke a seemingly unrelated > feature. As I already had Test Cases written, I decided to try to incorporate > the logging module into my class, and turn on debugging at the logger before > the newly-broken te

Re: Python Basic Doubt

2013-08-10 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > Because id(n) is not giving you the address of the NAME. It is giving > you the address of the "10" Actually, it is giving you the id of the int(10) object. Maybe it's an address, maybe it's not. Only your implementation knows for sure. -- http://mail

Re: How many times does unittest run each test?

2013-08-10 Thread Roy Smith
On Saturday, August 10, 2013 1:40:43 PM UTC-7, Roy Smith wrote: > > For example, you drag in the logging module, and do some semi-complex > > configuration. Are you SURE your tests are getting run multiple times, > > or maybe it's just that they're getting LOGG

Re: Am I not seeing the Error?

2013-08-10 Thread Roy Smith
In article , Chris Angelico wrote: > When you get a syntax error you can't understand, look at the previous > line of code. Perhaps something there is incomplete; maybe you have > mismatched parentheses, so this line is considered to be part of the > same expression. > > Next thing to do is spl

Re: Am I not seeing the Error?

2013-08-11 Thread Roy Smith
In article <52074b43$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Sun, 11 Aug 2013 03:33:52 +0100, Chris Angelico wrote: > > > Next thing to do is split it into more lines. Why is all that in a > > single line? > > The only good excuse for writing multiple statement

Re: PEP 450 Adding a statistics module to Python

2013-08-11 Thread Roy Smith
In article , Skip Montanaro wrote: > > See the Rationale of PEP 450 for more reasons why “install NumPy” is not > > a feasible solution for many use cases, and why having ‘statistics’ as a > > pure-Python, standard-library package is desirable. > > I read that before posting but am not

Re: Am I not seeing the Error?

2013-08-12 Thread Roy Smith
I can't quite sort out the multiple quoting levels, but somebody said: >>> Programming like that is called trolling. A programmer that uses >>> trolling is called a troll. A troll can also refer to such a line >>> of code itself. My scripts contain a lot of trolls. It is easier >>> for me to re

Re: Pair of filenos read/write each other?

2013-08-13 Thread Roy Smith
In article , Jack Bates wrote: > Can anyone suggest a way to get a pair of file descriptor numbers such > that data written to one can be read from the other and vice versa? > > Is there anything like os.pipe() where you can read/write both ends? > > Thanks! I think you're looking for socket

Re: Am I not seeing the Error?

2013-08-14 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Aug 14, 2013 at 7:59 AM, Joshua Landau wrote: > > On 14 August 2013 02:20, Gregory Ewing wrote: > >> Ned Batchelder wrote: > >>> > >>> Everyone: this program seems to be a direct and misguided transliteration > >>> from a bash script. > >> > >> Not

Re: many constructors in a class?

2013-08-15 Thread Roy Smith
In article <520c81f6$0$29885$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > [1] The constructor is __new__, not __init__. __init__ is called to > initialise the instance after __new__ constructs it. True, but be warned that writing your own __new__() is quite rare and probably

Re: .split() Qeustion

2013-08-15 Thread Roy Smith
In article <520da6d1$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 15 Aug 2013 16:43:41 +0100, Chris Angelico wrote: > > > A mole is as much a number (6e23) as the light year is a number > > (9.5e15). > > Not quite. A mole (abbreviation: mol) is a name for a spe

Re: .split() Qeustion

2013-08-16 Thread Roy Smith
In article , Ben Finney wrote: > Avogadro's Number is worth remembering, for mocking the pseudo-science > of homeopathy http://www.1023.org.uk/what-is-homeopathy.php>. You have obviously never argued science with a homeopath if you believe that knowing Avogadro's number will in any way shake t

Re: How to I do this in Python ?

2013-08-16 Thread Roy Smith
In article , Ganesh Pal wrote: > # Creating sparse files in the sparse path > sparse_path = os.path.join(path,'sparsefiles') > os.makedirs(sparse_path) > os.chdir(sparse_path) > sparsefiles = "dd if=/dev/zero of=sp1 count=0 bs=1 seek=10G" > process_0 = subprocess.Popen(

Re: .split() Qeustion

2013-08-16 Thread Roy Smith
In article <2d88bc0f-fdcb-4685-87ed-c17998dd3...@googlegroups.com>, wxjmfa...@gmail.com wrote: > A chemist has to work and is always working in mole; as his > balance can only measure a mass, the calculation mole <-> mass > is always mandatory. That's because chemists are lazy. The recipe says,

Re: PEP 450 Adding a statistics module to Python

2013-08-16 Thread Roy Smith
In article <0d60fd90-eb19-4702-acd5-dd7ba0edd...@googlegroups.com>, taldcr...@cfa.harvard.edu wrote: > Python is showing up in high-school and colllege intro programming > courses here in the U.S. Yup. For the past few years, I've been a judge in the NYC Science and Engineering Fair (http:

Re: .split() Qeustion

2013-08-17 Thread Roy Smith
I wrote: >> The recipe says, "Add one mole of carbon atoms". So, does the >> chemist follow the recipe and count out 6.022 x 10^23 atoms like >> he's supposed to? No. He says, "I don't have time for that. I'll >> just weigh out 12 grams. Good enough for government work." Sheesh. In articl

Re: Need somebody schmardter than me

2013-08-18 Thread Roy Smith
In article , Gene Heskett wrote: [much that doesn't appear to have anything to do with Python elided] > When cheese runs this camera, there is a several second delay while cheese > is apparently talking to it to establish the correct output format before > cheese starts displaying its output,

Re: Question about crypto

2013-08-18 Thread Roy Smith
In article , Anthony Papillion wrote: > I've just started working with the Crypto library and I've already run > into a wall even though I'm following a tutorial. Basically, I'm trying > to encrypt a string using AES in CBC mode. Here is the code: > > from Crypto import AES You don't say exact

Re: refresing the edited python function

2013-08-19 Thread Roy Smith
In article , Ben Finney wrote: > Developers use the interactive console for exploring, not developing. I am reminded of a (very strange) guy I went to school with. He linked /dev/tty to /dev/tty.c. That allowed him to run "cc /dev/tty.c" and type in the text of a C program to compile. -- h

Re: semicolon at end of python's statements

2013-08-28 Thread Roy Smith
In article , Mohsen Pahlevanzadeh wrote: > Dear all, > > I'm C++ programmer and unfortunately put semicolon at end of my > statements in python. > > Quesion: > What's really defferences between putting semicolon and don't put? In theory, nothing. In practice, all the real Python programmers

Re: semicolon at end of python's statements

2013-08-28 Thread Roy Smith
In article , Chris Angelico wrote: > This is about Perl, but may be of interest. > > http://www.perl.com/pub/2007/12/06/soto-11.html I got about halfway through, then raised an uncaught TLDNR Exception. But I did like what he had to say about Tcl. Tcl is under-appreciated. A few gigs back,

Re: Interface and duck typing woes

2013-08-28 Thread Roy Smith
In article , Cameron Simpson wrote: > Anyway, I digress. My point is that there are plusses to having > signature/type checking at coding time. It is not the Python Way, > but I surely cannot be alone in sometimes being frustrated chasing > a deeply nested runtime error that static type checking

Re: Interface and duck typing woes

2013-08-30 Thread Roy Smith
In article <52200699$0$6599$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > These days, it would be relatively simple to implement pre- and post- > condition checking using decorators, and indeed one of the motivating use- > cases for function annotations in Python 3 is to allow su

Re: semicolon at end of python's statements

2013-08-30 Thread Roy Smith
In article , Fábio Santos wrote: > On 29 Aug 2013 23:20, "Ben Finney" wrote: > > > > Fábio Santos writes: > > > > > It is a shame that this is not possible in python. for..if exists in > > > comprehensions and not in regular loops but that would be nice > > > sometimes. > > > > So you use it i

Re: HMAC encription issue

2013-08-31 Thread Roy Smith
In article <3479e08e-d435-492b-b2a0-a1c18678f...@googlegroups.com>, sergio7...@gmail.com wrote: > key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A3035" > key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A303$ To start with,

Re: HMAC encription issue

2013-08-31 Thread Roy Smith
In article , Sergio Sanchez wrote: > > To start with, your keys are not the same > > Sorry, that was a problem with the cut & paste. And your credentials are different too: var credentials = "admin:amin"; credentials = "admin:admin" Is this also a cut & paste error? Please, post EXACTlY the

Re: Interface and duck typing woes

2013-08-31 Thread Roy Smith
In article <5221352b$0$6599$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Heh, everybody has one of two reactions: > > "This is awesome!" [[i.e. what I said]] > > "You'll add type checking to my Python code over my dead body!!!" Duck typing is a funny thing. Sure, I don't ha

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-08-31 Thread Roy Smith
In article , anntzer@gmail.com wrote: > Hi, > > At startup, IPython (qtconsole) calls > "socket.gethostbyname_ex(socket.gethostname())[2]" to find a list of IP > addresses that point to the machine. On a Linux server that I manage this > call is extremely slow (>20s)... which I have troub

Not getting my head around pandas

2013-08-31 Thread Roy Smith
I've got a pandas DataFrame that looks like: Int64Index: 12960 entries, 0 to 12959 Data columns (total 2 columns): date12960 non-null values ms 12960 non-null values dtypes: datetime64[ns](1), float64(1) date ms 12955 2013-08-30 23:20:00 96.868491 12956

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-09-01 Thread Roy Smith
In article <48c8f8ca-d8c1-4a60-ba7f-8e8b00993...@googlegroups.com>, anntzer@gmail.com wrote: > It is the call to gethostbyname_ex that is very slow. The call to > gethostname is quick (and returns the same string as /usr/bin/hostname). First, please stop posting with Google Groups. It mak

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ethan Furman wrote: > On 09/01/2013 03:09 AM, Fabrice Pombet wrote: > > > > So I guess that we are actually all agreeing on this one. > > No, we are not. > > "encapsulation" != "inaccessible except by getters/setters" Nothing is accessible in Python except via getters and setters

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Tim Delaney wrote: > On 2 September 2013 06:33, Ethan Furman wrote: > > > > > class PlainPython: > > > > value = None > > > > > > In the Javaesque class we see the unPythonic way of using getters/setters; > > in the ProtectedPython* class we see the pythonic way of providing >

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ben Finney wrote: > One of the more annoying traits of humanity is that whatever context we > first encounter a term is disproportionately privileged, causing us to > irrationally dismiss better (more useful, more reasonable, more > pedagogically appropriate, more historically corre

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ethan Furman wrote: > On 09/01/2013 02:54 PM, Tim Delaney wrote: > > Roy Smith wrote: > >> > >> Nothing is accessible in Python except via getters and setters. The > >> only difference between Python and, say, C++ in this regard is that the >

Re: A Pragmatic Case for Static Typing

2013-09-02 Thread Roy Smith
In article <7xfvtnwsn9@ruckus.brouhaha.com>, Paul Rubin wrote: > "Russ P." writes: > > I just stumbled across this video and found it interesting: > > http://vimeo.com/72870631 > > My apologies if it has been posted here already. > > The slides for it are here, so I didn't bother watching

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-09-02 Thread Roy Smith
In article <00843d58-db21-4cf0-9430-85362a1dd...@googlegroups.com>, anntzer@gmail.com wrote: > As it happens I found a better way: just add the proper entry to /etc/hosts. You have not found a better way. You still have a network (or more specifically, DNS) configuration that's broken. Wh

Re: A Pragmatic Case for Static Typing

2013-09-02 Thread Roy Smith
In article <52245df4$0$2743$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano wrote: > One factor I don't see very often mentioned is that static typing > increases coupling between distant parts of your code. If func() changes > from returning int to MyInt, everything that calls func now n

Re: semicolon at end of python's statements

2013-09-02 Thread Roy Smith
In article , Tim Chase wrote: > On 2013-09-02 14:20, Grant Edwards wrote: > > >> This saves an indent level. > > > > > > Just out of interest: is saving an indent level a useful thing? > > > > Perhaps he's worried about the world running out of tabs? > > > > I heard that most of the tab mines

Re: How can I remove the first line of a multi-line string? (SOLVED)

2013-09-02 Thread Roy Smith
In article , Anthony Papillion wrote: > On 09/02/2013 11:12 AM, Chris “Kwpolska” Warrick wrote: > > On Mon, Sep 2, 2013 at 6:06 PM, Anthony Papillion > > wrote: > >> Hello Everyone, > >> > >> I have a multi-line string and I need to remove the very first line from > >> it. How can I do tha

Re: semicolon at end of python's statements

2013-09-02 Thread Roy Smith
In article , "albert visser" wrote: > I like being able to do e.g. > > with open('some_file') as _in, open('another_file', 'w') as _out: It would be nice if you could write that as: with open('some_file'), open('another_file, 'w') as _in, _out: -- http://mail.python.org/mailman/li

Re: semicolon at end of python's statements

2013-09-02 Thread Roy Smith
In article , Modulok wrote: > > So? Indeed there are too many people looking at these things as fighting > > for the one true way. That is IMO part a big part of the problem. I have > > no problem if someone else uses a different style than I do. Python as > > a language tries too hard to enforc

Re: Find out where a class is used throughout a program.

2013-09-04 Thread Roy Smith
In article <9d290db6-b9cb-41af-8107-e7f27d2da...@googlegroups.com>, Azureaus wrote: > To try and make this question as general as possible - is there a way of > finding out / visualising where a particular class is called/used throughout > a program? Sure. $ cd $ find . -name "*.py" | xarg

Re: Dealing with Lists

2013-09-10 Thread Roy Smith
In article <3d1eaccc-cf89-4eb0-b96c-b22a0a2f7...@googlegroups.com>, stas poritskiy wrote: > So head is parent of neck, while neck is parent of arms and so on. The head bone's connected to the neck bone. The neck bone's connected to the arm bone... -- https://mail.python.org/mailman/listinfo

Re: How can I remove the first line of a multi-line string? (SOLVED)

2013-09-11 Thread Roy Smith
In article , Fábio Santos wrote: One suggested solution: > > > > sansfirstline = '\n'.join(fullstring.split('\n')[1:]) To which I suggested a couple of alternatives: > > i = s.index('\n') > > print s[i+1:] > > [...] > > print re.sub(r'^[^\n]*\n', '', s) > > I'll admit, the split/slice/joi

Python in XKCD today

2013-09-11 Thread Roy Smith
http://xkcd.com/1263/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-11 Thread Roy Smith
In article <523127e2$0$29988$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > just 3 bits if you only cared about decimal digits. That's a neat trick. -- https://mail.python.org/mailman/listinfo/python-list

Re: Monitor key presses in Python?

2013-09-14 Thread Roy Smith
In article <5c59400c-45ca-40f0-846c-05bef3eb0...@googlegroups.com>, eamonn...@gmail.com wrote: > It might sound strange, but I'd need this to run without the user knowing. It's called a keylogger. And after all the revelations about the NSA over the past few weeks, it doesn't sound strange at

Re: How is this list comprehension evaluated?

2013-09-16 Thread Roy Smith
In article , Arturo B wrote: > Hello, I'm making Python mini-projects and now I'm making a Latin Square > > (Latin Square: http://en.wikipedia.org/wiki/Latin_square) > > So, I started watching example code and I found this question on > Stackoverflow: > > http://stackoverflow.com/questions/

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Roy Smith
In article , Ferrous Cranus wrote: > o want to avoid having to type somehting like this: > > if person="George": > times in range(0, 5): > > > Why it gives me an error when i'm trying to write it like this: > > > if person="George" for times in range(0, 5): Step One when reporting a

Re: iterating over a file with two pointers

2013-09-18 Thread Roy Smith
> > On Wed, Sep 18, 2013 at 9:12 PM, nikhil Pandey > > wrote: > >> hi, > >> I want to iterate over the lines of a file and when i find certain lines, > >> i need another loop starting from the next of that "CERTAIN" line till a > >> few (say 20) lines later. > >> so, basically i need two point

Re: iterating over a file with two pointers

2013-09-18 Thread Roy Smith
= tee(f) Are all of those g's just hanging around, eating up memory, while waiting to be garbage collected? I have no idea. But I do know that no such problems exist with the two file descriptor versions. > I would expect this to be more > efficient as well as less error-prone on Windows. > > > Oscar > --- Roy Smith r...@panix.com -- https://mail.python.org/mailman/listinfo/python-list

lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-18 Thread Roy Smith
I can create an Element with a 'foo' attribute by doing: etree.Element('my_node_name', foo="spam") But, how do I handle something like: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi" isn't a valid python

Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Roy Smith
In article , Chris Angelico wrote: > On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal wrote: > > I hope that cleared some confusion about what I wanted to ask. I wanted to > > gauge myself to find if I am progressing or not. > > Well, based on my definition, that's easy to answer. Have you solve

Re: Python Interview Questions

2013-09-23 Thread Roy Smith
Somebody, whose identity has been lost in three-deep quoting, said: > > > I am now appearing for Job Interviews these days and I am > > > wondering if anybody of you appeared for a Python > > > Interview. Can you please share the questions you were > > > asked. That will be great help to me. We ha

Re: Help with python functions?

2013-09-23 Thread Roy Smith
In article , kjaku...@gmail.com wrote: > 1.a. Write a function temp(T, from_unit, to_unit) where from_unit and to_unit > are temperature units, either 'F' (or 'f') for fahrenheit, or 'C' (or 'c') > for celsius, or 'K' (or 'k') for kelvin; and T is a temperature number for > the unit from_unit.

Re: combine pictures

2013-09-24 Thread Roy Smith
In article , Terry Reedy wrote: > On 9/24/2013 3:40 AM, and...@zoho.com wrote: > > hello, i have a picture and i want to merge it with an other picture which > > is half transparent and the first picture will shine through it, has python > > the library's to do this? > > Searching 'python ima

Re: How to quickly search over a large number of files using python?

2013-09-25 Thread Roy Smith
In article <60f36178-b584-4fcb-8ad9-2dac6052e...@googlegroups.com>, dwivedi.dev...@gmail.com wrote: > Hi all, > > I am a newbie to python. > > I have about 500 search queries, and about 52000 files in which I have to > find all matches for each of the 500 queries. Before anybody can even begi

Re: Nosetests

2013-09-25 Thread Roy Smith
In article <32f7bdcb-97e5-4a1c-a2c8-ab91e4052...@googlegroups.com>, melw...@gmail.com wrote: > Not sure How to proceed on with writing a few more tests with if statement to > test if the value is low or high. I was told to try a command line switch > like optparse to pass the number but not sur

Re: Nosetests

2013-09-26 Thread Roy Smith
In article , melw...@gmail.com wrote: > Initially I was shown pexpect, leaving that there, Can i make up 5 tests? I > tried tests two different ways and no luck. What am I supposed to be writing > up when I do a test and is there a particular way I can/should be referencing > it back to its ma

Re: Do I really need a web framework?

2013-09-30 Thread Roy Smith
In article , duf...@gmail.com wrote: > I want to set up a very simple website, and I need to know if it is necessary > to use a web framework (e.g. Django) to do basic interactive operations such > as receiving input from the user, looking up a database and returning some > data to the user. >

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , JL wrote: > What is the difference between running multiple python scripts and a single > multi-threaded script? May I know what are the pros and cons of each > approach? Right now, my preference is to run multiple separate python scripts > because it is simpler. First, let's ta

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith wrote: > > The downside to threads is that all of of this sharing makes them much > > more complicated to use properly. You have to be aware of how all the > > threads are interacting, and med

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , Chris Angelico wrote: > As to your corrupt data example, though, I'd advocate a very simple > system of object ownership: as soon as the object has been put on the > queue, it's "owned" by the recipient and shouldn't be mutated by > anyone else. Well, sure. I agree with you that t

Re: how to read list from file

2013-10-05 Thread Roy Smith
In article , Harvey Greenberg wrote: > I am looping as for L in file.readlines(), where file is csv. > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first > item is a dir and 2nd is a list, so parsing with split doesn't work. Is > there a way to convert L, which i

Re: how to read list from file

2013-10-05 Thread Roy Smith
In article , Tim Chase wrote: > sounds like you want ast.literal_eval(): This sounds like a better idea than either of my earlier suggestions! -- https://mail.python.org/mailman/listinfo/python-list

Re: Odd-length string

2013-10-06 Thread Roy Smith
In article <0f1b6cd6-3025-4bdc-8f80-73a51a7ed...@googlegroups.com>, markot...@gmail.com wrote: > print("Key-" + str(võti) + ": " + str(unhexlify("".join(tulemus > > IM getting this error on this line. This is the print line of a decryption > program. I wanti it to convert the tulemus which

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-06 Thread Roy Smith
In article , Chris Angelico wrote: > I would hope that an absence of libpq could simply result in a > courteous exception when the module's imported, but maybe that'd be > hard to implement. It works fine. I've had this in production for a while: # Psycopg2 is only needed for a single hacky l

Re: nginx config: different projects in different directories

2013-10-06 Thread Roy Smith
In article , Jabba Laci wrote: > The problem is I can't > figure out how to configure nginx for this. This is a python mailing list. You would do better asking nginx questions on an nginx mailing list. -- https://mail.python.org/mailman/listinfo/python-list

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Tue, Oct 8, 2013 at 5:48 PM, wrote: > > And if we were actually trying then that filename should just be "/w". > > Would get rid of another 19 chars. > > I'm working this on the assumption that the dictionary file already > exists (that's where it is o

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().spli > > t("\n"),4)) In article <68365e43-498f-4ad2-bac3-6a0293815...@googlegroups.com>, sprucebond...@gmail.com wrote: > import random as r > print(*

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Oct 9, 2013 at 12:38 PM, Roy Smith wrote: > > If you're willing to accept a sub-optimal random number generator: > > > > # Python-2, sorry > > import os > > print list(set(open('/usr/share/dict/words'

Re: Code golf challenge: XKCD 936 passwords

2013-10-09 Thread Roy Smith
In article , Nick Cash wrote: > >> # Python-2, sorry > >> import os > >> print list(set(open('/usr/share/dict/words')))[os.getpid():][:4] > > > So that steps by your pid? > > Not really. It seems to rely on list(set(...)) kinda randomizing order... > which is definitely not safe without hash

Re: Cookie gets changed when hit comes from a referrer

2013-10-09 Thread Roy Smith
In article <5255eb3c$0$29984$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > So, for the benefit of anyone, not just Nikos, who wants to learn about > how browsers connect to web sites and how to run a web server, does > anyone have any recommendation for tutorials, mailing lists

Re: I am never going to complain about Python again

2013-10-10 Thread Roy Smith
In article <52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano wrote: > Just came across this little Javascript gem: > > ",,," == Array((null,'cool',false,NaN,4)); > > => evaluates as true > > http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array > > I swear, I am

Re: closure = decorator?

2013-10-10 Thread Roy Smith
In article , Piet van Oostrum wrote: > I usually say that a closure is a package, containing a function with > some additional data it needs. The data usually is in the form of name > bindings. That's pretty close to the way I think about it. The way it was originally described to me is, "A c

Re: I am never going to complain about Python again

2013-10-10 Thread Roy Smith
In article , Neil Cerutti wrote: > >>> 5.0 == abs(3 + 4j) > False I'd like an argument, please. -- https://mail.python.org/mailman/listinfo/python-list

Re: Skipping decorators in unit tests

2013-10-10 Thread Roy Smith
On 10Oct2013 19:44, Ned Batchelder wrote: > > I have to admit I'm having a hard time understanding why you'd need > > to test the undecorated functions. After all, the undecorated > > functions aren't available to anyone. All that matters is how they > > behave with the decorators. In article ,

Re: Is this the room for an argument?

2013-10-11 Thread Roy Smith
In article <5223ac4a-783e-405d-84a4-239070b66...@googlegroups.com>, John Ladasky wrote: > On Thursday, October 10, 2013 5:07:11 PM UTC-7, Roy Smith wrote: > > I'd like an argument, please. > > 'Receptionist' (Rita Davies) - Yes, sir? > 'Man

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-11 Thread Roy Smith
In article , Oscar Benjamin wrote: > If someone tried to explain why their field couldn't use ð for the > circumference of a unit circle I would suggest that they adjust the > other parts of their notation not ð (there are other uses of ð. Pi is wrong: http://www.youtube.com/watch?v=jG7vhMMX

Re: Unicode Objects in Tuples

2013-10-12 Thread Roy Smith
In article , Ned Batchelder wrote: > This idea that the repr can reconstruct the object always fell flat with > me since the vast majority of classes don't have a repr that works that > way. I look at it a little differently: the repr is meant to be as > unambiguous as possible to a develope

Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-13 Thread Roy Smith
In article <525a15ad$0$29984$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > While I agree with your general thrust, I don't think it's quite so > simple. Perl has a king, Larry Wall, but his design is more or less > "throw everything into the pot, it'll be fine" and consequently

<    9   10   11   12   13   14   15   16   17   18   >