Statically linking part of a C extension module?

2015-03-23 Thread Dan Stromberg
Hi folks. I want to build a pair of wheels - one for numpy, one for scipy. And I want to statically link atlas (with blas and lapack) into these wheels. I don't want to statically link numpy or scipy into the Python interpreter. The goal is to decrease the frequency with which new wheels need t

Daylight savings time question

2015-03-24 Thread Dan Stromberg
Is there a way of "adding" 4 hours and getting a jump of 5 hours on March 8th, 2015 (due to Daylight Savings Time), without hardcoding when to spring forward and when to fall back? I'd love it if there's some library that'll do this for me. #!/usr/bin/python import pytz import datetime def main

Re: Daylight savings time question

2015-03-24 Thread Dan Stromberg
e') main() On Tue, Mar 24, 2015 at 3:24 PM, Dan Stromberg wrote: > Is there a way of "adding" 4 hours and getting a jump of 5 hours on > March 8th, 2015 (due to Daylight Savings Time), without hardcoding > when to spring forward and when to fall back? I'd love

Re: New to Python - block grouping (spaces)

2015-04-17 Thread Dan Sommers
On Fri, 17 Apr 2015 18:05:52 +0100, BartC wrote: > (Actually *I* would quite like to know why languages don't have > switchable syntax anyway to allow for people's personal preferences.) You want LISP, the programmable programming language. -- https://mail.python.org/mailman/listinfo/python-list

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Dan Sommers
only tools I remember from those days all ran inside UCSD Pascal and didn't expose much of the internals). Slash rant. Sorry. Now that we've settled on UTF-8 as a successor to ASCII, the program=textfile system has a long future in front of it. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Python xlrd

2015-05-03 Thread Dan Sommers
xlrd and python3-xlrd. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Throw the cat among the pigeons

2015-05-06 Thread Dan Sommers
d (but predictable) ways, and interrupts would have different (unpredictable) latency depending on how much internal state of the CPU had to be saved and restored. Man, am I *old*. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Camelot a good tool for me

2015-05-22 Thread Dan Sommers
On Fri, 22 May 2015 09:59:02 +0200, Cecil Westerhof wrote: > Would Camelot be a good tool to get me started, or can I better bite > the bullet and just start with Tkinter and SQLAlchemy? Bite the bullet and learn SQL. SQLAlchemy -> Database :: Python -> Assembly Language. HTH, D

Pep 484 Type Hint Checker - Python releases supported?

2015-05-28 Thread Dan Stromberg
I believe I heard that the PEP 484 type checker is to go into CPython 3.5. Since type annotations have been there since 3.0, is it at all likely that CPython versions < 3.5 will also be supported by this checker? Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Accessing DataSocket Server with Python

2015-05-28 Thread Dan Stromberg
I have no idea about the protocol used by NI DataSockets, but you might be able to reverse engineer the protocol by using the official client with a sniffer. Also, be aware that TCP/IP guarantees that you get the correct data in the correct order, but it doesn't guarantee anything about the sizes

Re: How to check in script if Python or Jython is used

2015-06-22 Thread Dan Stromberg
IMO, it's usually better to test for features and use them if they are present, than to build a list of features available in specific interpreters. I see it as analogous to the difference between huge C #ifdef's on OS, and autoconf. On Sun, Jun 21, 2015 at 1:12 AM, Cecil Westerhof wrote: > I in

Looking up a dictionary _key_ by key?

2015-06-23 Thread Dan Stromberg
I know that sounds strange: usually we look up values by key, not keys. But suppose you have a strange key type that despite being "equal", is not identical in some fields, and you need to see those fields. Is there a way of getting the key used by the dictionary, short of storing a reference to

Re: Looking up a dictionary _key_ by key?

2015-06-23 Thread Dan Stromberg
On Tue, Jun 23, 2015 at 5:33 PM, Ben Finney wrote: > Dan Stromberg writes: > >> Is there a way of getting the key used by the dictionary, short of >> storing a reference to it in the value, or using a second dictionary? > > The dictionary knows its keys and can provide t

Re: Most Pythonic way to store (small) configuration

2015-08-02 Thread Dan Sommers
On Sun, 02 Aug 2015 16:11:14 -0500, Tim Chase wrote: > On 2015-08-02 21:54, Ben Finney wrote: >> So, both XML and JSON should be considered write-only, and produced >> only for consumption by a computer; they are a poor choice for >> presenting to a human. [snip] > I second Ben's thoughts again

Re: Regular expressions

2015-11-03 Thread Dan Sommers
tc. > > Grep can use regular expressions (and I do so with it regularly), but > it's default mode is certainly not regular expressions ... Its very name indicates that its default mode most certainly is regular expressions. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: What does “grep” stand for?

2015-11-05 Thread Dan Sommers
Master. Around that same time frame was Programma Improved Editor on an Apple II. (Apple PIE. Get it?) old'ly yours, Dan -- https://mail.python.org/mailman/listinfo/python-list

python PEP suggestion

2015-11-08 Thread Dan Strohl
at this point to see if it resonates... (or if it falls flat and goes "splat" ). Thoughts? Dan Strohl New special method name to allow for more flexible object type casting/access, and extend type() to cast objects using this special method name. Overview: Have a new special m

RE: Script to extract text from PDF files

2015-11-08 Thread Dan Strohl
Its possible (likely) that I came into this in the middle, so sorry if this was already thrown out... but have you looked at any of the following suggestions? https://pypi.python.org/pypi?%3Aaction=search&term=pdf+convert&submit=search http://stackoverflow.com/questions/6413441/python-pdf-library

RE: python PEP suggestion

2015-11-10 Thread Dan Strohl
('a_string')" it would work (and often doesn't). The excessive indents of 31 and 15 spaces make the rest of this post unnecessarily hard to read. Sorry about that, damn outlook tabs being expanded to stupid numbers I guess. I will do better next time.. Does any of that hel

http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?

2014-06-06 Thread Dan Stromberg
I have some code for a web server. Right now, it uses BaseHTTPRequestHandler with Basic Auth, but we want to be able to log out, and there doesn't appear to be a general way to log out of something using Basic Auth, short of turning to unportable JavaScript. And this needs first and foremost to b

Decorating one method of a class C with another method of class C?

2014-06-06 Thread Dan Stromberg
Is there a way of decorating method1 of class C using method2 of class C? It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what "self" is until later in execution so there's apparently no way to specify @self.method2 when def'ing method1. -- https://mail.python.

Re: Decorating one method of a class C with another method of class C?

2014-06-08 Thread Dan Stromberg
On 6/6/14, Ben Finney wrote: > Dan Stromberg writes: > >> Is there a way of decorating method1 of class C using method2 of class >> C? > > Can you give a concrete example (i.e. not merely hypothetical) where > this would be a useful feature (i.e. an actual improvemen

Re: Python's re module and genealogy problem

2014-06-13 Thread Dan Sommers
untime extensibility, atop the "obvious" spellings you take the time to include in your software. And that's *not* a comment on your abilities; it's a comment on the abilities and creativity of their ancestors. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Python's numeric tower

2014-06-15 Thread Dan Sommers
On Sun, 15 Jun 2014 22:17:57 -0400, Roy Smith wrote: > I don't believe HandGrenade implements throw(). It does, however, > implement lobbeth(). And therein lies the problem with Object Oriented Programming: instances of HandGrenade neither throw nor lobbeth. One, Two, Five&#x

Re: PEP8 and 4 spaces

2014-07-05 Thread Dan Sommers
separation than a blank line is provided by > comments, not more whitespace. > > ChrisA http://legacy.python.org/dev/peps/pep-0008/#id15 says: "Separate top-level function and class definitions with two blank lines." With docstrings occurring inside function definitions, this

Re: PEP8 and 4 spaces

2014-07-06 Thread Dan Stromberg
On Thu, Jul 3, 2014 at 10:31 AM, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. I recently converted from tabs to spaces. I probably still have some code that uses tabs, but most of my personal stuff has been converted. I like tabs. Tabs work bette

Re: PEP8 and 4 spaces

2014-07-06 Thread Dan Sommers
On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > The makefile syntax is one of the excellent examples of why it's a > terrible idea to use tab characters in source code. It's also an > excellent example of how a poor design decision (a line beginning with > U+0020 SPACE is semantically diff

Re: open() and EOFError

2014-07-07 Thread Dan Stromberg
On 7/7/14, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano >> wrote: >>> How do people feel about code like this? >>> >>> try: >>> name = input("Enter file name, or Ctrl-D to exit") >>> # On Windows, use Ctrl-Z [enter]

Re: Python top learning language

2014-07-08 Thread Dan Stromberg
On Tue, Jul 8, 2014 at 12:19 PM, candide wrote: > http://www.infoworld.com/d/application-development/python-bumps-java-top-learning-language-245774 As a sort of nano-celebration, here's a blast from Python's past (May, 1997): https://web.archive.org/web/19970501011626/http://www.python.org/ -- h

Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
Hi folks. I'm having trouble with a strange AttributeError. I'm using RQ (Redis Queue) and Django, both of which are new to me, so perhaps they are somehow relevant. Anyway, the traceback looks like: Traceback (most recent call last): File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
On Thu, Jul 10, 2014 at 9:41 AM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks

Re: Python 3 is killing Python

2014-07-12 Thread Dan Stromberg
On Wed, May 28, 2014 at 12:23 PM, Larry Martell wrote: > Somthing I came across in my travels through the ether: > > https://medium.com/@deliciousrobots/5d2ad703365d/ Hey kids, maybe if we all chant this enough times, we can make it true! Wouldn't that be fun? -- https://mail.python.org/mailman

Re: codingbat question broken?

2014-07-12 Thread Dan Stromberg
This runs on 2.7 or 3.4, unmodified (other than the #!): #!/usr/local/cpython-2.7/bin/python #!/usr/local/cpython-3.4/bin/python def lucky_sum(*list_): lucky_total = 0 for element in list_: if element == 13: break lucky_total += element return lucky_total

Re: What Next After Python Basics

2014-07-13 Thread Dan Stromberg
On Sun, Jul 13, 2014 at 1:16 PM, Orochi wrote: > Hi, > I am beginner in Python > I have Completed Basic Python Course from Codecademy.com . > Now that I have a hands on the basics what is the next thing I should do. > I mean should I learn more or start a small Project(Any Ideas are Welcomed) > o

Re: Python 3 is killing Python

2014-07-17 Thread Dan Stromberg
On Thu, Jul 17, 2014 at 7:49 PM, alex23 wrote: > On 17/07/2014 1:14 PM, Steven D'Aprano wrote: >> >> There will never be a Python 2.8. When push comes to shove, the people >> bitching about Python 3 will not do the work necessary to fork Python 2.7 >> and make a version 2.8. > > > +1 > > The idea

Re: Is it possible to install Python on a network?

2014-07-22 Thread Dan Stromberg
On Tue, Jul 22, 2014 at 5:41 PM, roys2005 wrote: > > Emile, thanks for the quick response. > > Does this mean Python cannot be or should not be installed at a central > location? > If so, what is the root cause for this? Back when I was a sysadmin, I would install CPython to a few different NFS

Re: Is it possible to install Python on a network?

2014-07-23 Thread Dan Stromberg
On Wed, Jul 23, 2014 at 7:15 AM, roys2005 wrote: > > Dan, > > Thanks for the information. So, one option is to build Python > from source code to be able to install "/where/ever/..." > > I still wonder why there is no distribution package for *ix that >

Re: Prob. Code Downloaded for Programming the Semantic Web (python code)

2014-07-25 Thread Dan Stromberg
On Fri, Jul 25, 2014 at 5:21 PM, Skip Montanaro wrote: >> OK, Eclipse with PyDev doesn't like this first line, with the function: >> def add(self, (sub, pred, obj)): >> >> It complains about the parentheses just before sub. > > Seems like this code is Python 2.x. For me, this code ran on all of 2

Re: What meaning of this ""hello %s you are %s years old" % x"

2014-07-27 Thread Dan Stromberg
On Sun, Jul 27, 2014 at 11:49 AM, fl wrote: > In Python, when should you use lists and when tuples? > > Sometimes you don't have a choice, for example if you have > > "hello %s you are %s years old" % x > then x must be a tuple. > > But if I am the one who designs the API and gets to choose the da

Re: NameError: name 'requests' is not defined ?

2014-07-27 Thread Dan Stromberg
On Sun, Jul 27, 2014 at 8:52 PM, 水静流深 <1248283...@qq.com> wrote: > there is a simple file `mydown.py` saved in `D:\Python34\Lib\site-packages` > there is only one line in mydown.py . > > import requests > > > > C:\Users\pengsir>d:\Python34\python > Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 1

Re: How to loop through nodes of xml through xslt

2014-07-30 Thread Dan Stromberg
On Wed, Jul 30, 2014 at 5:16 AM, varun bhatnagar wrote: > Hi, > > I have two xml files. > I am trying to fetch an output file which looks like this: > > Output.xml > The number of Procedure tag () can be different every time. So I > have to read this tag every time from each xml and then merge i

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Dan Stromberg
I like to think of pylint as an expert system about how to write better Python. Some of the warnings are pointless (superfluous-parens really bugs me), but much of it is quite valuable. And for the -really- pointless stuff, you can create a pylintrc to ignore them forever. Personally, I prefer t

Re: How to loop through nodes of xml through xslt

2014-07-31 Thread Dan Stromberg
You're probably still better off finding an XSLT mailing list. On Thu, Jul 31, 2014 at 12:31 AM, varun bhatnagar wrote: > Hi Dan, > > Thanks a lot for the reply. I am using lxml for the transformation and I am > parsing xsl file using lxml module, that is why posted in this lis

Re: Dict when defining not returning multi value key error

2014-07-31 Thread Dan Stromberg
On Thu, Jul 31, 2014 at 4:24 AM, Dilu Sasidharan wrote: > Hi, > > I am wondering why the dictionary in python not returning multi value key > error when i define something like > > p = {'k':"value0",'k':"value1"} > > key is string immutable and sometimes shares same id. > > also if the key is immu

Re: Dict when defining not returning multi value key error

2014-07-31 Thread Dan Stromberg
On Thu, Jul 31, 2014 at 8:08 PM, Dan Stromberg wrote: >> p = {'1':"value0",'1.0':"value1"} > For 1 and 1.0 - they simply hash differently. Dictionaries are > resizeable hash tables. I removed some quotes, and noticed that 1 and 1.0 hash t

web2py and python3

2014-08-13 Thread Dan Stromberg
I heard there was a presentation about web2py in my area tonight. Trying to decide if I wanted to attend, I googled about web2py and python3. I was amazed by what I found. I've never seen a group so opposed to python3. They make the old (and long-since lost) Solaris 2 wars seem tame. I don't th

Re: get the min date from a list

2014-08-14 Thread Dan Stromberg
On Thu, Aug 14, 2014 at 5:44 PM, Mark Lawrence wrote: > I really don't understand why people here are spoon feeding you when you > still insist on top posting. Ever heard the term "manners"? Oh what a > stupid comment, obviously not. > > *plonk* Getting people to stop top-posting is a losing ba

Re: efficient partial sort in Python ?

2014-08-18 Thread Dan Stromberg
On Mon, Aug 18, 2014 at 10:18 AM, Chiu Hsiang Hsu wrote: > I know that Python use Timsort as default sorting algorithm and it is > efficient, > but I just wanna have a partial sorting (n-largest/smallest elements). Perhaps heapq with Pypy? Or with nuitka? Or with numba? -- https://mail.python

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 12:37 PM, Chiu Hsiang Hsu wrote: > On Tuesday, August 19, 2014 5:42:27 AM UTC+8, Dan Stromberg wrote: >> On Mon, Aug 18, 2014 at 10:18 AM, Chiu Hsiang Hsu wrote: >> >> > I know that Python use Timsort as default sorting algorithm and it is >&

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 4:05 PM, Dan Stromberg wrote: > When you use heapq, are you putting all the values in the heap, or > just up to n at a time (evicting the worst value, one at a time as you > go)? If you're doing the former, it's basically a heapsort which > proba

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 4:10 PM, Dan Stromberg wrote: > On Tue, Aug 19, 2014 at 4:05 PM, Dan Stromberg wrote: >> When you use heapq, are you putting all the values in the heap, or >> just up to n at a time (evicting the worst value, one at a time as you >> go)? If you'

Re: how to copy emails into local directory?

2014-08-20 Thread Dan Stromberg
On Wed, Aug 20, 2014 at 5:09 AM, luofeiyu wrote: > i want to copy all the emails in the gmailbox of > "[Gmail]/&kc2JgQ-" (the important mailbox in my gmail" > into local directory "g:\emails",how can i do that in python code? You could also try http://wiki.vpslink.com/Mount_a_Gmail_Account_as

Re: 'is not' or '!='

2014-08-21 Thread Dan Stromberg
On Mon, Aug 18, 2014 at 1:35 PM, ElChino wrote: > A newbie question to you; what is the difference between statements like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. You've got some good answers. I'd li

Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Dan Stromberg
Amusing. It works in hexadecimal too: numerator = 1 denominator = 0xffe001 shift = int(16 ** 30) print(hex(int(numerator * shift / denominator))) -- https://mail.python.org/mailman/listinfo/python-list

Re: Global indent

2014-08-22 Thread Dan Stromberg
On Fri, Aug 22, 2014 at 11:44 AM, Neil D. Cerutti wrote: > On 8/22/2014 2:19 PM, Seymore4Head wrote: >> >> Is there a way to indent everything again? >> >> Say I have a while statement with several lines of code and I want to >> add a while outside that. That means indenting everything. Is there

Re: Global indent

2014-08-22 Thread Dan Stromberg
On Fri, Aug 22, 2014 at 1:16 PM, Neil D. Cerutti wrote: >> Emacs and vim both have huge learning curves that I've decided aren't >> worth climbing. Notepad++ is an excellent GUI text editor for Windows. >> Geany is nearly as good, and runs on anything. > > > They do have a very long learning incl

Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-22 Thread Dan Stromberg
On Thu, Aug 21, 2014 at 12:55 AM, wrote: > Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic > (in a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the > language > this is what yours truly thinks: don't we all know that ":" means the next > token mus

Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-22 Thread Dan Stromberg
On Thu, Aug 21, 2014 at 12:55 AM, wrote: > Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic > (in a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the > language > this is what yours truly thinks: don't we all know that ":" means the next > token mus

Re: Media Conversion Using Python - Converting MP3 to Other Formats

2014-08-25 Thread Dan Stromberg
On Mon, Aug 25, 2014 at 9:04 AM, Mark Lawrence wrote: > On 25/08/2014 16:28, Parth Trivedi wrote: >> >> Dear All, >> >> I need some help of yours. I want to convert audio in MP3 format to >> other formats including uncompressed raw format, WAV etc. and I am using >> python 2.7. Is there any built-

Re: python string, best way to concat

2014-08-27 Thread Dan Stromberg
On Wed, Aug 27, 2014 at 1:31 PM, wrote: > > Hi, > > Sorry about the simple question but I am very new to Python. > > Anyway, I have a function that will be used to call a stored procedure and > I need to format the string with the correct number of parameter markers for > the ODBC driver,

Re: Distinguishing between maildir, mbox, and MH files/directories?

2014-08-31 Thread Dan Stromberg
On Sun, Aug 31, 2014 at 11:45 AM, Tim Chase wrote: > Tinkering around with a little script, I found myself with the need > to walk a directory tree and process mail messaged found within. > Sometimes these end up being mbox files (with multiple messages > within), sometimes it's a Maildir structur

Re: Storing instances using jsonpickle

2014-09-04 Thread Dan Sommers
uplicate) Okay, so what is value? Is it 'foo'? Is it None? (Yes, I can fix this. If I *know* that original is a float, then I could use original.hex() instead of str(original).) HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Prime testing [was Re: My backwards logic]

2014-09-07 Thread Dan Stromberg
On Sun, Sep 7, 2014 at 11:53 AM, Peter Pearson wrote: > On Sat, 6 Sep 2014 12:53:16 +0200, Manolo Martínez wrote: >> On 09/06/14 at 08:38pm, Steven D'Aprano wrote: >>> But even that's not how the specialists do it. If you want to check whether >>> (say) 2**3000+1 is prime, you don't want to use tr

Re: String representations of numbers and approximate equality

2014-09-24 Thread Dan Stromberg
On Wed, Sep 24, 2014 at 9:54 AM, Chris Angelico wrote: > Yes, it's another "how can I see if two numbers are approximately > equal" thread, but this time I have a concrete definition of > "approximately equal"... and they're Decimals, not floats. > > I have a number of files (this is an ongoing th

Re: Obscuring Python source from end users

2014-10-01 Thread Dan Stromberg
On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano wrote: > norman.i...@gmail.com wrote: > >> Hello list >> >> Python 3.4 applies. >> >> I have a project that involves distributing Python code to users in an >> organisation. Users do not interact directly with the Python code; they >> only know this

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Dan Stromberg
On Thu, Oct 2, 2014 at 12:15 PM, Ian Kelly wrote: > On Thu, Oct 2, 2014 at 10:33 AM, wrote: >> Ah, so at least there is a reason for it, I'm far from being a >> mathematician though so it's not particularly obvious (for me anyway). > > You're not alone; a lot of people find the terminology not i

Re: "High water" Memory fragmentation still a thing?

2014-10-04 Thread Dan Stromberg
On Fri, Oct 3, 2014 at 1:01 PM, Skip Montanaro wrote: > On Fri, Oct 3, 2014 at 1:36 PM, Croepha > wrote: > >> Long running Python jobs that consume a lot of memory while >> running may not return that memory to the operating system >> until the process actually terminates, even if everything is >

Re: python on Linux

2014-10-09 Thread Dan Stromberg
Try: sys.path.append(os.path.expanduser('~/MyLib')) On Thu, Oct 9, 2014 at 9:21 PM, Igor Korot wrote: > Hi, ALL, > When I am on Windows, I can write something like this: > > sys.path.append('C:\Users\Igor\Documents\MyLib') > > Now, when I'm on Linux, can I do this: > > sys.path.append('~/MyLib')

Re: How to select every other line from a text file?

2014-10-13 Thread Dan Stromberg
On Mon, Oct 13, 2014 at 10:38 AM, Rff wrote: > Hi, > I have a text file. Now it is required to select every other line of that > text to > generate a new text file. I have read through Python grammar, but still lack > the > idea at the beginning of the task. Could you tell me some methods to g

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Dan Stromberg
On Tue, Oct 14, 2014 at 7:13 PM, ryguy7272 wrote: > I'm just learning Python. It seems like indents are EXTREMELY important. I > guess, since there are no brackets, everything is controlled by indents. > Well, I'm reading a couple books on Python now, and in almost all of the > examples they

Re: Question About Running Python code

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 3:50 PM, ryguy7272 wrote: > I'm trying to run this script (using IDLE 3.4) > I would be most appreciative if someone could respond to a few questions. > > The error that I get is this. > 'invalid syntax' You may get better help if you give the context of this message. >

Re: Import Doesn't Import

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 5:40 PM, ryguy7272 wrote: > > ImportError: No module named 'urllib2' http://stackoverflow.com/questions/2792650/python3-error-import-error-no-module-name-urllib -- https://mail.python.org/mailman/listinfo/python-list

Re: Import Doesn't Import

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 5:44 PM, ryguy7272 wrote: > Either this is the most brilliant thing ever invented, or it's the biggest > piece of shit ever invented. I just can't tell. All I know for sure, is > that it doesn't do ANYTHING that I tell it to do. Maybe you should decide whether you wan

Re: Flush stdin

2014-10-18 Thread Dan Stromberg
On Sat, Oct 18, 2014 at 6:11 PM, Nobody wrote: > On Sat, 18 Oct 2014 12:32:07 -0500, Tim Chase wrote: > >> On 2014-10-18 17:55, Nobody wrote: >>> On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote: >>> >>> > I am using netcat to listen to a port and python to read stdin and >>> > print to the

Re: Flush stdin

2014-10-18 Thread Dan Stromberg
On Sat, Oct 18, 2014 at 6:34 PM, Dan Stromberg wrote: >> Once the "nc" process actually write()s the data to its standard >> output (i.e. desriptor 1, not the "stdout" FILE*) > I'm not sure why you're excluding stdout, but even if nc is using > file

Re: Flush stdin

2014-10-20 Thread Dan Stromberg
On Sun, Oct 19, 2014 at 9:45 PM, Marko Rauhamaa wrote: > I found this comment in CPython's source code (pythonrun.c): > > /* stdin is always opened in buffered mode, first because it shouldn't >make a difference in common use cases, second because TextIOWrapper >depends on the

Re: Flush stdin

2014-10-20 Thread Dan Stromberg
If I run the following in one tty: nc -l localhost 9000 | /tmp/z ...where /tmp/z has just: #!/usr/bin/python3 import sys for line in sys.stdin.buffer: print(line) And then run the following in another tty on the same computer: while read line; do echo $line; sleep 1;

Re: Flush stdin

2014-10-20 Thread Dan Stromberg
On Mon, Oct 20, 2014 at 4:18 PM, Marko Rauhamaa wrote: > Dan Stromberg : >> ...then everything acts line buffered, or perhaps even character >> buffered [...] >> >> That, or we're using two different versions of netcat (there are at >> least two available

Re: Flush stdin

2014-10-21 Thread Dan Stromberg
On Mon, Oct 20, 2014 at 9:41 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> Often with TCP protocols, line buffered is preferred to character >> buffered, > > Terminal devices support line buffering on write. Yes, though that's not the only place it's usefu

Re: Struggling with python-daemon and subprocess module to work together

2014-10-21 Thread Dan Stromberg
On Mon, Oct 20, 2014 at 2:16 AM, Praveen Kumar wrote: > I am writing a very basic server side application[0] which get data > from a client and create a virtual machine using provided data and > also tells client about what's going on during *virt-install* command > execution. Previously this basi

Re: Flush stdin

2014-10-21 Thread Dan Stromberg
On Tue, Oct 21, 2014 at 7:49 PM, Nobody wrote: > On Sat, 18 Oct 2014 18:42:00 -0700, Dan Stromberg wrote: > >> On Sat, Oct 18, 2014 at 6:34 PM, Dan Stromberg wrote: >>>> Once the "nc" process actually write()s the data to its standard >>>> o

Re: How to structure packages

2011-09-08 Thread Dan Sommers
The exception was the so-called Information Cluster, a collection of functions surrounding a data store, the predecessor to the modern day object-with-state and/or closure). Not a Java fan'ly yours, Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I pass a variable to os.popen?

2011-10-31 Thread Dan M
On Mon, 31 Oct 2011 13:16:25 -0700, extraspecialbitter wrote: > cmd = 'ethtool %interface' Do you perhaps mean: cmd = 'ethtool %s' % (interface, ) -- http://mail.python.org/mailman/listinfo/python-list

RSS feed creation?

2011-11-06 Thread Dan Stromberg
Is there an opensource Python tool for creating RSS feeds, that doesn't require large dependencies? I found feedformatter.py on pypi, but it seems a little old, and its sole automated test gives a traceback. Is there a better starting point? (I'd of course prefer something that'll run on 3.x and

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Dan Sommers
or message 'e'. I'm sure there's a > way and it's probably ridiculously simple. "except" catches any exception that inherits from its argument, and all MySQL exceptions inherit from MySQLError, so something like this will catch only MySQL exceptions and nothing els

Re: Using the Python Interpreter as a Reference

2011-11-20 Thread Dan Stromberg
On Sun, Nov 20, 2011 at 4:46 PM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, la

Re: Reading twice from STDIN

2011-12-01 Thread Dan Stromberg
On 12/1/11, janedenone wrote: > Hi, > > I would like to read from a pipe, parse the input and ask the user > what to do next: > > message = sys.stdin.read() > # message is parsed and URLs are printed as a list to choose from... > selected_index = raw_input('Which URL to open?') > > Calling raw_inp

Re: Python 2 or 3

2011-12-02 Thread Dan Stromberg
On 12/2/11, Antti J Ylikoski wrote: > > I'm in the process of learning Python. I already can code > objet-oriented programs with the language. I have in my hands the > O'Reilly book by Mark Lutz, Programming Python, in two versions: the > 2nd Edition, which covers Python 2, and the 4th edition,

Re: order independent hash?

2011-12-04 Thread Dan Stromberg
Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed 2) If you need your hash more often, you could keep your elements in a treap or red-black tree; these will maintain sortedness through

Re: order independent hash?

2011-12-05 Thread Dan Stromberg
On 12/5/11, 8 Dihedral wrote: > On Monday, December 5, 2011 1:50:08 PM UTC+8, Dan Stromberg wrote: >> Two methods: >> 1) If you need your hash only once in an infrequent while, then save >> the elements in a list, appending as needed, and sort prior to >> hashing

Re: Hints for writing bit-twiddling code in Python

2011-12-06 Thread Dan Stromberg
On 12/6/11, Steven D'Aprano wrote: > I have some bit-twiddling code written in Java which I am trying to port > to Python.: > > long newSeed = (seed & 0xL) * 0x41A7L; > while (newSeed >= 0x8000L) { > newSeed = (newSeed & 0x7FFFL) + (newSeed >>> 31L); > } > seed = (newSeed =

Re: Multiprocessing: killing children when parent dies

2011-12-07 Thread Dan Stromberg
On 12/7/11, Mihai Badoiu wrote: > ok, so the code is something like > #process A > p = Process(...) > p.daemon = 1 > p.start() # starts process B > ... > > If process A dies (say error, or ctrl-c), or finishes, then process B also > dies. But if process A is killed with the "kill" command

How safe is this way of getting a default that allows None?

2011-12-25 Thread Dan Stromberg
How safe is this? I like the idea. #!/usr/bin/python UNSPECIFIED = object() def fn(x, y=UNSPECIFIED): if y is UNSPECIFIED: print x, 'default' else: print x, y fn(0, 1) fn(0, None) fn(0) -- http://mail.python.org/mailman/listinfo/python-list

Re: Py-dea: Streamline string literals now!

2011-12-28 Thread Dan Sommers
now I can have comments, again, too x = ''"hello"'' # now x contains two double-quote characters I'm sure that the implementation is trivial, and it's so much easier to write strings that contain quotes (not to mention how easy it is to read those strings back later). -- Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Dan Sommers
On Wed, 04 Jan 2012 13:37:24 +1100, Chris Angelico wrote: > And "import pickle" objectifies pickles ... Not quite: "import pickle" merely readies the machinery that objectifies pickles. In order to objectify a pickle, you have to call pickle.loads: >>> import pickle # get ready to objectify

Re: while True or while 1

2012-01-22 Thread Dan Sommers
quot;with" statement, though, these loops are slowly disappearing. -- Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-05 Thread Dan Stromberg
On Feb 5, 2013 6:00 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > Chris Angelico wrote: > > > Python is not an "excellent option". It's a bad fit for shell > > scripting, it just happens to be way better than a weak shell. Having > > grown up on command.com, I found OS/2'

Re: Is Python programming language?

2013-02-11 Thread Dan Stromberg
Sent from my android phone. On Feb 9, 2013 6:41 PM, "Terry Reedy" wrote: > > On 2/9/2013 6:53 PM, Michael Torrie wrote: >> >> On 02/09/2013 04:26 PM, Tim Roberts wrote: >>> >>> Most people would call bash a "scripting language", but it is also clearly >>> a programming language. It has syntax, va

Re: Python3 curses behavior

2013-02-11 Thread Dan Stromberg
Sent from my android phone. On Feb 10, 2013 2:09 PM, "Vlasov Vitaly" wrote: > > суббота, 9 февраля 2013 г., 23:22:47 UTC+4 пользователь Terry Reedy написал: > > On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: > > > -- > > > > Terry Jan Reedy > > Thank you. > > I tried everything in my test script. > win

Re: Performance of int/long in Python 3

2013-03-25 Thread Dan Stromberg
On Mon, Mar 25, 2013 at 4:35 PM, Cousin Stanley wrote: > > Chris Angelico wrote: > > > The Python 3 merge of int and long has effectively penalized > > small-number arithmetic by removing an optimization. > > > > The cost is clear. > > > I thought I heard that Python 3.x will use machin

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