Accessing Self Inside Decorator with parameters

2017-12-14 Thread Brian Herman
def preform_action(self): print("test") Is there any way to do this pythonically? -- Thanks, Brian Herman kompile.org <http://www.kompile.org> -- https://mail.python.org/mailman/listinfo/python-list

Re: How to properly override the default factory of defaultdict?

2016-02-18 Thread Herman
d = dictutil.DefaultDictWithEnhancedFactory(lambda k: k) self.assertEqual("apple", d['apple']) From: Ben Finney > > you are using the inheritance hierarchy but thwarting it by not using > ‘super’. Instead:: > > super().__init__(self, default_factory, *a, **kw) > > and:: > > super(

How to properly override the default factory of defaultdict?

2016-02-14 Thread Herman
I want to pass in the key to the default_factory of defaultdict and I found that defaultdict somehow can intercept my call to dict.__getitem__(self, key), so my class's __getitem__ have to catch a TypeError instead instead of KeyError. The following class is my code: class DefaultDictWithEnhancedF

Re: Automate deployment of Python application from multiple VCS repositories

2015-04-08 Thread Michael Herman
Hi Ben, I would start with Fabric. -> http://www.fabfile.org/. It's "low-level", but super straightforward. Here's a blog post on how to setup deployment -> https://realpython.com/blog/python/kickstarting-flask-on-ubuntu-setup-and-deployment/ On Tue, Apr 7, 2015 at 7:24 PM, Ben Finney wrote: >

Python Weekend Challenge - $$

2013-08-30 Thread Michael Herman
https://gist.github.com/mjhea0/6390724 Check it out!:) Have a great labor day weekend. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

2013-06-14 Thread Michael Herman
Hi there - Yes, as others have said, this is not an easy project. That said, it can be down. I'd use a combination of DataNitro, to connect with Excel, and Scrapy, to easily scrap and crawl the sites. I'm adept at both and would be happy to help you with this. Email me at mich...@mherman.org for h

Re: How to: Setuptools

2013-05-28 Thread Michael Herman
I have a great video on how to setup Easy_Install via setuptools as well as pip - http://www.youtube.com/watch?v=MIHYflJwyLk On Mon, May 27, 2013 at 6:32 PM, ray wrote: > > I would like to use easy_install, but can't figure out how to install it. > > I have 64-bit Python 2.7.5 on Windows 7. > > F

Re: learning python

2013-05-06 Thread Michael Herman
realpython.com - just launched On Sun, May 5, 2013 at 9:08 AM, leonardo selmi wrote: > hi guys > > i need to find a good book to learn python with exercises and solutions, any > suggestions? > > thanks! > > best regards > > leonardo > > -- > http://mail.python.org/mailman/listinfo/python-list > -

Re: help..

2013-05-02 Thread Michael Herman
the problem is in your code: http://screencast.com/t/haF1NY5RvpMv On Thu, May 2, 2013 at 7:30 AM, Robert Kern wrote: > > On 2013-05-02 15:20, leonardo wrote: >> >> on codecademy there is an interactive box where you type your code, it is a >> kind of exercise program to practice. but i don't u

Re: Python in web development

2013-03-03 Thread Michael Herman
If Python is your personal choice, then it's the *best* for you. If you are literally just going to be processing an HTML form, then CGI is your best bet. However, if you think this functionally will grow, then it's worth learning a web framework. I would go with a micro framework. bottle.py is a

Re: What am I doing wrong installing Python 2.7.3?

2013-02-21 Thread Michael Herman
I assume you have admin privileges on your computer, correct? On Thu, Feb 21, 2013 at 6:39 AM, Etherus wrote: > I have downloaded the windows installer for a 32 bit installation of > python 2.7.3 but it tells me that: > > The feature you are trying to use is on a network resource that is > unava

Re: pypi changelog api

2013-02-21 Thread Michael Herman
rs, > > Philipp > > > On 02/21/2013 02:52 PM, Michael Herman wrote: > > I'd love to see https://crate.io/ set up an API or at the very least an > RSS > > feed for tracking changes. I've emailed the author about this. I think if > > enough people do, an RSS

Re: pypi changelog api

2013-02-21 Thread Michael Herman
totally agree. if you just had a listener setup you could just have a simple trigger-action setup. On Thu, Feb 21, 2013 at 6:07 AM, Philipp Hagemeister wrote: > On 02/21/2013 02:58 PM, Michael Herman wrote: > > Oh - and I haven't tried this site, but you may be able to set somethi

Re: pypi changelog api

2013-02-21 Thread Michael Herman
Oh - and I haven't tried this site, but you may be able to set something up on there to email when the changelog is updated. http://www.changedetection.com/ On Thu, Feb 21, 2013 at 5:52 AM, Michael Herman wrote: > I'd love to see https://crate.io/ set up an API or at the very l

Re: pypi changelog api

2013-02-21 Thread Michael Herman
I'd love to see https://crate.io/ set up an API or at the very least an RSS feed for tracking changes. I've emailed the author about this. I think if enough people do, an RSS feed would be easy to setup. On Thu, Feb 21, 2013 at 5:33 AM, Philipp Hagemeister wrote: > Hi Gregg, > > to get a smaller

Re: Urllib's urlopen and urlretrieve

2013-02-21 Thread Michael Herman
Are you just trying to get the html? If so, you can use this code- *import urllib* * * *# fetch the and download a webpage, nameing it test.html* *urllib.urlretrieve("http://www.web2py.com/";, filename="test.html")* I recommend using the requests library, as it's easier to use and more powerful:

Re: Python scheduler

2013-02-20 Thread Michael Herman
You could simply put a time delay in your program at the end of the loop before it starts again- import time # sleep for 1 minute time.sleep(60) On Wed, Feb 20, 2013 at 8:04 PM, Rita wrote: > Hello, > > > Here is what I am trying to do. (Currently, I am doing this in cron but i > need much more

Re: Import Question

2013-02-20 Thread Michael Herman
you can check each import as it varies in loading time: time python -c "import [name of module]" example: time python -c "import flask" On Wed, Feb 20, 2013 at 12:53 PM, eli m wrote: > How long does it take for the program to import something? I am asking > this because i have like 7 imports at

Re: Import Json web data source to xls or csv

2013-02-20 Thread Michael Herman
Looks like you got it figured out. The indentation error probably occurred from the copy and paste job into the email. If you're interested in getting up to speed quickly on Python and Python Web Development, I have a kickstarter going - http://kck.st/VQj8hq The $25 pledge will give you access to

Re: Crate is a new kind of Python package index

2013-02-20 Thread Michael Herman
It's really just a supplement to PyPI. I use it quite a bit. I wish they would collaborate with PyPi or have an open API. http://www.saltycrane.com/blog/2012/10/how-use-pip-crateio/ On Wed, Feb 20, 2013 at 6:12 AM, Mark Lawrence wrote: > > Today was the first I've heard about it, can anyone shed

Re: Import Json web data source to xls or csv

2013-02-19 Thread Michael Herman
First - you can use Python in Excel. http://www.python-excel.org/ or https://www.datanitro.com/ Updated code: import json import urllib import csv url = "http://bitcoincharts.com/t/markets.json"; response = urllib.urlopen(url); data = json.loads(response.read()) f = open("bitcoin.csv","wb") c =

Re: Quick IDE Question

2013-02-17 Thread Michael Herman
Yup - check out this post - http://www.chris-granger.com/2012/05/21/the-future-is-specific/ There's a Flask example On Sun, Feb 17, 2013 at 4:56 PM, Andrew Berg wrote: > On 2013.02.17 18:38, Claira wrote: > > Ok, thanks brilliant people! I can't really keep up with the > > conversation about whe

Re: request of information

2013-02-17 Thread Michael Herman
There's a syntax error at line 1 of circle.py. Try running circle.py, you'll get more information about the error - http://docs.python.org/2/tutorial/errors.html If you can't figure it out, post your code for circle.py. On Sun, Feb 17, 2013 at 10:47 AM, leonardo selmi wrote: > > > > > > > > > >

Re: python on windows

2013-02-16 Thread Michael Herman
http://www.youtube.com/watch?v=dFnuK9dlWdk On Sat, Feb 16, 2013 at 1:40 PM, babatunde akerele wrote: > hello, i'm having problem coding and running python on my pc...i just > started learning python last month in codeacademy.com but i've not > been able to code offline 'cos i don't knw how to go

Re: How to use "while" within the command in -c option of python?

2012-10-12 Thread Herman
I was just trying to do in a shell to quickly monitor a file. Imagine instead of printing hello, it is "os.system("cat somefile")", etc. Look like it works if i press an enter after the "import xxx". Thanks. On Fri, Oct 12, 2012 at 5:29 PM, Dave Angel wrote: &g

How to use "while" within the command in -c option of python?

2012-10-12 Thread Herman
python -c "import os; while True: print('hello')" File "", line 1 import os; while True: print('hello') ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list

Re: How to break long method name into more than one line?

2012-03-14 Thread Herman
I followed the rule because it was a very good advice. For example, def test_plus_1Plus1_2(self): If this test fails, you immediately know that it's testing the "plus" method, with 1 and 1 as the arguments, and expect to return 2. Sticking this rule also means your test cases are small enough, so

How to break long method name into more than one line?

2012-03-11 Thread Herman
I am trying to stick to the rule described in the TDD book that, each test method name consists of the method name to be tested, inputs and the expected outputs. It takes up a lot of space and my company has a rule of limiting 79 characters (or 80) per line. I found that def abcdeef\ dddaaa(self):

logging with logging.config.fileConfig

2012-02-19 Thread Herman
I tried to use file to config my logger and I got a weird situation that each message is outputted twice... Here is my scenario: python: 2.6 file abc_logging.conf: [loggers] keys=root,abc [handlers] keys=consoleHandler [formatters] keys=detailFormatter [logger_root] level=DEBUG handlers=consol

What is the difference between "new Class()" and "Class()"?

2011-11-20 Thread Herman
What is so special about the "new" operator? -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading/Writing files

2011-03-18 Thread Jon Herman
Wow, Jack, that is one awesome and simple module...thank you so much! I am happily storing and accessing all the arrays I could ever want :) Thanks to all for the quick assistance! On Fri, Mar 18, 2011 at 4:24 PM, Jack Trades wrote: > > On Fri, Mar 18, 2011 at 5:21 PM, Jon Herman

Re: Reading/Writing files

2011-03-18 Thread Jon Herman
on windows, and doesn't require escaping ("/foo/bar"). > > On Fri, Mar 18, 2011 at 2:56 PM, Jon Herman wrote: > >> Jack, >> >> thanks. >> >> Alright, so what I did is create a file called hello.txt with a single >> line of text in ther

Re: Reading/Writing files

2011-03-18 Thread Jon Herman
t the following error: IOError: [Errno 13] Permission denied: 'f' If I open to read, I get: IOError: [Errno 2] No such file or directory: 'f' Can anyone explain to me why this happens? On Fri, Mar 18, 2011 at 3:50 PM, Jack Trades wrote: > > On Fri, Mar 18, 2011 at 4:33

Reading/Writing files

2011-03-18 Thread Jon Herman
Hello all, I am pretty new to Python and am trying to write data to a file. However, I seem to be misunderstanding how to do so. For starters, I'm not even sure where Python is looking for these files or storing them. The directories I have added to my PYTHONPATH variable (where I import modules f

Re: Numerical representation

2011-03-08 Thread Jon Herman
ize for asking your time for such a beginner's oversight...I'll be fluent in Python some day ;-) On Mon, Mar 7, 2011 at 5:34 PM, Robert Kern wrote: > On 3/7/11 2:52 PM, Jon Herman wrote: > >> It really is exactly the same process, but sure. Below is my Matlab >> translat

Re: Numerical representation

2011-03-07 Thread Jon Herman
Thanks Terry! Of course, speed is not my main concern at this point and I'm more worried about precision...would you have some input on this discussion? :) Jon On Mon, Mar 7, 2011 at 2:35 PM, Terry Reedy wrote: > On 3/7/2011 1:59 PM, Jon Herman wrote: > >> And for the sak

Re: Numerical representation

2011-03-07 Thread Jon Herman
x=xwrk + dt * Xtemp2; t=twrk+dt; On Mon, Mar 7, 2011 at 1:50 PM, Chris Rebert wrote: > >>> On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman > wrote: > >>>> > >>>> I am new to the Python language and writing a Runge-Kutta-Fellberg > 7(8) &

Re: Numerical representation

2011-03-07 Thread Jon Herman
59 AM, Jon Herman wrote: > And for the sake of completeness, the derivative function I am calling from > my integrator (this is the 3 body problem in astrodynamics): > > def F(mu, X, ti): > > r1= pow((pow(X[0]+mu,2)+pow(X[1],2)+pow(X[2],2)),0.5) > r2= pow((pow(X[0]

Re: Numerical representation

2011-03-07 Thread Jon Herman
-mu)*(X[0]+mu)/r1**3-mu*(X[0]-(1-mu))/r2**3 Ay= X[1]-2*X[3]-(1-mu)*X[1]/r1**3-mu*X[1]/r2**3 Az= -(1-mu)*X[2]/r1**3-mu*X[2]/r2**3 XDelta=array([X[3], X[4], X[5], Ax, Ay, Az]) return XDelta On Mon, Mar 7, 2011 at 11:50 AM, Jon Herman wrote: > Sorry Robert, I'd missed y

Numerical representation

2011-03-07 Thread Jon Herman
Sorry Robert, I'd missed your post when I just made my last one. The output I am getting in Python looks as follows: array([ 9.91565050e-01, 1.55680112e-05, -1.53258602e-05, -5.75847623e-05, -9.64290960e-03, -8.26333458e-08]) This is the final state vector, consisting of 6 states (p

Re: Numerical representation

2011-03-07 Thread Jon Herman
mp2+c[l]*k[:,l] X=Xold + dt * Xtemp2 t=told+dt Xstore=vstack((Xstore,X)) tstore=vstack((tstore,t)) if abs(tf-t)< 1e-14: print('At tf') break On Fri, Mar 4, 2011 at 6:46 PM, Jon Herman wrote: > Actually,

Re: Numerical representation

2011-03-04 Thread Jon Herman
2011 at 4:49 PM, Santoso Wijaya wrote: > Have you taken a look at numpy? [1] It was written for exactly this kind of > usage. > > ~/santa > > [1] http://numpy.scipy.org/ > > > On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman wrote: > >> Hello all, >> >>

Numerical representation

2011-03-04 Thread Jon Herman
Hello all, I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) integrator in Python, which requires an extreme numerical precision for my particular application. Unfortunately, I can not seem to attain it. The interesting part is if I take my exact code and translate it to Matl

Re: Where is the correct round() method? Use math.ceil

2008-07-27 Thread Herman
> > Where is the correct round() method? > Hello, > > I need a round function that _always_ rounds to the higher integer if > the argument is equidistant between two integers. In Python 3.0, this > is not the advertised behavior of the built-in function round() as > seen below: > > >>> round(0.5) >

install py2exe in vista

2008-06-21 Thread Herman
I want to install it in vista, but i get this message in the process: could not create... py2exe-py2.5 I press 'OK', then.. could not set key value python 2.5 py2exe-0.6.8 I press 'OK' again, then... could not set key value c:\Python25\Removepy2e

how can I find out the process ids with a process name

2007-09-02 Thread herman
Hi, I would like to find out all the process id with the process name 'emacs'. In the shell, i can do this: $ ps -ef |grep emacs root 20731 8690 0 12:37 pts/200:00:09 emacs-snapshot-gtk root 25649 25357 0 13:55 pts/900:00:05 emacs-snapshot-gtk rtp.c root 26319 23926 0 14:06 pts

How can I wait for all the threads I spawn for 5 minutes

2007-08-31 Thread herman
Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = [] for j in range(5): t = MyThread() threads.append(t) for t in threads:

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > En Mon, 21 May 2007 07:39:09 -0300, Unknown <[EMAIL PROTECTED]> > escribió: > >> "Ant" <[EMAIL PROTECTED]> schreef in bericht >> news:[EMAIL PROTECTED

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Ant" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > Herman has shown you *how* to do static methods in Python, but > typically they are not used. Since Python has first class functions, > and they can be defined at the module level, there is no nee

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Daniel Gee" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > class Foo: > def statAdd(self,a): >return a+5 > > or do you drop the 'self' bit and just use a 1 variable parameter list? class Foo: @staticmethod def statAdd

Re: how to print without blank?

2006-04-08 Thread Ivan Herman
Ju Hui wrote: > I want to print 3 numbers without blank. for x in range(3): > ... print x > ... > 0 > 1 > 2 for x in range(3): > ... print x, > ... > 0 1 2 > > how to print > 012 > ? > > thanks. > You may want to use the write command with stdout: sys.stdout.write("%s

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Ivan Herman
I would certainly look at *all details* of the announcement, including the second line from the top which gives the date:-) Ivan Caleb Hattingh wrote: > WAIT- > > Did I just get caught by an April Fools Joke? > > I have a nasty feeling about this :)) > > C > -- http://mail.python.org/mailma

Re: PyXML: SAX vs. DOM

2006-01-21 Thread Ivan Herman
Original Message From: Matthias Kaeppler <[EMAIL PROTECTED]> To: Subject: Re:PyXML: SAX vs. DOM Date: 20/1/2006 21:26 > Oh and: > Where can I find an API reference for PyXML? Am I supposed to /guess/ > which methods and attributes e.g. Sax2 supplies? :D > > Thanks again, > Matth

Re: suppress pyc generation

2005-12-25 Thread Ivan Herman
There is a simple, though slightly ugly trick: if the directory where the python module resides, is not writable to the python process, the python runtime will silently ignore .pyc generation (as far as I know). It is not elegant, but it works... Ivan Original Message From: "Edd

Re: suppress pyc generation

2005-12-25 Thread Ivan Herman
There is a simple, though slightly ugly trick: if the directory where the python module resides, is not writable to the python process, the python runtime will silently ignore .pyc generation (as far as I know). It is not elegant, but it works... Ivan Original Message From: "Edd

Re: Using XML w/ Python...

2005-12-11 Thread Ivan Herman
Look at the standard python library reference http://docs.python.org/lib/dom-example.html the handleSlide function almost does what you want, except that you should use 'parse' and not 'parseString'. Original Message From: "Jay" <[EMAIL PROTECTED]> To: Subject: Re:Using XML w

Re: Python CGI Script

2005-10-02 Thread Ivan Herman
Efrat, I am afraid a CGI script is never *executed* by the browser. Instead, it sends the URL to a server, expects the server to execute the script, and display the server's response. If you just put a file name then (it seems, I never even tried that) Firefox uses the local file store as a 'serve

PIL question: keeping metadata

2005-06-29 Thread Ivan Herman
A question on using the PIL library. If I take a jpg file then, say, resize it and save it somewhere else, all metadata that is part of the jpg file is lost. This is a pity: digital cameras routinely add metainformation, so does, for example, Photoshop. Is there any way of keeping this info in P