Re: Homework help requested (not what you think!)
You have to utilize a set curriculum to teach. Look at several books like Dive Into Python, and such, then work with the student on an individualized project for each one. For 3D you go with pygame and trig, or go with Blender's python API or matplotlib. Just at first show the basic types of data, that is what I'd suggest, like mutable immutable, lists tuples, and dictionaries to get the hang of data containment that will probably move on to database management, and loopiing/iterating through data, or updating a GUI. Further teaching is moving on to what the student is trying to accomplish. HTH On Tue, Jul 16, 2013 at 6:43 PM, John Ladasky wrote: > Hi folks, > > No, I'm not asking for YOU to help ME with a Python homework assignment! > > Previously, I mentioned that I was starting to teach my son Python. > > https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ > > He just took a course at his high school called Web Technology and Design. > They had the students use tools like Dream Weaver, but they also > hand-coded some HTML and JavaScript. He has a little experience. I am > building on it. > > Well, a few other parents caught wind of what I was doing with my son, and > they asked me whether I could tutor their kids, too. I accepted the jobs > (for pay, actually). > > The kids all claim to be interested. They all want to write the next > great 3D video game. Thus, I'm a little surprised that the kids don't > actually try to sit down and code without me prompting them. I think that > they're disappointed when I show them how much they have to understand just > to write a program that plays Tic Tac Toe. > > Where programming is concerned, I'm an autodidact. I started programming > when I was twelve, with little more guidance than the Applesoft Basic > manual and the occasional issue of Byte Magazine. I hacked away. Over the > years, I have acquired a working knowledge of BASIC, 6502 assembly > language, Pascal, C, and finally Python (my favorite). If I knew how to > impart a love of experimentation to my students, I would do that. > > One kid looks like he's ready to forge ahead. In the mean time, one > parent has recognized his son's lack of independence, and has asked me to > assign programming homework. I hope it doesn't kill the kid's enthusiasm, > but I'm willing to try it. > > So, what I am seeking are suggestions for programming assignments that I > can give to brand-new students of Python. Please keep in mind that none of > them are even up to the task of a simple algorithm like Bubble Sort -- at > least, not yet. > > Many thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding other people's code
Any program, to me, is just like speaking english. The class, or function name might not fully mesh with what your cognitive structure assumes it to be.read through the imports first, and see the classes and functions come alive with experience comes intuition of what it does, and the instances that can be utilized with it. The term RTFM, and google always comes to mind as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
I've had a similar problem with a tkinter/3D app. right now I'm looking
toward Blender, and the Python API, but there is also wxpython, and the
usual python's library gtk.
There is also matplotlib with the ion window. but, I, personally, am going
to go with Blender, and Python API, with maybe a few other imports, and if
ctypes...includes if I remember C correctly without reference at this time
the usages of returned data type values
for you to utilize.
But for the plainer answer I'd go with wxpython if you decide not to use a
different library, and for a GDK, Blend
On Tue, Jul 16, 2013 at 8:57 PM, wrote:
> Hm. So I've written a GUI in tkinter. I've found two performance issues, I
> was hoping someone could point me in the right direction.
>
> Firstly, I'm using an image as a border, namely:
>
> from tkinter import *
> from tkinter import ttk
>
> root_frame = Tk()
> root_frame.configure(background = 'black')
>
> img1 = PhotoImage("frameBorder", data="""
>R0lGODlhQABAAMIHABkfLTMrMzMrZjNVZjNVmUFchywAQABD9A
>i63P4wykmrvTjrzbu/hlGMZGmeaBp2QmgIQSzPdG3fbShk+u3/wFkONAgaj7aBoWIo
>Ip9P5aQFrSJfkpd1C2xluWDfEhIKm2mrh/bM9qrZ8MDYYYiz54263Yxn6PdgfQt/gF
>uCCoSFVYcAiYpPjI6PR5GTVpWWUJiZV2SckJ6flKGiQZulP6eoN6qrNa2uM7CxMbO0
>trG4rrqrvKi+pcCiwp/EnMaZyJbKk8yPzorQhdKA1HuRMLQ0bnSSuYyN2mhZ2eLcD1
>
> TicjtZ3sPgfu7J8A0EBOWfQxg5a4/87BtcCBxIsKDBgh8SKlzIsKHDhxAVJgAAOw==""")
>
> style = ttk.Style()
> style.element_create("RoundedFrame", "image", "frameBorder",
> border=30, sticky="nsew")
> style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])
>
> input_frame = ttk.Frame(root_frame,
> style = "RoundedFrame",
> padding = 15,
> width = 640,
> height = 180
> )
> input_frame.pack(padx=10, pady=10)
>
> This works, yes, but is annoyingly laggy on an older computer when I try
> to move the window around. I figure it's because the program has to keep
> redrawing the image border when dragged around, and is exacerbated by the
> fact that I have two of the imageborder frames in my application. How can I
> remedy this? I've tried using a hard-drawn image on a Canvas instead of the
> image border, but it's suboptimal because that prevents resizing the window.
>
>
> The other performance issue I've found is that when the logic is running,
> the app doesn't redraw. Ordinarily this would be acceptable, but as part of
> my program, it loads data from a website, and during the load, the window
> completely freezes up and doesn't respond until the download is done; as I
> understand it, tkinter doesn't redraw until it is forced to by .update() or
> control is given back to the mainloop. How can I force a more frequent
> redraw rate?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Tue, Jul 16, 2013 at 9:32 PM, David Hutto wrote:
> I've had a similar problem with a tkinter/3D app. right now I'm looking
> toward Blender, and the Python API, but there is also wxpython, and the
> usual python's library gtk.
>
> There is also matplotlib with the ion window. but, I, personally, am going
> to go with Blender, and Python API, with maybe a few other imports, and if
> ctypes...includes if I remember C correctly without reference at this time
> the usages of returned data type values
> for you to utilize.
>
>
> But for the plainer answer I'd go with wxpython if you decide not to use a
> different library, and for a GDK, Blend
>
>
> On Tue, Jul 16, 2013 at 8:57 PM, wrote:
>
>> Hm. So I've written a GUI in tkinter. I've found two performance issues,
>> I was hoping someone could point me in the right direction.
>>
>> Firstly, I'm using an image as a border, namely:
>>
>> from tkinter import *
>> from tkinter import ttk
>>
>> root_frame = Tk()
>> root_frame.configure(background = 'black')
>>
>> img1 = PhotoImage("frameBorder", data="""
>>R0lGODlhQABAAMIHABkfLTMrMzMrZjNVZjNVmUFchywAQABD9A
>>i63P4wykmrvTjrzbu/hlGMZGmeaBp2QmgIQSzPdG3fbShk+u3/wFkONAgaj7aBoWIo
>>Ip9P5aQFrSJfkpd1C2xluWDfEhIKm2mrh/bM9qrZ8MDYYYiz54263Yxn6PdgfQt/gF
>>uCCoSFVYcAiYpPjI6PR5GTVpWWUJiZV2SckJ6flKGiQZulP6eoN6qrNa2uM7CxMbO0
>>trG4rrqrvKi+pcCiwp/EnMaZyJbKk8yPzorQhdKA1HuRMLQ0bnSSuYyN2mhZ2eLcD1
>>
>> TicjtZ3sPgfu7J8A0EBOWfQxg5a4/87BtcCBxIsKDBgh8SKlzIsKHDhxAVJgAAOw==""")
>>
>> style = ttk.Style()
>> style.element_create("RoundedFrame", "image", "frameBorder",
>> border=30, sticky="nsew")
>> style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])
>>
>> input_frame = ttk.Frame(root_frame,
>> style = "RoundedFrame",
>> padding = 15,
>> width = 640,
>> height = 180
>> )
>> input_frame.pack(padx=10, pady=10)
>>
>> This works, yes, but is annoyingly laggy on an older computer when I try
>> to move the window around. I figure it's because the program has to keep
>> redrawing the image border when dragged around, and is exacerbated by the
>> fact that I have two of the imageborder frames in my application. How can I
>> remedy this? I've tried using a hard-drawn image on a Canvas instead of the
>> image border, but it's suboptimal because that prevents resizing the window.
>>
>>
>> The other performance issue I've found is that when the logic is running,
>> the app doesn't redraw. Ordinarily this would be acceptable, but as part of
>> my program, it loads data from a website, and during the load, the window
>> completely freezes up and doesn't respond until the download is done; as I
>> understand it, tkinter doesn't redraw until it is forced to by .update() or
>> control is given back to the mainloop. How can I force a more frequent
>> redraw rate?
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> I've had a similar problem with a tkinter/3D app. right now I'm looking
> toward Blender, and the Python API, but there is also wxpython, and the
> usual python's library gtk.
>
> There is also matplotlib with the ion window. but, I, personally, am going
> to go with Blender, and Python API, with maybe a few other imports, and if
> ctypes...includes if I remember C correctly without reference at this time
> the usages of returned data type values
> for you to utilize.
>
>
> But for the plainer answer I'd go with wxpython if you decide not to use a
> different library, and for a GDK, Blender.
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Understanding other people's code
I forgot to mention idle. It can step through another's code and show you a step-by-step insructional, of what the code does. On Tue, Jul 16, 2013 at 8:05 PM, David Hutto wrote: > Any program, to me, is just like speaking english. The class, or function > name might not fully mesh with what your cognitive structure assumes it to > be.read through the imports first, and see the classes and functions come > alive with experience comes intuition of what it does, and the instances > that can be utilized with it. The term RTFM, and google always comes to > mind as well. > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
Just use an explanatory user tip that states it should be case sensitive, just like with most sites, or apps. On Fri, Jul 19, 2013 at 9:13 PM, Chris Angelico wrote: > On Sat, Jul 20, 2013 at 11:04 AM, Devyn Collier Johnson > wrote: > > > > On 07/19/2013 07:09 PM, Dave Angel wrote: > >> > >> On 07/19/2013 06:08 PM, Devyn Collier Johnson wrote: > >>> > >>> > >>> On 07/19/2013 01:59 PM, Steven D'Aprano wrote: > >> > >> > >> > >>> > >>> > >>> As for the case-insensitive if-statements, most code uses Latin > letters. > >>> Making a case-insensitive-international if-statement would be > >>> interesting. I can tackle that later. For now, I only wanted to take > >>> care of Latin letters. I hope to figure something out for all > characters. > >>> > >> > >> Once Steven gave you the answer, what's to figure out? You simply use > >> casefold() instead of lower(). The only constraint is it's 3.3 and > later, > >> so you can't use it for anything earlier. > >> > >> http://docs.python.org/3.3/library/stdtypes.html#str.casefold > >> > >> """ > >> str.casefold() > >> Return a casefolded copy of the string. Casefolded strings may be used > for > >> caseless matching. > >> > >> Casefolding is similar to lowercasing but more aggressive because it is > >> intended to remove all case distinctions in a string. For example, the > >> German lowercase letter 'ß' is equivalent to "ss". Since it is already > >> lowercase, lower() would do nothing to 'ß'; casefold() converts it to > "ss". > >> > >> The casefolding algorithm is described in section 3.13 of the Unicode > >> Standard. > >> > >> New in version 3.3. > >> """ > >> > > Chris Angelico said that casefold is not perfect. In the future, I want > to > > make the perfect international-case-insensitive if-statement. For now, my > > code only supports a limited range of characters. Even with casefold, I > will > > have some issues as Chris Angelico mentioned. Also, "ß" is not really the > > same as "ss". > > Well, casefold is about as good as it's ever going to be, but that's > because "the perfect international-case-insensitive comparison" is a > fundamentally impossible goal. Your last sentence hints as to why; > there is no simple way to compare strings containing those characters, > because the correct treatment varies according to context. > > Your two best options are: Be case sensitive (and then you need only > worry about composition and combining characters and all those > nightmares - the ones you have to worry about either way), or use > casefold(). Of those, I prefer the first, because it's safer; the > second is also a good option. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
Just use an explanatory user tip that states it should be case sensitive, just like with most sites, or apps. On Fri, Jul 19, 2013 at 10:21 AM, Joel Goldstick wrote: > > > > On Fri, Jul 19, 2013 at 9:51 AM, Devyn Collier Johnson < > [email protected]> wrote: > >> Aloha Python Users! >> >> I have some coding tips and interesting functions that I want to share >> with all of you. I want to give other programmers ideas and inspiration. It >> is all Python3; most of it should work in Python2. I am a Unix/Linux >> person, so some of these will only work on Unix systems. Sorry Microsuck >> users :-D ;-) >> >> All of the below Python3 code came from Neobot v0.8dev. I host an >> artificial intelligence program on Launchpad (LP Username: >> devyncjohnson-d). I have not released my Python version yet. The current >> version of Neobot (v0.7a) is written in BASH and Python3. >> >> To emulate the Linux shell's date command, use this Python >> >> function def DATE(): print(time.strftime("%a %B %d %H:%M:%S %Z %Y")) >> >> Want an easy way to clear the terminal screen? Then try this: >> >> def clr(): os.system(['clear','cls'][os.**name <http://os.name> == 'nt']) >> >> Here are two Linux-only functions: >> >> def GETRAM(): print(linecache.getline('/**proc/meminfo', >> 1).replace('MemTotal:', '').strip()) #Get Total RAM in kilobytes# >> def KDE_VERSION(): print(subprocess.getoutput('**kded4 --version | awk >> -F: \'NR == 2 {print $2}\'').strip()) ##Get KDE version## >> >> Need a case-insensitive if-statement? Check this out: >> >> if 'YOUR_STRING'.lower() in SOMEVAR.lower(): >> >> Have a Python XML browser and want to add awesome tags? This code would >> see if the code to be parsed contains chess tags. If so, then they are >> replaced with chess symbols. I know, many people hate trolls, but trolls >> are my best friends. Try this: >> >> if '> re.sub('', '♔', PTRNPRS, flags=re.I); DATA = >> re.sub('', '♕', DATA, flags=re.I); DATA = >> re.sub(''**, '♖', DATA, flags=re.I); DATA = >> re.sub(''**, '♗', DATA, flags=re.I); DATA = >> re.sub(''**, '♘', DATA, flags=re.I); DATA = >> re.sub('', '♙', DATA, flags=re.I); DATA = >> re.sub('', '♚', DATA, flags=re.I); DATA = >> re.sub('', '♛', DATA, flags=re.I); DATA = >> re.sub(''**, '♜', DATA, flags=re.I); DATA = >> re.sub(''**, '♝', DATA, flags=re.I); DATA = >> re.sub(''**, '♞', DATA, flags=re.I); PTRNPRS = >> re.sub('', '♟', DATA, flags=re.I) >> >> For those of you making scripts to be run in a terminal, try this for a >> fancy terminal prompt: >> >> INPUTTEMP = input('User ≻≻≻') >> >> >> I may share more code later. Tell me what you think of my coding style >> and tips. >> >> >> Mahalo, >> >> Devyn Collier Johnson >> [email protected] >> -- >> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> >> > > I'm guessing you may be posting with html. So all your code runs together. > > -- > Joel Goldstick > http://joelgoldstick.com > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
And also don't forget special char, or that it can bbe var char, or char in the DB lookup in boolean with the username. On Fri, Jul 19, 2013 at 11:43 PM, David Hutto wrote: > Just use an explanatory user tip that states it should be case sensitive, > just like with most sites, or apps. > > > On Fri, Jul 19, 2013 at 10:21 AM, Joel Goldstick > wrote: > >> >> >> >> On Fri, Jul 19, 2013 at 9:51 AM, Devyn Collier Johnson < >> [email protected]> wrote: >> >>> Aloha Python Users! >>> >>> I have some coding tips and interesting functions that I want to share >>> with all of you. I want to give other programmers ideas and inspiration. It >>> is all Python3; most of it should work in Python2. I am a Unix/Linux >>> person, so some of these will only work on Unix systems. Sorry Microsuck >>> users :-D ;-) >>> >>> All of the below Python3 code came from Neobot v0.8dev. I host an >>> artificial intelligence program on Launchpad (LP Username: >>> devyncjohnson-d). I have not released my Python version yet. The current >>> version of Neobot (v0.7a) is written in BASH and Python3. >>> >>> To emulate the Linux shell's date command, use this Python >>> >>> function def DATE(): print(time.strftime("%a %B %d %H:%M:%S %Z %Y")) >>> >>> Want an easy way to clear the terminal screen? Then try this: >>> >>> def clr(): os.system(['clear','cls'][os.**name <http://os.name> == >>> 'nt']) >>> >>> Here are two Linux-only functions: >>> >>> def GETRAM(): print(linecache.getline('/**proc/meminfo', >>> 1).replace('MemTotal:', '').strip()) #Get Total RAM in kilobytes# >>> def KDE_VERSION(): print(subprocess.getoutput('**kded4 --version | awk >>> -F: \'NR == 2 {print $2}\'').strip()) ##Get KDE version## >>> >>> Need a case-insensitive if-statement? Check this out: >>> >>> if 'YOUR_STRING'.lower() in SOMEVAR.lower(): >>> >>> Have a Python XML browser and want to add awesome tags? This code would >>> see if the code to be parsed contains chess tags. If so, then they are >>> replaced with chess symbols. I know, many people hate trolls, but trolls >>> are my best friends. Try this: >>> >>> if '>> re.sub('', '♔', PTRNPRS, flags=re.I); DATA = >>> re.sub('', '♕', DATA, flags=re.I); DATA = >>> re.sub(''**, '♖', DATA, flags=re.I); DATA = >>> re.sub(''**, '♗', DATA, flags=re.I); DATA = >>> re.sub(''**, '♘', DATA, flags=re.I); DATA = >>> re.sub('', '♙', DATA, flags=re.I); DATA = >>> re.sub('', '♚', DATA, flags=re.I); DATA = >>> re.sub('', '♛', DATA, flags=re.I); DATA = >>> re.sub(''**, '♜', DATA, flags=re.I); DATA = >>> re.sub(''**, '♝', DATA, flags=re.I); DATA = >>> re.sub(''**, '♞', DATA, flags=re.I); PTRNPRS = >>> re.sub('', '♟', DATA, flags=re.I) >>> >>> For those of you making scripts to be run in a terminal, try this for a >>> fancy terminal prompt: >>> >>> INPUTTEMP = input('User ≻≻≻') >>> >>> >>> I may share more code later. Tell me what you think of my coding style >>> and tips. >>> >>> >>> Mahalo, >>> >>> Devyn Collier Johnson >>> [email protected] >>> -- >>> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> >>> >> >> I'm guessing you may be posting with html. So all your code runs >> together. >> >> -- >> Joel Goldstick >> http://joelgoldstick.com >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
It seems, without utilizing this, or googling, that a case sensitive library is either developed, or could be implemented by utilizing case sensitive translation through a google translation page using an urlopener, and placing in the data to be processed back to the boolean value. Never attempted, but the algorithm seems simpler than the dozens of solutions method. -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
It seems that you could use import re, in my mind's pseudo code, to compile a translational usage of usernames/passwords that could remain case sensitive by using just the translational dictionaries, and refining with data input tests/unit tests. On Sat, Jul 20, 2013 at 12:15 AM, David Hutto wrote: > It seems, without utilizing this, or googling, that a case sensitive > library is either developed, or could be implemented by utilizing case > sensitive translation through a google translation page using an urlopener, > and placing in the data to be processed back to the boolean value. Never > attempted, but the algorithm seems simpler than the dozens of solutions > method. > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
I didn't see that this was for a chess game. That seems more point and click. Everyone can recognize a bishop from a queen, or a rook from a pawn. So why would case sensitivity matter other than the 16 pieces on the board? Or am I misunderstanding the question? On Sat, Jul 20, 2013 at 12:22 AM, David Hutto wrote: > It seems that you could use import re, in my mind's pseudo code, to > compile a translational usage of usernames/passwords that could remain case > sensitive by using just the translational dictionaries, and refining with > data input tests/unit tests. > > > On Sat, Jul 20, 2013 at 12:15 AM, David Hutto wrote: > >> It seems, without utilizing this, or googling, that a case sensitive >> library is either developed, or could be implemented by utilizing case >> sensitive translation through a google translation page using an urlopener, >> and placing in the data to be processed back to the boolean value. Never >> attempted, but the algorithm seems simpler than the dozens of solutions >> method. >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code Tips
32 if you count black, and white. On Sat, Jul 20, 2013 at 12:26 AM, David Hutto wrote: > I didn't see that this was for a chess game. That seems more point and > click. Everyone can recognize a bishop from a queen, or a rook from a pawn. > So why would case sensitivity matter other than the 16 pieces on the board? > Or am I misunderstanding the question? > > > > On Sat, Jul 20, 2013 at 12:22 AM, David Hutto wrote: > >> It seems that you could use import re, in my mind's pseudo code, to >> compile a translational usage of usernames/passwords that could remain case >> sensitive by using just the translational dictionaries, and refining with >> data input tests/unit tests. >> >> >> On Sat, Jul 20, 2013 at 12:15 AM, David Hutto wrote: >> >>> It seems, without utilizing this, or googling, that a case sensitive >>> library is either developed, or could be implemented by utilizing case >>> sensitive translation through a google translation page using an urlopener, >>> and placing in the data to be processed back to the boolean value. Never >>> attempted, but the algorithm seems simpler than the dozens of solutions >>> method. >>> >> >> >> >> -- >> Best Regards, >> David Hutto >> *CEO:* *http://www.hitwebdevelopment.com* >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
you could use , and I think its
david@david:~$ python
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call(['espeak', 'word_spoken'], stdin=None, stdout=None,
stderr=None, shell=False)
This is on ubuntu linux, using espeak.
this is on ubun
On Sat, Jul 20, 2013 at 12:21 AM, Stefan Behnel wrote:
> Devyn Collier Johnson, 20.07.2013 03:06:
> > I am making a chatbot that I host on Launchpad.net/neobot. I am currently
> > converting the engine from BASH code to Python3. I need to convert this
> for
> > cross-platform compatibility. I do not need to use Mplayer; I just show
> the
> > below code to give others a better idea what I am doing. I would prefer
> to
> > be Python3 independent; I do not want to use the system shell. I am fine
> > with using Python3 modules like Pygame (if there is a py3 module). As
> long
> > as the code is fast, efficient, and simple without depending on the
> system
> > shell or external apps, that would be nice. I also need the code to
> execute
> > while the rest of the script continues running.
> >
> > jobs = multiprocessing.Process(SEND = subprocess.getoutput('mplayer
> > -nogui -nolirc -noar -quiet ./conf/boot.ogg')) #Boot sound#
>
> Well, since you mentioned it already, have you actually looked at pygame?
> It should be able to do what you want. There's also pyaudio, which is more
> specialised to, well, audio. A web search for python and ogg might provide
> more.
>
> Stefan
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
This is using 3.2, which shouldn't be far off, the latest I could get on
ubuntu.
david@david:~$ python3.2
Python 3.2.3 (default, Apr 10 2013, 05:29:11)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call(['espeak', 'word_spoken'], stdin=None, stdout=None,
stderr=None, shell=False)
On Sat, Jul 20, 2013 at 12:39 AM, David Hutto wrote:
> you could use , and I think its
>
> david@david:~$ python
> Python 2.7.3 (default, Aug 1 2012, 05:16:07)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import subprocess
> >>> subprocess.call(['espeak', 'word_spoken'], stdin=None, stdout=None,
> stderr=None, shell=False)
>
>
>
> This is on ubuntu linux, using espeak.
> this is on ubun
>
>
> On Sat, Jul 20, 2013 at 12:21 AM, Stefan Behnel wrote:
>
>> Devyn Collier Johnson, 20.07.2013 03:06:
>> > I am making a chatbot that I host on Launchpad.net/neobot. I am
>> currently
>> > converting the engine from BASH code to Python3. I need to convert this
>> for
>> > cross-platform compatibility. I do not need to use Mplayer; I just show
>> the
>> > below code to give others a better idea what I am doing. I would prefer
>> to
>> > be Python3 independent; I do not want to use the system shell. I am fine
>> > with using Python3 modules like Pygame (if there is a py3 module). As
>> long
>> > as the code is fast, efficient, and simple without depending on the
>> system
>> > shell or external apps, that would be nice. I also need the code to
>> execute
>> > while the rest of the script continues running.
>> >
>> > jobs = multiprocessing.Process(SEND = subprocess.getoutput('mplayer
>> > -nogui -nolirc -noar -quiet ./conf/boot.ogg')) #Boot sound#
>>
>> Well, since you mentioned it already, have you actually looked at pygame?
>> It should be able to do what you want. There's also pyaudio, which is more
>> specialised to, well, audio. A web search for python and ogg might provide
>> more.
>>
>> Stefan
>>
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
> --
> Best Regards,
> David Hutto
> *CEO:* *http://www.hitwebdevelopment.com*
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
Just get a good dictionary, and distutils I believe, someone a little bit
more experienced in these should be along soon, or use the manual, and docs.
On Sat, Jul 20, 2013 at 12:52 AM, David Hutto wrote:
> This is using 3.2, which shouldn't be far off, the latest I could get on
> ubuntu.
>
> david@david:~$ python3.2
> Python 3.2.3 (default, Apr 10 2013, 05:29:11)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import subprocess
> >>> subprocess.call(['espeak', 'word_spoken'], stdin=None, stdout=None,
> stderr=None, shell=False)
>
>
> On Sat, Jul 20, 2013 at 12:39 AM, David Hutto wrote:
>
>> you could use , and I think its
>>
>> david@david:~$ python
>> Python 2.7.3 (default, Aug 1 2012, 05:16:07)
>> [GCC 4.6.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import subprocess
>> >>> subprocess.call(['espeak', 'word_spoken'], stdin=None, stdout=None,
>> stderr=None, shell=False)
>>
>>
>>
>> This is on ubuntu linux, using espeak.
>> this is on ubun
>>
>>
>> On Sat, Jul 20, 2013 at 12:21 AM, Stefan Behnel wrote:
>>
>>> Devyn Collier Johnson, 20.07.2013 03:06:
>>> > I am making a chatbot that I host on Launchpad.net/neobot. I am
>>> currently
>>> > converting the engine from BASH code to Python3. I need to convert
>>> this for
>>> > cross-platform compatibility. I do not need to use Mplayer; I just
>>> show the
>>> > below code to give others a better idea what I am doing. I would
>>> prefer to
>>> > be Python3 independent; I do not want to use the system shell. I am
>>> fine
>>> > with using Python3 modules like Pygame (if there is a py3 module). As
>>> long
>>> > as the code is fast, efficient, and simple without depending on the
>>> system
>>> > shell or external apps, that would be nice. I also need the code to
>>> execute
>>> > while the rest of the script continues running.
>>> >
>>> > jobs = multiprocessing.Process(SEND = subprocess.getoutput('mplayer
>>> > -nogui -nolirc -noar -quiet ./conf/boot.ogg')) #Boot sound#
>>>
>>> Well, since you mentioned it already, have you actually looked at pygame?
>>> It should be able to do what you want. There's also pyaudio, which is
>>> more
>>> specialised to, well, audio. A web search for python and ogg might
>>> provide
>>> more.
>>>
>>> Stefan
>>>
>>>
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>>
>> --
>> Best Regards,
>> David Hutto
>> *CEO:* *http://www.hitwebdevelopment.com*
>>
>
>
>
> --
> Best Regards,
> David Hutto
> *CEO:* *http://www.hitwebdevelopment.com*
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
It was supposed to show you that you can use a command line function from windows or linux that will play an ogg/.wav file/ etc with an if windows: do this or if linux do this. espeak was just a suggestion, unless you want your own voice played for the chatbot, or a selection of a male or female voice, and why ogg, why not wav? -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
With linux you can have your package listed in synaptic, and can use with a sudo apt-get install whatever ogg player like ogg123, and windows I don't work with that much, but I'm pretty sure I've played .wav files from the command line before while working with cross platform just for practice, so with python 3 you can use what's available in the system with an if command. -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
Yeah, its like yum used in others(or the point and click gui package installers). The main point kind of is in cross platform it would seem that you would just use what's available with try/except, or if statements, and the question is what os's is he going for. Then a simple usage of what's available in the command line for those os's. -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
Mainly I just use my apps for my own purposes. So it's usually on the debian/ubuntu distro I have, although I do have Windows XP SP3 in virtual box. I have been meaning to install some other linux distros in virtual box that are the main ones, percentage of utilization based, that are used, and practice more with the cross platform, but haven't had a chance to lately. -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
And just thinking about it,,, Devyn might want to install virtual box, and place in the os's he wants to target first, because there's usually always a glitch in 3rd party imports, This is especially true when using a newer version of python that the other developers of packages you can import from haven't had time to update them, as well as update for os's that might have changed, and everyone has a newer version. On Sun, Jul 21, 2013 at 2:42 AM, David Hutto wrote: > Mainly I just use my apps for my own purposes. So it's usually on the > debian/ubuntu distro I have, although I do have Windows XP SP3 in virtual > box. > > I have been meaning to install some other linux distros in virtual box > that are the main ones, percentage of utilization based, that are used, and > practice more with the cross platform, but haven't had a chance to lately. > > > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
Devyn, are you just trying to use this in an application? Would a browser
based web app work. I ask because there will still be some sort of DB
interaction, so could it be an option to go with a browser command?
On Mon, Jul 22, 2013 at 8:37 PM, alex23 wrote:
> On 20/07/2013 10:25 PM, Devyn Collier Johnson wrote:
>
>> I have not heard of Pyaudio; I will look into that. As
>> for Pygame, I have not been able to find any good documentation for
>> playing audio files. Plus, I recently learned that Pygame is not Python3
>> compatible.
>>
>
> Another option would be Pyglet, which uses the cross-platform binary AVBin
> to provide sound support. It may not provide as much control as PyAudio,
> but given your example usage it might be a bit more straightforward:
>
>pyglet.media.load('boot.ogg', streaming=False).play()
>
> http://www.pyglet.org/doc/**programming_guide/simple_**audio_playback.html<http://www.pyglet.org/doc/programming_guide/simple_audio_playback.html>
>
> The latest development release provides support for Python 3:
>
> https://code.google.com/p/**pyglet/downloads/list?q=1.**2alpha1<https://code.google.com/p/pyglet/downloads/list?q=1.2alpha1>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
There is the matter of how much time you want to put into this. There is the standard gtk library for python, and in the future, as soon as I'm well enough to focus, having recent problems, I'll be using the blender game engine to enhance my software to a 3d graphical form...to make my apps pop. So which tutorials are you willing to take time with, and which are benchmarked the best for your apps? For a 3d trig/quadrant cartesian 3d implementation for practice refresher, I used tkinter, and when using it was slow as hell. SO the question is, have you looked at the individual graphical tutorials for each, and decided on a look, a feel, and a time enhanced optimization yet? In other words, work a little bit with each to see which best fits your needs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner. 2d rotation gives unexpected results.
haven't used pygame that much, but it sounds like you drew Z. You have [0,0],[0,100],[100,0],[100, 100] 0,0 is the top left, if I recall 0, 100 would be the lower left, then you move to100, 0 which would go diagonal to the top right, and then 100,100 to the lower right, this is assuming 0,0 is the upper left. for a square you would go,[0,0],[0,100],[100,100],[100,0]then back to [0,0] to complete the square. This is assuming that 0,0 is the upper left, the coords are x,y in the brackets, and the increase in x takes you the right, and the increase in y takes you down. If that doesn't work,I'll download it later, and try it out. On Tue, Jul 23, 2013 at 8:34 AM, wrote: > Hello! > This is my first post, nice to meet you all! > I`m biology student from Russia, trying to learn python to perform some > > simple simulations. > > Here`s my first problem. > I`m trying to perform some simple 2d vector rotations in pygame, in order > > to learn the basics of linear algebra and 2d transformations. So far i > > understand matrix multiplication pretty well, and probably all my math is > > right. Eventually i`m planning to write Poly class, and use it to rotate > > and translate some simple shapes. But when i try and write it in the > > program, i get very weird results, like all points of rectangle with > > coordinates [0,0],[0,100],[100,0],[100,100] start to go spiral and > > eventually shrink to the center. Although even Excel calculations with > > this formulas give me right result. > I use Python 3.3 on Windows Xp. > What is wrong with my code? > > [code]import pygame > import math as m > > black = ( 0, 0, 0) > white = ( 255, 255, 255) > green = ( 0, 255, 0) > red = ( 255, 0, 0) > > class Poly(): > pos = [100,100] #x and y coordinates of a point > rot = m.radians(1) #rotation in degrees > def draw(self): #draw point > pygame.draw.circle(screen,white,self.pos,10,0) > def rotate(self): # rotation method > sin = m.sin(self.rot) #calculationg sin and cos > cos = m.cos(self.rot) > x_rot = int(self.pos[0]*cos-self.pos[1]*sin) #mulpitplicating > > vector to rotation matrix > y_rot = int(self.pos[0]*sin+self.pos[1]*cos) > > self.pos[0] = x_rot #set new coordinates to a point > self.pos[1] = y_rot > > a = Poly() #Some simple sample points giving rectangle > b = Poly() > c = Poly() > d = Poly() > > b.pos = [0,100] > c.pos = [100,0] > d.pos = [0,0] > > pygame.init() > size = [700,500] > screen = pygame.display.set_mode(size) > done = False > clock = pygame.time.Clock() > while done == False: > for event in pygame.event.get(): > if event.type == pygame.QUIT: > done = True > > a.rotate() #perform rotation > b.rotate() > c.rotate() > d.rotate() > > screen.fill(black) > > a.draw() #draw point > b.draw() > c.draw() > d.draw() > pygame.display.flip() > clock.tick(30) > > pygame.quit()[/code] > > P.S. Sorry for my english, bit rusty in that department. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
I've screwed up plenty of times in python, but can write code like a pro when I'm feeling better(on SSI and medicaid). An editor can be built simply, but it's preference that makes the difference. Some might have used tkinter, gtk. wxpython or other methods for the task. I think the main issue in responding is your library preference, or widget set preference. These can make you right with some in your response, or wrong with others that have a preferable gui library that coincides with one's personal cognitive structure that makes t On Wed, Jul 24, 2013 at 9:48 AM, Chris Angelico wrote: > On Wed, Jul 24, 2013 at 11:40 PM, wrote: > > Short example. Writing an editor with something like the > > FSR is simply impossible (properly). > > jmf, have you ever written an editor with *any* string representation? > Are you speaking from any level of experience at all? > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
I've screwed up plenty of times in python, but can write code like a pro when I'm feeling better(on SSI and medicaid). An editor can be built simply, but it's preference that makes the difference. Some might have used tkinter, gtk. wxpython or other methods for the task. I think the main issue in responding is your library preference, or widget set preference. These can make you right with some in your response, or wrong with others that have a preferable gui library that coincides with one's personal cognitive structure that makes it more usable in relation to how you learned a preferable gui kit. On Wed, Jul 24, 2013 at 10:17 AM, David Hutto wrote: > I've screwed up plenty of times in python, but can write code like a pro > when I'm feeling better(on SSI and medicaid). An editor can be built > simply, but it's preference that makes the difference. Some might have used > tkinter, gtk. wxpython or other methods for the task. > > I think the main issue in responding is your library preference, or widget > set preference. These can make you right with some in your response, or > wrong with others that have a preferable gui library that coincides with > one's personal cognitive structure that makes t > > > > > On Wed, Jul 24, 2013 at 9:48 AM, Chris Angelico wrote: > >> On Wed, Jul 24, 2013 at 11:40 PM, wrote: >> > Short example. Writing an editor with something like the >> > FSR is simply impossible (properly). >> >> jmf, have you ever written an editor with *any* string representation? >> Are you speaking from any level of experience at all? >> >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Modeling life on Earth –- an object-oriented (Python?) challenge
Never used pascal, and python might not be the fastest way to implement a program such as this. In a previous discussion, this was taken place by someone using a predator prey brain class.. The simulation will vary, until a full refinement of forecast is above a certainty percentage level. Visualization is needed as well. Collaboration is, of course , the best possible route. However you need to start with certain statistics, and know there will be an Uncerrtainty Principle rule applied. The algorithm for such massive amounts of data analysis in a simulation forecast, will involve HD space and RAM . You will also want to collaborate with certain databases in order to refine the accuracy of your models. This is kind of what I would consider being a Dune(Frank Herbert) planetary engineer. It also takes in other db data such as tagging marks of animals percentiles of bacterias/viruses/etcSO it's not as simple as it sounds, and python would be more of a prototyping language, and later translated into another language for faster maneuvering of data. On Tue, Jul 30, 2013 at 4:57 AM, wrote: > Dear List, > > I have to start this email by saying that I have recently attended > EuroPython in Florence, and it was the best and better organized conference > I have ever attended in 14 years of international meetings. > > I apologize if this is off topic, but I read in the list's description > that “[p]retty much anything Python-related is fair game for discussion”. > > Although I am not a Python developer, I decided to attend EuroPython in > search for a programmer interested in collaborating in the Python project I > briefly describe below. > > I use ecosystem models implemented with a procedural paradigm in a > language different from Python (Pascal, for the records). I would like to > migrate these ecosystem models (and code) to an object-oriented paradigm > using Python, as I have come to believe its expressiveness would help a lot > get the semantics right, rather than simply split procedural code into > objects corresponding to ecological elements. What's more, our models use > physiological analogies among the different levels of the food chain or > web, and this makes them amenable to an even higher level of > object-oriented abstraction given adequate expressiveness. > > The goal is to go beyond the currently (mostly) formal implementation of > the object-oriented paradigm in ecological models. To do that, I would need > help from an expert Python programmer (who also has some math skills, knows > English, and can work in the Rome area, or at least central Italy). I need > help because I am a Python beginner with limited programming experience in > general, and hence my contribution will mainly be the ecosystem modeling > insight. > > At EuroPython, I gave a lightning talk about the project that can be found > on YouTube > http://youtu.be/iUNbgNuN0qY?t=31m50s > > As I already made some very promising contacts at EuroPyton with > developers that are interested and willing to help, and many people shared > their views and provided useful insight into the issue (thanks!), this post > is meant to get further feedback on my idea and possibly reach other > interested developers. > > Kindly contact me if you have any interest in the idea and time to devote > it, as it is becoming a funded project. > > Kind regards, thanks for any hint, and apologies for the many inaccuracies, > > Luigi > -- > http://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: python CAD libraries?
Might have posted that too many times, I don't use the google groups that much. > > Best Regards, > > David Hutto > > CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Aggressive language on python-list
On Thu, Oct 18, 2012 at 1:29 AM, Steven D'Aprano wrote: > David, > > While I acknowledge and appreciate your efforts to be less aggressive on > this list, I think you have crossed a line by forwarding the contents of > an obviously personal email containing CLEARLY PRIVATE MATTERS to a > public list without permission, without even anonymising it. > I get that it was a in a thread, and we;'re always told to respond all, unless otherwise asked, and they didn't directly ask, so I responded back to the list like the etiquette dictates. > Not cool mate, not cool. > > The first amendment doesn't excuse this. You don't get to shout "Fire!" > in a crowded theatre either. That's an over exaggeration of whats going on. > > I think you owe Wu Wei, and Alex, apologies. But only for thinking that it's always reply all, and I do apologize, but they should have directly requested it in the email. If you follow the discussions here, again, it's always you should 'reply all'. > > Re-adding the list to a clearly Python-related question to the list is > marginally okay. (I normally wouldn't do it, but some people do.) Adding > the list to a personal comment is not. You know damn good and well opinions flutter like butterflies around here. > > And quite frankly, I sympathise with how hard your life has been, Don't, it's made me a better person to see the very worst people in life, be kind of a bad ass, and become better at being a stable person. It made me who I'm becoming, even if who I am now is just a transitional. but > this isn't your personal support group. There is such a thing as too much > sharing. It was mainly a business image, and wanting to revise myself, which I'm doing constantly. Most here are professionals, so I asked, and in the middle of a small flame war. > > My personal advice is that I think you need to take a break for a couple > of days and then come back focused on Python, rather than on defending > yourself against real or imagined slights. I'm not your dad and I'm not > sending you to your room, but sometimes a man has to know when it's best > to just walk away and let things cool off, regardless of who is right and > who is wrong. > I'm trying, but I do like to defend myself line for line. I can cool off, but can they lay off while I'm doing it, and do the same themselves? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Aggressive language on python-list
On Thu, Oct 18, 2012 at 2:19 AM, rusi wrote: > On Oct 18, 10:18 am, Zero Piraeus wrote: >> : >> >> On 18 October 2012 00:36, rusi wrote: >> >> > Unfortunately, I feel this whole discussion/thread has got derailed: >> > Zero you started this thread about aggressive behavior. It does not >> > seem to me that this was the case you were talking of, was it? >> >> Sorry, but I'm having trouble parsing that sentence. Could you rephrase it? > > I understood that your original post started after Etienne's outburst > against Steven. > David's outbursts are relatively harmless. > I tried to talk gently to him > http://mail.python.org/pipermail/python-list/2012-September/631949.html > And then gave up > http://mail.python.org/pipermail/python-list/2012-September/631950.html > > Not that I mind: People much wiser than we have expressed that war is > the most horrible thing in the universe and David is by his own > admission a war-damaged individual. > > If Steven chooses to engage him thats his call > If Alex chooses to fight with him thats his > I am betting that in the end, rurpy's suggestion -- Ignoring is the > best policy -- or Ben's -- Respond carefully, minimally and with > caution -- is what everyone will have to come to. > This does not mean I dont wish him well, just that I realize that the > sphere of my action and influence are intrinsically limited. > > And all this misses the point that you started this thread (I think) > with Etienne-Steven in mind not David-RestOfTheWorld. > > (Assuming this conjecture) I would like to say: > Etienne is not a 'dick' or a 'troll' just a human being with the same > buggy wetware that we all have whose logic goes: If you call me an > asshole (when justified) I'll call you can asshole (even if not). > Likewise Alex calling David racist may be justified but is not > helpful. > > IOW the robustness principle http://en.wikipedia.org/wiki/Robustness_principle > is as good for human networking as for computers. > > [BTW This was enunciated 2000 years ago by a clever chap: Love your > enemies; drive them crazy That only works if they're not already insane. Otherwise you're just prodding a cornered beast. ] -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Tue, Oct 23, 2012 at 10:31 AM, Virgil Stokes wrote:
> I am working with some rather large data files (>100GB) that contain time
> series data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII
> format. I perform various types of processing on these data (e.g. moving
> median, moving average, and Kalman-filter, Kalman-smoother) in a sequential
> manner and only a small number of these data need be stored in RAM when
> being processed. When performing Kalman-filtering (forward in time pass, k =
> 0,1,...,N) I need to save to an external file several variables (e.g. 11*32
> bytes) for each (t_k, y(t_k)). These are inputs to the Kalman-smoother
> (backward in time pass, k = N,N-1,...,0). Thus, I will need to input these
> variables saved to an external file from the forward pass, in reverse order
> --- from last written to first written.
>
> Finally, to my question --- What is a fast way to write these variables to
> an external file and then read them in backwards?
Don't forget to use timeit for an average OS utilization.
I'd suggest two list comprehensions for now, until I've reviewed it some more:
forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
for var in forward:
print var
for var in backward:
print var
You could also use a dict, and iterate through a straight loop that
assigned a front and back to a dict_one = {0 : [0.100], 1 : [1.99]}
and the iterate through the loop, and call the first or second in the
dict's var list for frontwards , or backwards calls.
But there might be faster implementations, depending on other
function's usage of certain lower level functions.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
> Don't forget to use timeit for an average OS utilization.
>
> I'd suggest two list comprehensions for now, until I've reviewed it some more:
>
> forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
> backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
>
> for var in forward:
> print var
>
> for var in backward:
> print var
>
> You could also use a dict, and iterate through a straight loop that
> assigned a front and back to a dict_one = {0 : [0.100], 1 : [1.99]}
> and the iterate through the loop, and call the first or second in the
> dict's var list for frontwards , or backwards calls.
>
>
> But there might be faster implementations, depending on other
> function's usage of certain lower level functions.
>
Missed the part about it being a file. Use:
forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
print forward,backward
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
> Missed the part about it being a file. Use: > > forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)] > backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)] > > print forward,backward > This was a dud, let me rework it real quick, I deleted what i had, and accidentally wrote the wrong function. > > > > -- > Best Regards, > David Hutto > CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
Whether this is fast enough, or not, I don't know:
filename = "data_file.txt"
f = open(filename, 'r')
forward = [line.rstrip('\n') for line in f.readlines()]
backward = [line.rstrip('\n') for line in reversed(forward)]
f.close()
print forward, "\n\n", "********\n\n", backward, "\n"
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Tue, Oct 23, 2012 at 6:53 PM, Steven D'Aprano wrote: > On Tue, 23 Oct 2012 17:50:55 -0400, David Hutto wrote: > >> On Tue, Oct 23, 2012 at 10:31 AM, Virgil Stokes wrote: >>> I am working with some rather large data files (>100GB) > [...] >>> Finally, to my question --- What is a fast way to write these variables >>> to an external file and then read them in backwards? >> >> Don't forget to use timeit for an average OS utilization. > > Given that the data files are larger than 100 gigabytes, the time > required to process each file is likely to be in hours, not microseconds. > That being the case, timeit is the wrong tool for the job, it is > optimized for timings tiny code snippets. You could use it, of course, > but the added inconvenience doesn't gain you any added accuracy. It depends on the end result, and the fact that if the iterations themselves are about the same time, then just using a segment of the iterations could be scaled down, and a full run might be worth it, if you have a second computer running optimization. > > Here's a neat context manager that makes timing long-running code simple: > > > http://code.activestate.com/recipes/577896 I'll test this out for big O notation later. For the OP: http://en.wikipedia.org/wiki/Big_O_notation > > > >> I'd suggest two list comprehensions for now, until I've reviewed it some >> more: > > I would be very surprised if the poster will be able to fit 100 gigabytes > of data into even a single list comprehension, let alone two. Again, these can be scaled depending on the operations of the function in question, and the average time of aforementioned function(s) > > This is a classic example of why the old external processing algorithms > of the 1960s and 70s will never be obsolete. No matter how much memory > you have, there will always be times when you want to process more data > than you can fit into memory This is a common misconception. You can engineer a device that accommodates this if it's a direct experimental necessity. > -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Tue, Oct 23, 2012 at 7:35 PM, emile wrote:
> On 10/23/2012 04:19 PM, David Hutto wrote:
>>
>> Whether this is fast enough, or not, I don't know:
>
>
> well, the OP's original post started with
> "I am working with some rather large data files (>100GB)..."
Well, is this a dedicated system, and one that they have the budget to upgrade?
Data files have some sort of parsing, unless it's one huge dict, or
list, so there has to be an average size to the parse.
So big O notation should begin to refine without a full file.
>
>
>> filename = "data_file.txt"
>> f = open(filename, 'r')
>> forward = [line.rstrip('\n') for line in f.readlines()]
>
>
> f.readlines() will be big(!) and have overhead... and forward results in
> something again as big.
>
Not if an average can be taken, and then refined as the actual gigs
are being iterated through.
>
>> backward = [line.rstrip('\n') for line in reversed(forward)]
>
>
> and defining backward looks to me to require space to build backward and
> hold reversed(forward)
>
> So, let's see, at that point in time (building backward) you've got
> probably somewhere close to 400-500Gb in memory.
>
> My guess -- probably not so fast. Thrashing is sure to be a factor on all
> but machines I'll never have a chance to work on.
But does the OP have access? They never stated their hardware, and
upgradable budget.
>
>
>> f.close()
>> print forward, "\n\n", "\n\n", backward, "\n"
>
>
>
> It's good to retain context.
Trying to practice good form ;).
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Tue, Oct 23, 2012 at 8:06 PM, Oscar Benjamin
wrote:
> On 23 October 2012 15:31, Virgil Stokes wrote:
>> I am working with some rather large data files (>100GB) that contain time
>> series data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII
>> format. I perform various types of processing on these data (e.g. moving
>> median, moving average, and Kalman-filter, Kalman-smoother) in a sequential
>> manner and only a small number of these data need be stored in RAM when
>> being processed. When performing Kalman-filtering (forward in time pass, k =
>> 0,1,...,N) I need to save to an external file several variables (e.g. 11*32
>> bytes) for each (t_k, y(t_k)). These are inputs to the Kalman-smoother
>> (backward in time pass, k = N,N-1,...,0). Thus, I will need to input these
>> variables saved to an external file from the forward pass, in reverse order
>> --- from last written to first written.
>>
>> Finally, to my question --- What is a fast way to write these variables to
>> an external file and then read them in backwards?
>
> You mentioned elsewhere that you are using numpy. I'll assume that the
> data you want to read/write are numpy arrays.
If that is the case always timeit. The following is an example of 3
functions, with repetitions of time that give an average:
import timeit
#3 dimensional matrix
x_dim = -1
y_dim = -1
z_dim = -1
s = """\
x_dim = -1
y_dim = -1
z_dim = -1
dict_1 = {}
for i in xrange(0,6):
x_dim = 1
y_dim = 1
z_dim = 1
dict_1['%s' % (i) ] = ['x = %i' % (x_dim), 'y = %i' % (y_dim), 'z =
%i' % (z_dim)]
"""
t = """\
import numpy
numpy.array([[ 1., 0., 0.],
[ 0., 1., 2.]])
"""
u = """\
list_count = 0
an_array = []
for i in range(0,10):
if list_count > 3:
break
if i % 3 != 0:
an_array.append(i)
if i % 3 == 0:
list_count += 1
"""
print timeit.timeit(stmt=s, number=10)
print timeit.timeit(stmt=t, number=10)
print timeit.timeit(stmt=u, number=10)
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Split single file into multiple files based on patterns
On Tue, Oct 23, 2012 at 11:01 PM, satyam wrote:
> I have a text file like this
>
> A1980JE3937 2732 4195 12.527000
> A1980JE3937 3465 9720 22.00
> A1980JE3937 1853 3278 12.50
> A1980JE3937 2732 2732 187.50
> A1980JE3937 19 4688 3.619000
> A1980JE3937 2995 9720 6.667000
> A1980JE3937 1603 9720 30.00
> A1980JE3937 234 4195 42.416000
> A1980JE3937 2732 9720 18.00
> A1980KK18700010 130 303 4.985000
> A1980KK18700010 7 4915 0.435000
> A1980KK18700010 25 1620 1.722000
> A1980KK18700010 25 186 0.654000
> A1980KK18700010 50 130 3.199000
> A1980KK18700010 186 3366 4.78
> A1980KK18700010 30 186 1.285000
> A1980KK18700010 30 185 4.395000
> A1980KK18700010 185 186 9.00
> A1980KK18700010 25 30 3.493000
>
> I want to split the file and get multiple files like A1980JE3937.txt and
> A1980KK18700010.txt, where each file will contain column2, 3 and 4.
> Thanks
> Satyam
#parse through the lines
turn_text_to_txt = ['A1980JE3937 2732 4195 12.527000',
'A1980JE3937 3465 9720 22.00',
'A1980JE3937 1853 3278 12.50',
'A1980JE3937 2732 2732 187.50',
'A1980JE3937 19 4688 3.619000',
'A1980KK18700010 30 186 1.285000',
'A1980KK18700010 30 185 4.395000',
'A1980KK18700010 185 186 9.00',
'A1980KK18700010 25 30 3.493000']
#then split and open a file for writing to create the file
#then start a count to add an extra number, because the files #you're
opening have the same name in some, which will #cause python to
overwrite the last file with that name.
#So I added an extra integer count after an underscore to #keep all
files, even if the have the first base number.
count = 0
for file_data in turn_text_to_txt:
#open the file for writing in 'w' mode so it creates the file, and
#adds in the appropriate data, including the extra count i#nteger just
in case there are files with the same name.
f = open('/home/david/files/%s_%s.txt' % (file_data.split(' ')[0],
count), 'w')
#write the data to the file, however this is in list format, I could
go further, but need a little time for a few other things.
f.write( str(file_data.split(' ')[1:]))
#close the file
f.close()
#increment the count for the next iteration, if necessary, and #again,
this is just in case the files have the same name, and #need an
additive.
# count += 1
Full code from above, without comments:
turn_text_to_txt = ['A1980JE3937 2732 4195 12.527000',
'A1980JE3937 3465 9720 22.00',
'A1980JE3937 1853 3278 12.50',
'A1980JE3937 2732 2732 187.50',
'A1980JE3937 19 4688 3.619000',
'A1980KK18700010 30 186 1.285000',
'A1980KK18700010 30 185 4.395000',
'A1980KK18700010 185 186 9.00',
'A1980KK18700010 25 30 3.493000']
#then split and open a file for writing to create the file
count = 0
for file_data in turn_text_to_txt:
print '/home/david/files/%s.txt' % (file_data.split(' ')[0])
f = open('/home/david/files/%s_%s.txt' % (file_data.split(' ')[0],
count), 'w')
f.write( str(file_data.split(' ')[1:]))
f.close()
count += 1
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: turn list of letters into an array of integers
On Wed, Oct 24, 2012 at 1:23 AM, seektime wrote:
> Here's some example code. The input is a list which is a "matrix" of letters:
>a b a
>b b a
>
> and I'd like to turn this into a Python array:
>
> 1 2 1
> 2 2 1
>
> so 1 replaces a, and 2 replaces b. Here's the code I have so far:
>
>>>> L=['a b a\n','b b a\n']
>>>> s=' '.join(L)
>>>> seq1=('a','b')
>>>> seq2=('1','2')
>>>> d = dict(zip(seq1,seq2))
>>>> # Define method to replace letters according to dictionary (got this from
>>>> http://gommeitputor.wordpress.com/2008/09/27/search-replace-multiple-words-or-characters-with-python/).
> ... def replace_all(text, dic):
> ... for i, j in dic.iteritems():
> ... text = text.replace(i, j)
> ... return text
> ...
>
>>>> seq = replace_all(s,d)
>>>> print seq
> 1 2 1
> 2 2 1
>
>>>> seq
> '1 2 1\n 2 2 1\n'
>
I'd suggest, if this is what you're referring to:
x = seq.split('\n ')
array_list = [ ]
next_3_d_array = []
range_of_seq = len(seq)
for num in range(0,range_of_seq):
if num % 3 != 0:
next_3_d_array.append(num)
if num % 3 == 0:
array_list.append(next_3_d_array)
next_3_d_array = [ ]
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: The pty module, reading from a pty, and Python 2/3
On Tue, Oct 23, 2012 at 11:41 PM, Evan Driscoll wrote:
> OK, one more self-reply. :-)
>
> I found http://bugs.python.org/issue5380 which seems to be relevant. Sounds
> like the OS is returning an error, and that's naturally being propagated
> through Python. And further testing reveals the problem only surfaces when
> the child actually exits -- if the child writes data to the pipe and is more
> enthusiastic about living, then the parent can read it successfully. While
> it'd be nice if my example worked, for my actual purpose I think that's good
> enough (I just won't be able to test *quite* as easily for a while).
>
> I am still curious if anyone know why it worked in 2 though.
>
> Evan
>
>
>
>
> On 10/23/2012 10:03 PM, Evan Driscoll wrote:
>>
>> Oh, and a little more information:
>>
>> The log.txt file I create has the message that it's "about to execlp", and
>> the exec() *does* actually happen -- the IOError is raised after the child
>> process quits.
>>
>> Evan
>>
>>
>>
>> On 10/23/2012 09:59 PM, Evan Driscoll wrote:
>>>
>>> I have the following program. Everything is sunshine and rainbows when I
>>> run in in Python 2, but when I run it under Python 3 I get an IOError. 2to3
>>> only reports one dumb suggestion re. a print call (which I can get rid of by
>>> importing __future__'s print_function, and then it just suggests removing
>>> that import).
>>>
>>> Can anyone shed any light? I am on Ubuntu Linux with Python 2.7.3 and
>>> 3.2.3.
>>>
>>>
>>> (Just for the record, I figured out that it ran under Python 2 by
>>> accident as I was reducing it for a "why doesn't this run?" email. :-) I'm
>>> not super-familiar with Py3 as I've mostly only worked with 2.)
>>>
>>> I'm not 100% sure how this will come through, so I've also put it at
>>> http://pastebin.com/60wjXSF3.
>>>
>>> Evan
>>>
>>>
>>> import sys
>>> import pty
>>> import os
>>>
>>> def get_text(filename):
>>> try:
>>> ( child_pid, fd ) = pty.fork()# OK
>>> except OSError as e:
>>> print(str(e))
>>> sys.exit(1)
>>>
>>> if child_pid == 0:
>>> try:
>>> with open("log.txt", "w") as f:
>>> f.write("about to execlp")
>>> os.execlp("cat", "cat", filename)
>>> except:
>>> with open("log.txt", "w") as f:
>>> f.write("could not spawn process")
>>> print("Could not spawn")
>>> sys.exit(1)
>>>
>>> child_pty = os.fdopen(fd)
>>> return child_pty.read()
>>>
>>>
>>> if __name__ == "__main__":
>>> print(get_text("my-pty-test.py"))
>>>
>>>
>>> The read error I get is
>>>
>>> Traceback (most recent call last):
>>> File "my-pty-test.py", line 28, in
>>> print(get_text("my-pty-test.py"))
>>> File "my-pty-test.py", line 24, in get_text
>>> return child_pty.read()
>>> IOError: [Errno 5] Input/output error
at first glance, you have the file open for writing('w'), not
reading('r'), but may not be that.
I'll check if I get a few minutes.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: The pty module, reading from a pty, and Python 2/3
import sys
import pty
import os
def get_text(filename):
#you need to find the file size, and place it as an integer in read
below, where you return the value
statinfo = os.stat(filename)
try:
( child_pid, fd ) = pty.fork() # OK
except OSError as e:
print(str(e))
sys.exit(1)
if child_pid == 0:
try:
with open("log.txt", "w") as f:
f.write("about to execlp")
os.execlp("cat", "cat", filename)
except:
with open("log.txt", "w") as f:
f.write("could not spawn process")
print("Could not spawn")
sys.exit(1)
child_pty = os.fdopen(fd)
#you have to input into read, how many characters you want read in. if
you place a random integer in, it will read to that integer within the
file
return child_pty.read(statinfo.st_size)
if __name__ == "__main__":
print(get_text("my-pty-test.py"))
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: The pty module, reading from a pty, and Python 2/3
#better coded for you to understand
import sys
import pty
import os
def get_text(filename):
try:
( child_pid, fd ) = pty.fork() # OK
except OSError as e:
print(str(e))
sys.exit(1)
if child_pid == 0:
try:
with open("log.txt", "w") as f:
f.write("about to execlp")
os.execlp("cat", "cat", filename)
except:
with open("log.txt", "w") as f:
f.write("could not spawn process")
print("Could not spawn")
sys.exit(1)
child_pty = os.fdopen(fd)
#you need to find the file size, and place it as an integer in read
below, where you return the value
#you have to input into read, how many characters you want read in
with statinfo.st_size
statinfo = os.stat(filename)
return child_pty.read(statinfo.st_size)
if __name__ == "__main__":
print(get_text("my-pty-test.py"))
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: The pty module, reading from a pty, and Python 2/3
in other words, the last two lines of your function should be: statinfo = os.stat(filename) return child_pty.read(statinfo.st_size) -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Wed, Oct 24, 2012 at 3:05 AM, Virgil Stokes wrote:
> On 24-Oct-2012 00:36, David Hutto wrote:
>>>
>>> Don't forget to use timeit for an average OS utilization.
>>>
>>> I'd suggest two list comprehensions for now, until I've reviewed it some
>>> more:
>>>
>>> forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
>>> backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
>>>
>>> for var in forward:
>>> print var
>>>
>>> for var in backward:
>>> print var
>>>
>>> You could also use a dict, and iterate through a straight loop that
>>> assigned a front and back to a dict_one = {0 : [0.100], 1 : [1.99]}
>>> and the iterate through the loop, and call the first or second in the
>>> dict's var list for frontwards , or backwards calls.
>>>
>>>
>>> But there might be faster implementations, depending on other
>>> function's usage of certain lower level functions.
>>>
>> Missed the part about it being a file. Use:
>>
>> forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
>> backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
>>
>> print forward,backward
>
> Interesting approach for small data sets (or blocks from a much larger data
> set).
>
> Thanks David :-)
No problem.
I think this was for a > 100GB, which might be able to be reduced for
parsing if I could see a snippet of the usual data being processed by
the function
But it does go to big O notation, and optimization of the average data
being passed through, unless the data varies in wide ranges, in which
that could be optimized to go from smaller to larger, vice versa, or
othe pieces of data with a higher priority level..
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
On Wed, Oct 24, 2012 at 3:17 AM, Virgil Stokes wrote: > On 24-Oct-2012 00:57, Demian Brecht wrote: >>> >>> This is a classic example of why the old external processing algorithms >>> of the 1960s and 70s will never be obsolete. No matter how much memory >>> you have, there will always be times when you want to process more data >>> than you can fit into memory. >> >> >> But surely nobody will *ever* need more than 640k… >> >> Right? >> >> Demian Brecht >> @demianbrecht >> http://demianbrecht.github.com >> >> >> >> > Yes, I can still remember such quotes --- thanks for jogging my memory, > Demian :-) This is only on equipment designed by others, otherwise, you could engineer the hardware yourself to perfom just certain functions for you(RISC), and pass that back to the CISC(from a PCB design). -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Split single file into multiple files based on patterns
On Wed, Oct 24, 2012 at 3:52 AM, Steven D'Aprano wrote: > On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > >> I have a text file like this >> >> A1980JE3937 2732 4195 12.527000 > [...] > >> I want to split the file and get multiple files like A1980JE3937.txt >> and A1980KK18700010.txt, where each file will contain column2, 3 and 4. > > Are you just excited and want to tell everyone, or do you actually have a > question? > > Have you tried to write some code, or do you just expect others to do > your work for you? > > If so, I see that your expectation was correct. > > > > -- > Steven Some learn better with a full example, better than any small challenge that can be thrown in at certain times. I think it should be a little of both, especially if you (an algorithmitist for the OP)only have enough time to throw out untested pseudo code. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman wrote:
> Hello all,
>
> I'm new to Python (running 2.6.6 but if necessary 3.x should also be
> fine). I have a little idea I hope to accomplish with Python. I want to
> listen for changes in Alsa sound volume level and base some actions on
> that.
With the few lines below I can check the current volume level. Can
> I extend this so that the script listens for changes in the volume level
> and I can base some actions on it? As speed is quite important it's not
> an option to poll every second or so for changes, it has to be close to
> instantaneous.
>
> If this is not possible with Python, any suggestions on what else are
> also welcome of course.
>
> Thanks in advance, Maarten
>
>
> #
> try
> mixer = alsaaudio.Mixer(Fake, 0)
> except alsaaudio.ALSAAudioError:
> sys.stderr.write("No such mixer\n")
> sys.exit(1)
>
> volumes = mixer.getvolume(1)
> #
> --
> http://mail.python.org/mailman/listinfo/python-list
first look at the docs for command line functions that utilize the
command line for access to certain CL apps.
Once you've found a way to access the CL apps with python(I use
subprocess.call usually, I think, but there's popen, etc.) then use
man alsamixer, or man aplayer, or man arecorder. in the shell on your
linux distro.
Then throw in a little tkinter, or a windowing system of your choice,
and distort the changes with command line calls.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. With the few lines below I can check the current volume level. Can > I extend this so that the script listens for changes in the volume level > and I can base some actions on it? As speed is quite important it's not > an option to poll every second or so for changes, it has to be close to > instantaneous. > You might have to go to c++(ctypes function call), like I'm going to have to for a oscilloscope(using arecord probably, or other options), and use in line assembly to push straight from/to the register. I haven't had a good look at python's IO module yet though. Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
On Thu, Oct 25, 2012 at 5:31 AM, Dave Angel wrote: > On 10/25/2012 05:21 AM, inshu chauhan wrote: >>> >>> or if the clist initial contents were relevant, perhaps you mean >>> >>>> clist += alist, blist >>> >> >> But not this because it will simply concatenate the list like >> [1,2,3,4,5,6] .. I dont want this actaully... >> >>> > > No, it won't. Try it to see. > Is this what you mean: >>> list_1 = [i for i in range(0,5)] >>> list_2 = [i for i in range(5,11)] >>> for i in list_2: ... list_1.append(i) ... >>> list_1 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] or would another example help you out more? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
On Thu, Oct 25, 2012 at 5:44 AM, inshu chauhan wrote: > > >> >> >> >> or if the clist initial contents were relevant, perhaps you mean >> >> >> >>> clist += alist, blist >> >> >> > >> > But not this because it will simply concatenate the list like >> > [1,2,3,4,5,6] .. I dont want this actaully... >> > >> >> >> >> No, it won't. Try it to see > > > Ok but it should be clist + = [alist, blist ] >> >> >> >> -- Also, try help(list) in the interpreter for functions utilizable by list. Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
On Thu, Oct 25, 2012 at 5:51 AM, inshu chauhan wrote: > > >> >> Is this what you mean: >> list_0 = [] list_1 = [i for i in range(0,5)] list_2 = [i for i in range(5,11)] list_0.append(list_1) list_0.append(list_2) >> >>> for i in list_2: >> ... list_1.append(i) >> ... >> >>> list_1 >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> >> or would another example help you out more? > > > No but really sorry this is what I DONT WANT... > > The output I want to have is : > > [ [0, 1, 2, 3, 4 ], [5, 6, 7, 8, 9, 10] ]. Then, this is what you want : >>david@david-desktop:~$ python Python 2.7.3 (default, Aug 1 2012, 05:16:07) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> list_0 = [] >>> list_1 = [i for i in range(0,5)] >>> list_2 = [i for i in range(5,11)] >>> list_0.append(list_1) >>> list_0.append(list_2) >>> list_0 [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] >>> -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
Also, >>> list_1 = [i for i in range(0,5)] >>> list_2 = [i for i in range(5,11)] >>> list_0 = [list_1,list_2] >>> list_0 [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
On Thu, Oct 25, 2012 at 5:58 AM, inshu chauhan wrote: > Yes Dave ..You are right and my problem is solved now.. Thanx to all... > > > On Thu, Oct 25, 2012 at 11:55 AM, David Hutto > wrote: >> >> On Thu, Oct 25, 2012 at 5:51 AM, inshu chauhan >> wrote: >> > >> > >> >> >> >> Is this what you mean: >> >> >> list_0 = [] >> list_1 = [i for i in range(0,5)] >> list_2 = [i for i in range(5,11)] >> list_0.append(list_1) >> list_0.append(list_2) >> >> >>> for i in list_2: >> >> ... list_1.append(i) >> >> ... >> >> >>> list_1 >> >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> >> >> >> >> or would another example help you out more? >> > >> > >> > No but really sorry this is what I DONT WANT... >> > >> > The output I want to have is : >> > >> > [ [0, 1, 2, 3, 4 ], [5, 6, 7, 8, 9, 10] ]. >> >> Then, this is what you want : >> >> >>david@david-desktop:~$ python >> Python 2.7.3 (default, Aug 1 2012, 05:16:07) >> [GCC 4.6.3] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> list_0 = [] >> >>> list_1 = [i for i in range(0,5)] >> >>> list_2 = [i for i in range(5,11)] >> >>> list_0.append(list_1) >> >>> list_0.append(list_2) >> >>> list_0 >> [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] if you have a format for the lists, there might be an easier way, or simpler. How are the lists coming in? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: can we append a list with another list in Python ?
On Thu, Oct 25, 2012 at 6:12 AM, inshu chauhan wrote: > > > On Thu, Oct 25, 2012 at 12:04 PM, David Hutto > wrote: >> >> On Thu, Oct 25, 2012 at 5:58 AM, inshu chauhan >> wrote: >> > Yes Dave ..You are right and my problem is solved now.. Thanx to all... >> > >> > >> > On Thu, Oct 25, 2012 at 11:55 AM, David Hutto >> > wrote: >> >> >> >> On Thu, Oct 25, 2012 at 5:51 AM, inshu chauhan >> >> wrote: >> >> > >> >> > >> >> >> >> >> >> Is this what you mean: >> >> >> >> >> list_0 = [] >> >> list_1 = [i for i in range(0,5)] >> >> list_2 = [i for i in range(5,11)] >> >> list_0.append(list_1) >> >> list_0.append(list_2) >> >> >> >>> for i in list_2: >> >> >> ... list_1.append(i) >> >> >> ... >> >> >> >>> list_1 >> >> >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> >> >> >> >> >> >> >> or would another example help you out more? >> >> > >> >> > >> >> > No but really sorry this is what I DONT WANT... >> >> > >> >> > The output I want to have is : >> >> > >> >> > [ [0, 1, 2, 3, 4 ], [5, 6, 7, 8, 9, 10] ]. >> >> >> >> Then, this is what you want : >> >> >> >> >>david@david-desktop:~$ python >> >> Python 2.7.3 (default, Aug 1 2012, 05:16:07) >> >> [GCC 4.6.3] on linux2 >> >> Type "help", "copyright", "credits" or "license" for more information. >> >> >>> list_0 = [] >> >> >>> list_1 = [i for i in range(0,5)] >> >> >>> list_2 = [i for i in range(5,11)] >> >> >>> list_0.append(list_1) list_0 = [list_1,list_2] >> >> >>> list_0.append(list_2) >> >> >>> list_0 >> >> [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] >> >> if you have a format for the lists, there might be an easier way, or >> simpler. How are the lists coming in? >> >> The list are in form of >> >> first list like [(x,y,z) ] >> >> and another as [(a,b,c), (a+i, b+i, c+i).] >> This shows tuples though, not appended lists, which are immutable. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about long-running web scripts
On Thu, Oct 25, 2012 at 8:03 AM, Tim Golden wrote: > On 25/10/2012 12:45, Gilles wrote: >> I'd like to check something about running Python web applications. >> >> Generally speaking, the reason scripts run faster when called >> through FastCGI or the mod_* modules, is because the interpreter is >> already up and running. But when running PHP scripts, this does >> nothing about fetching the file from disk, recompiling, rerunning it, >> and usually reconnecting to the database. >> I'd say that is the same as py, unless it's a cron job to limit script iterations >> OTOH, Python web scripts can be written as long-running scripts: In >> this case, what is the added-value of using FastCGI? Why can't the >> web server simply call the Python script directly, just like CGI? The server should call a the script, or script.sleep() There are also server options to setup when a script is run, other than a cron jo for php. > > (Your question is a little confused at the end. I'm choosing to > understand: why can't we just run Python one-shot, like CGI? The likely > alternative meaning is: why can't the incoming request be routed to an > already-running Python program -- which is not, of course, what CGI > generally does. Hence my confusion). > > The answer is: it can. CGI is a protocol rather than anything else. In > front of a CGI exchange is the browser (or some other web client). > Behind it is some program which is capable of producing a valid HTTP > response, including a Python program. > > It's perfectly possible to run a usable website against Python running > one-shot. You won't get terrific performance out of it, but for a > website which doesn't expect humungous amounts of traffic, it'll work fine. > > The amount of time it takes a half-decent, even shared, server to start > up a Python process, connect to a database, pull stuff together, and > send a response will likely not impact on an average user's experience. > As long as too many of them don't try to do that at the same time. > Exactly where the line is drawn will depend on your particular hosting > solution, your assumed traffic, and your users' expectations as to > responsiveness. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Quickie - Regexp for a string not at the beginning of the line
On Thu, Oct 25, 2012 at 9:08 PM, Rivka Miller wrote: > On Oct 25, 2:27 pm, Danny wrote: >> Why you just don't give us the string/input, say a line or two, and what you >> want off of it, so we can tell better what to suggest > > no one has really helped yet. > > I want to search and modify. > > I dont wanna be tied to a specific language etc so I just want a > regexp and as many versions as possible. If you just find the one command line app that will perform the task, like awk, then the other languages you will just need to call the commandline function, and return the output from awk. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast forward-backward (write-read)
> Data files have some sort of parsing, unless it's one huge dict, or > list, so there has to be an average size to the parse. > Not meaning the dict, or list isn't parsed, but that the file should be have parsable areas. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Migrate from Access 2010 / VBA
On Thu, Nov 22, 2012 at 10:19 PM, kgard wrote: > Greetings: > > I am the lone developer of db apps at a company of 350+ employees. Everything > is done in MS Access 2010 and VBA. I'm frustrated with the limitations of > this platform and have been considering switching to Python. I've been > experimenting with the language for a year or so, and feel comfortable with > the basics. > > I am concerned that I'll have a hard time replacing the access form and > report designers. I've worked a little with TKinter, but it's a far cry from > the GUI designer in Access. Finding a professional grade report designer > looks like an even bigger challenge. > > I don't need to port any applications, but I will need to use the data > (mdb/accede format), design a variety of reports with multi-level groupings, > and deliver them to many individual recipients via email. > > Has anyone here made this transition successfully? If so, could you pass > along your suggestions about how to do this as quickly and painlessly as > possible?http://www.youtube.com/watch?v=DksSPZTZES0 > > TIA > Keith Translate function for function to the new language(return values), then adapt the GUI to represent the new functions on event activity via widgets. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Exponential arrival distribution in Python
>> I am doing a project on traffic simulation. I want to introduce >> exponential arrival distribution to precede this task. Therefore I want >> write a code in python for exponential arrival distribution. I am very new >> for programming and if anybody can help me on this that would be great. First, I would suggest that you give yourself a GUI like tkinter, wxpython to visualize the data. An average of the sequential(averaged per 60 second intervals) traveled by drivers on the road, and at what times. Then, and I don't know why, but it seems you want a logarithmic, scale where: for i in range(0,4) print "%i = %i" % (i * 10 **i) -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Exponential arrival distribution in Python
I mean this one: for i in range(0,4): print "%i = %i" % (i * 10 **i) -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: mini browser with python
I think this is the snippe that you want:
david@david-desktop:~$ python
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urlliib
>>> url_to_read = urllib.urlopen('http://hitwebdevelopment.com')
>>> for line in url_to_read:
... print line
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Mon, Jan 28, 2013 at 10:10 AM, wrote: > > Hi guys, > > I am thinking of driving a DJ application from Python. > I am running Linux and I found the Mixxx app. > Does anyone know if there are python bindings, or if this is possible at all? > or does anyone have experience with another software that does the same DJ > thing? > > I have also found the pymixxx module that I could install... but I didn't > find any documentation so far or example code that could help me start (I'm > keeping on searching). > > Finally maybe that there is any DJ app that could be driven by pygame.midi? > > Any idea appreciated. > Sorry to fail to be more specific. I'd just go with a command line app that triggered a .wav file at certain points using time.sleep(x) Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:06 AM, David Hutto wrote: > On Mon, Jan 28, 2013 at 10:10 AM, wrote: >> >> Hi guys, >> >> I am thinking of driving a DJ application from Python. >> I am running Linux and I found the Mixxx app. >> Does anyone know if there are python bindings, or if this is possible at all? >> or does anyone have experience with another software that does the same DJ >> thing? >> Hydrogen, and audacity work perfectly together. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
>>> Does anyone know if there are python bindings, or if this is possible at >>> all? >>> or does anyone have experience with another software that does the same DJ >>> thing? >>> > >Hydrogen, and audacity work perfectly together. What I was about to do is take the mic, get the soundtrack/beat to the song going, and then plug it into audacity for further modification, or you can roll your own. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:16 AM, David Hutto wrote: >>>> Does anyone know if there are python bindings, or if this is possible at >>>> all? >>>> or does anyone have experience with another software that does the same DJ >>>> thing? >>>> >> >>Hydrogen, and audacity work perfectly together. > > What I was about to do is take the output to the headphones, get the soundtrack/beat to the song going, and then plug it into audacity(mic) for further modification, or you can roll your own. > -- > > > Best Regards, > David Hutto > CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:18 AM, wrote: > On Tuesday, January 29, 2013 4:13:09 PM UTC, David Hutto wrote: > [..] >> >> >> or does anyone have experience with another software that does the same >> >> DJ thing? >> >> >> >> >> Hydrogen, and audacity work perfectly together. > > > Hi David, > thanks for your reply. > I am not sure though that this is going to help me. > We have built a kind of basic controller that sends commands via bluetooth. > Then I should have some device (like a linux pc or raspberry Pi) where I have > my applications that listen for these bluetooth commands and drives a DJ > application accordingly (like mixing two sounds, sync them etc). > > Obviously to write the whole application will take ages and I saw that the > Mixxx one does everything I want. > So I am searching for a way to interface to it programatically. Well you can just use their(Mixx's) source code that they used from another wav form manipulation library(more than likely), after the trigger from the bluetooth. If you're talking voice, and music to sync, then either go with transmitting at the same, or take two receivers(one for each transmitter), and run them in unison on different frequencies, after they've been received.. I've never tried this, but it seems logical. > > Do you mean that Hydrogen and Audacity would replace the Mixxx app and I can > call their functionality from Python? > Or were you thinking about something else? > > Thanks, > Mik > -- > http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:45 AM, Ben wrote: > This may not be too helpful, but I built a TCP server into the Mixxx > application (in C++). I placed the server in ratecontroller (as I needed to > vary the rate remotely). I then could send and receive TCP packets with a > single board computer that ran a python client. > > So you used a digital buffer region for your wave forms? How did you handle the rest of the data; allocate memory, or delete if the data became too lengthy? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
> Thanks David. > It seems that the code is in C++ so I should write Python wrappers myself, Or ctypes. which could be interesting, but given the time frame I have is just not possible, Pity :-( > However I was not going to transmit sounds, but just commands to mix the > sounds that are already in the same machine were the Mixxx is going to run. A filter is minutia in comparison of code so it was always going to be a comand line app, with a python GUI, to perform alterations on the wave forms?. > I hope I will have time to come back to it in future. > Just a little practice, that makes every programmer listening scramble. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Ways to apply while learning....
On Tue, Jan 29, 2013 at 5:57 PM, wrote: > Hello, > I am learning programming as a spare time hobby and learning python through > codecademy. > > Today I have downloaded and installed aptana, and found out that although I > have been progressing for some time now but I do not remember how to code and > I have to look everything up. When using different languages to mean client needs,this will be a necessity. > > I want to know what is the best way to learn python and some small projects > that I can make using console you might need to utilize subrocess, but many ahve their preference. (I know there is a long way to develop something for the desktop) Do you mean command line app, or with a GUI? > > Thank you. > ps: I am coming from vb6 paradigm. > -- > http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble with Multi-threading
If you really want to have a discussion on multi-threading, then look at quantum bits/computers, and let's see where python can go from the real future of prototyping language, to the expert in it. On Wed, Dec 11, 2013 at 11:26 PM, rusi wrote: > On Thursday, December 12, 2013 7:30:38 AM UTC+5:30, Roy Smith wrote: > > In article Steven D'Aprano wrote: > > > > When did this forum become so intolerant of even the tiniest, most > minor > > > breaches of old-school tech etiquette? Have we really got nothing > better > > > to do than to go on the war path over such trivial issues? Out of five > > > responses to the Original Poster's email, there was *one* helpful > reply, > > > followed by no fewer than four people playing "Stacks on the n00b" > making > > > the same comment about being unable to delete the message. I'm sure all > > > four of you think you are ever such wits, but you're only half right. > > > I believe I started off the chain of responses you're referring to. I > > meant it semi-humorously, but also with a point. It is clear it turned > > out to be harmful, and for that I apologize. > > Sniping at someone -- especially a newcomer -- for a piece of technical > irrelevantia is unfortunate. However your semi-humorous pointing out > was good because it shows that all posting methods have their hiccups: > > html mail > undesired and nonsensical footers > reply/reply-all mixups > repeated posts > long and double-spaced lines > others Ive missed > > Reminds me that sometime ago when GG was habitually double-posting, > Steven started quadruple-posting, giving some of us a rare leg-pulling > opportunity :D > > > I share your dismay at where this group is going, and feel bad that I > > inadvertently moved it further in that direction. > > Unnecessary and uncalled for irascibility is of course a degradation. > > But (from my pov) a bunch of people -- especially so-called techies -- > unable to distinguish the following 3 is a much bigger degradation. > > 1 Problems caused by conscious malefic intent > 2 Kids/noobs/ignoramuses/immature just being themselves > 3 Problems of communication technology > > Conflating 1,3 with 2 will drive many of them (2s) away which is a > significant loss for the community > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: request for guidance
In my opinion, a novice always tries to reinvent the wheel. Take for example a simple text editor. But I would go with something that shows your creativity...like a game. It's not just about code, but graphics/enhancements, and other evolutions of the open source nature of programming. On Fri, Dec 13, 2013 at 12:46 PM, jennifer stone wrote: > hello! > thanks a ton for your warm response. I know the basics of python with some > modules like pickle, urllib, re. Its kind of basic I know. but it gotta > start somewhere and I really want to have real world experience. > thanks > jennifer > > > On Fri, Dec 13, 2013 at 10:45 AM, jennifer stone > wrote: > >> greetings >> I am a novice who is really interested in contributing to Python >> projects. How and where do I begin? >> thanking you in anticipation >> > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: request for guidance
Don't get me wrong, I didn't mean reinventing the wheel is a bad thing, just that once you get the hang of things, you need to display some creativity in your work to set yourself apart from the rest. Nowadays, everyone's a programmer. If it weren't for reinventing the wheel, then we wouldn't have abs(antilock breaking systems), or new materials, or different treading for water displacement or hydroplaning. The point was just to try something in python, and to 'boldly go where no 'man' has gone before'. Just to remind her that it's not just about python, but what you can accomplish with it, and distinguish yourself from others. On Fri, Dec 13, 2013 at 11:56 PM, Chris Angelico wrote: > On Sat, Dec 14, 2013 at 3:48 PM, David Hutto > wrote: > > In my opinion, a novice always tries to reinvent the wheel. Take for > example > > a simple text editor. > > Which isn't a bad thing. Especially in that particular case, it's good > to try your hand at writing a text editor - most of the hard > grunt-work is done for you (just plop down an edit control - in some > toolkits you can even deploy a control with full source code > highlighting), so you can focus on figuring out what it is that makes > yours different. And then you'll appreciate other editors more :) But > along the way, you'll learn so much about what feels right and what > feels wrong. And maybe you can incorporate some of your own special > unique features into whatever editor you end up using... quite a few > are scriptable. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: The increasing disempowerment of the computer user
Three word response...Conglomerate business intelligence. On Thu, Dec 12, 2013 at 5:59 AM, Steven D'Aprano < [email protected]> wrote: > On Thu, 12 Dec 2013 13:35:37 +1100, Ben Finney wrote: > > > Hmm, interesting Freudian slip there. I meant “cloud computing”, of > > course. That's where the computer owner pretends their service is always > > available and easy to access, while having terms of service that give > > them unilateral power to kick you off with no warning, no explanation, > > no accountability, and no recourse. > > Now Ben, you know that's not true. Everybody has the only recourse that > matters: buy the company and make them do what you want them to do. How > hard could that possibly be? > > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: About some problem
I think, but haven't tried, and this would be 2-3 from __future__ import On Thu, Jan 2, 2014 at 12:46 PM, Rustom Mody wrote: > On Thu, Jan 2, 2014 at 11:06 PM, Ned Batchelder > wrote: > > On 1/2/14 12:05 PM, Rustom Mody wrote: > > > >> > >> i'm not sure about this but isnt it normally the case that different > >> version modules dont get mixed up like that? > >> IOW if pytesser was a properly packaged 2.7 module would python 3 be > >> able to get at it ?? > >> > > > > If you use a Python 3 installer it can succeed at installing a Python 2 > > package. Then you won't find out until you try to run the package that > it is > > incompatible. A mechanism to prevent this seems like a good idea, but > since > > it wasn't in place at the dawn of Python 3, it would be difficult to put > in > > place now. > > $ python3 > Python 3.3.3 (default, Dec 8 2013, 16:34:29) > [GCC 4.8.2] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> from sys import path > >>> path > ['', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-i386-linux-gnu', > '/usr/lib/python3.3/lib-dynload', > '/usr/local/lib/python3.3/dist-packages', > '/usr/lib/python3/dist-packages'] > > > $ python > Python 2.7.6 (default, Dec 6 2013, 21:56:56) > [GCC 4.8.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> from sys import path > >>> path > ['', '/usr/local/lib/python2.7/dist-packages/pip-1.0-py2.7.egg', > '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', > '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', > '/usr/lib/python2.7/lib-dynload', > '/usr/local/lib/python2.7/dist-packages', > '/usr/lib/python2.7/dist-packages', > '/usr/lib/python2.7/dist-packages/PILcompat', > '/usr/lib/python2.7/dist-packages/gst-0.10', > '/usr/lib/python2.7/dist-packages/gtk-2.0', > '/usr/lib/pymodules/python2.7', > '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'] > > > So as far as I can see (on a debian linux system) the paths are > clearly 2.7-prefixed or 3.3-prefixed. > > So apart from being stupid and/or malicious to munge sys.path to tread > on the other python's toes...??? > > Oh ok I get what you are saying: python3 will not recognize a python2 > package and install it seemingly correctly but actually wrongly > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: About some problem
and as I usually do, keep with the older stable version in order to keep up with other packages compatibiity. On Thu, Jan 2, 2014 at 1:07 PM, David Hutto wrote: > I think, but haven't tried, and this would be 2-3 from __future__ import > > > On Thu, Jan 2, 2014 at 12:46 PM, Rustom Mody wrote: > >> On Thu, Jan 2, 2014 at 11:06 PM, Ned Batchelder >> wrote: >> > On 1/2/14 12:05 PM, Rustom Mody wrote: >> > >> >> >> >> i'm not sure about this but isnt it normally the case that different >> >> version modules dont get mixed up like that? >> >> IOW if pytesser was a properly packaged 2.7 module would python 3 be >> >> able to get at it ?? >> >> >> > >> > If you use a Python 3 installer it can succeed at installing a Python 2 >> > package. Then you won't find out until you try to run the package that >> it is >> > incompatible. A mechanism to prevent this seems like a good idea, but >> since >> > it wasn't in place at the dawn of Python 3, it would be difficult to >> put in >> > place now. >> >> $ python3 >> Python 3.3.3 (default, Dec 8 2013, 16:34:29) >> [GCC 4.8.2] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> from sys import path >> >>> path >> ['', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-i386-linux-gnu', >> '/usr/lib/python3.3/lib-dynload', >> '/usr/local/lib/python3.3/dist-packages', >> '/usr/lib/python3/dist-packages'] >> >> >> $ python >> Python 2.7.6 (default, Dec 6 2013, 21:56:56) >> [GCC 4.8.2] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> from sys import path >> >>> path >> ['', '/usr/local/lib/python2.7/dist-packages/pip-1.0-py2.7.egg', >> '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', >> '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', >> '/usr/lib/python2.7/lib-dynload', >> '/usr/local/lib/python2.7/dist-packages', >> '/usr/lib/python2.7/dist-packages', >> '/usr/lib/python2.7/dist-packages/PILcompat', >> '/usr/lib/python2.7/dist-packages/gst-0.10', >> '/usr/lib/python2.7/dist-packages/gtk-2.0', >> '/usr/lib/pymodules/python2.7', >> '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'] >> >> >> So as far as I can see (on a debian linux system) the paths are >> clearly 2.7-prefixed or 3.3-prefixed. >> >> So apart from being stupid and/or malicious to munge sys.path to tread >> on the other python's toes...??? >> >> Oh ok I get what you are saying: python3 will not recognize a python2 >> package and install it seemingly correctly but actually wrongly >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com > <http://www.hitwebdevelopment.com>* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: About some problem
Looks like you have a a list of 2.7 dependencies in the path args. The first you seem to have 3.3 args, and the second a longer list of 2.7 argsI would assume the second is the full list...correct? On Thu, Jan 2, 2014 at 1:07 PM, David Hutto wrote: > I think, but haven't tried, and this would be 2-3 from __future__ import > > > On Thu, Jan 2, 2014 at 12:46 PM, Rustom Mody wrote: > >> On Thu, Jan 2, 2014 at 11:06 PM, Ned Batchelder >> wrote: >> > On 1/2/14 12:05 PM, Rustom Mody wrote: >> > >> >> >> >> i'm not sure about this but isnt it normally the case that different >> >> version modules dont get mixed up like that? >> >> IOW if pytesser was a properly packaged 2.7 module would python 3 be >> >> able to get at it ?? >> >> >> > >> > If you use a Python 3 installer it can succeed at installing a Python 2 >> > package. Then you won't find out until you try to run the package that >> it is >> > incompatible. A mechanism to prevent this seems like a good idea, but >> since >> > it wasn't in place at the dawn of Python 3, it would be difficult to >> put in >> > place now. >> >> $ python3 >> Python 3.3.3 (default, Dec 8 2013, 16:34:29) >> [GCC 4.8.2] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> from sys import path >> >>> path >> ['', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-i386-linux-gnu', >> '/usr/lib/python3.3/lib-dynload', >> '/usr/local/lib/python3.3/dist-packages', >> '/usr/lib/python3/dist-packages'] >> >> >> $ python >> Python 2.7.6 (default, Dec 6 2013, 21:56:56) >> [GCC 4.8.2] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> from sys import path >> >>> path >> ['', '/usr/local/lib/python2.7/dist-packages/pip-1.0-py2.7.egg', >> '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', >> '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', >> '/usr/lib/python2.7/lib-dynload', >> '/usr/local/lib/python2.7/dist-packages', >> '/usr/lib/python2.7/dist-packages', >> '/usr/lib/python2.7/dist-packages/PILcompat', >> '/usr/lib/python2.7/dist-packages/gst-0.10', >> '/usr/lib/python2.7/dist-packages/gtk-2.0', >> '/usr/lib/pymodules/python2.7', >> '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'] >> >> >> So as far as I can see (on a debian linux system) the paths are >> clearly 2.7-prefixed or 3.3-prefixed. >> >> So apart from being stupid and/or malicious to munge sys.path to tread >> on the other python's toes...??? >> >> Oh ok I get what you are saying: python3 will not recognize a python2 >> package and install it seemingly correctly but actually wrongly >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com > <http://www.hitwebdevelopment.com>* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Blog "about python 3"
Just because it's 3.3 doesn't matter...the main interest is in compatibility. Secondly, you used just one piece of code, which could be a fluke, try others, and check the PEP. You need to realize that evebn the older versions are benig worked on, and they have to be refined. So if you have a problem, use the older and import from the future would be my suggestion On Thu, Jan 2, 2014 at 12:36 PM, Robin Becker wrote: > On 31/12/2013 15:41, Roy Smith wrote: > >> I'm using 2.7 in production. I realize that at some point we'll need to >> upgrade to 3.x. We'll keep putting that off as long as the "effort + >> dependencies + risk" metric exceeds the "perceived added value" metric. >> >> We too are using python 2.4 - 2.7 in production. Different clients > migrate at different speeds. > > >> To be honest, the "perceived added value" in 3.x is pretty low for us. >> What we're running now works. Switching to 3.x isn't going to increase >> our monthly average users, or our retention rate, or decrease our COGS, >> or increase our revenue. There's no killer features we need. In >> summary, the decision to migrate will be driven more by risk aversion, >> when the risk of staying on an obsolete, unsupported platform, exceeds >> the risk of moving to a new one. Or, there will be some third-party >> module that we must have which is no longer supported on 2.x. >> >> > +1 > > If I were starting a new project today, I would probably start it in 3.x. >> > +1 > > I just spent a large amount of effort porting reportlab to a version which > works with both python2.7 and python3.3. I have a large number of functions > etc which handle the conversions that differ between the two pythons. > > For fairly sensible reasons we changed the internal default to use unicode > rather than bytes. After doing all that and making the tests compatible etc > etc I have a version which runs in both and passes all its tests. However, > for whatever reason the python 3.3 version runs slower > > 2.7 Ran 223 tests in 66.578s > > 3.3 Ran 223 tests in 75.703s > > I know some of these tests are fairly variable, but even for simple things > like paragraph parsing 3.3 seems to be slower. Since both use unicode > internally it can't be that can it, or is python 2.7's unicode faster? > > So far the superiority of 3.3 escapes me, but I'm tasked with enjoying > this process so I'm sure there must be some new 'feature' that will help. > Perhaps 'yield from' or 'raise from None' or ... > > In any case I think we will be maintaining python 2.x code for at least > another 5 years; the version gap is then a real hindrance. > -- > Robin Becker > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Flip a graph
I would definitely utilize y axis as an altitudinal derivative of time,x. I'd go with more of a dart type of graphic, so you might be able to show a peak in altitude from take off, and the rotate the graphic in relation to the deceleration . But, you could also depict the velocity, fuel rate, etc with different colored plots, or as a side meter alongside the canvas the plot is being displayed on. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
price_per_book = 24.95 discount = .40 quantity = 60 Here: discounted_price = (1-discount) * price_per_book The discounted price should be price_per_book - discount shipping = 3.0 + (60 - 1) * .75 shipping should be, I think, should be 3.0 + (quantity * .75) total_price = 60 * discounted_price + shipping replace 60 with quantity (quantity * discounted_price) + shipping print total_price, 'Total price' total_price gives: 945.45 Total price and just 24.55(price per book - discount is ) * quantity is $1473 without the shipping, so the total is way off already: I think the following is what you're looking for: price_per_book = 24.95 discount = .40 quantity = 60 discounted_price = price_per_book-discount shipping = 3.0 + (quantity*.75) total_price = (quantity * discounted_price) + shipping print 'Total price: $%d' % (total_price) Total price: $1521 -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Sunday, February 2, 2014 11:11:07 AM UTC-5, David Hutto wrote: > price_per_book = 24.95 > > discount = .40 > > quantity = 60 > > > > Here: > > discounted_price = (1-discount) * price_per_book > > > > The discounted price should be price_per_book - discount > > > > shipping = 3.0 + (60 - 1) * .75 > > shipping should be, I think, should be 3.0 + (quantity * .75) > > > > total_price = 60 * discounted_price + shipping > > replace 60 with quantity (quantity * discounted_price) + shipping > > > > print total_price, 'Total price' > > > > total_price gives: > > 945.45 Total price > > and just 24.55(price per book - discount is ) * quantity is $1473 without the > shipping, so the total is way off already: > > > > > > I think the following is what you're looking for: > > > > price_per_book = 24.95 > > discount = .40 > > quantity = 60 > > discounted_price = price_per_book-discount > > shipping = 3.0 + (quantity*.75) > > total_price = (quantity * discounted_price) + shipping > > print 'Total price: $%d' % (total_price) > > Total price: $1521 My bad, I thought you were using $0.40 as a discount -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Sunday, February 2, 2014 11:38:57 AM UTC-5, MRAB wrote: > On 2014-02-02 16:11, David Hutto wrote: > > > price_per_book = 24.95 > > > discount = .40 > > > quantity = 60 > > > > > The original problem says: > > > > Suppose the cover price of a book is $24.95, but bookstores get a 40% > > discount. Shipping costs $3 for the first copy and 75 cents for each > > additional copy. What is the total wholesale cost for 60 copies? > > > > > Here: > > > discounted_price = (1-discount) * price_per_book > > > > > > The discounted price should be price_per_book - discount > > > > > No, the discount of 0.40 is 40%, not 40 cents. > > > > > shipping = 3.0 + (60 - 1) * .75 > > > shipping should be, I think, should be 3.0 + (quantity * .75) > > > > > No, the shipping is 75 cents starting from the second copy. > > > > > total_price = 60 * discounted_price + shipping > > > replace 60 with quantity (quantity * discounted_price) + shipping > > > > > > print total_price, 'Total price' > > > > > > total_price gives: > > > 945.45 Total price > > > and just 24.55(price per book - discount is ) * quantity is $1473 without > > the shipping, so the total is way off already: > > > > > > > > > I think the following is what you're looking for: > > > > > > price_per_book = 24.95 > > > discount = .40 > > > quantity = 60 > > > discounted_price = price_per_book-discount > > > shipping = 3.0 + (quantity*.75) > > > total_price = (quantity * discounted_price) + shipping > > > print 'Total price: $%d' % (total_price) > > > Total price: $1521 > > > Revised: price_per_book = 24.95 percent_discount = .40 discounted_price = price_per_book - (price_per_book * percent_discount) quantity = 60 shipping = 3.0 + ((quantity - 1)*.75) total_price = (quantity * discounted_price) + shipping print 'Total price: $%d' % (total_price) -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Sunday, February 2, 2014 12:43:01 PM UTC-5, Denis McMahon wrote:
> On Sun, 02 Feb 2014 08:57:03 -0800, David Hutto wrote:
>
>
>
> > Revised:
>
>
>
> > discounted_price = price_per_book - (price_per_book * percent_discount)
>
>
>
> by applying some simple algebra to the right hand side
>
>
>
> price_per_book - (price_per_book * percent_discount)
>
>
>
> "x = (x * 1)" so "price_per_book == (price_per_book * 1)" so rhs becomes
>
>
>
> (price_per_book * 1) - (price_per_book * percent_discount)
>
>
>
> and "(a * x) - (a * y)" == "a * (x - y)" so rhs becomes
>
>
>
> price_per_book * (1 - percent_discount)
>
>
>
> hence:
>
>
>
> discounted_price = price_per_book * (1 - percent_discount)
>
>
>
> --
>
> Denis McMahon
The one just looks out of place compare to using properly defined
names,(algebra aside) like this:
def order_total():
price_per_book = float(raw_input("Enter price per book: $"))
percent_discount_amount = float(raw_input("Enter percent discount
amount(in format example .40): "))
quantity = float(raw_input("Enter quantity of books: "))
first_book_shipping = float(raw_input("Enter first book's shipping: $"))
extra_book_shipping = float(raw_input("Enter extra book's shipping
costs: $"))
percent_discount = price_per_book * percent_discount_amount
amount_of_first_books = 1 # of course it would equal 1
discounted_price = price_per_book - percent_discount
shipping = first_book_shipping + ((quantity - amount_of_first_books) *
extra_book_shipping)
total_price = (quantity * discounted_price) + shipping
print 'Total price: $%d' % (total_price)
order_total()
Or Use with params for iterating through larger amounts of books to
be calculated*
def
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * percent_discount_amount
amount_of_first_book = 1 # of course it would equal 1
discounted_price = price_per_book - percent_discount
shipping = first_book_shipping + ((quantity - amount_of_first_book) *
extra_book_shipping)
total_price = (quantity * discounted_price) + shipping
print 'Total price: $%d' % (total_price)
price_per_book = float(raw_input("Enter price per book: $"))
percent_discount_amount = float(raw_input("Enter percent discount amount(in
format example .40): "))
quantity = float(raw_input("Enter quantity of books: "))
first_book_shipping = float(raw_input("Enter first book's shipping: $"))
extra_book_shipping = float(raw_input("Enter extra book's shipping costs: $"))
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping)
The numbers just seem out of place when a var can be used that properly defines
it, or another way to arrive at the same solution.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
Or a better iterating example for a database of shipping, or ordering books
would be:
import random as r
def
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * percent_discount_amount
amount_of_first_book = 1 # of course it would equal 1
discounted_price = price_per_book - percent_discount
shipping = first_book_shipping + ((quantity - amount_of_first_book) *
extra_book_shipping)
total_price = (quantity * discounted_price) + shipping
print "Book XYZ-%d-ABC \nPrice per book: $%d\nPercent discount amount:
%f\nQuantity of books: %f\nFirst book's shipping: $%f\nextra_book_shipping:
$%f\nTotal price: $%f\n" %
(books,price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping,total_price)
if __name__ == '__main__':
for books in range(0,10):
price_per_book = float(r.randint(1,100))
percent_discount_amount = float(".%d" % r.randint(0,100))
quantity = float(r.randint(0,100))
first_book_shipping = float(r.randint(0,100))
extra_book_shipping = float(r.randint(0,100))
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping)
--
https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
Should have been the following, which just shows the books price as a float as
well, but you get the point by now, I'm sure:
import random as r
def
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * percent_discount_amount
amount_of_first_book = 1 # of course it would equal 1
discounted_price = price_per_book - percent_discount
shipping = first_book_shipping + ((quantity - amount_of_first_book) *
extra_book_shipping)
total_price = (quantity * discounted_price) + shipping
print "Book XYZ-%d-ABC \nPrice per book: $%f\nPercent discount amount:
%f\nQuantity of books: %f\nFirst book's shipping: $%f\nextra_book_shipping:
$%f\nTotal price: $%f\n" %
(books,price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping,total_price)
if __name__ == '__main__':
for books in range(0,10):
price_per_book = float(r.randint(1,100))
percent_discount_amount = float(".%d" % r.randint(0,100))
quantity = float(r.randint(0,100))
first_book_shipping = float(r.randint(0,100))
extra_book_shipping = float(r.randint(0,100))
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping)
--
https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Saturday, February 1, 2014 2:32:22 PM UTC-5, Denis McMahon wrote: > On Fri, 31 Jan 2014 18:14:31 -0700, Scott W Dunning wrote: > > > > > little different from a few things you guys had mentioned. For one, I > > > got the correct time by calculating the number of time run and > > > converting that into seconds then back out to hr:mn:sc. I didn't > > > calculate from midnight. > > > > > SECONDS = 1 MINUTES = 60 * SECONDS HOURS = 60 * MINUTES > > > > > > time_left_house = 6 * HOURS + 52 * MINUTES > > > > This does actually calculate the time in seconds since midnight that you > > left the house > > > > > miles_run_easy_pace = 2 * (8 * MINUTES + 15 * SECONDS) > > > > > > miles_run_fast_pace = 3 * (7 * MINUTES + 12 * SECONDS) > > > > > > time_returned_home = miles_run_easy_pace + miles_run_fast_pace + > > > time_left_house > > > > And this calculates the time in seconds since midnight that you returned > > home > > > > So although you don't realise it, you are actually working in seconds > > since midnight, and then converting seconds back into hours, minutes and > > seconds. > > > > -- > > Denis McMahon A little OT, but these might peak your interest for this: http://en.wikipedia.org/wiki/Epoch_%28reference_date%29 http://en.wikipedia.org/wiki/Leap_second -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
I just happened to find this link: http://effbot.org/tkinterbook/ through this link: https://wiki.python.org/moin/TkInter which ALL happened to stem from this link: https://www.google.com/search?client=ubuntu&channel=fs&q=python+tkinter+tutorials&ie=utf-8&oe=utf-8 On Sun, Feb 2, 2014 at 3:38 PM, Lewis Wood wrote: > Thanks all who replied, will look further into megawidgets and the > Toplevel() function. Is there a way to get a separate window to return > something when closed? > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Calculator Problem
On Sunday, February 2, 2014 4:16:44 PM UTC-5, Charlie Winn wrote:
> Hey Guys i Need Help , When i run this program i get the 'None' Under the
> program, see what i mean by just running it , can someone help me fix this
>
>
>
> def Addition():
>
> print('Addition: What are two your numbers?')
>
> 1 = float(input('First Number:'))
>
> 2 = float(input('Second Number:'))
>
> print('Your Final Result is:', 1 + 2)
>
>
>
>
>
> def Subtraction():
>
> print('Subtraction: What are two your numbers?')
>
> 3 = float(input('First Number:'))
>
> 4 = float(input('Second Number:'))
>
> print('Your Final Result is:', 3 - 4)
>
>
>
>
>
> def Multiplication():
>
> print('Multiplication: What are two your numbers?')
>
> 5 = float(input('First Number:'))
>
> 6 = float(input('Second Number:'))
>
> print('Your Final Result is:', 5 * 6)
>
>
>
>
>
> def Division():
>
> print('Division: What are your two numbers?')
>
> 7 = float(input('First Number:'))
>
> 8 = float(input('Second Number:'))
>
> print('Your Final Result is:', 7 / 8)
>
>
>
>
>
>
>
> print('What type of calculation would you like to do?')
>
> Question = input('(Add, Subtract, Divide or Multiply)')
>
> if Question.lower().startswith('a'):
>
> print(Addition())
>
> elif Question.lower().startswith('s'):
>
> print(Subtraction())
>
> elif Question.lower().startswith('d'):
>
> print(Division())
>
> elif Question.lower().startswith('m'):
>
> print(Multiplication())
>
> else:
>
> print('Please Enter The First Letter Of The Type Of Calculation You
> Would Like To Use')
>
>
>
> while Question == 'test':
>
> Question()
Can anyone point out how using an int as a var is possible, unless it's
something I miss that changed in 3.3 from 3.2:
david@david:~$ python3.2
Python 3.2.3 (default, Sep 25 2013, 18:25:56)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 7 = float(input('First Number:'))
File "", line 1
SyntaxError: can't assign to literal
>>>
david@david:~$ python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 7 = float(input('First Number:'))
File "", line 1
SyntaxError: can't assign to literal
>>>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Calculator Problem
Missed that it's already pointed out, was looking at the google groups
combined email.
On Tue, Feb 4, 2014 at 10:43 AM, David Hutto wrote:
> On Sunday, February 2, 2014 4:16:44 PM UTC-5, Charlie Winn wrote:
> > Hey Guys i Need Help , When i run this program i get the 'None' Under
> the program, see what i mean by just running it , can someone help me fix
> this
> >
> >
> >
> > def Addition():
> >
> > print('Addition: What are two your numbers?')
> >
> > 1 = float(input('First Number:'))
> >
> > 2 = float(input('Second Number:'))
> >
> > print('Your Final Result is:', 1 + 2)
> >
> >
> >
> >
> >
> > def Subtraction():
> >
> > print('Subtraction: What are two your numbers?')
> >
> > 3 = float(input('First Number:'))
> >
> > 4 = float(input('Second Number:'))
> >
> > print('Your Final Result is:', 3 - 4)
> >
> >
> >
> >
> >
> > def Multiplication():
> >
> > print('Multiplication: What are two your numbers?')
> >
> > 5 = float(input('First Number:'))
> >
> > 6 = float(input('Second Number:'))
> >
> > print('Your Final Result is:', 5 * 6)
> >
> >
> >
> >
> >
> > def Division():
> >
> > print('Division: What are your two numbers?')
> >
> > 7 = float(input('First Number:'))
> >
> > 8 = float(input('Second Number:'))
> >
> > print('Your Final Result is:', 7 / 8)
> >
> >
> >
> >
> >
> >
> >
> > print('What type of calculation would you like to do?')
> >
> > Question = input('(Add, Subtract, Divide or Multiply)')
> >
> > if Question.lower().startswith('a'):
> >
> > print(Addition())
> >
> > elif Question.lower().startswith('s'):
> >
> > print(Subtraction())
> >
> > elif Question.lower().startswith('d'):
> >
> > print(Division())
> >
> > elif Question.lower().startswith('m'):
> >
> > print(Multiplication())
> >
> > else:
> >
> > print('Please Enter The First Letter Of The Type Of Calculation
> You Would Like To Use')
> >
> >
> >
> > while Question == 'test':
> >
> > Question()
>
> Can anyone point out how using an int as a var is possible, unless it's
> something I miss that changed in 3.3 from 3.2:
>
> david@david:~$ python3.2
> Python 3.2.3 (default, Sep 25 2013, 18:25:56)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 7 = float(input('First Number:'))
> File "", line 1
> SyntaxError: can't assign to literal
> >>>
>
> david@david:~$ python
> Python 2.7.3 (default, Sep 26 2013, 20:08:41)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 7 = float(input('First Number:'))
> File "", line 1
> SyntaxError: can't assign to literal
> >>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*
--
https://mail.python.org/mailman/listinfo/python-list
Re: Finding size of Variable
On Sat, Feb 8, 2014 at 8:17 AM, Mark Lawrence wrote:
> On 08/02/2014 02:48, Steven D'Aprano wrote:
>
>> On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote:
>>
>> Sorry, I'm only pointing you may lose memory when working with short
>>> strings as it was explained. I really, very really, do not see what is
>>> absurd or obsure in:
>>>
>>> sys.getsizeof('abc' + 'EURO')
>>>>>>
>>>>> 46
>>>
>>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
>>>>>>
>>>>> 37
>>>
>>
>>
>> Why do you care about NINE bytes? The least amount of memory in any PC
>> that I know about is 5 bytes, more than fifty million times more.
>> And you are whinging about wasting nine bytes?
>>
>
One could argue that if you're parsing a particular file, a very large one,
that those 9 bytes can go into the optimization of parsing aforementioned
file. Of, course we have faster processors, so why care?
Because it goes into the optimization of the code one is 'developing' in
python.
>
>> If you care about that lousy nine bytes, Python is not the language for
>> you. Go and program in C, where you can spent ten or twenty times longer
>> programming, but save nine bytes in every string.
>>
>> Nobody cares about your memory "benchmark" except you. Python is not
>> designed to save memory, Python is designed to use as much memory as
>> needed to give the programmer an easier job. In C, I can store a single
>> integer in a single byte. In Python, horror upon horrors, it takes 14
>> bytes!!!
>>
>> py> sys.getsizeof(1)
>> 14
>>
>> We consider it A GOOD THING that Python spends memory for programmer
>> convenience and safety. Python looks for memory optimizations when it can
>> save large amounts of memory, not utterly trivial amounts. So in a Python
>> wide build, a ten-thousand block character string requires a little bit
>> more than 40KB. In Python 3.3, that can be reduced to only 10KB for a
>> purely Latin-1 string, or 20K for a string without any astral characters.
>> That's the sort of memory savings that are worthwhile, reducing memory
>> usage by 75%.
>>
>> Could Python save memory by using UTF-8? Yes. But it would cost
>> complexity and time, strings would be even slower than they are now. That
>> is not a trade-off that the core developers have chosen to make, and I
>> agree with them.
>>
>>
>>
>>
> This is a C +1 to save memory when compared against this Python +1 :)
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask what
> you can do for our language.
>
> Mark Lawrence
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*
--
https://mail.python.org/mailman/listinfo/python-list
Re: Finding size of Variable
On Sat, Feb 8, 2014 at 8:25 PM, Rustom Mody wrote: > On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote: > > One could argue that if you're parsing a particular file, a very large > one, that those 9 bytes can go into the optimization of parsing > aforementioned file. Of, course we have faster processors, so why care? > > Because it goes into the optimization of the code one is 'developing' in > python. > > Yes... There are cases when python is an inappropriate language to use... > So??? > I didn't say she couldn't optimize in another language, and was just prototyping in Python. I just said she was optimizing her python code...dufus. > > Its good to get a bit of context here. > > loop: > jmf says python is inappropriate. > Someone asks him: Is it? In what case? > jmf: No answer > After a delay of few days jmp to start of loop > > loop: mov head,up_your_ass push repeat pop repeat jmp loop [BTW: In my book this classic trolling] > -- > And the title of this book would be..."Pieces of Cliche Bullshit Internet Arguments for Dummies" https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Finding size of Variable
On Sat, Feb 8, 2014 at 9:59 PM, Chris Angelico wrote: > On Sun, Feb 9, 2014 at 1:56 PM, David Hutto > wrote: > >> > >> Yes... There are cases when python is an inappropriate language to > use... > >> So??? > > > > > > I didn't say she couldn't optimize in another language, and was just > > prototyping in Python. I just said she was optimizing her python > > code...dufus. > > And there are a *lot* of cases where that is inappropriate language to > use. Please don't. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > it's also inappropriate for him to call people trolls, while they're just commenting on why what she might be using is a necessity for her particular case of developing in Python, and not using another language, yet. "He started it!" :P -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Finding size of Variable
Maybe I'll just roll my fat, bald, troll arse out from under the bridge, and comment back, off list, next time. -- https://mail.python.org/mailman/listinfo/python-list
Tanglin With Alpha
Just as a quick survey...Are individual programmers happier with tangling with the alpha code, or more comfortable with beta versions, or does it matter, dependant on the circumstances? -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
r character is e.g. a Latin h or a Cyrillic һ. Assuming the > original author wasn't being intentionally obfuscatory, if the rest of > the identifier is Cyrillic then the character is probably also > Cyrillic. If it's a one-character identifier, then hopefully the rest > of the module is consistent and you can guess from that. If the > identifier in question is just one symbol though, then you have a lot > less context. > > > > >> Second, at least in the case of decorators, while I don't dispute that > >> they can harm readability, I think that in the majority of cases they > >> actually help it. > > > > But that is not a fair comparison now, is it. What you are doing here > > is comparing actual use, to a worst case doom scenario. > > I contend that there is no scenario with arbitrary Unicode identifiers > where readability is improved. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
This brings us into a juxtaposition between how cultures have tried to hybridize their mentalities, into more of an empathic means of communication via a formulatic set of coding, and the philosophy thereof, and, 3D renderings of what we visualize, and how we come to the conclusions of these philosophies of what we want to accomplish within the technological age we live within. Maybe not the best way I could explain it, but it has a bunch of fancy words in it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
Caveat emptor(I have a copy of Latin For Idiots). When you get through with refining, in whatever language, the open source/proprietary app you're developing, is there anyway you can say for sure how many people's work went into things under different licenses accompanying what you may have copy and pasted into it, and neither can the individuals who developed the systems they "designed", and threw a license on it? *Standing on the shoulder's of giants can still be unsteady ground.* -- https://mail.python.org/mailman/listinfo/python-list
Re: Python IM server
hint: Tkinter server db update the tkinter apps, with the new data, after moving a line down On Tue, Apr 1, 2014 at 1:06 AM, Miki Tebeka wrote: > > I want to develop a instant message server, simply has user and group > entity. > > Is there any better existing open-source one? > > Thus I can download and have a look. > You can take a look at Twisted Words ( > https://twistedmatrix.com/trac/wiki/TwistedWords). > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 1:45 AM, Rustom Mody wrote:
> On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote:
>
> > Haskell has nifty pattern-matching syntax for this that looks quite close
> > to the mathematical hybrid function syntax, but in Python, we're limited
> > to explicitly using an if. If I were coding this, and I'm not, I'd wrap
> > it in a function. One advantage of a state variable rather than a
> > continuous time function is that we can do this:
> > def accel(state):
> > return {NO_BRAKING: 0.0,
> > LOW_BRAKING: 0.2,
> > MID_BRAKING: 0.425,
> > HIGH_BRAKING: 0.85}[state]
>
> Neat
> I would put the dict in a variable. And those _BRAKINGs are GALLing me!
>
> breaking = {NO:0.0, LOW:0.2, MID:0.425:, HIGH:0.85}
> def accel(state): return breaking[state]
>
>
> In using Haskell, I often wish for dicts especially python's nifty
> dict-literals
>
>
>
This still omits the viscosity(+-) of the enclosed, or exposed
track/environmental variables of the system in which the objects traveling.
http://www.synlube.com/viscosit.htm
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*
--
https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
> > > >> (1) v = u + at > >> (2) s = 1/2(u + v)t > >> (3) s = ut + 1/2(at^2) > >> (4) v^2 = u^2 + 2as > >> > >> Only (1) and (3) are needed. > > > > Okay, what's u here? Heh. > > u is the initial velocity; v is the velocity after accelerating at a for > time t. > This assumes that the viscosity is in a state of superfluidity, and in a perfect state between itself, and it's traveling environment. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
u is the initial velocity from a starting/resting point, not a static speed at that point, and begins to accelerate, over a particular timeframe, in which it's momentum is not stopped by friction on which the rails/environment it travels upon has, or the similar properties the object might have during acceleration in relation to the environment it travels within. So the object has a starting point at which there is no equal, or opposing force, as it begins to accelerate from a resting position(Newton: an object will remain in motion, until acted upon by an equal or opposite force, and in this case the motion is propulsion of the object, or the newtons of propulsion, until it is moving at the exact speed of the propulsion applied to the object->Vo-V1, with 0 friction/viscosity during this timeframe). The difference in our opinions, seems to be that there is an initial resting state, and not at an already accelerated motion that has reached it's maximum capacity. So there is a dynamic in my mind's eye, where the object is at a "resting" point initially, and either the environment, or the object can maneuver their own viscosity in relation to the other. On Tue, Apr 1, 2014 at 2:39 AM, Ian Kelly wrote: > On Tue, Apr 1, 2014 at 12:24 AM, David Hutto > wrote: > >> > >> >> (1) v = u + at > >> >> (2) s = 1/2(u + v)t > >> >> (3) s = ut + 1/2(at^2) > >> >> (4) v^2 = u^2 + 2as > >> >> > >> >> Only (1) and (3) are needed. > >> > > >> > Okay, what's u here? Heh. > >> > >> u is the initial velocity; v is the velocity after accelerating at a for > >> time t. > > > > > > This assumes that the viscosity is in a state of superfluidity, and in a > > perfect state between itself, and it's traveling environment. > > I fail to see how this is relevant. I would assume that the amount of > friction is already modeled in the acceleration constants; if it were > zero then the brakes would be nonfunctional and the train would not be > able to accelerate or decelerate at all. In any case, a change in > friction simply works out to a change in acceleration. The equations > above still hold true. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
You would be assuming a quantum leap type theory, that the object has no Vo->V1, it just adjusts to the constant immediately, instead of what I would call the quantum leap,without other 'theories' involved, that it has a classical physics type movement in which it can accelerate from a resting position, to a velocity, and then regain orbit: http://wiki.answers.com/Q/What_is_a_quantum_leap On Tue, Apr 1, 2014 at 3:21 AM, David Hutto wrote: > u is the initial velocity from a starting/resting point, not a static > speed at that point, and begins to accelerate, > over a particular timeframe, in which it's momentum is not stopped by > friction on which the rails/environment it travels upon has, or the similar > properties the object might have during acceleration in relation to the > environment it travels within. > > So the object has a starting point at which there is no equal, or opposing > force, as it begins to accelerate from a resting position(Newton: an object > will remain in motion, until acted upon by an equal or opposite force, and > in this case the motion is propulsion of the object, or the newtons of > propulsion, until it is moving at the exact speed of the propulsion applied > to the object->Vo-V1, with 0 friction/viscosity during this timeframe). > > The difference in our opinions, seems to be that there is an initial > resting state, and not at an already accelerated motion that has reached > it's maximum capacity. > > > So there is a dynamic in my mind's eye, where the object is at a "resting" > point initially, and either the environment, or the object can maneuver > their own viscosity in relation to the other. > > > On Tue, Apr 1, 2014 at 2:39 AM, Ian Kelly wrote: > >> On Tue, Apr 1, 2014 at 12:24 AM, David Hutto >> wrote: >> >> >> >> >> (1) v = u + at >> >> >> (2) s = 1/2(u + v)t >> >> >> (3) s = ut + 1/2(at^2) >> >> >> (4) v^2 = u^2 + 2as >> >> >> >> >> >> Only (1) and (3) are needed. >> >> > >> >> > Okay, what's u here? Heh. >> >> >> >> u is the initial velocity; v is the velocity after accelerating at a >> for >> >> time t. >> > >> > >> > This assumes that the viscosity is in a state of superfluidity, and in a >> > perfect state between itself, and it's traveling environment. >> >> I fail to see how this is relevant. I would assume that the amount of >> friction is already modeled in the acceleration constants; if it were >> zero then the brakes would be nonfunctional and the train would not be >> able to accelerate or decelerate at all. In any case, a change in >> friction simply works out to a change in acceleration. The equations >> above still hold true. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com > <http://www.hitwebdevelopment.com>* > -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>* -- https://mail.python.org/mailman/listinfo/python-list
