Re: Python installer hangs in Windows 7

2018-09-01 Thread james
Same problem, Win7, Unchecking "Install launcher for all users" sorted things.  
Thanks for the advice.
-- 
https://mail.python.org/mailman/listinfo/python-list


asyncio project code review

2021-01-08 Thread James

Good day everyone.

I have new asyncio project which use aiohttp connector and asyncio 
protocols/transports for tunneling packets through Tor Network cleanly. 
Project called aiotor: https://github.com/torpyorg/aiotor


If someone with experience in asyncio field can make code review I will 
be appreciated for any comments.


I prepared pull request to make it convenient to review and comment on 
the code: https://github.com/torpyorg/aiotor/pull/1



--
https://mail.python.org/mailman/listinfo/python-list


Asyncio project code review

2021-01-08 Thread James

Good day for everyone.

I have new asyncio project which use aiohttp connector and asyncio 
protocols/transports for tunneling packets through Tor Network cleanly. 
Project called aiotor: https://github.com/torpyorg/aiotor


If someone with experience in asyncio field can make code review I will 
be appreciated for any comments.


I prepared pull request to make it convenient to review and comment on 
the code: https://github.com/torpyorg/aiotor/pull/1


Thanks in advance.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Newbie

2005-10-05 Thread James
1. What toolkit is best for Windows development?
"Best" depends on your needs. wxPython seems to be the most popular
one.

2. Which toolkits can I exclude from consideration?

You haven't given enough exclusion criteria. But here are the possible
issues to consider.

Fox - Hasn't been updated with a binary release since the release for
Python 2.2.
OpenGL - not a toolkit for everyday windowing needs. But I don't know
what you have in mind.
FLTK - Light Weight but doesn't have a good "MS Windows" feel.
pyQt - Be sure you check if the licensing bothers you.

3. What toolkit is most popular for Windows development?
wxPython seems to be the most popular one for Python, not just on "MS
Windows". I think it has more apps written with, than any other, and
the toolkit has active support for MS Windows specific technologies.

4. Are there any impartial reviews of these packages anywhere?
http://www.python.org/doc/faq/gui.html. Google for others.

I personally prefer not to do Windows GUI development in Python. I
prefer to use mainstream GUI dev tools for windows (Delphi, Visual
Studio) and pull in Python as embedded or as COM. But that's just "my"
preference. A lot of people here do it all in Python happily.

-- 
http://mail.python.org/mailman/listinfo/python-list


datetime and daylight savings problem

2005-10-11 Thread James
I need to import a bunch of data into our database for which there's a
single entry each day which occurs at the same time every day in local
time - so I need to convert this to UTC taking into account local
daylight savings. However daylight savings just don't seem to be
working at all...

Python 2.3.5 (#2, May  4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pytz import timezone
>>> from datetime import datetime
>>> t=timezone("Europe/Paris")
>>> utc=timezone("UTC")
>>> d=datetime(2005,01,24,16,59,tzinfo=t)
>>> d
datetime.datetime(2005, 1, 24, 16, 59, tzinfo=)
>>> d.astimezone(utc)
datetime.datetime(2005, 1, 24, 16, 59, tzinfo=)
>>> d2=datetime(2005,06,01,16,59,tzinfo=t)
>>> d2
datetime.datetime(2005, 6, 1, 16, 59, tzinfo=)
>>> d2.astimezone(utc)
datetime.datetime(2005, 6, 1, 16, 59, tzinfo=)

One of these should be in DST, the other shouldn't, I'm not sure why.
Additional oddness here

>>> d.astimezone(utc).astimezone(t)
datetime.datetime(2005, 1, 24, 18, 59, tzinfo=)
>>> d2.astimezone(utc).astimezone(t)
datetime.datetime(2005, 6, 1, 17, 59, tzinfo=)

I'm not sure if it's just something I'm doing completely wrong here...

James
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: destroy your self????

2005-10-20 Thread James
Doesn't work for classes because self has no global reference.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for .NET and IronPython

2005-11-02 Thread James
IronPython is good if you want to bring in Python into a .NET world.

Python for .NET is good if you want to bring in .NET into a Python
world.

As for your learning concerns, there need be none. There is really
nothing to learn extra for the integration. They just work. Once you
learn the .NET framework and Python, there isn't much to know
additionally.

While you are on topic, check out Boo. It is not the same as the ones
you mentioned but you might find it interesting and useful while
working with .NET if you have Python tastes.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which feature of python do you like most?

2005-11-08 Thread James
Most of the responses are of the "Why Python is more pleasant than C++"
variety, but the original poster specifically said he had experience
with Perl.  As such, arguments like "automatic memory management" don't
carry any weight.

>From my experience as both a Perl and Python user--and I do prefer Perl
for many tasks--the big win for Python is when you have complex data
structures: dictionaries containing arrays, arrays of arrays, array of
dictionaries, and so on.  This kind of thing is awkward in Perl (you
need to use references), but perfectly natural and obvious in Python.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not enough arguments for format string

2005-11-14 Thread James
Missing a comma there :)

On 14/11/05, johnnie pittman <[EMAIL PROTECTED]> wrote:
>  So the line above should be:
>
>  os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
>  DISPLAY;  echo %s | sudo -S %s; sudo -k'  % (password binpath))
>
>  try that.

os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
 DISPLAY;  echo %s | sudo -S %s; sudo -k'  % (password, binpath))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse best/good or bad IDE for Python?

2005-12-01 Thread James
There is no answer for that question. All Python IDEs have their own
strengths and weaknesses and different programmers expect different
things from their IDEs. What's best for YOU depends on what features
you need. PyDev, without question a "good" IDE. BEST is a subjective
affair.

I use Eclipse (or SPE) when I am unfamiliar with an API and auto list
members helps in those cases. Otherwise SciTe (or Vim/Kate/Emacs in
your case) suits me well.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread James
Use Jython or IronPython.
(Almost) One click web deployment is only available for Java and .NET
platforms at the moment.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread James
No! Jython does not have any of the problems you describe. Jython makes
Java byte code. Java bytecode can be deployed via Web Start. Period.
Jython can be used anywhere Java can be used. That's the whole beauty
of Jython. I am not hypothesizing. I actually did this a while ago and
it worked just fine. Why shouldn't it?

There is a released version of IronPython at
http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742
In fact it's being released every 2-4 weeks for quite a while now.

True, IronPython is not quite there yet, but it works for most part.
.NET 2.0 One Click Deployment should work with the generated
executable. I have not tried this myself. Both Jython and Web Start are
definitely more mature at the moment.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python web publishing framework like Cocoon?

2005-12-07 Thread James
None of those are anything like Cocoon. I can't think of any other
Python equivalents.

-- 
http://mail.python.org/mailman/listinfo/python-list


threading and internet explorer com

2005-01-27 Thread James
hi,
i'm using python 2.4 with pywin32...
I've tried to use internet explorer control with a class.
it was fine until i decided to inherit thread for the class...
class domain01(threading.Thread):
def __init__(self):
#blabla
threading.Thread.__init__(self)
	def run(self):
		self.ie = win32com.client.Dispatch('InternetExplorer.Application.1') 
#this line gives error if i use .start(), but if i use .run.. no error...
		self.ie.Visibble = 1
		print "running"
		

xyz = domain()
xyz.start()
===
this is what i get:
Exception in thread Thread-23:
Traceback (most recent call last):
  File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
  File "C:\python2exe\domain01.py", line 41, in run
self.dologin()
  File "C:\python2exe\domain01.py", line 56, in dologin
self.ie=win32com.client.Dispatch('InternetExplorer.Application.1')
  File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", 
line 95, in Dispatch
dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
91, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
79, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
com_error: (-2147221008, 'CoInitialize has not been called.', None, None)


=
but if i run:
xyz = domain()
xyz.run()
##no error! it's weird
anyone know how to solve this problem?
thank you :)
best regards,
James
--
http://mail.python.org/mailman/listinfo/python-list


Re: threading and internet explorer com

2005-01-28 Thread James
thak you Roger :)
thank you so much :)
best regards,
James
Roger Upole wrote:
You'll need to call pythoncom.CoInitialize() in each thread.
  Roger
"James" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

hi,
i'm using python 2.4 with pywin32...
I've tried to use internet explorer control with a class.
it was fine until i decided to inherit thread for the class...
class domain01(threading.Thread):
def __init__(self):
#blabla
threading.Thread.__init__(self)
def run(self):
self.ie = win32com.client.Dispatch('InternetExplorer.Application.1') #this 
line gives error if i use .start(), but if i use .run.. no error...
self.ie.Visibble = 1
print "running"


xyz = domain()
xyz.start()
===
this is what i get:
Exception in thread Thread-23:
Traceback (most recent call last):
 File "C:\Python24\lib\threading.py", line 442, in __bootstrap
   self.run()
 File "C:\python2exe\domain01.py", line 41, in run
   self.dologin()
 File "C:\python2exe\domain01.py", line 56, in dologin
   self.ie=win32com.client.Dispatch('InternetExplorer.Application.1')
 File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 
95, in Dispatch
   dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
 File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
91, in _GetGoodDispatchAndUserName
   return (_GetGoodDispatch(IDispatch, clsctx), userName)
 File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
79, in _GetGoodDispatch
   IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
com_error: (-2147221008, 'CoInitialize has not been called.', None, None)


=
but if i run:
xyz = domain()
xyz.run()
##no error! it's weird
anyone know how to solve this problem?
thank you :)
best regards,
James 


== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list


Re: IPython colors in windows

2005-02-03 Thread James

Ashot wrote:
> I am using IPython in windows and the LightBG setting doesn't
correctly
> because the background of the text is black even if the console
background
> is white.  Anyone know whats going on?  Thanks.
>
> --
> ==
> Ashot Petrosian
> University of Texas at Austin, Computer Sciences
> (views expressed are solely my own)
> ==

Did you try installing readline for windows?
http://newcenturycomputers.net/projects/readline.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread James
Interesting thread ...

1.) Language support for ranges as in Ada/Pascal/Ruby
1..10 rather than range(1, 10)

2.) Contracts

3.) With

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-27 Thread James
[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

Since you already know a bit of C++, you can try C++ Builder 6 from
Borland. It's old but you may even get the Personal Edition for free if
you download the Nokia toolkit. Personal edition doesn't have database
components included however. C++ is not an easy language beyond class
room use but C++ Builder is about as easy as it can be made. You don't
need to truly understand C++ and OOP to get by with some simple Windows
apps in C++ Builder. And most of what you learn about VCL (GUI library
in C++ Builder) will more or less translate to other toolkits. Stay off
VC++. You need some expertise to use it. C++.NET may be OK for you too.
C# will also be natural to someone with C++ know how.

 Visual Studio.NET(C# and C++.NET in your case) and Delphi are other
good options. SharpDevelop (.NET) is free and should be very easy to
understand for beginners. You can also look at the (free trial) beta
release of Visual Studio 2005 if you want something a little more
sophisticated but SharpDevelop is probably better to start with (not
too many features to overwhelm). Boo is a Python like language that
works with .NET and is well integrated with SharpDevelop.

Java GUI toolkits (Swing and SWT) use sophisticated OOP designs and are
very complex. Not easy for beginners to wrap their minds around. Non
professionals should stay off them. Your Java 1 will not prepare you
enough for them.

While Python is a wonderful language, GUI Builders (Boa, PythonCard,
Glade etc) available for it are nowhere close in maturity compared to
the ones I mentioned above. So stay off Python for GUIs for now. You
can come back once you have understood programming better.

As for Visual Basic, version 6 is very easy to learn and use for basic
applications but is no longer sold (other than used copies at eBay).
The new VB.NET is a bit more sophisticated. You will be better off with
C# rather than VB.NET (both are essentially the same) here since it
will be a more familiar syntax for you.

The best advice I can give is to pick a language/IDE with which you can
get some live help (friend/neighbor/colleage) who can hold your hands
for a while.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-07-02 Thread James
Steven D'Aprano wrote:
> On Fri, 24 Jun 2005 14:29:37 -0700, James wrote:
>
> > Interesting thread ...
> >
> > 1.) Language support for ranges as in Ada/Pascal/Ruby
> > 1..10 rather than range(1, 10)
>
> What advantages do Pascal-like for loops give over Python for loops?
>
> The only two I can think of are trivial:
>
> (1) the Pascal-like for loop is six characters shorter to type:
>
> for i = 1 to 10:# 16 chars
> for i in range(1, 10):  # 22 chars
>
> (2) for very large ranges, you don't have to hold the entire list of
> integers in memory. But you can use xrange() instead of range(), which
> also doesn't hold the entire list in memory.

First, I was never concerned about what I can do with the new keyword
that I could not do without since most languages are turing complete.
The question is that of elegance and it is subjective. I do know that
if Python kept adding features that everyone liked, it will end up like
Perl (although D seems to be doing a great job incorporating everyone's
favorite features while still retaining language consistancy. Then
again, it is very new.). But this thread is about favorite features
from other languages.

Secondly, the point was about ranges. Their use in loops (as in Ada and
Ruby) is just one instance. For me, they are more readable in the same
way I like -- for comments as in Eiffel and Ada rather than // and #
which do the same.


> > 2.) Contracts
>
> Explain please.

Design By Contract (as in Eiffel and D)

> > 3.) With
>
> Explain please.

As in Delphi
http://www.delphibasics.co.uk/RTL.asp?Name=With

There have been some PEPs regarding this.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you program in Python?

2005-07-03 Thread James


Peter Hansen wrote:
> anthonyberet wrote:
> > What I would really like is something like an old-style BASIC
> > interpreter, in which I could list, modify and test-run sections of
> > code, to see the effects of tweaks, without having to save it each time,
> > or re-typing it over and over (I haven't even worked out how to cut and
> > paste effectively in the IDLE environment).
>
> I do all my work using Scite (a nice free editor that was built to
> demonstrate the Scintilla plugin that can also be used in Python
> programs through things like the StructuredTextControl in wxPython),
> with the auto-save-on-loss-of-focus feature enabled, and a command
> prompt open in another window.
>
> I edit in the Scite window, hit Alt-Tab (under Windows XP) to change
> focus to the cmd console (and instantly all my modified files are
> saved), press the Cursor Up key to retrieve the previous command (which
> is generally the name of my script, or a command like "python
> myscript.py"), and hit Enter to execute it.
>
> So, any time I need to test the changes, I hit four keys (which at this
> point is understandably more like a "chord" that I hit without direct
> awareness of it) and I'm done.  Sounds pretty close to old-style BASIC
> and since I've come that route too (in the distant past), this may not
> be a coincidence.

Just curious. Why do you Alt-Tab to a console when you can just hit F5
in SciTE? That's just 1 key instead of 4. And yes, SciTE can autosave
here too.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Programming Contest

2005-07-15 Thread James


Brian Quinlan wrote:
> I've decided that it would be be fun to host a weekly Python programming
> contest. The focus will be on algorithms that require a bit of thought
> to design but not much code to implement.
>
> I'm doing to judge the solutions based on execution speed. It sucks but
> that is the easiest important consideration to objectively measure. I'll
> also indicated which solutions I think are good examples of Python
> design. Hopefully, people's solutions can provide a resource for people
> looking for best practice examples and also for people looking for
> performance ideas.
>
> You can find the first problem here:
> http://www.sweetapp.com/pycontest/contest1
>
> I'm always looking for feedback, so let me know what you think or if you
> have any ideas for future problems.
>
> Cheers,
> Brian

I am not sure if it is a good idea to use a LiveCD for OS when you are
testing for speed. CD access speeds fluctuate and may even impact
performance even if you start measuring after the module loading is
complete.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I just wanna know about os.path module..

2005-07-17 Thread James


kimes wrote:
> I've just started digging into how python works..
> I found that other mudules are clearly declared like one file per a
> module..
>
> But the only os.path doesn't have their own file..
> ye I know is has actually depending on os like in my case posixpath..
>
> What I'd love to know is..
> when I call import os.path..
> how happened under the hood?
>
> I'm currently using python 2.4 in linux machine..
> I'd appreciate it

See line 5 of os.py (comment)
  - os.path is one of the modules posixpath, ntpath, or macpath
It says it sets os.path depending on the platform

and does so in line 132
sys.modules['os.path'] = path

In your case, os.path should be implemented in posixpath.py
See line 48 to see where it came from

In short, "use the source, Luke" :-)
especially when Python is exceptionally readable.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well, another try Re: while c = f.read(1)

2005-08-19 Thread James
> for data in iter(lambda:f.read(1024), ''):
> for c in data:

What are the meanings of Commands 'iter' and 'lambda', respectively? I
do not want you to indicate merely the related help pages. Just your
ituitive and short explanations would be enough since I'm really newbie
to Python.

-James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doubt C and Python

2005-08-23 Thread James
> Some people with C background use Python instead
> of  programming in C.why?

Becuase it is much more efficient.

-James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: loop in python

2005-08-25 Thread James
I am going to be a bit blunt. Don't get offended.

>> Also the first thing any newbie to python asks me is abt "raw speed in 
>> comparison with similar languages like perl" when i advocate python to perl.

Judging by your other posts, you are a newbie yourself. You are not
really in a position to 'advocate' any language over others.

>> I agree that python emphasizes on readability which i didnt see in many of 
>> the languages, but when the application concern is speed, does it mean that 
>> python is not yet ready? even most of the googling abt python vs perl  
>> convince me that perl is faster than python in most of the aspects.

One does not compare speed when they use Perl/Python/Ruby/Tcl. They are
all more or less in the same performance ball park.

Next don't make up your own benchmarks and jump to conclusions. Writing
good benchmarks is an art. If you need data, look at peer reviewed
benchmarks such as this one. http://shootout.alioth.debian.org/
As with all benchmarks, it is really hard to make general conclusions.

And you are simply looking at the wrong issue. Even if Python is 20
times slower than it's current implementation, it would still serve my
purposes. Do you believe that you need more speed? Tell us what is it
exactly that you are building and we will tell you what to do. Fetishes
with Speed and executable size are very common for young newbies. I
know because I had been there myself several years ago.

Python has been more than ready as far as speed goes. Real people, real
enterprises have been using Python in high load applications for quite
a while now and there is nothing really left to proove. People have
written entire application servers and databases in Python.

I taught myself atleast half a dozen ways to write native extensions
for Python, just in case. In the past 4 yrs or so that I have been
using Python as my main language, I did not need to speed up my Python
program even once with a custom extension. And I process multi giga
byte data sets. Why? Because, if your program is slow, chances really
are that your algorithm is slow, not the language. And most of the
Python modules that are available that need speed (GUIs, image
processing etc), are already written in C so that you, as a user, don't
have to worry.

Just get over your imaginary need for speed and learn to use Python for
what it is intended. Once again, post your actual application need, not
vague requirements with artificial conditions (I don't want C modules).

You said, elsewhere that you are writing a web application. People have
been using CGI, which has a terrible performace record for decades on
very slow machines compared to modern PCs. My point is, web
applications, "generally" aren't exactly the kind of applications that
have a lot of computational overhead, atleast not from the logic that
runs your site and is likely to be written in Python.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: loop in python

2005-08-25 Thread James
>> I don't want to offend you or anything, but doesn't the second sentence mean 
>> that someone DID do a speed comparison?

I did provide Language Shootout link in the next paragraph of the post
you referred to along with an obligatory caution about interpreting
benchmarks. The Language Shootout is a general enough benchmark to
cover all popular languages not just comparing between
Perl/Python/Ruby/Tcl (which I said was pointless). So the statements
are not in conflict.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: classes and list as parameter, whats wrong?

2005-08-26 Thread James
No, the default paramter LL is only ever created once, not
reinitialised every time the constructor is called - this is quite a
common gotcha! You want to do something like:

 class cClass:
 """ Base class to handle playlists, i.e. the files, the name, etc. """
 def __init__(self, LL=None):
 if LL == None:
 LL = []
 self.list=LL
 def addFile(self,L):
 self.list.append(L)

James

On 8/26/05, Dirk Zimmermann <[EMAIL PROTECTED]> wrote:
> Hi!
> 
> I have a problem in a program. And I don't understand what is going on.
> I can code something, that the "error" doesn't occur anymore. But I
> still don't know the reason and this is unsatisfactory: Did I understood
> something wrong or is there a bug? To make it short, I boiled down the
> program to the crucial part.  It looks like this:
> 
> --- START 
> #!/usr/bin/env python
> 
> class cClass:
> """ Base class to handle playlists, i.e. the files, the name, etc. """
> def __init__(self, LL=[]):
> self.list=LL
> def addFile(self,L):
> self.list.append(L)
> 
> def main():
> l1 = ['a','b','c']
> lNames=['n1','n2','n3']
> for name in lNames:
> objC=cClass()
> for each in l1:
> objC.addFile(each)
> print objC.list
> del objC
> 
> if __name__ == "__main__":
> main()
> --- END 
> 
> If I start it, I get the following output:
> 
> ['a', 'b', 'c']
> ['a', 'b', 'c', 'a', 'b', 'c']
> ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']
> 
> 
> Why does this list grow? I thought, with every new instance the list LL
> is set to []?
> 
> How can bring light in this?
> 
> 
> Best,
> Dirk
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Integrate C source in a Python project

2005-08-26 Thread James
billiejoex wrote:
> Hi all.
> I was wondering if it ispossible to integrate C source in a python project.

There is ofcourse Python/C API
http://docs.python.org/api/api.html

But you will probably be easier off with Pyrex or Swig.

Good summary on when to use which
http://www.rexx.com/~dkuhlman/python_201/python_201.html#SECTION00650

James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Language translation possible in python?

2005-08-26 Thread James
As Terry, mentioned BabelFish should be a good resource.

I have used Google Language tools in the past. It worked reasonably
well with French and German. Now they included English to Korean BETA.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well, Python is hard to learn...

2005-09-01 Thread James
I don't know about you but I would not learn ANY decent programming
language for a week and expect to know the idioms enough to understand
the source of a large software written in it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: infinite loop

2005-09-06 Thread James
Devan L wrote:
> LOPEZ GARCIA DE LOMANA, ADRIAN wrote:
> > Hi all,
> >
> > I have a question with some code I'm writting:
> >
> >
> > def main():
> >
> > if option == 1:
> >
> > function_a()
> >
> > elif option == 2:
> >
> > function_b()
> >
> > else:
> >
> > raise 'option has to be either 1 or 2'
> >
> > if iteration == True:
> >
> > main()
> >
> > def function_a():
> >
> > print 'hello from function a'
> >
> > return None
> >
> > def function_b():
> >
> > print 'hello from function b'
> >
> > return None
> >
> > iteration = True
> >
> > option = 1
> >
> > main()
> >
> >
> > I want an infinite loop, but after some iterations (996) it breaks:
> >
> >
> > [EMAIL PROTECTED] tmp]$ python test.py
> > hello from function a
> > hello from function a
> > hello from function a
> > .
> > .
> > .
> > hello from function a
> > hello from function a
> > Traceback (most recent call last):
> >   File "test.py", line 35, in ?
> > main()
> >   File "test.py", line 17, in main
> > main()
> >   File "test.py", line 17, in main
> >
> > .
> > .
> > .
> > .
> >   File "test.py", line 17, in main
> > main()
> >   File "test.py", line 17, in main
> > main()
> >   File "test.py", line 5, in main
> > function_a()
> > RuntimeError: maximum recursion depth exceeded
> >
> >
> > I don't understand it. Why am I not allowed to iterate infinitely? 
> > Something about the functions? What should I do for having an infinite loop?
> >
> > Thanks in advance for your help,
> >
> > Adrián.
>
> You've written a recursive function-you're not iterating. The recursion
> limit is there to keep you from making something which will do
> something bad, like recurse cyclically.

What you need is probably this...

def main():
while iteration:
if option == 1:
function_a()
elif option == 2:
function_b()
else:
raise 'option has to be either 1 or 2'

def function_a():
print 'hello from function a'

def function_b():
print 'hello from function b'

iteration = True
option = 1
main()

As a side note, note that you don't really need to return a None.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Django Vs Rails

2005-09-08 Thread James
I actually like the framework to reflect on my database. I am more of a
visual person. I have tools for all my favorite databases that allow me
to get a glance of ER diagrams and I would rather develop my data
models in these tools rather than in code. Further more I rather like
the idea of parsimonious use of code (which is probably why I use
Python in the first place) and do not really like manually specifying
data schemas in code as much as possible.

Is some familiar with a Python Framework that builds by reflection.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about consistency in python language

2005-09-11 Thread James
> Also, you shouldn't use "1", I mean "l", as a variable name. It gets confusing
> because "l", I mean "1", looks a lot like "1", I mean "l".

I have seen the same warnning above significantly several times.
Is this problem originally came from the similarities between 'l' and
'1'
or from bad looking news-browser?
Forgive me if it is out of your interests.

-James GOLD

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A great Alan Kay quote

2005-02-09 Thread James
Surely

"Perl is another example of filling a tiny, short-term need, and then
being a real problem in the longer term."

is better lol ;)


On Wed, 09 Feb 2005 11:00:32 -0800 (PST), Grant Edwards <[EMAIL PROTECTED]> 
wrote:
> In an interview at 
> http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273
> Alan Kay said something I really liked, and I think it applies
> equally well to Python as well as the languages mentioned:
> 
> I characterized one way of looking at languages in this
> way: a lot of them are either the agglutination of features
> or they're a crystallization of style. Languages such as
> APL, Lisp, and Smalltalk are what you might call style
> languages, where there's a real center and imputed style to
> how you're supposed to do everything.
> 
> I think that "a crystallization of style" sums things up nicely.
> The rest of the interview is pretty interesting as well.
> 
> --
> Grant Edwards   grante Yow!  Look!! Karl Malden!
>   at
>visi.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


wxgrid multiline cell editor

2005-02-09 Thread James
wxpython 2.5.3
hi,
anyone know how to make a multiline cell editor for wxgrid?
thank you :)
best regards,
James
--
http://mail.python.org/mailman/listinfo/python-list


Re: goto, cls, wait commands

2005-02-10 Thread James
On Windows, I use WConio
http://newcenturycomputers.net/projects/wconio.html

It provides other screen functions you might have gotten used to in
QBasic as well.

On unix/cygwin, use curses.

I am not aware of any portable library though.
I used to use cls a lot in my QBasic days. Now I just don't.

-- 
http://mail.python.org/mailman/listinfo/python-list


thanks jean

2005-02-14 Thread James
hi jean :)
thanks for your help :)
i'll try it :)
i missed your message... did a search in google and found your reply :)
thanks a lot :)
best regards,
James
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-17 Thread James
Mike Cox wrote:
> As you may or may not know, Microsoft is discontinuing Visual Basic
in favor
> of VB.NET and that means I need to find a new easy programming
language.  I
> heard that Python is an interpreted language similar to VB.

VB is not interpreted. Sure! You can compile it to P-Code if you want
to but most people compile to machine code (like C, C++, Assembler).
You are confusing between static linking in C++ etc and mandatory
dynamic linking with VB runtimes with interpreted languages. VB needs
runtimes but is not interpreted generally.

Python is NOT similar to VB. It is much better as a language. VB is
optimized to what you are doing currently. Python is a more general
purpose language.

> This means that
> it doesn't have all the hard stuff like pointers, classes and
templates like
> C, C++ and assembly language.

Python has classes.
C and Assembly do not have classes and templates.
If I remember correctly, VB could have pointers too (Address
function?).

> Where I work we use  Microsoft Office with a lot of customization
using
> Visual Basic.  I would like to switch to Python to do it since VB is
being
> discontinued.  Would Python meet our requirements? I need to make
lots of
> GUI applications (message boxes, forms, etc.) and do the underlying
business
> logic too.

You will probably find migrating to VB.NET easier than to Python if you
have to do WYSIWYG data bound form design.

VB.NET is quite a nice language (I personally prefer C#). Much nicer
than VB6. Python is better but it may not meet YOUR needs
infrastructure wise.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-17 Thread James
>> VB has a much better IDE than the IDE's for Python, although Eric3
is
one of the best, and is absolutely free.

There is no binary distribution for Eric3 on MS Windows. The OP sounds
like he is an exclusively windows programmer.

While we are on topic, is there no one in the Python open source
community who has a commercial license to Qt for Windows and can make a
binary distribution for Eric3 for MS Windows?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-17 Thread James
Before we discuss this any further, I suggest that you guys take a look
at OP's posts in comp.os.linux.advocacy.

I think we all regulars here know where VB and Python stand. Let's not
take bait on this one.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-17 Thread James
> We have almost finished Windows form designer support in SharpDevelop

> IDE for boo, a .NET language similar to Python.  But still in your
case
> I'd just use VB.NET since you are familiar with VB and all .NET
> languages are pretty comparable.

Wow! That's great news. I saw a few days ago an old post that said you
guys were waiting for the new .NET as implementing this kind of thing
is simpler in it. Anyway. Great work. This probably makes Boo the first
non-MS .NET language to have form designer support. Correct?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-18 Thread James
> You are right that VBA isn't being discontinued yet. My own interest
in
> learning python is to find a replacement for Excel VBA. I'm a
> mathematician who likes to throw quick programs together for things
> like statistical simulations. I liked the ability to get functioning
> code quickly in VBA, together with the ability to easily generate
> graphs of the results, etc., but I finally got tired of the slow
speed
> and verbose syntax. I'm hoping that Python (as packaged by Enthought
> together with various numerical and graphing modules) will be an
> appropriate replacement.
>
> -scattered

Enthought's distribution will suit your purposes.
Also consider http://www.r-project.org/
which is a tool created for just your needs. Some statisticians here
love it.

-- 
http://mail.python.org/mailman/listinfo/python-list


IronPython 0.7 released!

2005-03-23 Thread James
http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IronPython 0.7 released!

2005-03-23 Thread James
François Pinard emailed me that my posting of the link with no
explanation appeared rude.

So here is a some information.



IronPython is a Python implementation targeting the .NET and Mono
platforms from the same person who brought us Jython,  Jim Hugunin. MS
hired Jim since the first release (0.6) and this is the first and
eagerly awaited release since then.

Now if I hear something about the state of StarKiller, it would make my
day complete :-).

>From the release

 IronPython is the code name of the early pre-alpha preview release of
the new Implementation Running on .NET of the Python programming
language. The .NET Framework is a managed programming model for
Windows; Microsoft standardized part of it in ECMA  several years ago
as the Common Language Infrastructure and C# Language Specification
standards.

IronPython is fast - up to 1.8x faster than Python-2.4 on the standard
pystone benchmark. It supports an interactive interpreter with fully
dynamic compilation. It is well integrated with the rest of the
framework and makes all .NET libraries easily available to Python
programmers.

IronPython 0.7 is a pre-alpha release. It is suitable for experimenting
and playing with; however, a large amount of testing, packaging and
library development remains to be done before a production-quality
IronPython-1.0.  We want to be sure to release IronPython in this early
state in order to encourage feedback and discussion in the community of
IronPython's features and designs as early as possible so that we can
incorporate that into the 1.0 design.



Also see
Boo
Boo is a new object oriented statically typed programming language for
the Common Language Infrastructure with a python inspired syntax and a
special focus on language and compiler extensibility.
http://boo.codehaus.org/

Python for .NET
Python for .NET is a near-seamless integration of the Python runtime
with the .NET Common Language Runtime (CLR). It lets you script and
build applications in Python, using CLR services and components written
in any language that targets the CLR (C#, Managed C++, VB.NET, etc.).
www.zope.org/Members/Brian/PythonNet

James.

--
http://mail.python.org/mailman/listinfo/python-list


Document exchange!

2005-04-10 Thread James
This is not so much as a Python question though I will implement it in
it.

I am looking to securely aggregate documents based on a metadata from
multiple providers. I am getting the feeling that I am reinventing the
wheel. If anyone knows similar work elsewhere, please point me to it.

Security and simplicity (is it possible to use the two in the same
sentence? :-) ) of the protocol is king. I have the luxury of
implementing any protocol I choose on each reposity.

Thanks,
James

-- 
http://mail.python.org/mailman/listinfo/python-list


permission

2005-04-12 Thread James
Is it possible to check if you have permission to access and or change a
directory or file?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little request about spam

2005-04-14 Thread James
Yes - it's been like that for the last month or so now and it's quite
annoying, especially seeing as before it was working at near enough
100% accuracy.

On 4/14/05, mark hellewell <[EMAIL PROTECTED]> wrote:
> On 4/14/05, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
> > Please do not reply to spam. Replying to spam makes it much harder for
> > spam filters to catch all the spam or will produce very many false
> > positives. Atleast that's how gmail's filter works. And if you must
> > reply, please change the subject line.
> 
> Is anybody else finding that Gmails spam filter has started
> labelling a lot of python-list emails as spam? About 20
> python-list emails a day end up getting caught by their
> filter and I'm having to manually go in and mark them
> as "Not spam".
> 
> mark
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's use in RAD

2005-04-17 Thread James
[EMAIL PROTECTED] wrote:
> Active State's Komodo IDE is very nice for python development.  It
> includes integration with pdb (python's debugger).  The pro edition
> also has a GUI designer, however I've never used it.  The personal
> version for non commercial use can be had for $30 (and there's also a
> 30 day trial).  They have windows, linux, and solaris versions.
>
> Ross Cowie wrote:
> > Hi,
> >
> > I am currenly a second year university student and was wondering if
> you
> > could help me ut. As part of a project i have decided to write
about
> python,
> > i am not having very much luck with regards to finding infrmation
on
> pythons
> > use in Rapid Application Development, and was wondering of you
could
> > highlight some of the features that make it suitable for RAD. Like
> the use
> > of dinamic binding.
> >
> > Your healp would be appreciated.
> >
> > Hope to hear from you soon.
> >
> > Ross

I don't think he is asking for tools that he could use for creating GUI
apps. Instead he is asking for the features of Python that would make
it easier to build RAD tools to put in his homework.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python class have not private methods? Will this neverchanged?

2005-04-19 Thread James
Trolls?

On 4/19/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> "could ildg" <[EMAIL PROTECTED]> wrote:
> 
> > Private stuff always makes programming much easier.
> 
> says who?
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyDev 0.9.3 released

2005-04-25 Thread James
It does for me. I just installed through it.

http://pydev.sourceforge.net/updates/

I am having some other problems though. When I run it, I get ...

sys:1: DeprecationWarning: Non-ASCII character '\x90' in file
C:\Python24\python.exe on line 1, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
  File "C:\Python24\python.exe", line 1
MZ?$,000$0 0n.pdbAª330‡ª3‡::0ª3‡ª3‡
  ^

It is reading python.exe as a text source file. I must have configured
something off.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive generator for combinations of a multiset?

2013-11-21 Thread James
On Thursday, November 21, 2013 5:01:15 AM UTC-8, John O'Hagan wrote:
> On Thu, 21 Nov 2013 11:42:49 +
> 
> Oscar Benjamin  wrote:
> 
> 
> 
> > On 21 November 2013 06:46, John O'Hagan 
> 
> > wrote:
> 
> > >
> 
> > > I found a verbal description of such an algorithm and came up with
> 
> > > this:
> 
> > >
> 
> > > def multicombs(it, r):
> 
> > > result = it[:r]
> 
> > > yield result
> 
> > > while 1:
> 
> > > for i in range(-1, -r - 1, -1):
> 
> > > rep = result[i]
> 
> > > if rep < it[i]:
> 
> > > break
> 
> > > else:
> 
> > > break
> 
> > > for j, n in enumerate(it):
> 
> > > if n > rep:
> 
> > > break
> 
> > > result = result[:i] + it[j:j - i]
> 
> > > yield result
> 
> > 
> 
> > I'm not really sure what it is you're asking for. I thought if I ran
> 
> > the code I'd understand but that just confused me more. Is the output
> 
> > below correct? If not what should it be?
> 
> > 
> 
> > multicombs("abracadabra", 0)
> 
> > ['']
> 
> > multicombs("abracadabra", 1)
> 
> > ['a']
> 
> > multicombs("abracadabra", 2)
> 
> > ['ab', 'br', 'ra']
> 
> > multicombs("abracadabra", 3)
> 
> > ['abr', 'ara', 'bra']
> 
> > multicombs("abracadabra", 4)
> 
> > ['abra']
> 
> > multicombs("abracadabra", 5)
> 
> > ['abrac', 'abrbr', 'abrra', 'braca', 'brara', 'brbra', 'racad',
> 
> > 'racbr', 'racra']
> 
> 
> 
> 
> 
> I neglected to mention that multicombs takes a sorted iterable;
> 
> it doesn't work right otherwise. I'd forgotten that because my
> 
> wordlists are guaranteed sorted by the way they're built. Sorry about
> 
> that.
> 
> 
> 
> In my use-case the first argument to multicombs is a tuple of words
> 
> which may contain duplicates, and it produces all unique combinations
> 
> of a certain length of those words, eg:
> 
> 
> 
> list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3))
> 
> 
> 
> [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'),
> 
> ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'),
> 
> ('in', 'the', 'the')]
> 
> 
> 
> Contrast this with: 
> 
> 
> 
> list(itertools.combinations(('cat', 'hat', 'in', 'the', 'the'), 3))
> 
> 
> 
> [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'hat', 'the'),
> 
> ('cat', 'in', 'the'), ('cat', 'in', 'the'), ('cat', 'the', 'the'),
> 
> ('hat', 'in', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'),
> 
> ('in', 'the', 'the')]
> 
> 
> 
> which produces results which are redundant for my purposes.
> 
> 
> 
> What I'm looking for is a recursive algorithm which does what
> 
> multicombs does (order unimportant) so that I can apply a pruning
> 
> shortcut like the one I used in the recursive cartesian product
> 
> algorithm in my original post.
> 
> 
> 
> Multiset combination algorithms seem pretty thin on the ground out
> 
> there - as I said, I could only find a description of the procedure
> 
> above, no actual code. The ones I did find are non-recursive. I'm
> 
> hoping some combinatorics and/or recursion experts can offer advice. 
> 
> 
> 
> Regards,
> 
> 
> 
> --
> 
> 
> 
> John

Could convert the following perl script to python?

use Data::Dump qw(dump);
dump combo([@ARGV], 3);

sub combo {
my ($t, $k) = @_;
my @T = @$t;
my @R = ();
my %g = ();
if ($k == 1) {
for (@T) {
push @R, $_ unless $g{$_}++;
}
} else {
while (my $x = shift @T) {
$p = combo([@T], $k-1);
for (@{$p}) {
my $q = $x.",".$_;
push @R, $q unless $g{$q}++;
}
}
}
[@R];
}

$ prog.pl cat hat in the the
[
  "cat,hat,in",
  "cat,hat,the",
  "cat,in,the",
  "cat,the,the",
  "hat,in,the",
  "hat,the,the",
  "in,the,the",
]

James
-- 
https://mail.python.org/mailman/listinfo/python-list


pygtk beginner script not working

2015-11-14 Thread james
Hi guys

I'm new to Python so please bare with me :)

I'm using python 2.7.10 as advised (more tools apparently over 3.x)

Trying to use this script

[CODE]
#!/usr/bin/env python

# example base.py

import pygtk

pygtk.require('2.0')
import gtk

class Base:
   def __init__(self):
  self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  self.window.show()

def main(self):
   gtk.main()
   
   print __name__
   if __name__ == "__main__":
  base = Base()
  base.main()
[/CODE]

But get this error:

[i]File "C:\Users\CMDEV\Desktop\Py\pygtk_1.py", line 5, in 
import pygtk
ImportError: No module named pygtk[/i]

I've check the install and everything reports its installed right:

Here's a grab of the CLI


[CODE]
C:\Python27>easy_install -U pygtk
Searching for pygtk
Reading https://pypi.python.org/simple/pygtk/
Reading http://ftp.acc.umu.se/pub/gnome/binaries/win32/pygtk/2.24/
Reading http://www.daa.com.au/~james/pygtk/
Reading http://www.daa.com.au/~james/software/pygtk/
Reading http://www.pygtk.org
Reading http://www.pygtk.org/
Best match: pygtk 2.24.0
Processing pygtk-2.24.0-py2.7-win32.egg
pygtk 2.24.0 is already the active version in easy-install.pth
Installing pygtk_postinstall.py script to C:\Python27\Scripts
Installing pygtk_postinstall.pyc script to C:\Python27\Scripts

Using c:\python27\lib\site-packages\pygtk-2.24.0-py2.7-win32.egg
Processing dependencies for pygtk
Finished processing dependencies for pygtk

C:\Python27>python C:\Users\CMDEV\Desktop\Py\pygtk_1.py
Traceback (most recent call last):
  File "C:\Users\CMDEV\Desktop\Py\pygtk_1.py", line 5, in 
import pygtk
ImportError: No module named pygtk
[/CODE]


(not used google groups before to post on so not sure if BB code works here... 
also there doesn't seem to be a preview button so no idea how this turns out)

Cheers
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using XML w/ Python...

2005-12-10 Thread James
XPath is the least painful way of doing it.

Here are some samples with various libraries for XPath
http://www.oreillynet.com/pub/wlg/6225

Read XPath basics here
http://www.w3schools.com/xpath/default.asp

It is not practical and perhaps not polite to expect people write
tutorials just for you and send by email. There are a lot of tutorials
on the web on this. Just use Google.

-- 
http://mail.python.org/mailman/listinfo/python-list


Pythonic XML library with XPath support for Jython?

2005-12-11 Thread James
A couple of years ago there wasn't one and the recommendation was to
simply use Java libs. Have things changed since?

I see ElementTree promises one in the future but are there any out now?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using XML w/ Python...

2005-12-11 Thread James
ActivePython is same as Standard Python distribution but with a few
extras.

"As far as it should work since their both transparent, umm, well its
not."

Why do you think it is not transparent? Did you try installing it on
both?
I have ActivePython 2.4 here and it loads amara fine.

"
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named amara
"

That means you did not manage to install it properly. Are you new to
installing Python modules from command line? If you need more hand
holding, try the Python IRC channel on freenode. The responses will be
more in real time. You probably need that since you seem to have more
than one thing to learn about.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython and Amara

2005-12-13 Thread James
Jay,
  Profanity is unwelcome in this newsgroup. Alex's advice is very well
placed and you will realize that once you stop seeing it as a personal
attack. Different newsgroups have different attitudes. comp.lang.python
is not exactly a tech support group. Bug reports posters here are
frequently advised to go to the respective module forums. You were not
singled out.

  A large number of contributors to this group are well educated
professionals and strong contributors to Python. If you expect
responses, you must behave accordingly. If you cannot, you will have to
find a group where such culture is better tolerated, like IRC. And your
post is better suited for IRC to begin with as you seem to be needing a
number of clarifications at a time. Not to mention your impatience.
IRC, once again is more real time for you.

  And for the last time... your problem is not ActivePython related.
>From what has been established so far, it is a bug in the build of the
Win32 binary installer of the module for your Python version.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython and Amara

2005-12-14 Thread James
If you are having problems installing Amara, ElementTree is another
option

http://effbot.org/downloads/elementtree-1.2.6-20050316.win32.exe

from elementtree import ElementTree as ET
from urllib import urlopen

rss = ET.parse(urlopen('index.xml'))
title = rss.find('//channel/title').text
articles = [item.find('title').text for item in
rss.findall('//channel/item')]

This is quick and dirty. Read this
(http://diveintopython.org/http_web_services/review.html) before you
make the real thing.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython and Amara

2005-12-14 Thread James
OK! The story so far ...
You wanted to parse an RSS feed and wanted a simple library. You tried
Amara. The binary installer had a problem. Not sure what was the issue
with installing the source via distutils.

Since you have way too many options to do this, it is probably better
to switch to another module for now.

ElementTree is another good module
http://effbot.org/downloads/elementtree-1.2.6-20050316.win32.exe

Following is a snippet of code that probably does what you want.
You should be able to extend it from there.
You might want to read this before you finish your aggregator.
http://diveintopython.org/http_web_services/review.html
Basically some netiquette when you repeatedly poll someone's server.
---

from elementtree import ElementTree as ET
from urllib import urlopen

rss = ET.parse(urlopen('http://www.digg.com/rss/index.xml'))
title = rss.find('//channel/title').text
articles = [item.find('title').text for item in
rss.findall('//channel/item')]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython and Amara

2005-12-15 Thread James
Jay,
  You are practically asking the community to write your 4 line program
for you. Read Alex's post (first one in this thread, 2nd and 3rd
paragraphs) slowly and carefully again. If you understand the absolute
basics of Python, you would not be asking this question, nor the
previous one. You are trying to learn Python picecemeal, just enough to
write the next half a line of code at a time, and asking others to do
it for you. If you don't understand the basic Python data types (hint),
HTTP, XML, XPath or at least Regular Expressions, it is not the time
for you to write an RSS aggregator. You need to start with basics.

Please note that it is far simpler for me to give you your 1 line of
code to solve your problem than to type this lengthy post. But then I
would be giving you a fish, not teaching you to fish.

Start with simpler tutorials.

This is a great place to start. (It comes with your ActivePython
documentation).
http://www.ibiblio.org/obp/thinkCSpy/

Another good one.
http://www.ibiblio.org/g2swap/byteofpython/read/index.html

Make sure you read the easy tutorials till you understand most (or
better, all of) the Offical Python Tutorial.(It comes with your
ActivePython documentation)
http://docs.python.org/tut/tut.html

Then go for (It comes with your ActivePython documentation)
http://diveintopython.org/toc/index.html

Once you are done with these docs, we will be ready to talk.

Learning to program by building apps that you can actually use (as in
your RSS aggregator) is very fun. But it is very  bad process that
teaches you a number of habits that are hard to unlearn. I know because
I have been this route early on and have seen several others have
similar experiences.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython and Amara

2005-12-16 Thread James
Where I go to work, a quote stands etched in a very large font into the
concrete prominently to remind us to be humble.

The greatest obstacle to discovery is not ignorance - it is the
illusion of knowledge.
(Daniel J. Boorstin)

You just have to trust us on this. We are not jumping to conclusions
based on one or two silly posts. It was evident in almost *every* post
you posted so far. *You really are a newbie* and there is nothing wrong
with that. We all have been there. But you must stop being defensive
about it. You just need to be patient and read all the docs before
trying to do what you are trying to do now.

Here is a link to keep you busy.
http://www.awaretek.com/tutorials.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wingide is a beautiful application

2005-12-17 Thread James
>> I haven't used an IDE in a long time but gave wing ide a try because
>> I wanted the same development platform on Linux and Windows.

>> I'm currently using Ultraedit and it works fine but needed something
>> more portable as I'm moving my main platform over to Ubuntu. I first
>> tried jedit and was reasonably happy with it but it felt slow and it
>> did not have a native look and feel to it. It was really hard on the
>> eyes.

Then you owe it to yourself to also try SPE, PyDev and Boa Constructor
(got off to a slow start, but it looks promising now). All are free,
open source, cross platform, native look and feel and support more or
less the features you list.

>> Does anyone know what gui toolkit wingide uses? it really is one of the
>> best applications I've seen for some time and it's a great way to
>> support python.

GTK.

Two minor peeves about WingIDE.
1.) Not native look and feel.
2.) Auto List members implementation is great. But what about call
tips? Just as important and every other Python IDE has it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is unique about Python?

2005-12-19 Thread James
>> The indentation-based syntax seems to be unique

I think Haskell was there first. As well as ABC, one of Python's
precursors.

Python is a pragmatic language, just like C (I wish I could say that
about Java). It does not necessarily innovate but incorporates things
known to work elsewhere. C and Java have not done anything particularly
unique either. They are included in curricula by their popularity.
Isn't that a good enough argument?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Queueing in Python (ala JMS)

2005-12-20 Thread James
Stefan Arentz wrote:
> Is there a JMS-like API available for Python? I would like to
> quickly receive messages through the network and then process
> those slowly in the backgound. In the Java world I would simply
> create a (persistent) queue and tell the JSM provider to run
> N messagehandlers parallel.
>
> Is something like that available for Python?

You could always use Jython or JPype.

There is a wrapper for Spread that might be interesting for you.
http://www.zope.org/Members/tim_one/spread

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Queueing in Python (ala JMS)

2005-12-20 Thread James

Wolfgang Keller wrote:
> > Is there a JMS-like API available for Python?
>
> Better. >:-> Omninotify, a Corba notification service implementation.
>
> Sincerely,
>
> Wolfgang Keller

And it's ICE (a CORBA alternative with Python bindings) equivalent

IceStorm
A messaging service with support for federation. In contrast to most
other messaging or event services, IceStorm supports typed events,
meaning that broadcasting a message over a federation is as easy as
invoking a method on an interface.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or Java or maybe PHP?

2006-01-02 Thread James
Now I am curious. How do Python 2.5 and Ruby create new control
structures? Any code samples or links?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Productivity and Quality of IDE

2006-01-03 Thread James
It depends on a number of factors including yourself. I am a very
visual person. I consider visual design as the native language of
expression and representation (at least from a human stand point) for
objects that have visual end presentation. I know I am productive this
way. Your mileage may wary on how you prefer to think.

It also depends on how good the tool chain is designed. Delphi, Visual
Studio.NET, Dreamweaver for example are a sheer pleasure for me to
design interfaces with. In my Delphi days, I used to feel that thhe IDE
was critical to my productivity. But the old VB6 and FrontPage and even
recent Java IDEs get in my way often. I tend to think most people find
seamless integration more productive. If you are an outlier, good for
you.

As for simple language IDEs, some languages benefit more than others.
Even though I like more integrated solutions like PyDev, SPE etc and
have a long history of IDE usage, I keep coming back to SciTE when it
comes to Python. But I would not dream using Java/C# without an IDE.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or Java or maybe PHP?

2006-01-03 Thread James
While on topic of custom contructs, the topic of syntactic macros has
come up in the past. Does anyone know if the dev team ever considered
for or against them? My interest in them was renewed when I came across
Logix
http://www.livelogix.net/logix/
It does not seem very active at the moment nor do they see Python as a
long tem platform for their project. Although it already seemed usable
in the little programs I tested it with.

I keep asking myself why isn't this more popular especially when many
prominent Python devs seem to be well aware of Lisp where macros are
done right. But then again, Gosling's great Lisp prowess did not seem
to transfer into Java at all :-). Won't macros and type inference make
Python a Lisp with a syntax that I can stand and libraries that I could
use :-) ? Unfortunately there doesn't seem to be a peep from Mike Salib
on StarKiller either. Did he move on to other pursuits?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or Java or maybe PHP?

2006-01-03 Thread James
Guido's concerns about preserving simplicity resonate well with me.
Maybe I am just a kid excited with his new toy. I have always admired
macros. Quite a few functional languages have them now. But they have
always been in languages with sub-optimal community code base, which
meant I never went too deep into any of those languages. So I never
used any macro supported language for long to have strong opinions
about any one implementation.

However, Logix's implementation looks rather interesting. By creating
sub languages that are close to but isolated from Python, it does not
really mess with the existing language but creates nice oppurtunities
to encapsulate boiler-plate code structures when the need arises.

I would not necessarily expect such functionality to be in the standard
distribution but language oriented programming could just be another
jewel in Python's multi-paradigm crown and set it distinctly apart from
competitors like Ruby.

Do you have any specific comments towards Logix's implementation?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: download full sites?

2006-01-08 Thread James
This isn't a Python question unless you are looking for a Python
implementation.

HTTrack is one that I have used in the past as a general purpose tool.
http://www.httrack.com/

As for Python
http://harvestman.freezope.org/
I have no experience with it. I just searched in the CheeseShop.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ALLAH

2006-08-10 Thread James
> I dont know why post a subject like this here! Anyway, the post is in
> Turkish and talks about Islam, with the format, sub-heading (which is a
> main topic in Islamic belief) and then a story relating to the
> sub-heading, which is used to explain the topic.

He is an Internet Looney. According to Google groups, he has posted 639
messages in the last 2 months to Usenet under this identity, everyone
of them to a very large number of unrelated newsgroups. Effectively
this is spam. I reported abuse in Google groups (if that works at all)
and will try to contact his ISP.

-- 
http://mail.python.org/mailman/listinfo/python-list


Problem installing Python 2.4.3 on FreeBSD 5.3-RELEASE-p31

2006-08-17 Thread james
I have a problem installing Pyhton 2.4.3, running "./configure
--with-threads=no" completes, but gives the warning:

configure: WARNING: curses.h: present but cannot be compiled
configure: WARNING: curses.h: check for missing prerequisite
headers?
configure: WARNING: curses.h: see the Autoconf documentation
configure: WARNING: curses.h: section "Present But Cannot Be
Compiled"
configure: WARNING: curses.h: proceeding with the preprocessor's result
configure: WARNING: curses.h: in the future, the compiler will take
precedence

Running "make" then gives the error:

gcc -shared build/temp.freebsd-5.3-RELEASE-p31-i386-2.4/_cursesmodule.o
-L/usr/local/lib -lncursesw -o
build/lib.freebsd-5.3-RELEASE-p31-i386-2.4/_curses.so
Segmentation fault (core dumped)
*** Error code 139

I assume this is related to the configure warning... ?  Same error with
just a standard "./configure" and "make".

Any help would be great :)

Regards,
James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can python be a "shell" of c++ program?

2006-06-03 Thread James
Yes you can, although it might be a fair bit of work depending on the
complexity of your codebase. Basically you would need to write Python
extensions to expose your C++ classes as Python modules, using SWIG or
the Python extension code in the Boost C++ libraries. You'd then embed
an interpreter in your program which would allow you to use Python
code within it - either from a script or individual commands.

It's a fairly common use of Python :)

James

On 03/06/06, key9 <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I have some data to process, whith complex mechanism,I put these process
> mechanism as plugins.
> and design lots of classes to abstract data themselves.
>
> but the question is how to drive them work together.
>
> That cause too much jobs: I should write UI,parser..almost a completed
> system.
>
> The problem is I don't know what these processed data will finally needed to
> display to user.
> maybe this , may be that, these can not know on design time.
>
> what I need is on outside of program,
> I can use some interface to get these data what I want , or push back data,
> or told program to recalculate it.
>
>
> can I have a way to drive c++ code use this script-like way ?
>
>
> thank you very much
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you practice Python?

2006-06-03 Thread James
Thirded here. Perhaps better for me is that although I program
client-side Java for my job, as much of the backend as possible I code
in Python, which makes it easier to do a lot of data processing stuff
much simpler than Java would. And it's let me use and understand all
of the new features of the language... last time I did it for a job
was in the days of Python 1.5.2.

Being non-critical utilities on the backend means whenever new
features are introduced I can upgrade my code to take advantage of
them without worrying about things going wrong as well ;)

James

On 02/06/06, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> I second that. I moved from Python to J2EE in my job, but I didn't stop
> writing Python code for my spare-time projects. Now, when tight schedule
> made my project's manager to shift paradigm from buzz to productivity, I
> am happy I can write programs in Python again. On AS/400, but still
> better than Java... :D
>
> --
> Jarek Zgoda
> http://jpa.berlios.de/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you practice Python?

2006-06-03 Thread James
Any code which requires serious algorithmic work I write and test in
Python before converting into Java - it's so much easier to use
Python's datatypes and interpreter to get things right before having
to deal with Java's clunky class libraries.

James

On 02/06/06, Norbert Kaufmann <[EMAIL PROTECTED]> wrote:
> Convince your project manager to develop prototypes. No one in your
> company is better and faster in prototyping than the Python expert Ray.
>
> HTH
>
> Norbert
-- 
http://mail.python.org/mailman/listinfo/python-list


changing a file's permissions

2006-10-01 Thread James
I'm writing a script in linux to excercise my python skills and have encountered a minor issue.Writing the script and creating an ouput file was simple enough and didn't take too long. However, I don't have permissions to execute the file by default. Now, I could simply chmod 755 the sucker and have done with it, but I want to apply the permissions within the python script if I can.
So my question is: how does one change a file's permissions inside of python?James
-- 
http://mail.python.org/mailman/listinfo/python-list

Python at MS Event!

2005-05-05 Thread James
Just back from an MS event. They normally don't show anything non-MS.
This time they showed a Python client (interpreter in interactive mode)
interop with a .NET web service. They even had a few nice things to say
of Python.

Of course, then the rest of the presentation was about WSE which
doesn't interop with anything currently.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python at MS Event!

2005-05-06 Thread James
Standard. 2.4.x

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Found python for delphi new web site

2005-05-06 Thread James
It has been around for a while now. But I am glad I visited it again.
The new PyScripter IDE is great. They should really announce new
software like these here.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Found python for delphi new web site

2005-05-06 Thread James
I didn't either since it needs some components to be installed. I will
surely try playing with the source. It should be a lot easier to
customerize than other IDEs.

I just installed the binary
http://mmm-experts.com/Downloads.aspx?ProductId=4

It does have code insight in the interpreter, but not in the editor
like SPE etc. Also, I could not figure what the shortcut for code
completion is. Should not be a problem once I compile the source since
it uses SynEdit.

The debugger feels very nice (Window layout wise. Visual Studio-ish
feel). Better than PythonWin even, though it doesn't do anything new as
far as I can tell.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-15 Thread James
If you're thinking of things like superstrings, loop quantum gravity
and other "theories of everything" then your friend has gotten
confused somewhere. There is certainly no current experiments which we
can do in practise, which is widely acknowledged as a flaw. Lots of
physicists are trying to work out low-energy consequences of these
theories so that they can be tested, but the maths is extremely hard
and the theories aren't even well understood in many cases; but that
doesn't mean that they've decided that they'll accept them fully and
not bother testing them!

On 6/14/05, Andrea Griffini <[EMAIL PROTECTED]> wrote:
> On 14 Jun 2005 00:37:00 -0700, "Michele Simionato"
> Wow... I always get surprises from physics. For example I
> thought that no one could drop confutability requirement
> for a theory in an experimental science... I mean that I
> always agreed with the logic principle that unless you
> tell me an experiment whose result could be a confutation
> of your theory or otherwise you're not saying anything
> really interesting.
> In other words if there is no means by which the theory
> could be proved wrong by an experiment then that theory
> is just babbling without any added content.
> A friend of mine however told me that this principle that
> I thought was fundamental for talking about science has
> indeed been sacrified to get unification. I was told that
> in physics there are current theories for which there
> is no hypotetical experiment that could prove them wrong...
> (superstrings may be ? it was a name like that but I
> don't really remember).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UML to Python/Java code generation

2005-06-16 Thread James
> Is there any UML tools that is able to take UML and generate Python codes?

Dia2code generates Python from UML.
Boa Constructor generates UML from Python.
PyUt.
Object Domain's UML Tool (Commercial)

You need to use Google.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Alternative Ways to install Python 2.4?

2005-06-16 Thread James
If this is a bug with the standard distribution alone, maybe he can try
ActiveState's distribution (ActivePython) instead.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UML to Python/Java code generation

2005-06-17 Thread James
Peter Dembinski wrote:
> "Grigoris Tsolakidis" <[EMAIL PROTECTED]> writes:
>
> > There is tool to generate UML from Python Code...
>
> The best is human brain.

No! It isn't. In fact, it's the worst.

The brain may be fine for generating Python from UML but it is MANY
MANY orders of magnitude harder to generate UML from code with just
your brain than using a tool (usually zero effort and error free) no
matter how good you are at Python.

-- 
http://mail.python.org/mailman/listinfo/python-list


regular expression

2007-06-22 Thread James

Hi folks,

I have a little script that sits in a directory of images and, when ran,
creates thumbnails of the images. It works fine if I call the function
inside the program with something like "thumbnailer("jpg), but I want to use
a regular expression instead of a plain string so that I can match jpeg,
jpg, JPEG etc.



Here's the script:

---

#!/usr/bin/env python
from PIL import Image
import glob, os, re

size = 128, 128

# takes an extension (e.g. jpg, png, gif, tiff) as argument
def thumbnailer(extension):
#glob the directory the script is in for files of the type foo.extension
 for picture in glob.glob("*." + extension):
   file, ext = os.path.splitext(picture)
   im = Image.open(picture)
   im.thumbnail(size, Image.ANTIALIAS)
   im.save(file + ".thumbnail." + extension)


jpg = re.compile("jpg|jpeg", re.IGNORECASE)
thumbnailer(jpg)



---

And here's the error:

---

Traceback (most recent call last):
 File "./thumbnail.py", line 19, in ?
   thumbnailer(jpg)
 File "./thumbnail.py", line 11, in thumbnailer
   for picture in glob.glob("*." + extension):
TypeError: cannot concatenate 'str' and '_sre.SRE_Pattern' objects

---


It looks to me like the conversion to a regex object instead of a plain
string is screwing up the file glob + extension concatenation. Is there a
simple way to accomplish what I'm trying to do here and get rid of that
error?

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list

strip newline from string

2007-04-28 Thread James

I have a program that reads as follows:

#!/usr/bin/env python
import string
import os

def ssher():
#ssher takes a port input (if none entered, it defaults to 2024) and


def connector():
#connector checks to see if the autoconfigure file exists. If so, it uses that
#for information for where the public ssh machine exists, if not then it tries
#something sensible.
 global ipAddress, username

 if os.path.isfile("autoconf.txt"):
   autoconfigurer = open ( 'autoconf.txt' )
   ipAddress = autoconfigurer.readline()
   username = autoconfigurer.readline()
   autoconfigurer.close()
   string.strip(ipAddress)
   string.strip(username)
   print "IPAddress is %s and username is %s" % (ipAddress, username)
   print "using if"

 else:
   from getpass import getuser
   ipAddress = raw_input("We're 'pitching' this connection to another
machine. What's its IP address? Remember, this is probably a public
address.")
   username = getuser()
   string.strip(username)
   print "username is %s" % username



 print "Attempting to set up the tunnel from %s as %s" % (ipAddress, username)

 cmd2 = 'ssh -nNT -R 2024:localhost:2024 [EMAIL PROTECTED]' % (username, 
ipAddress)
 os.system(cmd2)

connector()


The autoconf.txt contains two lines, which first has an ip address and
second a username. The problem I'm having is that the string.strip()
doesn't appear to be stripping the newline off the username.

Any ideas? If you need more information, just ask!


James
-- 
http://mail.python.org/mailman/listinfo/python-list

capturing system exit status

2007-04-01 Thread James

Hi folks,

in a program I'm writing I have several commands I pass to the unix OS
underneath the code.

I want to perform error checking to make sure that the OS commands' exit
gracefully, but I'm not seeing a simple python module to do this. The
closest I can see is system(), as detailed here:
http://www.python.org/doc/2.1.3/lib/os-process.html, but I can't formulate a
way to use it.

What I want is a simple if statement such that:

if ExitStatusIsBad:
 sys.exit()
else:
 go on to next code chunk



James
-- 
http://mail.python.org/mailman/listinfo/python-list

Python new user question - file writeline error

2007-02-07 Thread James
Hello,

I'm a newbie to Python & wondering someone can help me with this...

I have this code:
--
#! /usr/bin/python

import sys

month ={'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':
8,'SEP':9,'OCT':10,'NOV':11,'DEC':12}
infile=file('TVA-0316','r')
outfile=file('tmp.out','w')

for line in infile:
item = line.split(',')
dob = item[6].split('/')
dob = dob[2]+'-'+str(month[dob[1]])+'-'+dob[0]
lbdt = item[8].split('/')
lbdt = lbdt[2]+'-'+str(month[lbdt[1]])+'-'+lbdt[0]
lbrc = item[10].split('/')
lbrc = lbrc[2]+'-'+str(month[lbrc[1]])+'-'+lbrc[0]
lbrp = item[14].split('/')
lbrp = lbrp[2]+'-'+str(month[lbrp[1]])+'-'+lbrp[0]
item[6] = dob
item[8] = lbdt
item[10]=lbrc
item[14]=lbrp
list = ','.join(item)
outfile.writelines(list)
infile.close
outfile.close
-

And the data file(TVA-0316) looks like this:
-
06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
NOV/2006,V1,,,21/NOV/2006,AST,19,U/L,5,40,,
06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
NOV/2006,V1,,,21/NOV/2006,GGT,34,U/L,11,32,h,
06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
NOV/2006,V1,,,21/NOV/2006,ALT,31,U/L,5,29,h,
06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
NOV/2006,V1,,,21/NOV/2006,ALKP,61,U/L,40,135,,
-

Basically I'm reading in each line and converting all date fields (05/
MAR/1950) to different format (1950-03-05) in order to load into MySQL
table.

I have two issues:
1. the outfile doesn't complete with no error message.  when I check
the last line in the python interpreter, it has read and processed the
last line, but the output file stopped before.
2. Is this the best way to do this in Python?
3. (Out of scope) is there a way to load this CSV file directly into
MySQL data field without converting the format?

Thank you.

James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python new user question - file writeline error

2007-02-07 Thread James
On Feb 7, 4:59 pm, "Shawn Milo" <[EMAIL PROTECTED]> wrote:
> On 7 Feb 2007 11:31:32 -0800, James <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > I'm a newbie to Python & wondering someone can help me with this...
>
> > I have this code:
> > --
> > #! /usr/bin/python
>
> > import sys
>
> > month ={'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':
> > 8,'SEP':9,'OCT':10,'NOV':11,'DEC':12}
> > infile=file('TVA-0316','r')
> > outfile=file('tmp.out','w')
>
> > for line in infile:
> > item = line.split(',')
> > dob = item[6].split('/')
> > dob = dob[2]+'-'+str(month[dob[1]])+'-'+dob[0]
> > lbdt = item[8].split('/')
> > lbdt = lbdt[2]+'-'+str(month[lbdt[1]])+'-'+lbdt[0]
> > lbrc = item[10].split('/')
> > lbrc = lbrc[2]+'-'+str(month[lbrc[1]])+'-'+lbrc[0]
> > lbrp = item[14].split('/')
> > lbrp = lbrp[2]+'-'+str(month[lbrp[1]])+'-'+lbrp[0]
> > item[6] = dob
> > item[8] = lbdt
> > item[10]=lbrc
> > item[14]=lbrp
> > list = ','.join(item)
> > outfile.writelines(list)
> > infile.close
> > outfile.close
> > -
>
> > And the data file(TVA-0316) looks like this:
> > -
> > 06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
> > NOV/2006,V1,,,21/NOV/2006,AST,19,U/L,5,40,,
> > 06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
> > NOV/2006,V1,,,21/NOV/2006,GGT,34,U/L,11,32,h,
> > 06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
> > NOV/2006,V1,,,21/NOV/2006,ALT,31,U/L,5,29,h,
> > 06-0588,03,701,03701,046613,JJB,05/MAR/1950,M,20/NOV/2006,08:50,21/
> > NOV/2006,V1,,,21/NOV/2006,ALKP,61,U/L,40,135,,
> > -----
>
> > Basically I'm reading in each line and converting all date fields (05/
> > MAR/1950) to different format (1950-03-05) in order to load into MySQL
> > table.
>
> > I have two issues:
> > 1. the outfile doesn't complete with no error message.  when I check
> > the last line in the python interpreter, it has read and processed the
> > last line, but the output file stopped before.
> > 2. Is this the best way to do this in Python?
> > 3. (Out of scope) is there a way to load this CSV file directly into
> > MySQL data field without converting the format?
>
> > Thank you.
>
> > James
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> Your script worked for me. I'm not sure what the next step is in
> troubleshooting it. Is it possible that your whitespace isn't quite
> right? I had to reformat it, but I assume it was because of the way
> cut & paste worked from Gmail.
>
> I usually use Perl for data stuff like this, but I don't see why
> Python wouldn't be a great solution. However, I would re-write it
> using regexes, to seek and replace sections that are formatted like a
> date, rather than breaking it into a variable for each field, changing
> each date individually, then putting them back together.
>
> As for how MySQL likes having dates formatted in CSV input: I can't
> help there, but I'm sure someone else can.
>
> I'm pretty new to Python myself, but if you'd like help with a
> Perl/regex solution, I'm up for it. For that matter, whipping up a
> Python/regex solution would probably be good for me. Let me know.
>
> Shawn

Thank you very much for your kind offer.
I'm also coming from Perl myself - heard many good things about Python
so I'm trying it out - but it seems harder than I thought :(

James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python new user question - file writeline error

2007-02-08 Thread James
On Feb 8, 3:26 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Shawn Milo a écrit :
>
>
>
> > To the list:
>
> > I have come up with something that's working fine. However, I'm fairly
> > new to Python, so I'd really appreciate any suggestions on how this
> > can be made more Pythonic.
>
> > Thanks,
> > Shawn
>
> > Okay, here's what I have come up with:
>
> > #! /usr/bin/python
>
> > import sys
> > import re
>
> > month
> > ={'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':8,'SEP':9,'­OCT':10,'NOV':11,'DEC':12}
>
> > infile=file('TVA-0316','r')
> > outfile=file('tmp.out','w')
>
> > def formatDatePart(x):
> >"take a number and transform it into a two-character string,
> > zero padded"
> >x = str(x)
> >while len(x) < 2:
> >x = "0" + x
> >return x
>
> x = "%02d" % x
>
> > regex = re.compile(r",\d{2}/[A-Z]{3}/\d{4},")
>
> regexps are not really pythonic - we tend to use them only when we have
> no better option. When it comes to parsing CSV files and/or dates, we do
> have better solution : the csv module and the datetime module
>
> > for line in infile:
> >matches = regex.findall(line)
> >for someDate in matches:
>
> >dayNum = formatDatePart(someDate[1:3])
> >monthNum = formatDatePart(month[someDate[4:7]])
> >yearNum = formatDatePart(someDate[8:12])
>
> >newDate = ",%s-%s-%s," % (yearNum,monthNum,dayNum)
> >line = line.replace(someDate, newDate)
> >outfile.writelines(line)
>
> > infile.close
> > outfile.close
>
> I wonder why some of us took time to answer your first question. You
> obviously forgot to read these answers.

No offense - but the fact that 're' module is available, doesn't that
mean we can use it? (Pythonic or not - not sure what is really
pythonic at this stage of learning...)
Like Perl, I'm sure there are more than one way to solve problems in
Python.

I appreciate everyone's feedback - I definitely got more than
expected, but it feels comforting that people do care about writing
better codes! :)

-- 
http://mail.python.org/mailman/listinfo/python-list


interacting with shell - another newbie question

2007-02-09 Thread James
Hello,

I work in this annoying company where I have to autheticate myself to
the company firewall every 30-50 minutes in order to access the
internet.  (I think it's a checkpoint fw).

I have to run "telnet what.ever.ip.address 259" then it prompts me
with userid, then password, then I have to select "1".  Then the
program closes itself and the internet is enabled.

I would like to automate this process with Python and run it every 30
miniutes so I don't have to keep typing in these userid/password
everytime.  How can this be done?  Is there a module I can use to
interact with the shell? (I'm running linux)

Thank you.

James

-- 
http://mail.python.org/mailman/listinfo/python-list


Mail System Error - Returned Mail

2007-11-06 Thread james
This Message was undeliverable due to the following reason:

Your message was not delivered because the destination computer was
not reachable within the allowed queue period. The amount of time
a message is queued before it is returned depends on local configura-
tion parameters.

Most likely there is a network problem that prevented delivery, but
it is also possible that the computer is turned off, or does not
have a mail system running right now.

Your message was not delivered within 5 days:
Host 207.81.166.39 is not responding.

The following recipients did not receive this message:


Please reply to [EMAIL PROTECTED]
if you feel this message to be in error.





__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
Esta parte del correo contenía un archivo adjunto con un nombre de archivo 
prohibido:

  Tipo MIME: application/octet-stream
  Nombre de archivo: document.zip
  Tamaño de archivo: 30.62 kB


El archivo adjunto ha sido eliminado por Kerio MailServer 6.4.1 
en lnx-27.

-- 
http://mail.python.org/mailman/listinfo/python-list

How to recast integer to a string

2006-05-09 Thread James
How to recast an integer to a string?

something like
n = 5
str = str + char(n)


J.L

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to recast integer to a string

2006-05-09 Thread James

Christoph Haas wrote:
> On Tue, May 09, 2006 at 12:17:34PM -0700, James wrote:
> > How to recast an integer to a string?
> >
> > something like
> > n = 5
> > str = str + char(n)
>
> str(n)
>
> Kindly
>  Christoph

In python2,4, I 've got
TypeError: 'str' object is not callable 

J.L

-- 
http://mail.python.org/mailman/listinfo/python-list


syntax for -c cmd

2006-05-10 Thread James
Wrong syntax is shown below. What should be the delimiter before else?

python -c 'if 1==1: print "yes"; else print "no"'

James

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combining a C# GUI with Python code?

2006-05-20 Thread James
Yes! It is. Just make your GUI in C# and assign event handlers using
Python for .NET
http://www.zope.org/Members/Brian/PythonNet/

Python for .NET is a great tool and has a minimal learning curve.
Unfortunately, it hasn't attracted enough attention from the Python
community. It does not have a .NET 2.0 release yet but it is in the
works.

Or you could use Boo with SharpDevelop. You will get Visual form design
with a very Pythonic language. But you won't get to use Python
libraries.

IronPython is getting IDE integration in the CTP releases for Visual
Studio. Maybe it will support form design in the future. I have not
tried it yet.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: John Bokma harassment

2006-05-24 Thread James
> We seem to have strayed a long way from Voltaire's
> "I do not agree with what you say, but I will defend to the death your
> right to say it."

Not at all. My problem with Xah Lee is that he is abusing the Usenet as
a personal BLOG. He has a web site to post these articles and he can
certainly put up a discussion board there if he wants a vigorous
discussion of his ideas. It's worse. He does not even respond to
questions directly posed to him in the thread of his "articles". Just
imagine if every blogger on the Internet started using Usenet instead
and cross-posting at that.

-- 
http://mail.python.org/mailman/listinfo/python-list


Cost of Queue.put

2008-03-17 Thread James
Hi all,
I'm struggling with the following problem:

I need to disconnect a web service invocation from the addition of
some content to a search engine, so that the web service will always
return in reasonable time.

Basically, what I need is a multi-process safe persistent quick queue.
The arrangement I had was a simple XML-RPC service running on the web
server which the various web server threads POST the relevant search
engine updates to. These updates were added to a persistent queue
built on top of Queue.Queue and cPickle, and there was a separate
thread in the XML-RPC server actually adding the updates to the search
engine.

However, the CPU consumption of the XML-RPC server seems to grow
pretty much linearly with the length of the persistent queue. Isn't
Queue.put O(1)?

I include the code for the persistent queue below - it's a modified
version of this code: 
http://mail.python.org/pipermail/python-list/2002-December/177394.html

I suppose the addition of cPickle to the mix must hurt Queue.put()...
Any recommendations for alternative persistent queues?

Thanks,
James


class PickleQueue(Queue.Queue):
"""A multi-producer, multi-consumer, persistent queue."""


def __init__(self, filename, maxsize=0):
"""Initialize a persistent queue with a filename and maximum
size.


The filename is used as a persistent data store for the
queue.
If maxsize <= 0, the queue size is infinite.
"""
self.filename = filename
Queue.Queue.__init__(self, maxsize)

def _init(self, maxsize):
# Implements Queue protocol _init for persistent queue.
# Sets up the pickle files.
self.maxsize = maxsize
try:
self.readfile = file(self.filename, 'r')
self.queue = cPickle.load(self.readfile)
self.readfile.close()
except IOError, err:
if err.errno == 2:
# File doesn't exist, continue ...
self.queue = Queue.deque()
else:
# Some other I/O problem, reraise error
raise err
except EOFError:
# File was null? Continue ...
self.queue = Queue.deque()

# Rewrite file, so it's created if it doesn't exist,
# and raises an exception now if we aren't allowed
self.writefile = file(self.filename, 'w')
cPickle.dump(self.queue, self.writefile, 1)
log.info("(PickleQueue._init) created queue")


def __sync(self):
# Writes the queue to the pickle file.
self.writefile.seek(0)
cPickle.dump(self.queue, self.writefile, 1)
self.writefile.flush()


def _put(self, item):
# Implements Queue protocol _put for persistent queue.
self.queue.append(item)
self.__sync()


def _get(self):
# Implements Queue protocol _get for persistent queue.
item = self.queue.popleft()
self.__sync()
return item
-- 
http://mail.python.org/mailman/listinfo/python-list


Accessing POST parameters from BaseHTTPServer

2008-11-06 Thread James
Hi all,
I'm writing a super simple little debugging HTTP server which simply
returns the path and parameters it receives requests for.

E.g. requesting /meth?a=b returns something like:
Command: GET
Path: /meth
Params: {'a': ['b']}

This is fine for GET, but I can't see how I access parameters passed
by POST requests...

The particular client programme I'm testing will be passing stuff up
as text/xml, if that's any help...

Thanks!
James
--
http://mail.python.org/mailman/listinfo/python-list


Re: How complex is complex?

2009-03-28 Thread james
this is hardly a fair reply to a fair question. the question of time,  
space, or algorithmic complexity comes up all the time in the choice  
of which algorithm or data structure is best suited to attack a problem.


donald knuth's anaylses of the computational complexity of algorithms  
has provided us with the tools to answer how complex an algorithm is  
and to compare its complexity to another algorithm. whoever wants to  
deal with issues of complexity might want to start there.


knowing the complexity of an algorithm provides a starting point for  
answering whether the level of complexity the algorithm adds to a  
program makes it acceptable for use or not, or whether using it will  
be ok to run against small datasets but not against large; or even  
whether another attack on the problem to be solved should be considered.


i dare say, the question "what level of complexity is acceptable" is a  
fair question, and the possible answers to choose from is the  
bread-and-butter of computer sciences.


again, for those who want to get a handle on the issue, start with  
donald knuth's work or introductory texts that build on his work.


-james

Quoting r :


On Mar 18, 12:30 pm, Kottiyath  wrote:

When we say readability counts over complexity, how do we define what
level of complexity is ok?


[snip= mommie can i go out an play?]


How do we decide whether a level of complexity is Ok or not?



Hmm?
How did you know what shoes to put on this morning or what to eat for
breakfast? I'll tell you, you made a choice that was best suited for
you, thats how. Do you really need the opinion of others before making
a decision this simple. Have the people of the world become so needy
that they cannot even choose between pink panties with purple polka-
dots or purple panties with pink polka-dots anymore without asking for
input?. It seems seems the world has become a dimension of drooling
mindless zombies wondering aimlessly through life who can even think
for them selfs. God help us all!!!
--
http://mail.python.org/mailman/listinfo/python-list




--
http://mail.python.org/mailman/listinfo/python-list


Re: How complex is complex?

2009-03-28 Thread james

thanks, paul.

if i understand correctly, questions about "about how intricate [an]  
algorithm [is] (this affects its difficulty of implementation and  
understanding)" are also fair and deserve fair answers.


again, if i understand correctly, this issue gets its share of  
attention in computer sciences, and cs teachers discuss it in class,  
passing along their own appreciation of it to their students.


- james

Quoting Paul Rubin <"http://phr.cx"@NOSPAM.invalid>:


ja...@biosci.utexas.edu writes:

donald knuth's anaylses of the computational complexity of algorithms


I think the question was about how intricate the algorithm was (this
affects its difficulty of implementation and understanding), not its
computational complexity.
--
http://mail.python.org/mailman/listinfo/python-list




--
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >