Re: 1 Million users.. I can't Scale!!
> Quite true and this lack of clarity was a mistake on my part. Requests > from users do not really become a significant part of this equation > because, as described above, once a user subscribes the onus is upon us > to generate messages throughout a given period determined by the number > of updates a user has subscribed to receive. > So you are trying to SEND a million times several packets every 5 minutes? No way Python is the bottleneck in that volume. I have a POS app in Python that handles 10,000 packets per SECOND including a MySQL lookup. You have a bottleneck, but its not Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedded Systems Python?
I developed for my former employee a thin client whose primary purpose was AS400 connectivity. This required a fairly complex interactive gui configuration which I wrote in Python. This system could also be configed by a remote manager. Wrote that also in python using UDP sockets. The hardware was 64Mb memory and 64Mb compact flash. OS wa 2.4.20 linux from Debian I did a lot of cleanup removing unneeded modules but other than that, standard Python 2.3.4 worked great. Dennis Clark wrote: > Hi all, > > I've looked through the threads about embedded Python that are a year > and a half old, and I thought that I'd ask this question now to see if > anything has changed. > > Has anyone, or is anyone working with Python in an embedded Linux > environment? Mine is NO where near as constrained as a cell phone since > I've got plenty of memory to work with, I'm just running a Linux 2.4 kernel > on an ARM9 platform. > > Are there success stories for Python on embedded Linux systems today? > The embedded Java JVM's seem to all be propriatary and have quite high > license fees (don't mention Kaffe, it seems pretty fragile to me.) > > I'm a bit of a newb when it comes to Python, is there anyone with experience > compiling it on Linux platforms that can offer me pointers to try this out > myself? > > thanks, > DLC > -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
I see several on this list have their opinion and lean toward VB. Not me, done that and vc++. Hate'em. Been developing 30 years and I like control over what I'm doing and Python and Tkinter are the best tools I've ever used. And for the most part IDE's like BOA Constructor are just confusing. IMHO. [EMAIL PROTECTED] wrote: > I'm a manager where I work(one of the cogs in a food service company). > The boss needed one of us to become the "tech guy", and part of that is > writing small windows programs for the office. He wants the development > work done in house, and he knows I am in school for a CS minor. I know > basic C++(Part 2 of that is in the fall), and I will be taking Java 1 > in the fall also. What is the easiest way for me to make windows > programs that will do basic things like(Inventory, Menu Management, > etc...)? I have heard visual basic is where it's at. I want to keep an > open mind though, so I am wondering if python could be an option. The > programs have > no speed requirement. But they must be pretty, and not confuse my > boss. Plus he wants well documented help for each function. I asked the > windows programming group, but I thought I would ask here also. Thanks. > > Xeys > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> > Theres even a version of Python for .NET, called IronPython. The major > advantage of this is that you get to program in Python, which I can > tell you from experience is a lot more enjoyable and pain-free than C, > C++, Fortran, or Java (and, I would highly suspect, VB and C#). But > apparently the available GUI builders aren't as good for Python - > having not done a whole lot of GUI building in general, I'll leave this > for more experienced people to judge. > From 30 years of application development experience I will tell you NOT HUMBLY, that Python is easily the most productive, the most read-write and the most elegant of any of the above. Handsdown better than Java, the runner up in that group. Now let me explain somthing about "GUI buiders" or IDE's, from some experience, Visual Studio being the worst. The IDE takes a picture of what they think you want to do, they then ask you some questions about the components, and they afford you the opportunity to modify the properties of the objects. Then they store all this info in tables and build code at buildtime. The tables are rarely documented well and sometimes have very confusing layouts. So you usually go back to the IDE to make changes and if the changes are compilcated and there are interconnected events to consider, you better know what you are doing. I consider it a nightmare of hiding code from the programmer. The IDE is taking on the burden of a couple layers of abstraction and the IDE ain't that smart. You would be wise, if you choose Python to choose Tkinter or WxWindows and learn the properties of a radio button and how to trigger events. Writing simple GUIs is not that hard. Then after you know what is going on behind the scenes, a BOA Constructor will not be as mysterious or dangerous. -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> > You are quite correct to point out how much better it is to know what is > going on behind the scenes. But heck, once you know how to extract square > roots - you need to let the computer do it! > > GUI interfaces should be the same deal! > Thomas Bartkus > I think I pretty much agree. I essentially code my own gui builder but in text files. I just think it is really important to emphasise the operative "but once you know how" in your comments. Then some would counter with "oh, so we should code everthing in assembler?" Ouch. No, I will admit there is judgement required. Everything should be done the easiest way, with the qualification that you need to understand how using someone else's shortcut leaves you vulnerable. This guy is trying to get started and looking for our advice and I saw most of the advice leaning towrd VB (aarrgh!) and I thought I should give him other food for thought. I'm going to take this opportunity for a short rant. I believe our society ( I'm an old fart) is drifting toward a VERY small percentage of people knowing, caring or even being curious about "how stuff works". I teach high school geometry and am APPALLED at the apathy. I am concerned about the future of this nation, economically, but spirtually as well. So, this influences my advice. Know how your stuff works if it is reasonable. Tom Wolfe talked in a book about two kinds of kids. Those that play video games and those that make video games, and the numbers of the latter is shrinking. -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> I may > try to convince the boss that I can write dos programs for the existing > machine. If we get any kind of upgrade, I'm sure it will be able to run > linux with X and a low overhead window manager. If that happened, I'd > be able to use python and this "tk" thing you have talked about and > make something that will work for him, am I correct? The other > alternative is to install console mode linux on it and hope that the > ncurses library can be used by python. 1. Python/Tkinter runs perfectly well on Win. don't need Linux. In fact, easier to install on Win32 than Linux. 2. The hardware you describe would actually get much better performance from Linux than Win, if you are confident in going to Linux. 3. Python/Tkinter OR Visual Basic may perform a little doggy but not too bad -- The main thing is memory. 128mb works fine for moderm Linux or Win32 but not really fast. 4. I'm not aware of Python ncurses. Doesn't sound like fun. I mean 2 hours of your pay buys 256MB memory. Unless you are free, even then -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> I don't want to start a flamewar here - > No heat, no flames. Everyone's cool > Let me emphasize a little more. Even though Python itself is great, I think we > don't have quite yet tools that offer > Ya know, I just don't know enough about javaworld. The language I do not like. I wonder what percentage of the tools you refer to are Eclipse and not Java per se. ?? I don't know. The really big bucks of IBM sent Eclipse through the roof. Python reminds me more of Linux. Incredible no of packages, kinda disjointed, docs pretty bad, not integrated. But amazing stuff if you have the stomach for it. (seen pygame?) Maybe Python will get a daddy someday. Comes down to preference. Isn't it absolutely amazing how many choices we have. Remember the 70's - Cobol, ASM, C, Basic.CICS(shudder) I am pleased that folks on a Python list feel free to praise other technologies. That's neat. -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> About teaching in the exact sciences: I think we need a more hands-on > applied approach, to some extent this holds for the entire school > system. YES! As a geometry(& trig) teacher, I am going to have them build a shed, a kite, a sundial. I would love some doable ideas for hands on which would teach more principles without being major construction projects. -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
> Wow! How about a sextant? > Simple device really. And a great practical demonstration of trigonometry. > Excellent idea, even found a few how to sites. We'll do it. Any others? I think I am going to have them build a shed because they need to get their hands on SOMETHING. But the geometry/time ratio is pretty poor. Anyone have any construction ideas: High geometry/low work would be great. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for everything?
Python is in my opinion the best "all-purpose" language ever designed ( lisp is extremely cool but not as all purpose.) Much more elegant than perl and far far easier to do cool things than java (java is c++ on valium). HOWEVER, "all purpose" needs a little disclosure. A well coded C program may be 100 times faster than Python. C forces you to learn some things about relative addressing and memory management. C is pretty much required for interrupt handling. Python is coded in C. (everthing is coded in C, including C) The C language embodies a language design philosophy which has influenced everything for 30 years. So Python is just a wonderful way to learn about things like algorithms, with relatively little pain. But the bottom line for a would be computer scientist is that Python is sort of like a model or an abstraction of C (which itself is a very weak (but convenient) model of the CPU) IMHO There probably is NO college where you can get out of C++ and Java. Too bad. [EMAIL PROTECTED] wrote: > I posted a article earlier pertaining programming for my boss. Now I am > gonna ask a question about programming for myself. I just finished my > first C++ Class. Next semester is a class on encryption(and it's > probably gonna be a math class too). And finally back in programming in > the fall with C++ and Java 1. The C++ will cover pointers, and linked > lists, sorting algorithms, etc... I run linux and OS X. I have read in > the old days that C was used for everything. It was a systems > programming language, and also did a lot of the same stuff Bash scripts > and perl do now. So, in that era, C did it all, from short to tall. My > question is, can Python "do it all"? I am wondering what to learn as my > scripting language. I have read that perl is good up to about 250 > lines, and after that it gets kind of hairy. However, from what little > I have heard about Python, it's very well suited for readability due to > the whitespace requirements of the language, and very good for large > projects due to it's large amount of modules and it's object oriented > structure. I would like opinions as to the suitability of Python as a > general purpose language for programming unix, everything from short > scripts to muds. Thanks for your patience, opinions, and comments. > > Xeys > > -- http://mail.python.org/mailman/listinfo/python-list
Re: What are the other options against Zope?
Peter Hansen wrote: > godwin wrote: > >> I wanna thank Martin for helping out with my ignorance concerning >>execution of stored procedure with python. Now i have decided to write >>a web app that googles into my companies proprietary database. >> > > Just checking... do you really mean "googles", or is that in your mind a > synonym for "search"? > > >>I need >>to know whether zope is good for that job. >> > > For which part of it? The web part, or the searching part? It's not > likely sufficient for the searching part, since it doesn't include > database interfaces other than to its own ZODB. What proprietary > database is involved? > > -Peter > I think the guy might like to know what Zope is. I went to an IBM all day once, can't even remember the name of their "web services". At smoke breaks would compare notes with other attendees. I'm not sure we ever understood, but we all agreed the problem was "undefined terms" which I call organic buzz words. Zope is like that to me. I ask what is it and the answer sounds like "Oh, it's oierbv for the zxcvioupo of 7cvn^djh'. Now understand, I know what very well what Python, Apache, PhP, MySQL, IE and javascript do. I just don't know what Zope does. And if the answer is going contain phrases like "brings together" or "sits on top of", don't bother. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: What are the other options against Zope?
> either... It sits under... Well that's a relief, cause ...sits on top of was confusing. > A rather object-oriented system for managing and serving web > applications and data (using object inheritance for common behavior, > etc.) This makes Zope a toolkit, not an end application itself. So that would make it Apache, with a Python CGI. Oh wait, Apache has a Python CGI which can access Data bases and send objects to the client. A web application is you deliver am html page and the user fills in some forms, then submits the form, which is then validated and another form is delivered. Right? Cool idea, IBM had that in 1975 it was called CICS. I once asked my son-in-law tech support guy what is the Windows registry, what does it do? He thought for a while and said "Think of it as the soul of the machine". So I thought about it as the soul of the machine for a while, then I asked; "You don't know, do you", and he said "No." -- http://mail.python.org/mailman/listinfo/python-list
Re: What are the other options against Zope?
> I did already post a serious reply, but now I'm afraid I've been > trolled. :-P > I hope you did not think I was dissing your response, because I certainly was not and in fact recognized your response as a sincere effort to enlighten. To whomever I directed sarcasm I apologize. My frustration is 20 years old and has nothing to do with you or Zope. Anyway, thanks Terry, I still don't know what Zope is but I need to accept that it's just a toolkit and I'm not gonna know until I dig in and as long as my web needs are simple, I probably won't. -- http://mail.python.org/mailman/listinfo/python-list
Re: What are the other options against Zope?
> It's an object oriented database, with a structure that is similar to > files and directories in an ordinary OS. > > But it is a lot smarter, because the files and directories are actually > objects with different attributes and parameters. > > The methods on these objects can then be called eg. from a web browser > with different parameters. But you can also use other protocols than > http like dav, ftp etc. Well, that's interesting. I've never seen an explantion like this. Actually I think I have, and was too dumb to realize what I was reading. A data base with properties and methods. Cool. -- http://mail.python.org/mailman/listinfo/python-list
PROBLEM?? deepcopy
I wrote the following to prove to myself that
deepcopy would copy an entire dictionary
which contains an instance of a class to
one key of another dictionary.
Note that after copying adict to ndict['x']
I delete adict.
Then ndict['x'] contains a good copy of adict.
works great.
class aclass:
def __init__(s):
s.anint = 123
aninstance = aclass()
adict = {}
adict['y'] = aninstance
ndict = {}
ndict['x'] = copy.deepcopy(adict)
del adict
print ndict
print ndict['x']['y']
print ndict['x']['y'].anint # this line prints 123
print
Then in the following code when I try to deepcopy
s.glob.objs I get following error
Note that s.glob.objs is a dictionary and I am
attempting to copy to a key of s.save, another dict,
just like above.
??
s.glob.objs may have several keys, the data for each
will be instance of classes like line and circle.
Those instances will have tkinter canvas objects in them.
class Graph:
def __init__(s):
class DummyClass: pass
s.glob = DummyClass()
s.glob.objs = {}
.. # here add some instance of objects like
.. # circles and lines to s.glob.objs
# instantiate dialog
s.DI = dialog(s.glob)
class dialog:
def __init__(s,glob):
s.glob = glob
s.save = {}
def proc(s):
cur = someint
s.save[cur] = copy.deepcopy(s.glob.objs)
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "/home/phil/geo/g.py", line 303, in enter
else:s.proc()
File "/home/phil/geo/g.py", line 245, in proc
s.save[cur][k] = copy.deepcopy(s.glob.objs[k][0])
File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python2.3/copy.py", line 307, in _deepcopy_inst
state = deepcopy(state, memo)
File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python2.3/copy.py", line 270, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python2.3/copy.py", line 307, in _deepcopy_inst
state = deepcopy(state, memo)
File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python2.3/copy.py", line 270, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/lib/python2.3/copy.py", line 206, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/local/lib/python2.3/copy.py", line 338, in _reconstruct
y = callable(*args)
File "/usr/local/lib/python2.3/copy_reg.py", line 92, in __newobj__
return cls.__new__(cls, *args)
TypeError: function() takes at least 2 arguments (0 given)
--
http://mail.python.org/mailman/listinfo/python-list
More On - deepcopy, Tkinter
I posted the following yesterday and got no response
and did some testing simplifying the circumstances
and it appears that deepcopy fails when the object
to be copied contains a reference to a Canvas Object.
Perhaps any Tkinter object, didn't get that far.
The problem arises because I have a geometry tutorial
with a progression of drawings and want the students to
be able to go "back". Creating "snapshots" of points
in time in the tutorial makes a clean and elegant solution
possible. Other solutions I am trying to come up with are
very messy.
It is frustrating to think that in a language like python
there might be things which you can't make a copy of.
That is bizarre enough to wonder about a deep flaw or
hopefully I'm just doing something very wrong.
Any ideas appreciated.
phil wrote:
> I wrote the following to prove to myself that
> deepcopy would copy an entire dictionary
> which contains an instance of a class to
> one key of another dictionary.
> Note that after copying adict to ndict['x']
> I delete adict.
> Then ndict['x'] contains a good copy of adict.
> works great.
>
>
> class aclass:
> def __init__(s):
> s.anint = 123
> aninstance = aclass()
> adict = {}
> adict['y'] = aninstance
>
> ndict = {}
> ndict['x'] = copy.deepcopy(adict)
> del adict
> print ndict
> print ndict['x']['y']
> print ndict['x']['y'].anint # this line prints 123
> print
>
> Then in the following code when I try to deepcopy
> s.glob.objs I get following error
> Note that s.glob.objs is a dictionary and I am
> attempting to copy to a key of s.save, another dict,
> just like above.
> ??
> s.glob.objs may have several keys, the data for each
> will be instance of classes like line and circle.
> Those instances will have tkinter canvas objects in them.
>
> class Graph:
> def __init__(s):
> class DummyClass: pass
> s.glob = DummyClass()
> s.glob.objs = {}
> .. # here add some instance of objects like
> .. # circles and lines to s.glob.objs
> # instantiate dialog
> s.DI = dialog(s.glob)
>
> class dialog:
> def __init__(s,glob):
> s.glob = glob
> s.save = {}
>
> def proc(s):
> cur = someint
> s.save[cur] = copy.deepcopy(s.glob.objs)
>
> Exception in Tkinter callback
> Traceback (most recent call last):
>File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
> return self.func(*args)
>File "/home/phil/geo/g.py", line 303, in enter
> else:s.proc()
>File "/home/phil/geo/g.py", line 245, in proc
> s.save[cur][k] = copy.deepcopy(s.glob.objs[k][0])
>File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
> y = copier(x, memo)
>File "/usr/local/lib/python2.3/copy.py", line 307, in _deepcopy_inst
> state = deepcopy(state, memo)
>File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
> y = copier(x, memo)
>File "/usr/local/lib/python2.3/copy.py", line 270, in _deepcopy_dict
> y[deepcopy(key, memo)] = deepcopy(value, memo)
>File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
> y = copier(x, memo)
>File "/usr/local/lib/python2.3/copy.py", line 307, in _deepcopy_inst
> state = deepcopy(state, memo)
>File "/usr/local/lib/python2.3/copy.py", line 179, in deepcopy
> y = copier(x, memo)
>File "/usr/local/lib/python2.3/copy.py", line 270, in _deepcopy_dict
> y[deepcopy(key, memo)] = deepcopy(value, memo)
>File "/usr/local/lib/python2.3/copy.py", line 206, in deepcopy
> y = _reconstruct(x, rv, 1, memo)
>File "/usr/local/lib/python2.3/copy.py", line 338, in _reconstruct
> y = callable(*args)
>File "/usr/local/lib/python2.3/copy_reg.py", line 92, in __newobj__
> return cls.__new__(cls, *args)
> TypeError: function() takes at least 2 arguments (0 given)
>
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: More On - deepcopy, Tkinter
> The deepcopy protocol does allow you to specify how complicated objects > should be copied. Try defining __deepcopy__() in your objects to just copy > the reference to the Canvas object instead of the object itself. I can't figure out from the docs what __deepcopy__ is or how it works. I have about 25 classes of drawn objects. for instance class linefromslope creates an instance of class line. One of my "ugly solutions" involves a class prop: within each class, put properties like slope and midpoint within the self.prop instance and making a copy of that. Would __deepcopy__ facilitate this? Or am I assuming too much: is __deepcopy__ just a method I invent to do what I want? -- http://mail.python.org/mailman/listinfo/python-list
Re: More On - deepcopy, Tkinter
> but you clearly haven't > been getting the results from this forum that you expected. > Yes I have, this is a wonderful forum. I was just providing more info due to more testing. -- http://mail.python.org/mailman/listinfo/python-list
Re: More On - deepcopy, Tkinter
Thanks, I used some of your methods and believe it is now
working.
I also did a lot of experiments, which I've needed to do,
investigating when references vs values are passed and
returned. Not as obvious as I thought.
Duncan Booth wrote:
> phil wrote:
>
>
>>
>>
>>>The deepcopy protocol does allow you to specify how complicated
>>>objects should be copied. Try defining __deepcopy__() in your objects
>>>to just copy the reference to the Canvas object instead of the object
>>>itself.
>>>
>>
>>I can't figure out from the docs what __deepcopy__ is or how it
>>
>>works.
>>I have about 25 classes of drawn objects. for instance
>>class linefromslope creates an instance of class line.
>>One of my "ugly solutions" involves a class prop: within each class,
>>put properties like slope and midpoint within the self.prop instance
>>and making a copy of that.
>>Would __deepcopy__ facilitate this?
>>Or am I assuming too much: is __deepcopy__ just a method
>>I invent to do what I want?
>>
>>
>
> The docs say:
>
>
>>In order for a class to define its own copy implementation, it can
>>define special methods __copy__() and __deepcopy__(). The former is
>>called to implement the shallow copy operation; no additional
>>arguments are passed. The latter is called to implement the deep copy
>>operation; it is passed one argument, the memo dictionary. If the
>>__deepcopy__() implementation needs to make a deep copy of a
>>component, it should call the deepcopy() function with the component
>>as first argument and the memo dictionary as second argument.
>>
>
> __deepcopy__ is a method which overrides the default way to make a deepcopy
> of an object.
>
> So, if you have a class with attributes a, b, and c, and you want to ensure
> that deepcopy copies a and b, but doesn't copy c, I guess you could do
> something like:
>
>
>>>>class MyClass:
>>>>
>_dontcopy = ('c',) # Tuple of attributes which must not be copied
>
>def __deepcopy__(self, memo):
> clone = copy.copy(self) # Make a shallow copy
> for name, value in vars(self).iteritems():
> if name not in self._dontcopy:
> setattr(clone, name, copy.deepcopy(value, memo))
> return clone
>
>
>>>>class Copyable(object):
>>>>
> def __new__(cls, *args):
> print "created new copyable"
> return object.__new__(cls, *args)
>
>
>
>>>>m = MyClass()
>>>>m.a = Copyable()
>>>>
> created new copyable
>
>>>>m.b = Copyable()
>>>>
> created new copyable
>
>>>>m.c = Copyable()
>>>>
> created new copyable
>
>>>>clone = copy.deepcopy(m)
>>>>
> created new copyable
> created new copyable
>
>>>>m.a is clone.a
>>>>
> False
>
>>>>m.c is clone.c
>>>>
> True
>
>
> As you can see, the deepcopy only creates deep copies of 2 of the 3
> attributes, 'c' is simply copied across as a shallow copy.
>
> and if you subclass MyClass you can modify the _dontcopy value to add
> additional attributes which must not be copied.
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: Async PySerial (was Re: pySerial Windows write problem)
I use PySerial in a 16 line data collection system with LOTS of threads, and yes am frustrated by read(). This sounds excellent, keep us updated. BTW, haven't done any event driven Python except Tkinter. Would this a class library which would let you define an event and a handler? Do you have a one line code example? Thanks. Peter Hansen wrote: > Neil Benn wrote: > >>PySerial doesn;t have any kind of event firing to notify you when data >>is available. The way I get round this is to have a loop polling (in a >>seperate thread) to see if any data is available (it's a method on the >>interface), then read all the data in and fire this off to my >>listeners/observers with the read data. >> > > On that note, I've got a preliminary version of something I call "Bent" > (think "slightly Twisted") which is focused for now on providing an > asynchronous version of PySerial which is designed around the > event-driven model instead of its current polled scheme. > > It shares a number of features with the Twisted-based PySerial port > (also done by Chris Liechti, for the Twisted team, judging by the code > comments) but doesn't require one to adopt the whole Twisted framework. > Basically it provides you with the equivalent of one "reactor" per > thread for PySerial stuff. On Win32 only for now. There are other > limitations too. Not ready for prime time. > > On the plus side, it's been letting me convert my serial stuff to be > fully event-driven and with the resulting much lower latencies and > better CPU efficiency, while keeping my code more "traditional" instead > of having to force it entirely into the Twisted point of view. > > Just an FYI. And, obviously, to hear back from those interested. I > don't know if this is something that should be contributed to the > PySerial project (it's more of a rewrite than an add-on), or set up as a > new project, or passed around quietly behind the scenes for a while. > No docs yet, no contrived examples (but various pieces of working code > in real daily use). Did I mention it wasn't ready for prime time? > > If you've ever been annoyed having to do .read(1) to get characters one > at a time in PySerial, or .read(100) with a timeout, or whatever, this > might be of interest to you... > > -Peter > -- http://mail.python.org/mailman/listinfo/python-list
Re: Decline and fall of scripting languages ?
> Kay Schluehr ([EMAIL PROTECTED]) wrote: > : No good news for scripting-language fans: > > : http://www.phpmag.net/itr/news/psecom,id,23284,nodeid,113.html > What incredible horse dooey. The only thing that NEVER "penetrates the enterprise space" is good sense. Does anyone read history books? There is no such thing as a large corporation that is not doomed. There are a few names which are older than 1/2 a century but the companies and players are unrecognizable. We have barbeque joints in Texas older than IBM. And noone from 1970 would recognize IBM. The "enterprise" is good for one thing. Devouring each other. The "enterprise"'s opinion about what is good for the future is like this broker I knew in Dallas. All you had to do was find out which stock he was recommending, then short it. -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI tookit for science and education
> > Tkinter is the default GUI for Python, it runs on lots of platforms > and often comes already installed (on Linux or Unix distributions). > I use Tkinter for a geometry course. I think it is fairly easy to learn, much easier than say VB. VERY portable and pretty well documented and very well supported on this list. It doesn't have much math built in. For functions you have to plot points. -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI tookit for science and education
> As I said, I'm looking for multiplatform solution. > So, I will go with Python, Tk and C++ (for algorithm and critical parts > of applications). Tk is simple, very simple, Python I like, C++ I love, > as I'm professional C++ programmer. Good choice! -- http://mail.python.org/mailman/listinfo/python-list
Fonts
I'm cpmpletely lost on fonts. I'm using Tkinter I do medarial = '-*-Arial-Bold-*-*--24-*-*-*-ISO8859-1" or Courier or Fixed in various sizes. Works great on my RH 7.2 But a small embedded system Im working on, nothing seems to work, almost everything falls back to a fixed 12 The X*4 fontpaths are the same and all the fonts, 75, 100, misc Speedo, PEX, etc are there. There is something wrong with where the fonts are. Help? -- http://mail.python.org/mailman/listinfo/python-list
tkinter entry eat chars?
In a Tkinter entry field (or Pmw entry) how could I eat charactres? Say a certain char is keyed in. Say & I notice in the event handler for . I don't want any more charactres to display or be in the field until I handle a see, in the event handler, another character. Say ? Can the event handler somehow destroy the char? Thanks -- http://mail.python.org/mailman/listinfo/python-list
tkinter absorb chars
Sorry for the repost, but moderator jeld the last one, In a Tkinter entry field (or Pmw entry) how could I eat charactres? Say a certain char is keyed in. Say & I notice in the event handler for . I don't want any more charactres to display or be in the field until I handle, in the event handler, another character. Say ? Can the event handler somehow destroy the chars in the meantime? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter absorb chars
Jeff Epler wrote:
On Wed, Mar 02, 2005 at 04:58:03PM -0600, phil wrote:
Sorry for the repost, but moderator
jeld the last one,
We saw both posts.
In a Tkinter entry field (or Pmw entry)
how could I eat charactres?
create a binding on the widget for the particular character you want to
treat specially. If you want to suppress that character, return the
string "break" from the binding. Example:
from Tkinter import *
t = Tkinter.Tk()
e = Tkinter.Entry(t); e.pack()
e.bind("x", lambda event: "break")
Jeff
Thanks, that helps.
But after noticing an'&' I want to 'disappear'
All characters form the field. But I need to process
those characters in the event handler.
I've already bound ' to inputevent.
Are you saying if I just do: return 'break' from
inputevent the characters will never see light?
I'll try it.
--
http://mail.python.org/mailman/listinfo/python-list
Suspicious header
everything I post to this list bounces awaiting moderator approval, due to suspicious header. COuld someone tell me what's wrong. I'm on lots of list with no problem. -- http://mail.python.org/mailman/listinfo/python-list
tkinter credit card scan
Problem, the focus is on a field which has contents and I scan the credit card card, which is keyboard input. The field is altered and a bunch of chars fly acroos the field. messy. Ok, I can solve this in a very clumsy manner. 1. I see the first character of the scan, '%', configure the field to show ' ' temporarily, do a get() and after the scan is thru, restore the contents. clumsy and messy, but ok. The WORST PROBLEM, is if the previous contents of the field had been selected, which it would be if it is the first field in the payment window or they had tabbed to the field. The the ist char of the scan, the '%' replaces the contents before I can do a get(). Suggestions? -- http://mail.python.org/mailman/listinfo/python-list
thread/queue bug
I have a very strange bug. A thread in a .pyc stops dead. This program has many threads and queues and has worked great for months. One thread listens for UDP messages from other programs, and puts the messages in listenq. Procmsgs gets from listenq and for a certain kind of message creates another mq = Queue(0). I don't wish to distribute the source to pnetx.py so I have a short program pnet.py import it, that is pnetx.pyc. Then the procmsgs thread dies at the Queue statement. But if I run pnetx.py as the main program, all works fine. So if pnetx.py or .pyc is imported this thread dies. ??? I've tried this with 2.3.3 and 2.3.4. Anyone? -- http://mail.python.org/mailman/listinfo/python-list
thread/queue bug
> 4. The fact that you have a .pyc file instead of a .py > file very likely has *nothing* to do with any threading > problem you are facing, so I suggest you get past that mental > block and look elsewhere. Well, I tried to make it clear that the ONLY difference between working and not working was the pnetx.pyc when imported did not work when #!/usr/bin/python # pnet.py, exists only to import pnetx.py import pnetx.py Otherwise the program has worked fine for months. I don't think its a mental block, its the ONLY difference. It freezes on the following statement: mq = Queue(0) and I haven't a clue why. All the other threads continue to run. > 5. Sorry I can't be more help. You don't give anyone much > to go on. All that stuff about "Queue(0)" and "listenq" > is pretty much meaningless to us, you know... You know, I get this all the time on language support groups. All of my Linux support groups, if they don't understand, say why and ask for elaboration. I tried to explain what was going on, without incuding the source. I have about 200 man hours in the source and I bet it would take longer to understand it. If my explanation was insufficient, I'm sorry. ALSO, you did not respond to my email, so I didn't know how to reply. There is nothing on the archives page which gives me a clue as to how to respond. SO, if there is ZERO chance there is some sort of inadvertent lock occuring in saved byte code, I just kludge around and move on. Maybe 2.4 Thanks. -- http://mail.python.org/mailman/listinfo/python-list
thread/queue bug
>Wow, amazing! Imagine that... asking for elaboration when >someone posts unclear confusing questions and extraneous >information. The noive! I would be happy to elaborate. No one asked to me to elaborate. I was simply told I didn't give enough information. I wasn't given an idea of what additional information was needed or some clue as to how to better phrase my question. >I also find it remarkable that so many different people are >all doing the same thing to you. It must be a conspiracy. >Certainly not a problem with, say, you... I didn't say so many people are doing the same thing to me. Some language support groups make me feel like I am asking stupid questions in a stupid way, not all. And the Linux and FreeBSD support groups never do. In fact it seems on those groups the more newbie and inadequate your questions are the more patience and help you get. I've never before on any group seen anyone told they had a mental block, because they were fishing for info. I have a genuine problem here, which I have no clue how to approach, and I am very sorry I started a flame over protocol. THAT has certainly never happened to me before. signing off. -- http://mail.python.org/mailman/listinfo/python-list
thread/queue bug
And sorry I got ticked, frustrating week
>And I could help more, being fairly experienced with
>threading issues and race conditions and such, but
>as I tried to indicate in the first place, you've
>provided next to no useful (IMHO) information to
>let anyone help you more than this
This is about 5% of the code.
Uses no locks.
I am mystified, I have written probably 100,000 lines
of Python and never seen a thread just lock up and quit
running. It happens on a Queue() statement so my suspicion
is a bug. ??
I have kludged around it by putting all the thread/queue stuff
in the main program and import the stuff I don't want to
distribute. But mysteries haunt your dreams, sooo...
#!/usr/local/bin/python
# pnetx.py
from threading import *
from time import *
from Queue import Queue
from socket import *
import sys
import os
# glob is a DUMMY CLASS
glob.listenq = Queue(1000)
def listener():
while 1:
msg,addrport = listenersocket.recvfrom(BUFSIZE)
addr = addrport[0]
glob.listenq.put (( msg,addr),1)
if msg == 'DIE': break
def procmsgs():
while 1:
msg,addr = glob.listenq.get(1)
if msg == 'DIE': break
wds = msg.split(';')
if wds[0] == 'S': recvsucc(msg); continue
if wds[0] == 'E': recvevent(msg); continue
if wds[0] == 'ACK': recvack(msg[4:]); continue
if wds[0] == 'MONITOR':
if addr not in monitorlist:
print 'This line ALWAYS PRINTS'
queuelist.append( Queue(0) )
## The above fails if this code is imported
## It doesn't matter whether it is imported
##as .py or .pyc
## also mq = Queue(0); queuelist.append(mq) # fails
print 'This line ALWAYS PRINTS if i execute this source'
print 'but NEVER PRINTS if I import '
print 'this source from a 1 line program'
print 'Thats weird'
monitoron.append( 1 )
monitorlist.append( addr )
queuelist = [Queue(0)]
listenersocket = socket(AF_INET,SOCK_DGRAM)
listenersocket.bind(ListenAddr)
procm = Thread(target=procmsgs)
procm.start()
listenr = Thread(target=listener)
listenr.start()
## Then start a bunch of other threads and queuea.
Don't spend a lot of time on this, not worth it.
I just thought someone might have experienced
something similar.
--
http://mail.python.org/mailman/listinfo/python-list
thread/queue bug
>You have the source to Queue.py in your standard library >folder. Why not throw a few more print statements into >its __init__ and see what you learn? Yeah I put some print statements in init and it seems to complete. >Are you by any chance running on a new version of the >Linux kernel, where the threading model has changed? >(Or was it just RedHat 9.0?) RedHat 7.2, 2.4.20 kernel. Get the same hangup on Win2000 Pro. Which leads me to believe it has nothing to do with kernel threads. Well its an anomaly. I sent to bug list. Probably never see it again. I think some sort of semaphore thingy, which I know nothing about, is sneaking in under unreproducible conditions. I'm moving on. I'm love python for multi-thread, simple socket programming and lots of reasons. This is the first thing that's looked like a bug in 5 years (1.5), I'm not worried. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
win32 process name
I need to know if a process is running. not just python.exe but python.exe myapp from win32all EnumProcesses gives me the pids, then OpenProcess(pid) gives me a handle. Then what? GetModuleFileNameEX? It requires two handles as args and I can't figure out which one is the handle from OpenProcess and what it wants for the other one and I can't find any Win32 SDK docs that help. Or if I could figure out this function, would it even give me the answer. I discovered wmi. Win32_Process returns a list of processes. then process.Name just gives me python.exe. But I could have python.exe running several times. I need to know is python.exe myapp running. In other words, the command line. This ought to be a nobrainer. But Nooo. Its Windows. Any help or ideas appreciated. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter weirdness item count
Using Tkinter Canvas to teach High School Geometry with A LOT of success. My drawing gets very slow after a lot of actions. For instance I have created code to rotate a set of objects about a rotation point. rotate 360 degrees starts to get slow after 720 degrees its crawling. I checked the item list with with find_all: IT GROWS! OK, I create 3 lines using a line Class I created. When I rotate these 3 lines thru 360 degrees it creates 360 lines times 3. But each new instance of line REPLACES the old instance. The line class has a destructor to delete the drawn object. class line: count = 0 def __init__(s,glob,argl,color=''): line.count = line.count + 1 ## ## buncha code here ## s.obj = glob.can.create_line(x0,y0,x1,y1, width=glob.width,fill=s.color) def __del__(s): line.count = line.count - 1 ## delete the line object if the ## class instance is deleted s.glob.can.delete(s.obj) After the rotation I check line.count and it is 3 But find_all returns a tuple ofover 1000 items. The drawn objects are not being deleted. Which is kinda weird because the rotation works. That is they appear to be deleted. Is find_all() fooling me? Is this the reason drawing slows down? Is it refreshing invisible objects? This slowing down also occurs when I draw a lot of objects. Lets say I draw a sine wave, say 1000 individual points. If I draw 4 or 5 sine waves it gets really slow. I should mention I call update() after each drawing action. This is necessary for the students to watch the progress. I might be drawing objects in a lengthy loop and without update() they only appear at the end of the loop. Thanks for any help. -- Confused -- http://mail.python.org/mailman/listinfo/python-list
Calendar module question
Thank you for reading this. My adventures with Python have just begun and during the few weeks I have tried many IDEs. The following piece of code fails under all IDEs, and the interpreter, except under the Wing IDE. Why would this code work under the Wing IDE and nowhere else? Could there be a different calendar module included with Wing? import calendar cal = calendar.prcal(2013) print cal Traceback (most recent call last): File "calendar.py", line 1, in import calendar File "/home/phil/calendar.py", line 3, in cal = calendar.prcal(2013) AttributeError: 'module' object has no attribute 'prcal' -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Calendar module question
On 17/02/13 18:01, Andrew Berg wrote: On 2013.02.17 01:47, Phil wrote: Why would this code work under the Wing IDE and nowhere else? Could there be a different calendar module included with Wing? import calendar cal = calendar.prcal(2013) print cal Traceback (most recent call last): File "calendar.py", line 1, in import calendar File "/home/phil/calendar.py", line 3, in cal = calendar.prcal(2013) AttributeError: 'module' object has no attribute 'prcal' If you look at the traceback, you'll see you have a calendar.py in your home directory that is being imported instead of the one from the stdlib. Thank you for your quick response Andrew. Of course, I now have another question; how do I use the correct calendar module? The Wing IDE apparently uses the correct module. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Calendar module question
On 17/02/13 18:40, James Griffin wrote: - Phil [2013-02-17 17:47:15 +1000] - : Thank you for reading this. My adventures with Python have just begun and during the few weeks I have tried many IDEs. The following piece of code fails under all IDEs, and the interpreter, except under the Wing IDE. Why would this code work under the Wing IDE and nowhere else? Could there be a different calendar module included with Wing? import calendar cal = calendar.prcal(2013) print cal Traceback (most recent call last): File "calendar.py", line 1, in import calendar File "/home/phil/calendar.py", line 3, in ^^^ There is your problem. Parsedatetime is a good calendar module. I've been using it recently for an email related script. Thanks James - a trap for the uninitiated. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Eric - "No module named MainWindow"
Thank you for reading this. I've been playing with Eric all day and I almost have a working GUI application, but not quite. I have followed the two tutorials on the Eric site and I'm sure that I haven't miss entered anything and so I think the error is the result of something missing from my system or perhaps a path error. This is the error message: The debugged program raised the exception unhandled ImportError "No module named MainWindow" File: /home/phil/main.py, Line: 4 And this is the code: !/usr/bin/python from PyQt4.QtGui import QApplication from ui.MainWindow import MainWindow def main(): import sys app = QApplication(sys.argv) wnd = MainWindow() wnd.show() sys.exit(app.exec_()) if __name__ == '__main__': main() I have tried mainWindow and mainwindow as well so it appears not to be a case error. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Eric - "No module named MainWindow"
On 17/02/13 21:35, Vincent Vande Vyvre wrote:
Le 17/02/13 10:08, Phil a écrit :
Thank you for reading this.
I've been playing with Eric all day and I almost have a working GUI
application, but not quite. I have followed the two tutorials on the
Eric site and I'm sure that I haven't miss entered anything and so I
Are you sure you have a class MainWindow in your ui.MainWindow.py ?
Can you show us the code of this MainWindow ?
Thank you Vincent and Joel. I think I have already tried every
conceivable combination but I still cannot get past the error message.
At the risk of burdening the list with lots of code I have decided to
show the code as it stands. It's substantially that from the mini
browser example.
This is the auto generated code for Ui_mainWindow.py:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file
'/home/phil/mainWindow.ui'
#
# Created: Sun Feb 17 15:54:33 2013
# by: PyQt4 UI code generator 4.9.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(200, 200)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(40, 120, 91, 24))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
MainWindow.setCentralWidget(self.centralWidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("MainWindow",
"PushButton", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
This is the code for mainWindow.py"
class MainWindow(QMainWindow, Ui_MainWindow):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QMainWindow.__init__(self, parent)
self.setupUi(self)
And this is the main script that I had originally used and named new_gui.py:
from PyQt4 import QtCore, QtGui
from ui.MainWindow import MainWindow
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
ui = MainWindow()
ui.show()
sys.exit(app.exec_())
Finally, for completeness, this is the error message when I attempt to
execute new_gui.py:
The debugged program raised the exception unhandled ImportError
"No module named mainWindow"
File: /home/phil/new_gui.py, Line: 2
Could it simply be a case of conflict between my file names and the
module name?
--
Regards,
Phil
--
http://mail.python.org/mailman/listinfo/python-list
Re: Eric - "No module named MainWindow" - solved
On 17/02/13 21:35, Vincent Vande Vyvre wrote: Le 17/02/13 10:08, Phil a écrit : Thank you for reading this. I've been playing with Eric all day and I almost have a working GUI application, but not quite. I have followed the two tutorials on the Eric site and I'm sure that I haven't miss entered anything and so I think the error is the result of something missing from my system or perhaps a path error. This is the error message: The debugged program raised the exception unhandled ImportError "No module named MainWindow" File: /home/phil/main.py, Line: 4 The solution is to save the various files in their correct directories as mentioned in the tutorial. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Eric - "No module named MainWindow"
On 18/02/13 18:07, Vincent Vande Vyvre wrote: Le 18/02/13 00:04, Phil a écrit : ... from PyQt4 import QtCore, QtGui from ui.MainWindow import MainWindow As I've sayed in my last post, this is not "ui.MainWindow" but "ui.mainwindow" Thanks again Vincent, Your answer is correct but that wasn't the only problem. Anyway, as I said in my previous message, it works now and I'm pleased that I have advanced a little with pyqt4. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a graphical GUI builder?
On 20/02/13 08:19, Rex Macey wrote: I'm new to Python and only a hobbyist programmer. A long time ago I used Microsoft's Visual Basic which had a nice (graphical) facility for creating GUIs which was part of the development environment. I'm wondering if there's a utility for Python to build GUIs. I see that there is TKinter, which is a scripting function to build GUIs. To be clear, I'm looking for a graphical interface to build GUIs. Thanks. I'm new to Python myself and the best IDE that I've found is Eric. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Read arrow keys
Thank you for reading this. I'm attempting to put a simple remote control program together and to do so I need to check if the arrows are pressed. I could probably do this with pyqt4 but I'm looking for something simple to experiment with. Pygame looked like a suitable solution but the error message makes me think that pygame doesn't work from the console: "video system not initialized" Is there a simple way to read the direction keys within a while loop? -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Read arrow keys
On 21/02/13 13:36, Ned Deily wrote: In article <[email protected]>, Phil wrote: I'm attempting to put a simple remote control program together and to do so I need to check if the arrows are pressed. I could probably do this with pyqt4 but I'm looking for something simple to experiment with. Thanks for your reply Ned. You don't say which o/s platform(s) you are interested in but, if they are all unix-y and you don't mind running from a shell terminal session, you could just use the venerable curses module in the Python standard library. Whatever I manage to cobble together will only be used under Linux. I had a look at the curses module and it seems that it will detect key presses but I don't know if it will detect two arrow presses at the same time, which is what I need. I haven't had much success with pygame so I have put something together with pyqt4 which almost works. def keyPressEvent(self, event): self.firstrelease = True #astr = "pressed: " + str(event.key()) self.keylist.append(event.key()) # the following if and elif statements only detects single key presses # key = event.key() # if key == QtCore.Qt.Key_Left: # print "left" # elif key == QtCore.Qt.Key_Up: # print "up" # elif key == QtCore.Qt.Key_Up and key == QtCore.Qt.Key_Left : # print "left and up" def keyReleaseEvent(self, event): if self.firstrelease == True: self.processmultikeys(self.keylist) self.firstrelease = False del self.keylist[-1] def processmultikeys(self,keyspressed): print keyspressed I'm not sure how to handle "keyspressed". For example, "keyspressed" returns 16777235 for "up" and returns 16777234 for "left". What logic do I need to detect when "up" and "left" are both pressed? Another problem. When "up" and "left" are pressed "keyspessed" returns 16777235 and 16777234. From then on "keyspressed" always returns 16777235 and 16777234 even after a single key is pressed. It seems to me that "keylist" needs to be emptied. My experiments in this area have also not yielded anything useful. -- Regards, Phil -- http://mail.python.org/mailman/listinfo/python-list
Tkinter weirdness item count
>> Using Tkinter Canvas to teach High School Geometry >> with A LOT of success. >Can you post a link to your code. >I'd like to see what you are doing. >Thx, >Alan Isaac Yes, I will release it open source at the end of may. There are too many features I want to add to release it now. Essentially it is a script language for making complex drawings, rotating objects, plotting simple functions, and with a dialogue. Which means you can make a simple concept or a whole chapter into a lesson. Eventually I will write a whole course based on Cliff notes geometry review. Why, are you a teacher? -- http://mail.python.org/mailman/listinfo/python-list
Canvas drawing slow
I'm mapping quadratic equations on a Canvas. But that's irrelevant, the point is I am drawing a lot of points in a loop without returning to mainloop until the end. I want my students to see the drawing progress, so I call update_idletasks() after each tiny rectangle. ( I use to call update() and it seems to make no difference) This is so fast at first I am tempted to put a sleep(.01) in the loop. But after a few thousand points it starts to slow down dramatically. WHy? I thought udate_idletasks would only redraw the 'damaged' portion. Maybe my approach is wrong. I was hoping to use Canvas to do some simple instructional animation, but not if I can't solve this mystery. Any help appreciated. BTW: I posted a couple days ago about rotating objects making the item stack grow. My bad, debugging bug, fixed it. -- http://mail.python.org/mailman/listinfo/python-list
compare two voices
You didn't indicate how deep you want to get into the code yourself. I am gonna step way out of my mathematical depth here and say this should not be too difficult in python. 1. you need to know the format of .wav surely it is a set of frequency amplitude pairs. 2. you need to know the sampling rate is the same, say its a hundred points per second, a five second speech is only a 500 hundred point pair of curves. 3. then perhaps a package like MatLAb would give you the curve fitting algorithms to obtain a score. It might even compensate for an average frequency diff between the two samples. The difference in tonal quality between native Germans and native Thais I would think would not enter into it, because that is part of what you are testing for. The math for comparing two waves which are different at every point, have different base frequencies and different rates is hellacious, but its been done. Python would just be the wrapper, and a good one. -- http://mail.python.org/mailman/listinfo/python-list
compare two voices (Jeremy Bowers)
>>I am gonna step way out of my mathematical depth here >> > > I mean no disrespect, but this is the last accurate statement you made. > You are probably correct, I am certainly out of my field and hope that noone would embark on a hopeless project based on my few words. However, the school district (and some teachers) tell me that Rosetta Stone does this quite well (phrasal pronunciation scoring). I've heard there are other packages that do as well This tells me the math has been done. But you are correct that he would not want to attempt the math himself, I just think it can probably be found somewhere and MatLab users might be a good starting point. Personally, I have done from scratch lots of things which were done before and sometimes better. Anyway, it is a truly fascinating subject. The true test of whether you are learning a language is whether native speakers can understand you well, not some computer graded pronunciation test. The pattern fitting capabilities of the auditory regions of the neo-cortex and limbic regions are so awesome we may be decades away from automating them. Emulating hundreds of thousands of synaptic connections and meta-language itself is gonna take a lot of work. I will defend one statement though. I have yet to see anything which Python would not make a good wrapper for. Some of the OpenGL pygame stuff is very cool. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter weirdness item count
> I seem to remember a thread a while ago about a 'bug' with the Tk Canvas > widget keeping a reference to objects that had been deleted... > > Have you thought about using the 'move' method to move your lines? I > think this will result in less supprises... > Actually I solved that problem. My bug. It does delete the objects. My current problem, in another post, is that when I draw thousands of objects plotting complex functions, the drawing gets really slow. If I draw 12000 points and then return to mainloop it takes 2 seconds. If I draw each point then call update_idletasks() it takes about 60 seconds. It goes very fast at first and gradually gets slower. -- http://mail.python.org/mailman/listinfo/python-list
Read / Write image file
> I have a image file on my pc, say a .jpg. Basically I want to setup a
> client/server socket, and I want the client to read in the jpg and send
> it to the server, where the server can write that data into a new file
> on the server.
>
> I tried just doing something like..
>
> x = open("abc.jpg")
> y = x.read()
> tmp = open("newFile.jpg", "w")
> tmp.write(y)
> tmp.close()
> x.close()
>
> ...but that doesn't give me a copy of abc.jpg
>
> any ideas? Thanks
>
What in the world does it give you?
If this is Windoze you should open x "rb"
and tmp "wb", otherwise it will expand linefeeds.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Read / Write image file
>
> By the way, what is 'rb' and 'wb' ?
>
Read Binary, Write Binary
In Win32 the default is text mode which
will screw up binary files
> Also, when I create a client/server sockets I do something like...
>
> SERVER
> ---
> server.bind(('', 4321))
> (sock, addr) = server.accept()
> x = server.recv(1024)
>
> CLIENT
>
> client.connect(('localhost', 4321))
> x = open("abc.txt", "rb")
> client.send(x)
> client.close()
> x.close()
>
> ...when I do this I get a constant beeping on my PC, any idea why?
> Also, on the server ...how can I set that up so I can receive a
> file/data of unknown size instead of just 1024?
>
1024 is just the buffer size. You need to recv in a loop
until the len(x) is 0. You need to do a little reading on sockets.
Beeping I've no idea. Perhaps packets not handled
--
http://mail.python.org/mailman/listinfo/python-list
How To Reply
I get a digest several times a day. When I wish to respond to an item I must cut and paste the item and the subject line. Is there something to click on for a simple reply? Using an old mozilla mail. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Read / Write image file REC SEP
>> >>So what if the client sends 4 bytes, and then sends 8000 bytes? WIll I >>get the first 4 bytes as a separate msg so to speak? Basically i want >>to catch each message from the client as a whole. >> IF YOU WANT SEPARATE MESSAGES: Modify the client to send an end of record, then: On Server: datasep = '' # or whatever you like datal = [] seversocket.settimeout(5.0) # or 0(infinite) or something reasonable while 1: try: data = serversocket.recv(BUFFERSIZE) # fails on timeout if not data: break datal.append(data) except: break msglist = datal.split(datasep) # a list of messages -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie.......Python and Networking
xeron wrote: > Hi ya fellas > > I am planning to learn Python, and because i have a networking > background so would like to direct my learning in a way that is > beneficial to my tasks in the mentioned field, please suggest a couple > of projects which i can implement so as to accelerate the learning > process(Python projects in Networking domain, let it be > big...3 months2 hrs per day) > > Really appreciate any help > > I let my students learn on a VERY simple chat program, UDP only. I think it was less than 50 lines of Python. I cut my teeth on a message handler, POS application posts its requests to MySQL via a Python message handler. Want BIG? spread.org is very powerful and somewhat complicated. A python message server, guaranteed orderly delivery over 1 UDP port, which is a little easier to understand than spread, would be cool. Even BIGGER? Every linux distro has its own set of complex and nearly unreadable networking scripts and none of them handle routing and firewalls well. Be the hero who rights a universal, well documented python networking script. Easy to read config file: ethmodule= IPADDR=192.168.1.12/24 DEFGATEWAY=192.168.1.1 DNSSERV1=208.208.1.1 or even a GUI with help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bandwith Shaping
flamesrock wrote: > Just curious - is there an easy way to shape bandwith in python. If I > wanted to have a max download speed for instance > > -thanks > Interesting normally bandwidth shaping is an IP stack function in the Kernel. You are receiving a download within a python program? And want to slow it down? You could put a sleep(.01) in your receive loop. That's about as fine as sleep gets, i've read. But those packets ( I assume TCP ) are going to stack up somewhere, the sender is gonna keep trying and retrying. In other words you are increasing overall load to someone's router and the network. Someone correct me if I'm drunk on this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie.......Python and Networking
xeron wrote:
> Thanks phil, I think I'll start off with your chat prog (UDP-- 50 lines
> code ) and then try for routing and firewall scripts for linux, yepp
> that would be really tough but why not give it a try, i am going to
> have my vacations for like 13 days so will be preparing for my CCNA and
> also learning python in that duration.
>
> You have been most helpful through ur well thought and scaled reply
>
> xeron
>
>
I could send you the chat program they wrote if it would help.
It has 2 threads, listener and sender.
Might spoil your fun.
However it is very primitive and asynchronous and needs work.
Oh heck, here it is.
DO NOT PEEK BEYOND THIS POINT IF YOU WISH TO SOLVE YOURSELF.
# chat1.py
# remote unknown, firewall allow UDP 12101
import os
from threading import *
from socket import *
HOST = ''
BUFSIZE = 1024
ListenPort = 12101
ListenAddr = (HOST,ListenPort)
listenersocket = socket(AF_INET,SOCK_DGRAM)
listenersocket.bind(ListenAddr)
sendsocket = socket(AF_INET,SOCK_DGRAM)
sendsocket = socket(AF_INET,SOCK_DGRAM)
def listener():
while 1:
msg,addr = listenersocket.recvfrom(BUFSIZE)
print '<',msg
if msg == 'die-now': break
def sender():
print; print
print 'Type away. When you are thru with your'
print ' message, hit enter an extra time'
print ' to let the other guy know its his turn.'
print 'To exit, enter exit'
print; print
while 1:
msg = raw_input()
if msg == 'exit':
sendsocket.sendto( 'die-now', ('localhost',ListenPort) )
break
sendsocket.sendto( msg, (sendtoip,ListenPort) )
# Main program start here
print
sendtoip = raw_input('Enter IP address of other computer: ')
sendtoip = sendtoip.strip()
# Define and start 2 threads
listnr = Thread(target=listener)
sendr = Thread(target=sender)
listnr.start()
sendr.start()
listnr.join()
sendr.join()
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to detect a double's significant digits
fl = 1.0002
x = str(fl)
pos = x.find('.')
print len( x[pos+1:] )
>>> 4
mrstephengross wrote:
> Hi all... How can I find out the number of significant digits (to the
> right of the decimal place, that is) in a double? At least, I *think*
> that's what I'm asking for. For instance:
>
> 0.103 --> 3
> 0.0103 --> 4
> 0.00103 --> 5
> 0.000103 --> 6
> 0.103 --> 7
>
> Thanks in advance!
> --Steve ([EMAIL PROTECTED])
>
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to detect a double's significant digits
Bollocks, works here. That looks like Java!!! Aaaihh! mrstephengross wrote: > Ok, that won't work. First of all, str() is not a function. If I want > to convert the float into a string, the conversion function will have > to use some kind of numeric precision, which will screw things up. > Consider this: > > float f = 1.004; > ostringstream s; > s << f; > cout << s.str(); > > The above code may produce "1.004", or "1.0040", or "1.00400", > depending on the stream's precision setting. I need a way to detect the > number of digits to the right of decimal point *prior* to doing any > kind of string conversion. > > --Steve > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption with Python?
Bill Gates us MD5. Hah! Sorry. :-) Blake T. Garretson wrote: > I want to save some sensitive data (passwords, PIN numbers, etc.) to > disk in a secure manner in one of my programs. What is the > easiest/best way to accomplish strong file encryption in Python? Any > modern block cipher will do: AES, Blowfish, etc. I'm not looking for > public key stuff; I just want to provide a pass-phrase. > > I found a few modules out there, but they seem to be all but abandoned. > Most seem to have died several years ago. The most promising package > is A.M. Kuchling's Python Cryptography Toolkit > (http://www.amk.ca/python/code/crypto.html). > > Is this the defacto Python encryption solution? What does everyone > else use? Any other suggestions? The SSLCrypto package > (http://www.freenet.org.nz/python/SSLCrypto/) may be a good alternative > too, but I am not sure if it is actively maintained. > > Thanks, > Blake > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice needed on __del__
> > Fredrik Lundh wrote: > >>Python is not C++. >> Praise the Lord. >> > > I dunno if this makes QOTW, but I vote we put this in our list text that > goes out with each and every list message. > > There will still be a lot of people who don't read it, but at least > we'll get to say, "We told you so." I'm probably dense and don't quite get the point, even though I have coded about 200,000 lines of Python and coded .5 million lines of C before there was a C++ A class instance based language doesn't have to BE C++ to have a destructor method. All I wanted to know is: is the apparent treatment of __del__ which SEEMS to work fine for me in 2.3.4 deprecated or mangled in some later release or future plans. If someone doesn't know the answer to this question or if noone knows the answer to this question, I will still love and respect the Python Community. In large part cause it ain't C++> -- http://mail.python.org/mailman/listinfo/python-list
Desrtuctor WOES, was Advice on __del__
> you haven't answered my question, btw: why are you using __del__ > to do something that the garbage collector should do for you? After more reading it seems I have made an ass of my self on this subject. Here is my problem at length. I teach high school geometry. I have created a program with a scalable graph on which to make drawings to illustrate concepts. This is working well. I like to MOVE the objects one pixel at a time or ROTATE them one degree at a time so the students can follow the progress of the lesson. A script of a simple drawing might be: scale 100 color red tr1 = triangle from x y base baselength angles 30 60 rotate centerx centery degrees objlist # eg tr1 This would create an instance of triangle which would create an instance of polygon which would create 3 instances of lines, which are point pairs. class line: def __init__(s,glob,argl,color=''): s.glob = glob ::: ::: x0 = a0 * s.glob.scale + 400 y0 = 300 - b0 * s.glob.scale x1 = a1 * s.glob.scale + 400 y1 = 300 - b1 * s.glob.scale s.obj = glob.can.create_line(x0,y0,x1,y1, width=glob.width,fill=s.color) def __del__(s): s.glob.can.delete(s.obj) This calls Canvas.create_line. Tkinter keeps its own list of drawn objects. I store the ref in s.obj NOW when I rotate the triangle 45 degrees, recomputing the points each time, it creates 45 new instances of triangle but dels the old one. __del__ then deletes the Canvas line object. Without that, the list of objects grows very long, and refresh gets slow. This is a very complex program, 1000 lines now, propably 2000 lines eventually. There are dozens of places where I depend on __del__ deleteting canvas objects. SO: without significant rewrite of each class such as triangle and line, how can I ensure those canvas lines get deleted? You don't really need to understand Canvas, just trust me I have to delete those objects and they are not properties of the class which go away with garbage collection. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Destructor Woes, was Advice needed on __del__
> Then i got a tip that you can register a function that needs to be > called when the object is going to be deleted. > For instance to register a function __exit, you do this: > Here is the complete line class with your suggestion: Below is the output. Nice idea, maybe I did something wrong? class line: def __init__(s,glob,argl,color=''): atexit.register(s.__exit) s.glob = glob s.type = 'line' s.color = color if not s.color: s.color = glob.color if len(argl) == 2: wobj = glob.objs[ argl[0] ][0] s.x0 = a0 = wobj.x s.y0 = b0 = wobj.y wobj = glob.objs[ argl[1] ][0] s.x1 = a1 = wobj.x s.y1 = b1 = wobj.y elif len(argl) == 4: s.x0 = a0 = float( argl[0] ) s.y0 = b0 = float( argl[1] ) s.x1 = a1 = float( argl[2] ) s.y1 = b1 = float( argl[3] ) else: return s.midx = (s.x0 + s.x1) / 2 s.midy = (s.y0 + s.y1) / 2 s.len = sqrt( (s.x1 -s.x0)**2 + (s.y1 -s.y0)**2 ) if (s.y1 -s.y0) == 0: s.slope = 0 elif (s.x1 -s.x0) == 0: s.slope = 99 else: s.slope = ( (s.y1 -s.y0) / (s.x1 -s.x0) ) # center point of graph is 400,300 # scale is no of pixels per unit of measure x0 = a0 * s.glob.scale + 400 y0 = 300 - b0 * s.glob.scale x1 = a1 * s.glob.scale + 400 y1 = 300 - b1 * s.glob.scale s.obj = glob.can.create_line(x0,y0,x1,y1, width=glob.width,fill=s.color) def __exit(s): print 'exit' s.glob.can.delete(s.obj) # def __del__(s): # s.glob.can.delete(s.obj) exit Error in sys.exitfunc: Traceback (most recent call last): File "/usr/local/lib/python2.3/atexit.py", line 20, in _run_exitfuncs func(*targs, **kargs) File "./graph.py", line 972, in __exit s.glob.can.delete(s.obj) File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 2085, in delete self.tk.call((self._w, 'delete') + args) _tkinter.TclError: invalid command name ".1076354284" -- http://mail.python.org/mailman/listinfo/python-list
TAKE_FOCUS
WM_TAKE_FOCUS does not work on WinXP ?? I was sure I had used that on win before. Works on Linux. I have a function I need to run when the window gets the focus. How do you do that in Tkinter on Win32? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
> > do you (or whoever gave you the tip) have the slightest idea what atexit does? > Yeah, I got the tip on this group. researched and found it was for when program ends! I was trying to treat it like a destructor. darn. -- http://mail.python.org/mailman/listinfo/python-list
Re: TAKE_FOCUS
Thanks, works great. >>I have a function I need to run when the window >>gets the focus. How do you do that in Tkinter >>on Win32? >> > > binding the event should work. > > (and make sure that the takefocus option is set) -- http://mail.python.org/mailman/listinfo/python-list
iso_8859_1 mystery/tkinter
These work fine on Linux
s.const = {}
s.const['DEG'] = '%c' % (0xb0)
s.const['DIV'] = '%c' % (0xf7)
s.const['ANG'] = '%c' % (0xd8)
On WinXP the symbols for division and angle work fine.
But the symbol for degrees, a little circle, produces
a vertical bar in Tkinter Text box or Canvas.
However, if I run from IDLE and output to a console
window, 0xb0 produces the correct character for degrees.
Any idea why?
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
Re: iso_8859_1 mystery/tkinter
> | > s.const['DEG'] = '%c' % (0xb0) > | > But the symbol for degrees, a little circle, produces > | > a vertical bar in Tkinter Text box or Canvas. > t.insert(0.0, u'%c' % 0xb0) > > should do the trick though. > COOL! Thanks, though that seems a little odd. As far as I know %c ignores the sign bit everywhere else, including X11 and Win consoles. But I'll just note it and do it. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: iso_8859_1 mystery/tkinter
Thanks. My confusion was man 3 printf u is unsigned. But of course that would be after %. Never paid any attention to unicode, but will now. I'll figure out on my own why Tkinter and WinXP console treated differently or used different codepage. Thanks. Jeff Epler wrote: > this isn't about the "sign bit", it's about assumed encodings for byte > strings.. > > In iso_8859_1 and unicode, the character with value 0xb0 is DEGREE SIGN. > In other character sets, that may not be true---For instance, in the > Windows "code page 437", it is u'\u2591' aka LIGHT SHADE (a half-tone > pattern). > > When you write code like > x = '%c' % (0xb0) > and then pass x to a Tkinter call, Tkinter treats it as a string encoded > in some system-default encoding, which could give DEGREE SIGN, could > give LIGHT SHADE, or could give other characters (a thai user of Windows > might see THAI CHARACTER THO THAN, for instance, and I would see a > question mark because I use utf-8 and this is an invalid byte sequence). > > By using > x = u'%c' % (0xb0) > you get a unicode string, and there is no confusion about the meaning of > the symbol---you always get DEGREE SIGN. > > Jeff > -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Return/Enter key handling
If you are talking Linux there's .Xdefaults
Which I had to resort to for tn5250.
For Tkinter apps its a LOT easier to just use bind.
Win32? dunno.
Bob Greschke wrote:
> I have a Tkinter Text() widget in a program that the user can type stuff
> into. Most of our keyboards have the regular keys with a "Return" key, and
> a numeric keypad with an "Enter" key. The Return key generates events with
> "" for the keysym, and the Enter key generates events with
> "" as the keysym. The Text() widget does a carriage
> return/linefeed when the Return key is pressed, but does nothing when the
> Enter key is pressed. So I did a
>
> Text.bind("
> with a suitable
>
> def Return(e):
> TheText.insert(END, linesep)
>
> But isn't there a way to handle this with some sort of keyboard remapping
> thingy?? I'm right on the edge of understanding half of what I read about
> Tkinter. :)
>
> Thanks!
>
> Bob
>
>
>
--
http://mail.python.org/mailman/listinfo/python-list
Tkinter special math chars
Using Tkinter to teach high school geometry.
Sorta committed to Tkinter at least for now.
Would like to use some special chars like
limits, infinity, square root, cube root
and a buch more.
in Text Box and Cancas
Is there some package I can integrate with
Tkinter to do this.
Even better would a 'supplemental' font file.
In other words I create my own fonts without
disturbing the regular fonts and I have to write the
code which tells it when to use the special fonts.
I haven't a clue how to do something like that.
I know Tkinter will let you change fonts but
I would have to control it on a char basis
somthing like:
'As the function approaches {INFINITY}'
scan and somehow replace.
TIA.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter special math chars
So far, on RedHat Linux:
I have used your method successfully in a Label
and in Canvas Text. very slow.??
In A Text box I just get \N{INFINITY}.
But thanks, I will investigate Text Box more.
Jeff Epler wrote:
> I wrote the following code:
> import Tkinter
> t = Tkinter.Label()
> t.configure(
> text=u"As the function approaches \N{INFINITY}, \N{HORIZONTAL
> ELLIPSIS}")
> t.pack()
> t.mainloop()
> It worked for me on Windows NT 4.0 with Python 2.4, and on RedHat 9 with
> a self-compiled Python 2.3, showing an infinity symbol and an ellipsis.
>
> u'\N{...}' stands for the Unicode character named '...'. Unicode.org
> (and other sites) have lists of Unicode character names.
>
> Tk tries very hard to find the requested character in some font
> available on the system, but when it fails it just displays a unicode
> escape sequence like "\u220e" (instead of the END OF PROOF symbol, in
> this case), and there's really no way for Python to find out and fall
> back in some graceful way.
>
> Relying on this behavior, here's a somewhat-falliable way to detect the
> presence of a symbol in the font used in a given widget:
> def symbol_exists(s, w, f = None):
> if f is None:
> f = w.cget("font")
> width_symbol = w.tk.call("font", "measure", f, s)
> width_bench = w.tk.call("font", "measure", f, "000")
> return width_symbol < width_bench
> This finds the width in pixels of the given symbol (s) and the string "000",
> in
> the font f. If the width of the symbol is smaller, then it's probably
> available.
> If it's wider, then it's probably rendered as an escape sequence like
> "\u220e".
> This is falliable because there's no guarantee that the symbol would not be as
> wide as 000, but also it's possible for some escape code (say \u) to be
> narrower than 000. Neither of these seem very likely in practice.
>
> Jeff
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter special math chars
> text=u"As the function approaches \N{INFINITY}, \N{HORIZONTAL
> ELLIPSIS}")
Never mind, works in a Text widget, my bad.
Why is it so slow? (RH Linux, 2.4.20, 1.6Ghz AMD)
3/4 second slower to display widget w/unicode,
even if I encode u'\u221e'
Works though, this is great.
--
http://mail.python.org/mailman/listinfo/python-list
Re: prime number
> What civil engineers need with all this programming is beyond me. One of my best friends and expartner and top civil-structural engineers in the country (he built Dallas Reunion Arena and many other complex structures) was an ace programmer in many languages. He was not willing to just accept the results of canned packages, he wanted to know where the answers came from and make software that made sense to his engineers. I presume you are young and if you wish to be an engineer and not a salesman you must be eaten up with the desire to know "How Stuff Works". Computers are ubiquitous in engineering and if you want to be the best, learn how they work. -- http://mail.python.org/mailman/listinfo/python-list
Unicode Congruence
I can't find, anyone know the unicode symbol CONGRUENT. either tilde over equal or triple tidde would do. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode Congruence
Thanks. I did search that site but, wow, huge. That page had no reference to congruence and the pdf did not contain the pattern congru. But I'll have some better ideas how to search next time. thanx I used \u2245 btw John Machin wrote: > phil wrote: > >>I can't find, >> > > Having looked where? > > >>anyone know the unicode symbol >>CONGRUENT. >>either tilde over equal or triple >>tidde would do. >>Thanks. >> >> > > Go to > > http://www.unicode.org > > click on: > Where is my Character? > > follow your nose till you get to: > > http://www.unicode.org/charts/symbols.html > > What you need is: > > http://www.unicode.org/charts/PDF/U2200.pdf > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Developers Handbook
Not taking a position for or against the original post: Everytime this comes up, on any group, one little annoying post results in and endless discussion and sometimes hurtful flame war. Perhaps the rest of us should let the moderator handle it and get back to something interesting, like Python. :-} -- http://mail.python.org/mailman/listinfo/python-list
Re: Dealing with marketing types...
> > What experiences have those in the Python community had in these kinds > of situations? > Ive had lots of experience updating my resume and developing software at home. In Python. Java is a clumsy kludge. And the java environment has gone to hell. Managers DO NOT listen to engineers. Marketing people cannot spell indianere. Sorry, to be so pessimistic. They are gonna outsource anyway. It's such a sexy buzzword, how can they resist? How can you have an interesting management/marketing meeting in which noone knows their head from their richard, without cool buzzwords? There are lots of good projects to work on at home. Get your unemployment then a good waiter job. Seriously, its cottage industry/small business that drives this world, not the clowns you are describing. They are losers. Don't let them drag you down. If you really want to fight this on their terms, you need engineering to write a white paper which is absolute horsedooey but is loaded with stuff they cannot possible comprehend and arrives at totally unsupported conclusions that you like. Have all the engineers sign off and get some authoritative endorsement. This will introduce fear and paralysis at the mgmt level. Then get a couple happy customers and lock it in. -- http://mail.python.org/mailman/listinfo/python-list
Re: About reading Python code
On 2008-03-18, sturlamolden <[EMAIL PROTECTED]> wrote: > First, I recommend that you write readable code! Don't use Python as > if you're entering the obfuscated C contest. > > Two particularly important points: > > * Comments are always helpful to the reader. It would be nice if this was the case! I once saw a preogram where a line of code like this: foo++; Would be annotated with a comment like this: // /* */ /* Increment foo*/ /* */ // This comment was worse than useless, because it (and others like it) took up space that distracted from the information-containing parts of the code. -- http://mail.python.org/mailman/listinfo/python-list
imports in __init__.py
I use distutils / setup.py to install 'packagename', where... /packagename __init__.py modulename.py modulename.py has a class named 'classname'. >From an arbitrary python module, I 'import packagename'. In said module, I want to use the 'classname' class from 'packagename.modulename', by doing 'packagename.classname(params)'. I have seen this done by having either 'import modulename' and/or 'from modulename import *' in 'packagename's __init__.py. I don't really know which one or combination of them would work, but I can't get it to work either way. Unless I am missing something, webpy does this with, among other things, its application class that is in application.py. From a new web app, you would just use web.application (params). I am using Python 3.1.1, although I don't think that should matter. Any help is appreciated. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: imports in __init__.py
I understand all of the above, including the reasons as to why this is bad. For purposes of experimenting, I would still like to do it. I guess I'm (still) wondering how it is done in webpy. I recall seeing it done elsewhere too. All I noticed was that in webpy's package 'web', it defines the 'application' class in 'application.py'. And in web's __init__.py it has... from application import * And in whatever app you are creating, it has... import web app = web.application(params) That being said, I can't get similar functionality with my own package. Is there more to this? Within my package's __init__.py, I am unable to import a module from the package without an import error. Thanks again! -- http://mail.python.org/mailman/listinfo/python-list
Re: imports in __init__.py
I wrote my last message late last night. When I said "I am unable to import a module from the package without an import error.", I did mean the 'modulename' module. However, I just set up a Debian VM with Python 2.5.2 and what I was trying to do works. So it is either something that changed with Python 3.1.1, or a problem with Windows. -- http://mail.python.org/mailman/listinfo/python-list
Problem with wsgiref.headers.Headers
I am having an issue with wsgiref.headers.Headers. For example, if I do this... from wsgiref.headers import Headers list = [] wrapper = Headers(list) wrapper['content-type'] = "text/html" print(list) print(wrapper) I get an empty list printed, and then the correct result for wrapper printed. Am I misunderstanding the documentation? class wsgiref.headers.Headers(headers) Create a mapping-like object wrapping headers, which must be a list of header name/value tuples as described in PEP 333. Any changes made to the new Headers object will directly update the headers list it was created with. Thanks for any help, Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with wsgiref.headers.Headers
I left one crucial detail out. My concern was the fact that the
original headers list being wrapped ('list' in my example) is not
being updated.
--
http://mail.python.org/mailman/listinfo/python-list
Propagate import for all modules in a package.
I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire package. Here is an example... __init__.py module1.py module2.py ... moduleN.py I was thinking that I could just, for example, 'from datetime import datetime' in __init__.py and have the ability to use 'datetime' anywhere in any of the modules in 'package'. This didn't work for me. Did I just do something wrong? Is what I am trying to do possible? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Propagate import for all modules in a package.
Thanks to both of you for the fast and detailed responses. I will just treat the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list
Re: Propagate import for all modules in a package.
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list
Re: Propagate import for all modules in a package.
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list
__import__(x) VS __import__(x, {}, {}, [''])
I am trying to understand the difference between __import__(x) and
__import__(x, {}, {}, ['']).
The documentations wording was a bit weird for me to understand:
"The standard implementation does not use its locals argument at all,
and uses its globals only to determine the package context of the
import statement."
Does that mean it passes in the globals by default, or does the above
statement stand true only if globals() is passed in?
--
http://mail.python.org/mailman/listinfo/python-list
Re: __import__(x) VS __import__(x, {}, {}, [''])
"If you call it without a value for 'globals', it uses the current value of globals()." Thanks, this is what I was trying to ask. I typed my question up way too fast before dinner. You've been great help. -- http://mail.python.org/mailman/listinfo/python-list
Python on the Web
I've seen lots of web sites explaining everything, but for whatever reason I seem to not be picking something up. I am a graphical person, which is probably the reason I haven't found my answer. May somebody please confirm if my diagram accurately represents the stack, generally speaking. http://i26.tinypic.com/1fe82x.png Even if that is the case, I'm having a hard time understanding the differences. I guess wsgiref has absolutely nothing to do with FCGI/ SCGI/CGI and simply receives and responds to HTTP requests following the WSGI specification? Does it just spawn a new thread for each request? If so, then how is this any different than a production server with FCGI? The way I am understanding the 'Production' side of that picture is that the web server (eg. lighttpd) creates a single FCGI process. The FCGI process is actually the entry point of the Framework/Application which sets up Flup's WSGIServer, being the interface between FCGI and the Framework/Application? What I mean is, it is just the code that the web server loads to start with, example... from flup.server.fcgi import WSGIServer from app import application WSGIServer(application).run() ... Then for each HTTP request, Flup's WSGIServer creates a new thread to handle the request? As I've read elsewhere, "These days, FastCGI is never used directly. Just like mod_python it is only used for the deployment of WSGI applications." As far as I understand, the main (or only?) reasoning for this is because WSGI makes Python applications easier to deploy without having to worry about whether using FCGI/SCGI/CGI. What would be involved to run Python on the web using FCGI without WSGI? I can feel the flames already. This isn't the only reason I want to know, but one reason is that I want to use Python 3.1 and as I understand, this will have to wait for the WSGI 2.0 specification to ensure time isn't wasted. I apologize if the questions are ridiculous. I've just recently got into web programming and it seems that in order for me to use Python, I need a deep understanding of web servers, HTTP, FCGI, etc. I have more questions but they go more off topic, so I will save it for another thread, another day. I realize there is a large number of questions, so thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
Thank you for the helpful and timely response. My interest in Python 3.1 was actually to develop a framework. Again, I can feel the flames. :) I understand there are enough frameworks but I actually have no applications that I wish to develop. I enjoy developing these kinds of things from scratch as a learning experience. I've been doing fine with 2.x and WSGI, even without understanding half of this stuff. It is actually my first Python project. Haha. I just have my own design philosophies that I wish to experiment with. Python 3.x just makes everything nicer with UNICODE, etc. Although you've been helpful with almost all of the mentioned concerns, I am still looking for more details on some of the questions I've asked. So, if others stumble upon this post, feel free to contribute further. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
On Aug 25, 11:17 pm, alex23 wrote: > Phil wrote: > > My interest in Python 3.1 was actually to develop a framework. Again, > > I can feel the flames. :) I understand there are enough frameworks but > > I actually have no applications that I wish to develop. > > No offense intended, but that's probably the worst approach to take. > > Frameworks created for the sake of creating a framework, as opposed to > those written to meet a defined need, tend to be the worst examples of > masturbatory coding. No offense taken. I understand your concern. I actually do have some important design decisions I wish to meet. It has sort of been a process of evaluating the things I love and hate most from existing frameworks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
Thanks to everybody. I believe I am understanding things better. I have looked at the links that have been provided, although I have seen most of them in the past month or so that I've been looking into this stuff. I do agree with most of the things Armin stated in that NIH post. I agree with everybody in this thread so far. If I wanted to write an application, I would use an existing framework and wait for it to be ported to 3.x. However, I do not have the need to write a web application at this time, and creating blogs or other applications I do not need for fun is getting old. My reasoning for working on my own instead of following the 'NIH' concept or contributing to an existing framework is because I have experimented with many existing frameworks and I have figured out what I like/dislike, and have envisioned my own design that I feel would work potentially better for others, or at least newcomers. Things like this are fun for me, and I do not mind the challenge. I don't want to pollute the web with (sigh) 'another framework', but it would be fun for me to write it and get some feedback. I would love for people like you, Armin, and others who take a look at the various frameworks that pop up seemingly every day, to look at my (hypothetical) framework and just rip it apart with (constructive) criticism. That is just the way I do things, whether the community agrees with it or not. The reason I was asking about Python 3 on the web was just because I like some of the changes that have been made, and would like to use it for my framework. That is when I realized that I was absolutely clueless about the details of how Python, or any language, works on the web. Graham, regarding number 3 in your list of ways to host WSGI: I haven't really looked into mod_wsgi at all, but basically it sounds like the web server would be running this embedded module. That module would then serve the function of both FCGI and the 'WSGI Server' in my diagram? That actually sounds really neat. Unfortunately I missed this because I've been hooked on lighttpd, as the minimalist I am. Here are the things I am still confused with: 1) Why do I not want to consider running Python on the web with FCGI, without WSGI? You said 'no' straight up, no questions asked. I would imagine that there is a good reason of course, as you've been in this field for a long time. I just feel more comfortable understanding why. >From my understanding, the only real purpose of WSGI is to remain independent of FCGI/SCGI/CGI/AJP (whatever that is) and the web server it is run on. However, 99.9% of the discussion I see with Python on the web is around FCGI. So for example, lets say everybody used FCGI. All that would be left to deal with is web server independence. Now this is what I don't get, I thought that FCGI itself was supposed to be the protocol that deals with web server independence. Maybe I just need to re-read entire WSGI specification to understand, along with all the details of FCGI. There are just so many details regarding web servers, FCGI, and WSGI that it is hard to absorb it all and see how it works together. That is why I tried to create the diagram, but it doesn't provide enough details. And those are the details I am missing. I've been trying to find a simple diagram or explaination of the process a request takes to make a response, from HTTP all the way up to the application, to the the user. 2) In the development stack, the 'WSGI Server' seems to take on the role of the web server (dealing with HTTP specification), skips FCGI, and deals with the WSGI specification. Then, the 'WSGI Server' in the production stack (eg. Flup, CherryPy, etc) only deals with FCGI and WSGI specification, because the HTTP is already taken care of by the web server? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
Thanks a lot for another response. I've never posted in groups like this before but the results are amazing. I will definitely consider trying mod_wsgi when I get a chance. I like the approach taken with it. It is unfortunate that I completely missed all Apache related material because I was using lighttpd. Is there no mod_wsgi for lighttpd? I guess I could always just Google that myself. Thanks again for the help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
Thanks Graham. I actually ended up reading that blog post from a Google search last night before I saw your response. It was very informative. Bruno, I will take a look at those groups to expand my knowledge. When I gave that arbitrary percentage, I was basing it off of the information I had seen with regards to launching applications built with existing frameworks using lighttpd. I do realize I was missing a lot of information by looking up something that specific. I also understand that there are enough frameworks. That still won't change my mind. I do not want to write a web application, otherwise I would use an existing framework as suggested. I just wanted to experiment and see what kind of framework I could develop with some ideas I had in mind. The original post was mostly just because I was having a difficulty understanding some lower level concepts as a result of trying to get Python 3 on the web before figuring out that it wasn't quite ready for that. I just really like some of the new features of Python 3, and most importantly, unicode compliance is just that much straight forward in my opinion. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on the Web
Haha. While I don't disagree with you, I seem to be under the impression that you think I haven't been reading the web where nearly every blog post complains about the abundance of Python frameworks. The thing is, most of the frameworks being commented on in such a way are 'microframeworks' that provide next to nothing. I'm do not mean to say anything negative about them, but I strongly feel that my approach will be much more functional without having to include, or at least a good starting point for newcomers to both Python and web programming. The ideas I had for mine lied somewhere in between a full stack framework and a minimalist approach like said microframeworks. -- http://mail.python.org/mailman/listinfo/python-list
RE: Total Beginner - Extracting Data from a Database Online (Screenshot)
On 28 May 2013 02:21, "Carlos Nepomuceno" wrote: > > > > Date: Mon, 27 May 2013 17:58:00 -0700 > > Subject: Re: Total Beginner - Extracting Data from a Database Online (Screenshot) > > From: [email protected] > > To: [email protected] > [...] > > > > Oh goodness, yes, I have no clue. > > For example: > > # to retrieve the contents of all column '# fb' (11th column from the image you sent) > > c11 = [tables[0][r][10] for r in range(len(tables[0]))] Or rather: c11 = [row[10] for row in tables[0]] In most cases, range(len(x)) is a sign that you're doing it wrong :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Split a list into two parts based on a filter?
On 12 Jun 2013 01:36, "Roy Smith" wrote: > > In article , > Serhiy Storchaka wrote: > > > 11.06.13 07:11, Roy Smith написав(ла): > > > In article , > > > Roel Schroeven wrote: > > > > > >> new_songs, old_songs = [], [] > > >> [(new_songs if s.is_new() else old_songs).append(s) for s in songs] > > > > > > Thanks kind of neat, thanks. > > > > > > I'm trying to figure out what list gets created and discarded. I think > > > it's [None] * len(songs). > > > > It is the same as your klunky code, but consumes more memory. > > Well, continuing down this somewhat bizarre path: > > new_songs, old_songs = [], [] > itertools.takewhile( > lambda x: True, > (new_songs if s.is_new() else old_songs).append(s) for s in songs) > ) > > I'm not sure I got the syntax exactly right, but the idea is anything > that will iterate over a generator expression. That at least gets rid > of the memory requirement to hold the throw-away list :-) You could equivalently pass the generator to deque() with maxlen=0 - this consumes the iterator with constant memory usage. We are of course firmly in the twilight zone at this point (although this can be a useful technique in general). Cheers, Phil > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
