CDF python

2008-03-20 Thread Josef
Hi,
 I have a bunch of CDF files that I need to read/process and I'd like
to use python for that. Does anybody know an API for interfacing with
CDF? So far I only found pycdf for netCDF, and pytables for HDF but
nothing for CDF.
Josef
-- 
http://mail.python.org/mailman/listinfo/python-list


Object Reference question

2009-08-20 Thread josef
To begin, I'm new with python. I've read a few discussions about
object references and I think I understand them.

To be clear, Python uses a "Pass By Object Reference" model.
x = 1
x becomes the object reference, while an object is created with the
type 'int', value 1, and identifier (id(x)). Doing this with a class,
x = myclass(), does the same thing, but with more or less object
attributes. Every object has a type and an identifier (id()),
according to the Python Language Reference for 2.6.2 section 3.1.

x in both cases is the object reference. I would like to use the
object to refer to the object reference. If I have a gross
misunderstanding, please correct me.

The following is what I would like to do:
I have a list of class instances dk = [ a, b, c, d ], where a, b, c, d
is an object reference. Entering dk gives me the object: [MyClass0
instance at 0x, MyClass1 instance at 0x0008, MyClass2 instance at
0x0010 ... ]

I need the object reference name (a,b,c,d) from dk to use as input for
a file. Where do I find the memory location of the object reference
and the object reference name memory location? I am unconcerned with
the fact that the memory location will change the next time I run a
python session. I will be using the object reference name for
processing right away.

My main focus of this post is: "How do I find and use object reference
memory locations?"

Thoughts?
Thanks,

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


Re: Object Reference question

2009-08-21 Thread josef
On Aug 21, 1:34 am, Miles Kaufmann  wrote:
> On Aug 20, 2009, at 11:07 PM, josef wrote:
>
> > To begin, I'm new with python. I've read a few discussions about
> > object references and I think I understand them.
>
> > To be clear, Python uses a "Pass By Object Reference" model.
> > x = 1
> > x becomes the object reference, while an object is created with the
> > type 'int', value 1, and identifier (id(x)). Doing this with a class,
> > x = myclass(), does the same thing, but with more or less object
> > attributes. Every object has a type and an identifier (id()),
> > according to the Python Language Reference for 2.6.2 section 3.1.
>
> > x in both cases is the object reference. I would like to use the
> > object to refer to the object reference.
>
> Stop right there.  'x' is not *the* object reference.  It is *an*  
> object reference (or in my preferred terminology, a label).  Suppose  
> you do:
>
> x = myclass()
> y = x

It would not make sense to do that in the context of the software I am
writing. The documentation will specifically state not to do that. If
the user does do that, then the user will be disappointed and possibly
angry.

>
> The labels 'x' and 'y' both refer to the same object with equal  
> precedence.  There is no mapping from object back to label; it is a  
> one-way pointer.  Also importantly, labels themselves are not objects,  
> and cannot be accessed or referred to.

I would just like to store the name of the one way pointer.

>
> (This is a slight oversimplification; thanks to Python's reflection  
> and introspection capabilities, it is possible to access labels to  
> some extent, and in some limited situations it is possible to use  
> stack inspection to obtain a label for an object.  But this is hackish  
> and error-prone, and should never be used when a more Pythonic method  
> is available.)

Hackish is fine. How error-prone is this method?
>
> > The following is what I would like to do:
> > I have a list of class instances dk = [ a, b, c, d ], where a, b, c, d
> > is an object reference. Entering dk gives me the object: [MyClass0
> > instance at 0x, MyClass1 instance at 0x0008, MyClass2 instance at
> > 0x0010 ... ]
>
> > I need the object reference name (a,b,c,d) from dk to use as input for
> > a file.
>
> It sounds like you should either be storing that name as an attribute  
> of the object, or using a dictionary ({'a': a, 'b': b, ...}).

That solution was mentioned in some of the discussions I read, but I
would like to stay away from something like: a = MyClass
(name='a', ...). Is it possible to assign an object reference name in
a class __init__ defintion?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object Reference question

2009-08-21 Thread josef
On Aug 21, 4:26 am, Ben Finney  wrote:
> josef  writes:
> > To be clear, Python uses a "Pass By Object Reference" model.
>
> Yes. (I'm glad this concept has propagated to newcomers so well :-)

I found one really good discussion on python semantics versus other
languages. It gave me this gem of a quote:

"When I turn on the TV and see Chuck Norris, though, I know it's only
a reference to Chuck Norris, or I would be blinded.  The only case he
needs is "Pass By Roundhouse Kick"." -Chuckk

>
> > x = 1
> > x becomes the object reference
>
> It becomes *a* reference to that object, independent of any other
> references to that same object.
>
> > while an object is created with the type 'int', value 1, and
> > identifier (id(x)).
>
> Not really “while”. The object creation happens first, then the
> assignment statement binds a reference to that object.
>
> > Doing this with a class, x = myclass(), does the same thing, but with
> > more or less object attributes. Every object has a type and an
> > identifier (id()), according to the Python Language Reference for
> > 2.6.2 section 3.1.
>
> Any expression can be on the right side of the assignment operator. The
> expression will evaluate to some object, which the assignment will then
> bind to the reference on the left side of the assignment operator.
>
> > x in both cases is the object reference.
>
> It is *an* object reference; that is, it's an identifier which refers to
> an object. There's nothing about that identifier that makes it “the (one
> and only) object reference”.
>
> > I would like to use the object to refer to the object reference. If I
> > have a gross misunderstanding, please correct me.
>
> Yes, it's a simple misunderstanding: objects do not, in general, know
> any of the references there may be to them.
>
> > The following is what I would like to do: I have a list of class
> > instances dk = [ a, b, c, d ], where a, b, c, d is an object
> > reference.
>
> Note that, after that list is created, each item in that list is *also*
> a reference to the corresponding object. That is, ‘a’ is a reference to
> an object, and ‘dk[0]’ is a *different* reference to the *same* object.
> The object has no knowledge about those references.

This is surprising. My initial thought is that dk[0] hold the object
reference 'a,' but that wouldn't be true "pass by object reference."
When defining the object reference dk[0], python takes the object
reference 'a,' finds the object MyClass0(), and then assigns the
object identity to dk[0]? Or something close to that.

>
> > Entering dk gives me the object: [MyClass0 instance at 0x,
> > MyClass1 instance at 0x0008, MyClass2 instance at 0x0010 ... ]
>
> This is a hint that, when asked for a string representation, each of the
> objects in that list can say little more than that they are of a
> particular type, and are located at a particular memory address. They do
> not know any of the references to themselves.
>
> > I need the object reference name (a,b,c,d) from dk to use as input for
> > a file.
>
> You'll have to track that yourself.

I'm a bit shocked that there isn't a method for catching object
reference names. I think that something like a = MyClass0(name =
'a', ...) is a bit redundant. Are definitions treated the same way?
How would one print or pass function names?

>
> A good way to keep track of name-to-object mappings is with Python's
> built-in mapping type, ‘dict’::
>
>     dk = {'a': a, 'b': b, 'c': c, 'd': d}
>
> (There are more efficient ways to create a dictionary without such
> repetition, of course, but this is more illustrative of the point.)
>
> You can then get a list (assembled in arbitrary sequence) of just the
> keys, or just the values, or the key-value pairs, from the dict with its
> ‘keys’, ‘values’, and ‘items’ methods respectively::
>
>     >>> dk = {'a': a, 'b': b, 'c': c, 'd': d}
>     >>> dk.keys()
>     ['a', 'c', 'd', 'b']
>     >>> dk.values()
>     [, ,  instance at 0x3717>, ]
>     >>> dk.items()
>     [('b', ), ('c',  0x3462>), ('a',  ), ('d',   0x3717>)]
>
> Each of these is even better used as the iterable for a ‘for’ loop::
>
>     >>> for (key, value) in dk.items():
>     ...     print "Here is item named", key
>     ...     print value

I think I'll just add a 'name' to the classes' init defintion.

>
> > My main focus of this post is: "How do I find and use object reference
> > memory locations?"
>
> You don't. Use the references in your code, forget about the memory
> addresses, and remember that container objects themselves contain
> references, so use them for organising your objects.
>
> --
>  \     “Demagogue: One who preaches doctrines he knows to be untrue to |
>   `\                     men he knows to be idiots.” —Henry L. Mencken |
> _o__)                                                                  |
> Ben Finney

Thanks,

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


Re: Object Reference question

2009-08-27 Thread josef
Thanks to everyone who responded.

I will be going with some sort of a = MyClass(name = 'a') format. It's
the Python way.

For me, it was very hard to accept that EVERYTHING is an object
reference. And that there are no object reference names, just string
entries in dictionaries. But I think it all makes sense now.

Thanks again,

Josef


On Aug 21, 1:07 am, josef  wrote:
> To begin, I'm new with python. I've read a few discussions about
> object references and I think I understand them.
>
> To be clear, Python uses a "Pass By Object Reference" model.
> x = 1
> x becomes the object reference, while an object is created with the
> type 'int', value 1, and identifier (id(x)). Doing this with a class,
> x = myclass(), does the same thing, but with more or less object
> attributes. Every object has a type and an identifier (id()),
> according to the Python Language Reference for 2.6.2 section 3.1.
>
> x in both cases is the object reference. I would like to use the
> object to refer to the object reference. If I have a gross
> misunderstanding, please correct me.
>
> The following is what I would like to do:
> I have a list of class instances dk = [ a, b, c, d ], where a, b, c, d
> is an object reference. Entering dk gives me the object: [MyClass0
> instance at 0x, MyClass1 instance at 0x0008, MyClass2 instance at
> 0x0010 ... ]
>
> I need the object reference name (a,b,c,d) from dk to use as input for
> a file. Where do I find the memory location of the object reference
> and the object reference name memory location? I am unconcerned with
> the fact that the memory location will change the next time I run a
> python session. I will be using the object reference name for
> processing right away.
>
> My main focus of this post is: "How do I find and use object reference
> memory locations?"
>
> Thoughts?
> Thanks,
>
> Josef

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


Re: Object Reference question

2009-08-28 Thread josef
On Aug 27, 1:35 pm, Ethan Furman  wrote:
> josef wrote:
> > Thanks to everyone who responded.
>
> > I will be going with some sort of a = MyClass(name = 'a') format. It's
> > the Python way.
>
> > For me, it was very hard to accept that EVERYTHING is an object
> > reference. And that there are no object reference names, just string
> > entries in dictionaries. But I think it all makes sense now.
>
> > Thanks again,
>
> > Josef
>
> My apologies if I missed it, but what *exactly* are you planning on
> doing with your 'name' attribute?  From the posts I've seen so far, I
> think you are only setting yourself up for failure.
>
> ~Ethan~

I'm going to use it for printing purposes. dk = MyClass(name='dk')
When I need a name dk.name. There will only ever be one dk defined.

Does that read like I'm setting myself up for failure?
-- 
http://mail.python.org/mailman/listinfo/python-list


Need to pass a class instance to a gettext fallback

2017-09-07 Thread Josef Meile
Hi

I'm working with gettext and need to define a language Fallback. I got this 
working, but with a global variable. I don't really like this and I would like 
to pass this variable to the gettext Fallback's contructor, but I don't know 
how. For simplicity, I won't put the whole code here, just the important parts.

Before you look at it, I want to ask you: how can I pass the variable: 
"my_plugin" to the constructor of the "MissingTranslationsFallback" class? If 
you see, an instance of this class will be created automatically by gettext. I 
don't create it. When calling the " add_fallback" method of the 
gettext.GNUTranslations class, you have to pass a class and not an instance.

#Defining a global dict, which is ugly, I know
MY_GLOBALS = {}

class TranslationService(object):
  """...__init__ and other methods are defined here"""

  def install(self):
"""...some code goes here..."""
#Now the ugly part :-(
MY_GLOBALS['py_plugin'] = self._py_plugin
current_catalog = gettext.translation(plugin_name, localedir = 
locale_folder,
class_= MissingTranslationsFallback, languages = [current_language])
current_catalog.install()

class MissingTranslationsFallback(gettext.GNUTranslations, object):
  def __init__(self, *args, **kwargs):
super(MissingTranslationsFallback, self).__init__(*args, **kwargs)

#And here is where I need to access py_plugin :-(
py_plugin = MY_GLOBALS['py_plugin']
i18n_service = py_plugin.get_i18n_service()
#Adds an instance to the class that will handle the missing translations
self.add_fallback(MissingTranslationsLogger(i18n_service.get_language()))

class MissingTranslationsLogger(gettext.NullTranslations):
  def __init__(self, language):
self._language = language
self._missing = set()

  def gettext(self, message):
if (message not in self._missing):
  self._missing.add(message)
  print "Missing message: " + message + " current language: " + 
self._language
return message

Any help would be appreciated.

Best regards
Josef
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Need to pass a class instance to a gettext fallback

2017-09-08 Thread Josef Meile
Hi Peter

Your code worked, but I did some changes. First of all: I decided that I don't 
really needed to pass the py_plugin instance. I only needed an attribute 
called: self._language. Anyway, if I passed it without doing anything else, I 
got:
TypeError: __init__() got an unexpected keyword argument 'language'

In this call inside the MissingTranslationsFallback class.
super(MissingTranslationsFallback, self).__init__(*args, **kwargs)

The error is clear, the constructor of: "gettext.GNUTranslations" isn't 
expecting an argument called: 'language', so, I removed it before doing the 
call:
language = kwargs['language']
del kwargs['language']
super(MissingTranslationsFallback, self).__init__(*args, **kwargs)

And it worked. Thanks a lot for your help. Now it looks nice without those 
nasty global variables :-)

Here the resulting code:
class TranslationService(object):
  """...__init__ and other methods are defined here"""

  def install(self):
"""...some code goes here..."""
current_catalog = gettext.translation(plugin_name, localedir = 
locale_folder,
   class_= 
functools.partial(
   
MissingTranslationsFallback, 
   language 
= self._language
  ),
  languages 
= [current_language]
 )
current_catalog.install()

class MissingTranslationsFallback(gettext.GNUTranslations, object):
  def __init__(self, *args, **kwargs):
language = kwargs['language']
del kwargs['language']
super(MissingTranslationsFallback, self).__init__(*args, **kwargs)
self.add_fallback(MissingTranslationsLogger(language))

Best regards
Josef

-Original Message-
From: Python-list [mailto:python-list-bounces+jmeile=hotmail@python.org] On 
Behalf Of Peter Otten
Sent: Freitag, 8. September 2017 08:15
To: python-list@python.org
Subject: Re: Need to pass a class instance to a gettext fallback

Josef Meile wrote:

> Hi
> 
> I'm working with gettext and need to define a language Fallback. I got 
> this working, but with a global variable. I don't really like this and 
> I would like to pass this variable to the gettext Fallback's 
> contructor, but I don't know how. For simplicity, I won't put the 
> whole code here, just the important parts.
> 
> Before you look at it, I want to ask you: how can I pass the variable:
> "my_plugin" to the constructor of the "MissingTranslationsFallback" class?
> If you see, an instance of this class will be created automatically by 
> gettext. I don't create it. When calling the " add_fallback" method of 
> the gettext.GNUTranslations class, you have to pass a class and not an 
> instance.

Provided the class_ argument to gettext.translation() accepts an arbitrary 
callable the following may work:

import functools

> #Defining a global dict, which is ugly, I know MY_GLOBALS = {}
> 
> class TranslationService(object):
>   """...__init__ and other methods are defined here"""
> 
>   def install(self):
> """...some code goes here..."""
 
 current_catalog = gettext.translation(
 plugin_name, 
 localedir=locale_folder,
 class_=functools.partial(
 MissingTranslationsFallback, 
 py_plugin=self._py_plugin
 ), 
 languages=[current_language]
  )
> current_catalog.install()
> 
> class MissingTranslationsFallback(gettext.GNUTranslations, object):
>   def __init__(self, *args, **kwargs):

  py_plugin = kwargs.pop("py_plugin")

> super(MissingTranslationsFallback, self).__init__(*args, **kwargs)

> i18n_service = py_plugin.get_i18n_service()
> #Adds an instance to the class that will handle the missing
> #translations
> 
self.add_fallback(MissingTranslationsLogger(i18n_service.get_language()))


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


RE: Need to pass a class instance to a gettext fallback

2017-09-09 Thread Josef Meile
Hi Peter

>> language = kwargs['language']
>> del kwargs['language']
>
>Not really important, but there's a method for that:
>
>language = kwargs.pop("language")
Thanks, this looks better and I indeed think it is important. The "del ..." 
line looks ugly.

>>   def __init__(self, *args, **kwargs):
>> language = kwargs['language']
>> del kwargs['language']
>
>In Python 3 this can also be spelt with a keyword-only language argument:
>
>def __init__(self, *args, language, **kwargs):
>...  # no pop() or del
I'm using Python 2.7.10, but this also works there, so, I replace it with your 
suggestion.

And before you tell me that python 2.7 is old, the thing is that I'm writing a 
pluging for Gimp and this is the version they distribute :-(

Thanks for your valuable help

Best regards
Josef
-- 
https://mail.python.org/mailman/listinfo/python-list


sting to list of enums

2021-08-21 Thread Josef Kleber
Hi,

I need to configure a script with a command line switch and/or
environment variable (-> string) to a list of enums. I found the
following to work:

from enum import Enum

class Provider(Enum):
NONE = 0, ''
Amazon = 40, 'Amazon'
Netflix = 42, 'Netflix'
SkyTicket = 104, 'Sky Ticket'
AmazonChannels = 140, 'Amazon Channels'
Disney = 176, 'Disney+'

def __new__(cls, value, name):
member = object.__new__(cls)
member._value_ = value
member.fullname = name
return member

def __int__(self):
return self.value

def __str__(self):
return self.fullname

providers = []
test = "Amazon, AmazonChannels, Netflix, Disney, SkyTicket"

for t in test.split(','):
providers.append(Provider[t.strip()])

print(providers)

I would prefer a more direct input string like "Provider.Amazon,
Provider.Netfilx" Any idea?

Or even a better way from cli option to enum list?

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


Re: Send password over TCP connection

2005-10-10 Thread Josef Meile
> Anyone know of a simple ssl api in python :-)
Perhaps pow may help:
http://sourceforge.net/projects/pow

or pyopenssl:
http://pyopenssl.sourceforge.net/

Regards,
Josef

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


Re: Double replace or single re.sub?

2005-10-26 Thread Josef Meile
Hi Iain,

 > Would this be a quicker/better way of doing it?
I don't know if this is faster, but it is for sure more elegant:

http://groups.google.ch/group/comp.lang.python/msg/67b8767c793fb8b0

I really like it because of its simplicity an easy use. (Thanks to
Fredrik Lundh for the script). However, I suggested it once to replace
the approach you suggested in a web application we have, but it was
rejected because the person, who benchmarked it, said that it was OK for
small strings, but for larger ones performance were an issue. Anyway,
for my own applications, performance isn't an issue, so, I use it some
times.

By the way, the benchmarking, from which I don't have any information,
was done in python 2.1.3, so, for sure you will get a better performance
with 2.4.

Regards,
Josef


Iain King wrote:
> I have some code that converts html into xhtml.  For example, convert
> all  tags into .  Right now I need to do to string.replace calls
> for every tag:
> 
> html = html.replace('','')
> html = html.replace('','')
> 
> I can change this to a single call to re.sub:
> 
> html = re.sub('<([/]*)i>', r'<\1em>', html)
> 

> 
> Iain
> 


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


Re: OpenSSL in Python

2005-11-01 Thread Josef Meile
>>First, is the PYTHON OpenSSL C wrapper what I need to get running.
> 
> 
> I think that first you have to get OpenSSL running. Only then can you
> think about wrapping it.
I think Sybren is allright here. After installing openssl, pyopenssl
won't be a problem. So, if you want to install openssl, you could
download the binaries for windows (google for them) or you could compile
it from source, which is the best approach for this kind of libraries.
The last approach is out of the scope of this list as Sybren said. You 
should try first to find the answer in the openssl documentation or in
its official list. Then if you aren't able to compile it, then you have
to ask there.

If on the other hand, you have already installed openssl, but the
pyopenssl fails to run, then you can first see if pyopenssl has a
mailing list and ask there. On the contrary, you can ask here.

Regards,
Josef

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


Re: useradd command in Zope

2005-11-07 Thread Josef Meile
> su zope (or whoever your zope runs)
> ./yourmethod.py someuser somepass
> 
> You will see it fail (apart from the fact you need
> the #!/path/to/python.bin and set the execution bit
> with chmod a+x before you try)
> 
> 
>  >   i tried using another user outside of zope .
>  working very well(adding user to system)
Perhaps the other user is either root or it belongs to the root's
groups.

>  owner of external method is root and set_user_id bit is set.
>  but problem is when i run attached app it is not adding user 
set_user_id only works with C binary files. So, here you have to use
sudo.

Regards,
Josef

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


Re: useradd command in Zope

2005-11-07 Thread Josef Meile
Sorry, I replied to the Wrong list :-(




Josef Meile wrote:
>> su zope (or whoever your zope runs)
>> ./yourmethod.py someuser somepass
>>
>> You will see it fail (apart from the fact you need
>> the #!/path/to/python.bin and set the execution bit
>> with chmod a+x before you try)
>>
>>
>>  >   i tried using another user outside of zope .
>>  working very well(adding user to system)
> 
> Perhaps the other user is either root or it belongs to the root's
> groups.
> 
>>  owner of external method is root and set_user_id bit is set.
>>  but problem is when i run attached app it is not adding user 
> 
> set_user_id only works with C binary files. So, here you have to use
> sudo.
> 
> Regards,
> Josef
> 


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


Re: Sending an event from a python COM server to a VB COM client

2005-11-16 Thread Josef Meile
Hi Gary,

> I am trying to send an event from a Python COM server to a VB (or VB.NET) 
> COM client.
> I am a newbie both in VB and in python.
> Can anyone give me a simple (but complete) code example both of the Python 
> server side and the VB client side for raising a single event.
Do you mean interprocess communication? If so, then you could use the
WM_CopyData message from the Windows API. However, this will only work
if the two applications are running in the same machine and if at least
one of them (the receiver) has a Window were to send the messages.

I have been used the following application to comunicate two C#
applications:

* Simple Interprocess Communications using WM_COPYDATA
http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows_Messages/Simple_Interprocess_Communication/article.asp

However, the zip contains a VB.Net example as well. I haven't ever done
this with python, so, I don't know how it works. However, you could take
a look at the following thread, which discuss how to implement this
with python:

* PyWin SendMessage
http://groups.google.ch/group/comp.lang.python/browse_frm/thread/cf7412ec873cd265/c362e88d9e5d7e80

I have also tried other approaches, but they didn't work on my case, or
they require you to have additional hardware (ie: a network card), or to
install additional software (ie: Microsoft Windwos Message Queuing).
However, they might work for you:

* Windows Sockets may be the easiest solution and you can find several
   examples of this with google. In my case, I didn't use them 'cause
   they require my users to have a network card and my system is just
   a single user application with several processes running on the same
   machine.

* Named Pipes, which are a feature of windows:
   - Inter-Process Communication in .NET Using Named Pipes, Part 1
 http://ivanweb.com/articles/namedpipes/index.cfm

   - How to use named pipes for interprocess communication in Visual
 Basic .NET
 http://support.microsoft.com/?kbid=871044

* Microsoft Windows Message Queuing (MSMQ) -> I don't have a VB/VB.NET
   example for this; only a C# example, but it may work in VB/VB.NET
   as well since if I'm not wrong, it also uses the Windows Api. Again,
   I didn't used it because it requires my users to install the MSMQ
   software from Microsoft, which is included with Windows.

   - Using MSMQ from C#
 http://www.codeproject.com/csharp/mgpMyQueue.asp

Unfortunatelly, I don't have python examples, but since they use the
Windows Api it may be possible to implement with the windows extensions
for python. You just have to look for them in the python list.

Regards,
Josef

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


Re: Overloading

2005-12-09 Thread Josef Meile
>>In C++ you can overload functions and constructors. For example if I have a
>>class that represents a complex number, than it would be nice if I can
>>write two seperate constructors
> 
> 
> Python doesn't support this, but it does support default arguments:
Yes, in part you are right since the python core doesn't include them.
However they can be implemented with decorators:

* Subject: decorators and multimethods
   Group:   comp.lang.python
   Link:http://tinyurl.com/d45ym

Anyway, as you, I also use the default arguments.

Regards
Josef

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


Re: Overloading

2005-12-09 Thread Josef Meile
>>> In C++ you can overload functions and constructors. For example if I 
>>> have a
>>> class that represents a complex number, than it would be nice if I can
>>> write two seperate constructors
>>
>>
>>
>> Python doesn't support this, but it does support default arguments:
> 
> Yes, in part you are right since the python core doesn't include them.
> However they can be implemented with decorators:
> 
> * Subject: decorators and multimethods
>   Group:   comp.lang.python
>   Link:http://tinyurl.com/d45ym
There is even a better recipe, explained step by step from Guido:
* Five-minute Multimethods in Python
   Link: http://tinyurl.com/8ppd6

Regards
Josef

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


Re: how to ncurses on win32 platform

2005-01-26 Thread Josef Meile
Hi Brane,
I was wondering about the same thing some days
ago. I found the following alternatives:
* Curses for Windows for Python (It was previously
mentioned on a follow-up. there are some missing
features):
http://flangy.com/dev/python/curses/
* PDCurses (It looks promissing):
http://pdcurses.sourceforge.net/
* The Console Module:
http://www.effbot.org/zone/console-handbook.htm
* Windows CONsole I/O for Python:
http://newcenturycomputers.net/projects/wconio.html
Please note that I haven't tested any of the mentioned
packages, so, I don't know if they are really a good
replacement for ncurses, so, it's up-to-you to test
them.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 binaries for accessing PostgreSQL from Windows?

2005-02-04 Thread Josef Meile
Hi Frank
I tried the psycopg site, but it does not seem to have binaries at all.
Does anyone know if either of these will be available in binary form
for Python 2.4 on Windows?
For psycopg, there is a site with binaries for windows:
http://www.stickpeople.com/projects/python/psycopg/
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Josef Meile
Hi Brent,
Brent W. Hughes wrote:
The Python program won't decide whether a commercial is playing, I will.  At 
that point, I will run my program which will press mute, wait 20 seconds, 
and then press mute again.

Actually, I could leave the program running but minimized to the task bar. 
When I hear the advertisement, I just click on the program in the task bar. 
It knows what to do from there.
You don't need python for this. You can use auto-it to achieve the same
thing. You can download it at:
http://www.hiddensoft.com/AutoIt/
It is easy to program and it works nicely. There is also some similar
thing for python. Perhaps a litle bit more complicated (I haven't
tested it):
WATSUP - Windows Application Test System Using Python
http://www.tizmoi.net/watsup/intro.html
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Office COM automatisation - calling python from VBA

2005-06-25 Thread Josef Meile
Hi guy,

> I'll be using COM, and I could probably make an application that
> controls Outlook (externally). But I'd also like to have this
> functionality exposed in OL itself. So I guess I'll need to use VBA,
> but I don't really like VBA - relax, please, it's just an opinion.. ;)
> 
> So, ideally, I'd like to program as much as possible in python (I'm
> pretty new to that, too, btw), and only use VBA if needed - say, to
> call python objects/methods (+ wxGUI, please).
You could try to do an addin/addon for Word, Excel, and Outlook. You
don't need to code with VBA. Here you just need a language from where
you can access the microsoft interop assemblies (ie: C++ or C#;
IronPython maybe?)

I'm now working in an addon for Visio, but I'm not using python. I'm
using C#. The main idea is that we have an exe application, which
creates a COM object, with the first running instance of visio (if some
is found). Then, I use a class (event handler) to catch some events
comming from visio (this is in part documented at the msdn). I even
embebbed a windows form in Visio (it was an example in the sdk).

So, I think in theory, you could do the same with python. I have heard
you can somehow create COM objects there. You could also try the new
version of python for net: IronPython. I guess you can from there access
all the assemblies to interact with office:

Microsoft.Office.Interop.Excel,
Microsoft.Office.Interop.Word, and
Microsoft.Office.Interop.Outlook

A good start is to see the SDK documentation of each office product you
need at each developer center in www.msdn.microsoft.com

Good luck,
Josef

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


Re: String Manipulation

2005-07-13 Thread Josef Meile
Hi,

> for punctuation in punctuations:
> line=line.replace(punctuation,'')
I would use maketrans or even a regex instead. However, If you care
about speed, it is well known that in some cases regex take more
time than multiple replaces. Even the maketrans could take more time
(I don't know; you may benchmark it -> homework)

Regards,
Josef

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


Re: Web Framework Reviews

2005-07-19 Thread Josef Meile
> "barely use python with it" and "can only be used with these two" are
> not entirely true.  Zope development can be done in a through-the-web
> (TTW) fashion or via filesystem products.  When developing TTW, it
> is true that you are somewhat limited in the amount of Python that
> you will be able to use.
I just want to add that ZPT and DTML are only intended for the
presentation and not for the logic, which can be done all using python.
However, as you may see, there are some zope developers that use it
wrong and do lots of logic stuff within dtml or zpt.

Regards,
Josef

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


Re: functions without parentheses

2005-07-29 Thread Josef Meile
Steven D'Aprano wrote:
> On Fri, 29 Jul 2005 06:37:52 +, Bengt Richter wrote:
> 
> 
>>I suggested in a previous thread that one could support such a syntax by
>>supporting an invisible binary operator between two expressions, so that
>>examine "string" translates to examine.__invisbinop__("string") if
>>examine as an expression evaluates to an object that has a __invisbinop__ 
>>method.
> 
> 
> Why would you want to?
> 
My best guest is that the OP uses VB, where you can do that. I
personally hate this feature because it just makes me do a lot of
mistakes. ie: In VB you can do:

fooFunction fooParameter

but if you want to assign this to a variable you **must** use this:

fooVer = fooFunction(fooParaMeter)

I really get confused because I automatically use the braces.

Regards,
Josef

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


Re: Zope, Python 2.4 pythonScripts import problem

2005-08-13 Thread Josef Meile
Hi,

> I have installed brand new platform - Zope-2-7-6, Python 2.4.1, Plone
> 2.0.5, OS Debian 1:3.3.6-2.

You may then ask in a zope or plone list. This is a python specific
list. But I will answer you any way.

> After import a old Plone site from the following platform
> Zope-2-7-4, Python 2.3.3, Plone 2.0.3 to the new one, I get error when
> I visit PuthonScript in the ZMI.
 > "invalid syntax (Script (Python), line 1)"
 >
 > There 2 are examples of 1 line:
 > from DateTime import DateTime
 > and
 > request = container.REQUEST
 >
 > There is no syntax error!
 >
 > When I just save this script in ZMI then error disappers :)

So, you are exporting the plone site, then importing it? I had once some
problem like that and the solution was to call an script that compiled
all python scripts again. I'm not sure if this solves your problem, but
you may look at the first script here:

http://www.zope.org/Members/goppelt/2-4-3Upgrade

> What is the reason???

As I said, you may ask in a zope or plone list for a better answer. My
best guess is that somewhere there is some old compiled version of your
script.

> p.s I have the same problem when I import to the same platform but with
> Python 2.4.0

I just have to warn you that some persons in the zope list are going to
tell you "Python 2.4 isn't a supported option for zope". So, you may use
it only for testing and not in a production environment.

Regards,
Josef

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


urllib.urlopen doesn't work

2005-09-02 Thread Josef Cihal



Hallo,
 
i need a help with module URLLIB.
 
I am trying to open url via:
-    urllib.urlopen 
('http://brokerjet.ecetra.com/at/markets/stocks/indices.phtml?notation=92866')
 
 
Problem is, that I am always redirecting to 

- LOGIN page (www.brokerjet.at),
and cannot get my page with "news", which I want to 
download.
 
Can it be, that I forgot to pass all (hidden too) 
parameters to form by submit?
 
Is it possible to get (ask) for all existing valid 
parameters, which I need to pass to form 
for getting requested page?
Is action submit correct in my case?
 
 
Thank you very much for all your help or 
ideas
 
 
Code (Python 2.3.3, Windows)
=
import urllib2, os,sys, urllib
x = 
urllib.urlopen( 'http://brokerjet.ecetra.com/at/markets/stocks/indices.phtml?notation=92866', urllib.urlencode({ 'iNotation':'92866',    
                
  'keyword':'',    
                
  'fulltext':'1',    
                
  'value':'',  'action': 
'Submit'}))
data = "">
#f = 
open(r"C:\Tmp\Brokerjet\login.html","w")f.writelines(data)f.close()
os.system(r"C:\Tmp\Brokerjet\login.html")
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Fw: urllib.urlopen doesn't work

2005-09-02 Thread Josef Cihal



 
- Original Message - 
From: Josef Cihal 
To: python-list@python.org 
Sent: Saturday, September 03, 2005 12:09 AM
Subject: urllib.urlopen doesn't work 

Hallo,
 
i need a help with module URLLIB.
 
I am trying to open url via:
-    urllib.urlopen 
('http://brokerjet.ecetra.com/at/markets/stocks/indices.phtml?notation=92866')
 
 
Problem is, that I am always redirecting to 

- LOGIN page (www.brokerjet.at),
and cannot get my page with "news", which I want to 
download.
 
Can it be, that I forgot to pass all (hidden too) 
parameters to form by submit?
 
Is it possible to get (ask) for all existing valid 
parameters, which I need to pass to form 
for getting requested page?
Is action submit correct in my case?
 
 
Thank you very much for all your help or 
ideas
 
 
Code (Python 2.3.3, Windows)
=
import urllib2, os,sys, urllib
x = 
urllib.urlopen( 'http://brokerjet.ecetra.com/at/markets/stocks/indices.phtml?notation=92866', urllib.urlencode({ 'iNotation':'92866',    
                
  'keyword':'',    
                
  'fulltext':'1',    
                
  'value':'',  'action': 
'Submit'}))
data = "">
#f = 
open(r"C:\Tmp\Brokerjet\login.html","w")f.writelines(data)f.close()
os.system(r"C:\Tmp\Brokerjet\login.html")
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Problem with: urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

2005-09-05 Thread Josef Cihal
Hi,

I get an error, when I am trying to download URL with using Cookies.
Where is the Problem?

Thank u very much for all ideas!!!

sincerely

Josef


import os, cookielib, urllib2
cj = cookielib.MozillaCookieJar()
os.environ["http_proxy"] = "http://proxy.irm.at:1234";
os.environ['HOME']= r"C:\tmp\COOKIE"
#
cj.load(os.path.join(os.environ["HOME"], "cookies.txt"))
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://brokerjet.ecetra.com/at/news/?/";)

Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Programme\Python24\lib\urllib2.py", line 358, in open
response = self._open(req, data)
  File "C:\Programme\Python24\lib\urllib2.py", line 376, in _open
'_open', req)
  File "C:\Programme\Python24\lib\urllib2.py", line 337, in _call_chain
result = func(*args)
  File "C:\Programme\Python24\lib\urllib2.py", line 1021, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "C:\Programme\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
urllib2.URLError: 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OCR librarys

2005-09-12 Thread Josef Meile
Hi Timothy,

first at all, sorry if you receive this message twice, but I sent a
message five hours ago and I don't see it on
mail.python.org/python-list.

Now at least the OP will receive it since I included it in a CC.

This thread may give you an start:
http://groups.google.ch/group/comp.lang.python/browse_frm/thread/362ac64a3c3aece2/

It mentioned how to call simpleocr, which according to the website:
http://www.simpleocr.com

it is Royalty Free. I haven't tried it, so, I can say how accurate it
is.

Regards,
Josef


Timothy Smith wrote:
> i'm looking for ocr librarys with reasonably free licensing and the 
> ablity to use python with them. c library's that i can call from python 
> are acceptable.
> so far all i have run into is voodoo and wild claims. i've tried gocr, 
> and it wasn't very impressive. i'm like to be able to ocr handwriting 
> but it's not a major requirment. anyone with any pointers or idea's i'm 
> all ears. i'd really not like to have to use somthing like imagemagick 
> and start from scratch.


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


Re: OCR librarys

2005-09-13 Thread Josef Meile
Hi Timothy

> i'm looking for ocr librarys with reasonably free licensing and the 
> ablity to use python with them. c library's that i can call from python 
> are acceptable.
This thread may give you an start:
http://groups.google.ch/group/comp.lang.python/browse_frm/thread/362ac64a3c3aece2/

It mentioned how to call simpleocr, which according to the website:
http://www.simpleocr.com

it is Royalty Free. I haven't tried it, so, I can say how accurate it
is.

Regards,
Josef


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


Re: testing a website from python

2005-09-21 Thread Josef Meile
Hi,

> I just want to test that a given website is up or not from a python 
> script.  I thought of using wget as an os command.  Any better ideas?
Here is how I did it:

import urllib2
import socket
def checkUrl(url, timeout=1):
   """Checks an url for a python version greater
  than 2.3.3.

  Note: For me isn't important the kind of
HTTP Error. If you want to know it,
then take a look at the existent
solutions like CMFLinkChecker and
see how they extract the code from
the error message.
   """
   error={'code':1, 'msg':'Success'}
   defTimeOut=socket.getdefaulttimeout()
   socket.setdefaulttimeout(timeout)
   try:
 urllib2.urlopen(url)
   except (urllib2.HTTPError, urllib2.URLError,
   socket.error, socket.sslerror):
 error['code']=-2
 error['msg']="The link: \"${link}\" couldn't be validated"
   except:
 socket.setdefaulttimeout(defTimeOut)
 raise

   socket.setdefaulttimeout(defTimeOut)
   return error

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


Re: Curses on Windows

2005-02-08 Thread Josef Meile
Hi Peter,
Last November I posted a message asking for advice on using simple
screen handling techniques under Windows.  Since then I have been
occupied with family / job /Christmas /living  and trying to
understand curses under linux (it works, seems very complex, sure I'm
missing something ...).  Only now am I returning to my original query.
One reply (in fact the only reply - thanks Tim Golden) suggested I
look at http://flangy.com/dev/python/curses/
There was a similar thread last month. See my reply for more links. I
haven't tested them, but they may help.
how to ncurses on win32 platform:
http://mail.python.org/pipermail/python-list/2005-January/262511.html
Just tried that and got the message
"You don't have permission to access
/dev/python/curses/files/wcurses-0.1-py2.4.zip on this server."
Yes, I also have problems.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Testing web applications

2005-02-11 Thread Josef Meile
Hi Achim,
I'm looking for frameworks to make testing web applications - i.e. 
parsing and filling out forms - easier. I found Puffin, which looks good 
but not very usable in the current state. I know that I once read about 
other nice frameworks, but could not find one via google. Any hints?
Zope + Formulator is a nice combination to validating and designing
forms and add some functionality. If you want a more complicated content
management framework, then you can additionally install plain CMF or
Plone, which is based on CMF. There is also something called Silva, but
it doesn't have many products as the other two; however, it is also
nice.
I have heard also about CherryPy, Quixote, Twisted Matrix and Webware,
but I haven't tested them. Once I saw that somebody posted a link, which
compares some of them, but I lost that thread :-(
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Testing web applications

2005-02-11 Thread Josef Meile
Zope + Formulator is a nice combination to validating and designing
forms and add some functionality. If you want a more complicated content
management framework, then you can additionally install plain CMF or
Plone, which is based on CMF. There is also something called Silva, but
it doesn't have many products as the other two; however, it is also
nice.
I have heard also about CherryPy, Quixote, Twisted Matrix and Webware,
but I haven't tested them. Once I saw that somebody posted a link, which
compares some of them, but I lost that thread :-(
I found it:
http://www.cmsmatrix.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-11 Thread Josef Dalcolmo

You can distribute GPL'ed code in binary form, you just have to make
the sources available as well.  And, yes I would use this as a test:
if your program needs gpl-ed code for some of it's functionality, you
have to licence your program according to the GPL - unless you
distribute the GPL'ed parts separately and your program is still
basically functioning without the GPL'ed code.

Now, if you are unsure about these questions and are serious about
writing a program using GPL'ed code, the FSF is probably willing to
help you with your questions.

Besides this, why not putting your code under the GPL? 

- Josef

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


Re: - E02 - Support for MinGW Open Source Compiler

2005-02-18 Thread Josef Meile
It looks like here the only worth words are yours. Didn't
you close this thread?
I will refresh your mind with your own unpolite way:
"""
Ilias Lazaridis wrote:
[...]
closing thread
http://groups-beta.google.com/group/comp.lang.python/msg/f2ae9cdbe16676d1
"""
Anyway, I will add some comments:
The defined "extra effort" is the effort to provide the patches for the
main source-code base?
If you can send me an email of how to do this, I would take this effort.
Good for you.
of course I must first know, that the python-team would accept those
patches (technical applicability provided).
There is no guaranty. Did you forget the reply from Tim Peters:
> [...] A problem is that a
> patch won't get reviewed unless a volunteer does a review, and we've
> got an increasing backlog of unreviewed patches because of that.  The
> most effective way for a person P to get their patch reviewed now is
> for P to volunteer to review 5 other patches first.  There are a few
> Python developers who have promised, in return, to review P's patch
> then.
So, you will have to review some patches first.
>Ilias> Now, can you please tell me the process I have to follow to
>Ilias> suggest the following (to the PSF or to the programmers or to
>Ilias> the decision takers),possibly to get at least a vote on it:
>Tim> No such thing will happen -- forget that.  For MinGW to be
>Tim> supported forever, it's necessary and sufficient that a specific
>Tim> person volunteer to support MinGW forever.  If that person goes
>Tim> away, so does the support they provided; it's the same story for
>Tim> Cygwin, and even for Linux and native Windows.
So, it is not just making the patch. You will have to compromise to
support it and not just go away.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: split a directory string into a list

2005-02-25 Thread Josef Meile
Hi Duncan,
This should work reasonably reliably on Windows and Unix:

somestring = '/foo/bar/beer/sex/cigarettes/drugs/alcohol/'
os.path.normpath(somestring).split(os.path.sep)
['', 'foo', 'bar', 'beer', 'sex', 'cigarettes', 'drugs', 'alcohol']
However a better solution is probably to call os.path.split repeatedly 
until it won't split anything more:


somestring = r'C:\foo\bar\beer'
def splitpath(p):
res = []
while 1:
p, file = os.path.split(p)
if not file:
break
res.append(file)
res.append(p)
res.reverse()
return res

splitpath(somestring)
['C:\\', 'foo', 'bar', 'beer']
splitpath('foo/bar')
['', 'foo', 'bar']
The first component is an empty string for relative paths, a drive letter 
or \ for absolute Windows paths, \\ for UNC paths, / for unix absolute 
paths.
I don't understand why the second approach is better than the first
one. In my opinion it is the contrary:
On the first approach, you only scan the string twice:
when you do "os.path.normpath(somestring)" and finally when splitting
the string. On the other hand, the second approach goes through the
string several times, when doing the os.path.split. Finally when doing
the res.reverse(). Or am I wrong? I also saw you said:
"This should work ***reasonably*** reliably on Windows and Unix". Are
there any cases when it does not work?
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: split a directory string into a list

2005-02-28 Thread Josef Meile
The most obvious case where it wouldn't work would be for a UNC path name. 
Using the string split method gives two empty strings:


os.path.normpath(r'\\machine\share').split(os.path.sep)
['', '', 'machine', 'share']

whereas the splitpath function I proposed gives you:

splitpath(r'\\machine\share')
['', 'machine', 'share']
So to find out the type of path (relative, absolute, unc), you only have to 
consider the first element with my function but you have to look at the 
first two elements if you just naively split the string.
Thanks for the explanation. I forgot that you could do thinks like that
on windows.
Also a relative windows path with a drive letter doesn't get fully split:

os.path.normpath(r'c:dir\file').split(os.path.sep)
['c:dir', 'file']
splitpath(r'c:dir\file')
['c:', 'dir', 'file']
Again, I forgot it.
If you really are worried about speed (and are sure you aren't optimising 
prematurely), then you could combine some special case processing near the 
start of the string with a simple split of the remainder.
No, I'm not worried about speed. Actually, the original post wasn't
mine. I was just curious about your answer.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: capturing text from a GUI window

2005-03-10 Thread Josef Meile
Hi Earl,
Anyone know how to capture text from GUI output?  I need to process
information returned via a GUI window.
Earl
Assuming Windows, then these guys have an interesting tool:
   http://www.skesoft.com/textcatch.htm
It's not free, but you can try it before you buy it.
You will need COM to control it from Python.

This sounds like just what I need.  What is COM, and where do I get it? 
(I'm really a Linux guy. I don't ken the mysteries of Window very well.)
You may also try WATSUP - Windows Application Test System Using Python:
http://www.tizmoi.net/watsup/intro.html
Now the website seems to be down, but perhaps there is a mirror
somewhere.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Web framework

2005-03-14 Thread Josef Meile
Hi Joe,
Not wrong. I am aware of this, but it's not like that many development
tools can work through FTP or WebDav... Besides, how to have the
source code under source control if it's stuck in the ZODB?
I guess you are reffering to "Python Scripts" and "ZClasses", which
indeed are stuck in the ZODB. But in fact you can write external python
products for zope, which reside on your file system. What is stuck in
the ZODB would be the instances of those products.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: fastest postgresql module

2005-03-18 Thread Josef Meile
my only issue with psycopg, is last time i looked they had no win32 port?
Not completely true. Since long time ago there is a website with
unofficial psycopg binaries:
http://www.stickpeople.com/projects/python/psycopg/
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: IronPython 0.7 released!

2005-03-24 Thread Josef Meile
well that's nice, but I don't do blogs and certainly don't do M$ 
Passport logins which it seems the gotdotnet site requires.
I agree, even for reading the FAQ and the Readme you need a password :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: check interpreter version before running script

2005-04-05 Thread Josef Meile
Is there a recommended or 'Best Practices' way of checking the version 
of python before running scripts? I have scripts that use the os.walk() 
feature (introduced in 2.3) and users running 2.2 who get errors. 
Instead of telling them, 'Upgrade you Python Install, I'd like to use 
sys.version or some other way of checking before running.

Whatever I do, I need it to work on Linux, Mac and Windows.
I thought of sys.version... but getting info out of it seems awkward to 
me. First 5 chars are '2.4.1' in string format have to split it up and 
convert it to ints to do proper checking, etc. It doesn't seem that 
sys.version was built with this type of usage in mind. So, what is the 
*best* most correct way to go about this?

What's about:
>>> import sys
>>> print sys.version_info
(2, 1, 3, 'final', 0)
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zope3 and Plone

2005-04-18 Thread Josef Meile
Hi Mir,
you are asking in the wrong place. This is a python specific list. You
can find a suitable list here:
http://mail.zope.org/mailman/listinfo
Regards,
Josef
Mir Nazim wrote:
Hi,
I wanted to know what will happen to plone once Zope3 will be official
version. Is plone being ported to Zope3. I googled it but did not come
accross anything stating the plone's migration to zope3.
I am thinking to take up a project. plone is a candidate for it. should
i want to take  benifit of zope3 features too.
what should be done. 

Please comment
thanks

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


Re: Is vars() the most useless Python built-in ever?

2015-11-30 Thread Josef Pktd
On Monday, November 30, 2015 at 8:01:14 PM UTC-5, Steven D'Aprano wrote:
> I'm trying to understand why vars() exists. Does anyone use it?
> 
> Every time I try to use it, I find it doesn't quite do what I want. And even
> if it did, there are more obvious and/or correct alternatives.
> 
> For instance, I want to check whether a particular name is an instance
> attribute. So first I write:
> 
> "name" in obj.__dict__
> 
> but when I see the dunder name I think that's an implementation detail. And
> sure enough, not all instances have a __dict__ (e.g. if it uses __slots__
> instead) and so I re-write it as:
> 
> "name" in vars(obj)
> 
> but that also fails if obj has no instance __dict__.
> 
> But why am I looking just in the instance __dict__? Chances are I should be
> looking for the attribute *anywhere* in the instance/class/superclass
> hierarchy: 
> 
> hasattr(obj, "name")
> 
> Or, if you are worried about triggering dynamic attributes using
> __getattr__, you can do this:
> 
> sentinel = object()
> inspect.getattr_static(obj, "name", sentinel) is not sentinel
> 
> which only checks for pre-existing attributes without triggering
> __getattr__, __getattribute__, or the descriptor protocol.
> 
> 
> Either way, vars() doesn't solve the problem. What problem does it solve?

I'm using dir and vars pretty often when I'm trying to figure out new code or 
review a pull request, or when I'm reviewing code that I don't remember.

Both are convenient for quickly checking which attributes are available at the 
moment. I never realized that there might be issues with "fancy" problems. 

`vars` is convenient, for example, to check which attributes have been 
initialized to None, and which already have assigned values. And checking again 
after some calculations, I roughly see which attributes have been added or 
changed in the mean time.

aside: I'm boring and like code that has no magic, especially if I have to 
maintain it.

Josef

> 
> 
> 
> -- 
> Steven

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


Re: Help on error " ValueError: For numerical factors, num_columns must be an int "

2015-12-16 Thread Josef Pktd
On Wednesday, December 16, 2015 at 9:50:35 AM UTC-5, Robert wrote:
> On Wednesday, December 16, 2015 at 6:34:21 AM UTC-5, Mark Lawrence wrote:
> > On 16/12/2015 10:44, Robert wrote:
> > > Hi,
> > >
> > > When I run the following code, there is an error:
> > >
> > > ValueError: For numerical factors, num_columns must be an int
> > >
> > >
> > > 
> > > import numpy as np
> > > import pandas as pd
> > > from patsy import dmatrices
> > > from sklearn.linear_model import LogisticRegression
> > >
> > > X = [0.5,0.75,1.0,1.25,1.5,1.75,1.75,2.0,2.25,2.5,2.75,3.0,3.25,
> > > 3.5,4.0,4.25,4.5,4.75,5.0,5.5]
> > > y = [0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1]
> > >
> > > zipped = list(zip(X,y))
> > > df = pd.DataFrame(zipped,columns = ['study_hrs','p_or_f'])
> > >
> > > y, X = dmatrices('p_or_f ~ study_hrs', df, return_type="dataframe")
> > > ===
> > >
> > > I have check 'df' is this type:
> > > =
> > > type(df)
> > > Out[25]: pandas.core.frame.DataFrame
> > > =
> > >
> > > I cannot figure out where the problem is. Can you help me?
> > > Thanks.
> > >
> > > Error message:
> > > ..
> > >
> > >
> > > ---
> > > ValueErrorTraceback (most recent call 
> > > last)
> > > C:\Users\rj\pyprj\stackoverflow_logisticregression0.py in ()
> > >   17 df = pd.DataFrame(zipped,columns = ['study_hrs','p_or_f'])
> > >   18
> > > ---> 19 y, X = dmatrices('p_or_f ~ study_hrs', df, 
> > > return_type="dataframe")
> > >   20
> > >   21 y = np.ravel(y)
> > >
> > > C:\Users\rj\AppData\Local\Enthought\Canopy\User\lib\site-packages\patsy\highlevel.pyc
> > >  in dmatrices(formula_like, data, eval_env, NA_action, return_type)
> > >  295 eval_env = EvalEnvironment.capture(eval_env, reference=1)
> > >  296 (lhs, rhs) = _do_highlevel_design(formula_like, data, 
> > > eval_env,
> > > --> 297   NA_action, return_type)
> > >  298 if lhs.shape[1] == 0:
> > >  299 raise PatsyError("model is missing required outcome 
> > > variables")
> > >
> > > C:\Users\rj\AppData\Local\Enthought\Canopy\User\lib\site-packages\patsy\highlevel.pyc
> > >  in _do_highlevel_design(formula_like, data, eval_env, NA_action, 
> > > return_type)
> > >  150 return iter([data])
> > >  151 design_infos = _try_incr_builders(formula_like, 
> > > data_iter_maker, eval_env,
> > > --> 152   NA_action)
> > >  153 if design_infos is not None:
> > >  154 return build_design_matrices(design_infos, data,
> > >
> > > C:\Users\rj\AppData\Local\Enthought\Canopy\User\lib\site-packages\patsy\highlevel.pyc
> > >  in _try_incr_builders(formula_like, data_iter_maker, eval_env, NA_action)
> > >   55   data_iter_maker,
> > >   56   eval_env,
> > > ---> 57   NA_action)
> > >   58 else:
> > >   59 return None
> > >
> > > C:\Users\rj\AppData\Local\Enthought\Canopy\User\lib\site-packages\patsy\build.pyc
> > >  in design_matrix_builders(termlists, data_iter_maker, eval_env, 
> > > NA_action)
> > >  704 factor_states[factor],
> > >  705 
> > > num_columns=num_column_counts[factor],
> > > --> 706 categories=None)
> > >  707 else:
> > >  708 assert factor in cat_levels_contrasts
> > >
> > > C:\Users\rj\AppData\Local\Enthought\Canopy\User\lib\site-packages\patsy\design_info.pyc
> > >  in __init__(self, factor, type, state, num_columns, categories)
> > >   86 if self.type == "numerical":
> > >   87 if not isinstance(num_columns, int):
> > > ---> 88 raise ValueError("For numerical factors, 
> > > num_columns "
> > >   89   

Re: Installing PyCharm on Windows (was: issues)

2015-12-19 Thread Josef Pktd
On Saturday, December 19, 2015 at 1:32:27 PM UTC-5, Thomas 'PointedEars' Lahn 
wrote:
> Anna Szaharcsuk wrote:
> 
> > I was trying to install PyCharm, but didn't worked and needed interpreter.
> > the computer advised to install the python for windows.
> 
> Not “the python for windows” (that would be some species of snake), but 
> _Python_ for _Windows_, the programming language interpreter.  Just do as 
> “the computer advised”.
> 
> > Can you help me, please, PyCharm stillnot working...allways gives a
> > message for repair, after- the repair successful and again message for
> > repair...
> 
> Have you installed Python first?  If no, it cannot work (and please think 
> about this: What good is an IDE/editor for a programming language if you do 
> not also have the interpreter/compiler?).  It says so in the “Quick Start 
> Guide” in the “PyCharm 5.0 Help”, currently to be found on the PyCharm Web 
> site under “Docs & Demos”:
> 
> <https://www.jetbrains.com/pycharm/help/quick-start-guide.html#prereq>
> 
> Have you tried to install Python ≥ 3.4.4rc1 on Windows XP?  If yes, it 
> cannot work; you need Python < 3.4.4rc1 instead (and you should seriously 
> consider upgrading Windows or even better, to switch to a real operating 
> system, like GNU/Linux – many of the latter come for free and give you more 
> freedom than Windows):

Thanks for the tip, I will switch away from Windows when I have an extra year 
to figure out weird things in other operating systems.

So far I never managed more than two weeks in a Linux virtual machine before 
never opening it again.


Josef
PS: loyal Windows user since Windows 95, currently considering whether to 
upgrade from 7 and 8 to 10.

PPS: The mainstream: Python and Windows ("it's not just for 'hackers'"):
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
https://www.netmarketshare.com/operating-system-market-share.aspx?qprid=10&qpcustomd=0

PPPS: Scientific Python mailing list have been free of snide remarks about 
Windows users for a while, but not of real problems with Windows (or OSX or 
Linux)

S: Windows 10 with Computer as a Service following Apple will lock in many 
users again to "everything Microsoft", but without the monopoly.


> 
> <http://stackoverflow.com/a/32942216/855543>
> 
> Before your next posting, please read
> 
> <http://www.catb.org/~esr/faqs/smart-questions.html>
> 
> -- 
> PointedEars
> 
> Twitter: @PointedEars2
> Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing PyCharm on Windows

2015-12-20 Thread Josef Pktd
On Sunday, December 20, 2015 at 3:29:34 AM UTC-5, Thomas 'PointedEars' Lahn 
wrote:
> Josef Pktd wrote:
> ^^
> I doubt that is your real name.

But it's the name I used for almost all of my Python open source development, 
and can be easily googled.
except I misspelled my "name" josef-pkt when I set up my github account.


> 
> > On Saturday, December 19, 2015 at 1:32:27 PM UTC-5, Thomas 'PointedEars'
> > Lahn wrote:
> >> Have you tried to install Python ≥ 3.4.4rc1 on Windows XP?  If yes, it
> >> cannot work; you need Python < 3.4.4rc1 instead (and you should seriously
> >> consider upgrading Windows or even better, to switch to a real operating
> >> system, like GNU/Linux – many of the latter come for free and give you
> >> more freedom than Windows):
> > 
> > Thanks for the tip, I will switch away from Windows when I have an extra
> > year to figure out weird things in other operating systems.
> 
> Ordinary people (as opposed to tech-savvy people) have been known to set up 
> a current Linux distribution in a day and get accustomed to it in a week.  
> Those “weird things” you are talking about are merely something that needs a 
> little getting used to if you had gotten used to Windows.  Of course, not 
> all people are (still) that flexible in their thinking.

Maybe I don't **want** to be this flexible because I allocate my "flexibility" 
to other things (instead of, for example, figuring out how packaging and paths 
work on Linux).


> 
> > So far I never managed more than two weeks in a Linux virtual machine
> > before never opening it again.
> 
> Your problem alone.

If I have a problem, then I assume many other Windows users will also have 
problems, if they are even willing to try.


> 
> > PPS: The mainstream: Python and Windows ("it's not just for 'hackers'"):
> 
> Non-Windows operating systems are not just for hackers since more than a 
> decade.  They are for reasonably smart people, though, who would not give up 
> at the first sign of trouble.
> 
> And who cares about the mainstream opinion?

I do!

Almost all economists and econometricians that I know are using Windows. And I 
was working for many years on open software to get to a stage where they can 
use Python instead of commercial packages like GAUSS, Stata or Matlab.

The main target group are not programmers or users with a computer science 
background.

> 
> > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
> 
> Thank you so much for providing that valuable reference. I am sure nobody 
> here knew :->
> 
> > https://www.netmarketshare.com/operating-system-market-share.aspx?qprid=10&qpcustomd=0
> 
> A million flies can be wrong.
> 
> <https://en.wikipedia.org/wiki/Microsoft_Windows#Third-party_analysis>
> 
> > PPPS: Scientific Python mailing list have been free of snide remarks about
> > Windows users for a while, but not of real problems with Windows (or OSX
> > or Linux)
> 
> Thanks to you that would have changed if this were a “scientific Python 
> mailing list”.

I complained a few times on the mailing lists when the response to a question 
by a Windows users was to switch to Linux. It's not helpful in almost all 
cases, and now the standard response for setup problems is to use Anaconda or 
WinPython.

I also found it silly if Software Carpentry courses use exclusively Linux in 
the course and people are then surprised that users go back to their office and 
their Windows machine, and their commercial software, ignoring most of what 
they learned.


> 
> Mine was not a snide remark, but the truth.  Those other operating systems I 
> was talking about do give users more freedom.  For example, the freedom to 
> use it on as many different machines as you like without an extra license, 
> to see the source code, to modify it, and to redistribute the modification 
> including an attribution to yourself.

"Richtige Männer nehmen Pitralon"  everything else is "unreal"

I'm writing BSD licensed software, but I never felt the urge to change more 
than a few options in the operating system, and was never interested in the 
"freedom" to fix the kernel (and I was never interested in fixing my car 
either).

Josef

PS: I learned a lot from this mailing list when I started with Python 12 to 15 
years ago. But either the mailing list or my perception has changed in that I 
see now several or many comments that ignore that there are many users and 
developers using Python without an explicit programming background.



>  
> > S: Windows 10 with Computer as a Service following Apple will lock in
> > many users again to "everything

Re: GitHub's "pull request" is proprietary lock-in

2016-01-04 Thread Josef Pktd
On Monday, January 4, 2016 at 12:41:32 PM UTC-5, Michael Torrie wrote:
> On 01/04/2016 03:21 AM, m wrote:
> > W dniu 03.01.2016 o 05:43, Ben Finney pisze:
> >> That and other vendor-locked workflow aspects of GitHub makes it a poor
> >> choice for communities that want to retain the option of control over
> >> their processes and data.
> > 
> > I'm also afraid that Github will make to git the same thing as Google
> > did to Jabber/XMPP.
> > 
> > Decade ago, I had plenty of friends on my jabber contacts list. Next,
> > Google made it's talk compatible with jabber, then my friends slowly
> > migrated to gtalk, because if they used gmail anyway, then why not use
> > it also for jabber?
> > 
> > And then Google turned off XMPP support and suddenly I lost ability to
> > contact with 80% of my friends without having stupid hangouts running,
> > or without falling back to email (which is not so bad BTW).
> 
> I use gtalk with Pidgin every day using XMPP.  So Google still supports
> XMPP.  However what they stopped doing was allowing federated XMPP,
> which pretty much breaks XMPP, at least the spirit of it.  So the only
> way to chat with gtalk users is to use your gtalk account.  But you
> certainly don't need hangouts.  XMPP works fine between your client and
> the Google server.
> 
> I agree that Google really pulled a bad one with gtalk though.  Dropping
> federated XMPP support was definitely not in keeping with their original
> "do no evil" mantra.
> 
> > The same can be with Github and git. PPL will forget how to use git
> > without github. When Github will make git-incompatible changes, vast
> > majority will need/want to follow the changes and eg. will use Gitlabs
> > propertiary binary.
> 
> Yup you are correct.  However for the foreseeable future, you can still
> do a git clone from github, and you can still use your local repository
> normally.  In fact I think this is really part of the github workflow.
> But who knows what the future will bring.  I can sure see the wisdom of
> the GPLv3 as we move into a world of software as a service, where even
> Microsoft uses Linux, and charges us for it.


about:
> PPL will forget how to use git without github.

We cannot forget what we never learned. 

git is way to complicated for regular users without support like what github 
provides.

I haven't done a merge without the Green Button in a long time. And when I did 
I always had to triple check to make sure to avoid any mistakes.
I never needed to check what a pull request would be in pure git.

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


Re: psss...I want to move from Perl to Python

2016-01-29 Thread Josef Pktd
On Friday, January 29, 2016 at 4:50:25 PM UTC-5, Cody Piersall wrote:
> On Fri, Jan 29, 2016 at 2:42 PM, Fillmore 
> wrote:
> > I actually have a few followup question.
> 
> > - will iNotebook also work in Python 3?
> Yes!  And just FYI, it's called they Jupyter Notebook now, but pretty much
> everyone still (colloquially) calls it the IPython Notebook so you're in
> good company.  When you're searching online, you should search for Jupyter
> though, or you might get obsolete docs.
> 
> > - What version of Python 3 do you recommend I install on Windows?
> Might as well go for Python 3.5.
> 
> > [snip questions I don't know the answer to]
> > - Is there a good IDE that can be used for debugging? all free IDEs for
> Perl suck and it would be awesome if Python was better than that.
> PyCharm is a really good IDE.  You can use the community edition for free
> as long as it's for open source projects or your company makes less than $1
> million a year.  For bigger projects I use PyCharm, but it's not bad to use
> just a plain text editor either.  If your company is making $1 million a
> year, presumably they can afford the license fees.  Download link:
> https://www.jetbrains.com/pycharm/download/

spyder is great for developing scripts (especially data analysis and scientific)
pydev/eclipse is very good for larger packages or projects.

Great features: automatic, immediate code checking for finding those typos, 
undefined names and unused names, and similar  (look out for red)
(and of course code completion, nicer than in IDLE)

Another very useful tool for me during bug hunting sessions is to drop into the 
debugger when running nosetests.

In my experience notebooks are for when I know what I'm doing and want a nice 
summary or presentation, but not when I need to figure out what I'm supposed to 
be doing.

Josef

> 
> Cody

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


URL - Python ?

2015-02-17 Thread Josef Achkar
Hi i was wondering if it's possible to trace a website.
If im for example is interested of the content of www.example.com/cars/audi
and i have noticed that they are changing all URL's on the site so it dosent 
change at all and that it always stays the same like for example 
www.example.com and that i want to still be able to visit the page using 
"www.example.com/cars/audi"

I would want to know if it's possible to trace the url to the new location 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 450 Adding a statistics module to Python

2013-08-17 Thread Josef Pktd
I think the install issues in the pep are exaggerated, and are in my opinion 
not a sufficient reason to get something into the standard lib.

google appengine includes numpy
https://developers.google.com/appengine/docs/python/tools/libraries27

I'm on Windows, and installing numpy and scipy are just binary installers that 
install without problems.
There are free binary distributions (for Windows and Ubuntu) that include all 
the main scientific applications. One-click installer on Windows
http://code.google.com/p/pythonxy/wiki/Welcome
http://code.google.com/p/winpython/

How many Linux distributions don't include numpy? (I have no idea.)

For commercial support Enthought's and Continuum's distributions include all 
the main packages.

I think having basic descriptive statistics is still useful in a basic python 
installation. Similarly, almost all the descriptive statistics moved from 
scipy.stats to numpy.

However, what is the longterm scope of this supposed to be?

I think working with pure python is interesting for educational purposes
http://www.greenteapress.com/thinkstats/
but I don't think it will get very far for more extensive uses. Soon you will 
need some linear algebra (numpy.linalg and scipy.linalg) and special functions 
(scipy.special).

You can reimplement them, but what's the point to duplicate them in the 
standard lib?

For example:

t test: which versions? one-sample, two-sample, paired and unpaired, with and 
without homogeneous variances, with 3 alternative hypothesis.

If we have t test, shouldn't we also have ANOVA when we want to compare more 
than two samples?

...

If the Python versions that are not using a C backend need a statistics package 
and partial numpy replacement, then I don't think it needs to be in the CPython 
lib.


If think the "nuclear reactor" analogy is in my opinion misplaced.

A python implementation of statistics is a bycycle, numpy is a car, and if you 
need some heavier lifting in statistics or machine learning, then the trucks 
are scipy, scikit-learn and statsmodels (and pandas for the data handling).
And rpy for things that are not directly available in python.


I'm one of the maintainers for scipy.stats and for statsmodels.

We have a similar problem of deciding on the boundaries and scope of numpy, 
scipy.stats, pandas, patsy, statsmodels and scikit-learn. There is some overlap 
of functionality where the purpose or use cases are different, but in general 
we try to avoid too much duplication.


https://pypi.python.org/pypi/statsmodels
https://pypi.python.org/pypi/pandas
https://pypi.python.org/pypi/patsy  (R like formulas)
https://pypi.python.org/pypi/scikit-learn


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


Re: statsmodels.api

2013-09-17 Thread Josef Pktd
On Tuesday, September 17, 2013 8:13:27 AM UTC-4, Davide Dalmasso wrote:
> You are right... there is a problem with scipy intallation because this error 
> arise...
> 
> 
> 
> >>> from scipy.interpolate import interp1d
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> 
> from scipy.interpolate import interp1d
> 
>   File "C:\Python33\lib\site-packages\scipy\interpolate\__init__.py", line 
> 150, in 
> 
> from .interpolate import *
> 
>   File "C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py", line 
> 12, in 
> 
> import scipy.special as spec
> 
>   File "C:\Python33\lib\site-packages\scipy\special\__init__.py", line 529, 
> in 
> 
> from ._ufuncs import *
> 
> ImportError: DLL load failed: Impossibile trovare il modulo specificato.
> 
> 
> 
> I tryed to re-install the scipy executable that I downloaded from 
> http://www.lfd.uci.edu/~gohlke/pythonlibs/
> 
> but the problem persists

Did you also install numpy from gohlke?
My guess would be binary incompatibility if numpy is not the MKL version.

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


Re: statsmodels.api

2013-09-17 Thread Josef Pktd
On Tuesday, September 17, 2013 9:06:59 AM UTC-4, Oscar Benjamin wrote:
> On 17 September 2013 13:13, Davide Dalmasso  wrote:
> 
> >
> 
> > You are right... there is a problem with scipy intallation because this 
> > error arise...
> 
> >
> 
> >>>> from scipy.interpolate import interp1d
> 
> > Traceback (most recent call last):
> 
> >   File "", line 1, in 
> 
> > from scipy.interpolate import interp1d
> 
> >   File "C:\Python33\lib\site-packages\scipy\interpolate\__init__.py", line 
> > 150, in 
> 
> > from .interpolate import *
> 
> >   File "C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py", 
> > line 12, in 
> 
> > import scipy.special as spec
> 
> >   File "C:\Python33\lib\site-packages\scipy\special\__init__.py", line 529, 
> > in 
> 
> > from ._ufuncs import *
> 
> > ImportError: DLL load failed: Impossibile trovare il modulo specificato.
> 
> >
> 
> > I tryed to re-install the scipy executable that I downloaded from 
> > http://www.lfd.uci.edu/~gohlke/pythonlibs/
> 
> > but the problem persists
> 
> 
> 
> There are potential compatibility problems with the binaries from
> 
> there as described at the top of the page. One thing is that you need
> 
> to use Christopher's own numpy build to go with scipy:
> 
> http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
> 
> If you installed numpy from somewhere else then that could be your problem.
> 
> 
> 
> Essentially scipy isn't quite ported to Python 3.3 yet so my general
> 
> advice is to use Python 3.2 and to use the official numpy/scipy
> 
> binaries from sourceforge (they don't yet provide binaries for 3.3).
> 
> 
> 
> Alternatively an easier approach might be to use Python(x, y) (which
> 
> is free) or the Enthought Python Distribution (which is free for
> 
> academic users). These are distributions that bundle Python with
> 
> numpy/scipy and lots of other packages. I think they both still use
> 
> Python 2.7 though.
> 
> 
> 
> (As an aside, this is all much simpler if you're using Ubuntu or some
> 
> other Linux distro rather than Windows.)

scientific python on a stick

https://code.google.com/p/winpython/wiki/PackageIndex_33

I haven't seen any problems so far on python 3.3
The statsmodels test suite passes without problems on python 3.3 also, as far 
as I remember.
(and no problems using Windows. just use the right binaries.)

Josef

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


Re: statsmodels.api

2013-09-17 Thread Josef Perktold
Oscar Benjamin  gmail.com> writes:

> 
> On 17 September 2013 14:35, Josef Pktd  gmail.com> wrote:
> >> (As an aside, this is all much simpler if you're using Ubuntu or some
> >> other Linux distro rather than Windows.)
> >
> > scientific python on a stick
> >
> > https://code.google.com/p/winpython/wiki/PackageIndex_33
> 
> Thanks, I've just installed that and I'll try it out later.
> 
> > I haven't seen any problems so far on python 3.3
> > The statsmodels test suite passes without problems on python 3.3 also,
as far as I remember.
> > (and no problems using Windows. just use the right binaries.)
> 
> Well that's exactly my point. On a Linux distro you would have the
> right binaries first time. No need to search through project webpages
> or documentation, weigh up different installers, or download 750MB of
> software that you mostly won't use. Similarly on a Linux distro it's a
> lot easier to get all of the build tools set up to build these things
> from source if you'd prefer.

This might be true for many Linux users.
However, the last time I tried to install something in a virtual Linux OS
that was not in the standard repository, I was completely lost.
(I'm a Windows user.)


> 
> Windows users are often dependent on inconsistent sources of binaries.
> In this case I imagine that the OP installed numpy from sourceforge
> since it has 3.3 binaries but it doesn't have the same for scipy at
> which point googling would easily lead to Cristoph's page.

Another problem with relying on binaries on Windows is when the matching
binaries are not available. For example, the Windows binaries on pypi of
pandas and statsmodels are compiled against the latest numpy release and
will not work with older numpy versions.
(
http://stackoverflow.com/questions/17709641/valueerror-numpy-dtype-has-the-wrong-size-try-recompiling/18369312
)

On the other hand, python-xy comes with MingW, and I never had any problems
compiling pandas and statsmodels for any version combination of python and
numpy that I tested (although 32 bit only so far, I never set up the
Microsoft sdk).

(latest news: moving to MingW-64 for numpy and scipy, and related packages,
might be on the way.)

Josef


> 
> Oscar
> 




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


Re: statsmodels.api

2013-09-17 Thread Josef Perktold
Oscar Benjamin  gmail.com> writes:

> 
> On 17 September 2013 15:52, Josef Perktold  gmail.com> wrote:
> >
> > On the other hand, python-xy comes with MingW, and I never had any problems
> > compiling pandas and statsmodels for any version combination of python and
> > numpy that I tested (although 32 bit only so far, I never set up the
> > Microsoft sdk).
> 
> Just out of interest: out of the box Python.org distutils is
> incompatible with recent versions of MinGW. If Python-xy distributes
> MinGW (and it works) then they're either creating a special patched
> MinGW set up or patching distutils. I don't want to install Python-xy
> myself since it'll clobber my existing Python installation but could
> you answer the following for me:
> 
> 1) What gcc version did Python-xy install for you?
> 
> 2) Does the distutils.cygwincompiler module it installs contain the
> following lines (around about line 300) specifically with the
> '-mno-cygwin' option?
> 
>  self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
>   compiler_so='gcc -mno-cygwin -mdll -O -Wall',
>   compiler_cxx='g++ -mno-cygwin -O -Wall',
>   linker_exe='gcc -mno-cygwin',
>   linker_so='%s -mno-cygwin %s %s'

I installed python-xy 2 years ago with python 2.6 and didn't update, so my
information is not up-to-date

It looks like my MingW version uses mingw32-gcc-4.4.0.exe

for python 2.6 which came with python-xy:
self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
 compiler_so='gcc -mno-cygwin -mdll -O -Wall',
 compiler_cxx='g++ -mno-cygwin -O -Wall',
 linker_exe='gcc -mno-cygwin',
 linker_so='%s -mno-cygwin %s %s'
% (self.linker_dll, shared_option,
   entry_point))

However, I'm running python 2.5, 2.7, 3.2 and 3.3 additionally. And they are
all python.org versions without any changes (except IDLE bugs :).
I don't have any compilation problems with any of them.

Until recently statsmodels used distutils from numpy which adds some patches
AFAIK. The current statsmodels setup.py just uses plain distutils and
setuptools. (The setup.py is largely copied from pandas which has a lot more
C extensions than statsmodels.)

numpy scipy binaries for Windows are still compiled against MingW 3.x, but
David Cournapeau is looking into upgrading to the latest MingW(-64) right now.

also (from some comments about problems a long time ago): I don't have
cygwin installed, so there is no confusion between cygwin and msys/mingw
paths possible. 

Josef

> 
> Oscar
> 




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


Re: statsmodels.api

2013-09-17 Thread Josef Perktold
Josef Perktold  gmail.com> writes:

> 
> Oscar Benjamin  gmail.com> writes:
> 
> > 
> > On 17 September 2013 15:52, Josef Perktold  gmail.com>
wrote:
> > >
> > > On the other hand, python-xy comes with MingW, and I never had any
problems
> > > compiling pandas and statsmodels for any version combination of python and
> > > numpy that I tested (although 32 bit only so far, I never set up the
> > > Microsoft sdk).
> > 
> > Just out of interest: out of the box Python.org distutils is
> > incompatible with recent versions of MinGW. If Python-xy distributes
> > MinGW (and it works) then they're either creating a special patched
> > MinGW set up or patching distutils. I don't want to install Python-xy
> > myself since it'll clobber my existing Python installation but could
> > you answer the following for me:
> > 
> > 1) What gcc version did Python-xy install for you?

I did a bit of homework. I didn't know about the -mno-cygwin issue since it
didn't affect me yet.

python-xy is staying below 4.6: GCC Core, G77, G++ 4.5.2 ; MingW 4.5.2.3 
https://code.google.com/p/pythonxy/wiki/StandardPlugins
and has open issue on it

pandas has an open issue where a user reported problems with --mno-cygwin.

Josef


> 
> Josef
> 
> > 
> > Oscar
> > 
> 
> 




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


Re: linregress and polyfit

2013-09-17 Thread Josef Pktd
On Tuesday, September 17, 2013 10:34:39 PM UTC-4, Krishnan wrote:
> I created an xy pair
> 
> 
> 
> y = slope*x + intercept
> 
> 
> 
> then I added some noise to "y" using
> 
> 
> 
> numpy.random.normal - call it z 
> 
> 
> 
> I could recover the slope, intercept from (x,y) using linregress
> 
> BUT cannot calculate the slope, intercept from (x, z)
> 
> 
> 
> What is puzzling is that for both pairs (x,y) and (x,z) the
> 
> polyfit (order 1) works just fine (gives me the slope, intercept)
> 
> --
> 
> import numpy as np
> 
> import scipy
> 
> # create a straight line, y= slope*x + intercept 
> 
> x = np.linspace(0.0,10.0,21)  
> 
> slope = 1.0  
> 
> intercept = 3.0   
> 
> y = []  
> 
> for i in range(len(x)):  
> 
> y.append(slope*x[i] + intercept)  
> 
> # now create a data file with noise
> 
> z= []  
> 
> for i in range(len(x)):  
> 
> z.append(y[i] + 0.1*np.random.normal(0.0,1.0,1))  

When z is converted to a numpy array then it has an extra dimension that 
linregress cannot handle, because np.random.normal(0.0,1.0, 1) returns an array 
and not a scalar.

much easier: use vectorized numpy instead of loop

z = y + 0.1*np.random.normal(0.0,1.0, len(y))

which is a one dimensional array and works with linregress

Josef

> 
> # now calculate the slope, intercept using linregress
> 
> from scipy import stats  
> 
> # No error here this is OK, works for x, y
> 
> cslope, cintercept, r_value, p_value, std_err = stats.linregress(x,y)
> 
> print cslope, cintercept
> 
> # I get an error here
> 
> #ValueError: array dimensions must agree except for d_0
> 
> nslope, nintercept, nr_value, np_value, nstd_err = stats.linregress(x,z)  
> 
> print nslope, nintercept
> 
> # BUT polyfit works fine, polynomial or order 1 with both data sets
> 
> ncoeffs = scipy.polyfit(x,z,1)  
> 
> print ncoeffs
> 
> coeffs = scipy.polyfit(x,y,1)  
> 
> print coeffs
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-10-05 Thread Josef Pktd
related
https://youtu.be/wsczq6j3_bA?t=20m9s

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


Re: Pyarmor, guard your python scripts

2015-10-06 Thread Josef Pktd
On Monday, October 5, 2015 at 11:27:58 PM UTC-4, Ian wrote:
> On Oct 5, 2015 4:27 PM, "Ben Finney"  wrote:
> 
> >
> 
> > Josef Pktd  writes:
> 
> >
> 
> > > related
> 
> >
> 
> > Care to give us a summary of what that is, and describe what you think
> 
> > is the relevant point?
> 
> Following the link reveals it to be the video of a talk on Python exe 
> compilation from PyCon 2014.
> 
> If you're worried about the safety of the link, know that youtu.be is the 
> official URL shortener for YouTube and only leads to YouTube videos.

The talk is by Brandon Rhodes that I found quite refreshing the first time I 
attended Pycon https://us.pycon.org/2014/schedule/presentation/201/
The approach is building an exe file, but the motivation is the same as here.

About the keys:

Consider it as price discrimination between "cheap" hackers and plain users.

When I was a student I wasn't very reluctant to install cracked versions, but 
as far as I remember, I haven't installed a cracked version of a program in 15 
years or so. 
All the application and music on the ipads in my family are legitimate 
versions, either free minimal functionality versions or purchased on apps store 
or through itunes.

The python community in general seems to be a lot in favor of SaaS but not much 
in favor of selling (small) software products. When we got our first ipad, (I'm 
traditionally a Windows user) I was surprised how large the market for small 
and larger programs is and the opportunities that it provides for single 
developers or small groups of developers. In contrast, SaaS requires a much 
larger setup cost and larger scale.

I pretty much share Jondy Zhao's view.


That doesn't mean it's always a good idea. I have been working for many years 
on BSD licensed open source software.

Josef

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


Re: Strong typing implementation for Python

2015-10-13 Thread Josef Pktd
On Tuesday, October 13, 2015 at 2:52:32 PM UTC-4, Sibylle Koczian wrote:
> Am 13.10.2015 um 00:10 schrieb Ben Finney:
> > Sibylle Koczian <> writes:
> >
> >> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano:
> >>> Auto-complete is a fine and useful tool. But if you are crippled as a
> >>> programmer without it, well, then you can hardly claim to understand the
> >>> language or framework you are programming in if you cannot use it without
> >>> an IDE doing half the work for you.
> >>>
> >>
> >> Well ... you're certainly quite right as far as Python and its
> >> standard library is concerned. But I don't know who would really want
> >> to use .NET without auto-complete and for all I know Java may be just
> >> as awful.
> >
> > Yes, and that is quite compatible with Steven's assertion. The two
> > assertions:
> >
> > * A programmer who feels crippled without auto-complete cannot claim to
> >understand the language or framework they're programming in.
> >(assertion made by Steven)
> >
> > * The overwhelming majority of .NET and Java programmers would feel
> >crippled without auto-complete. (assertion made by Sibylle)
> >
> Not really wanting to do without x isn't the same as feeling crippled 
> without it.

To support this

I have been writing numpy/scipy based code in python for many years, and still 
I make a lot more mistakes without autocompletion and having pyflakes or 
similar run in the editor in the background.

I know roughly where everything is in a large class hierarchy with more 
information hidden in attached classes (instances). But it's easy to figure out 
the details with code completion and standard inspection.
It works pretty well maybe 90 % of the time (except in chained expressions).
I also memorize only the main arguments in the signatures, and rely for the 
rest on the pop-up hints.

> 
> > can both be true. An obvious resolution is to conclude that the
> > overwhelming majority of Java and .NET programmers cannot claim to
> > understand those technologies.
> >
> I don't think you can measure understanding by the ability and 
> willingness (!) to type those overlong and yet similar names again and 
> again in full.
> 
> > Python, on the other hand, has the huge advantage that programming in
> > even a bare minimal editor is feasible, and editor features that make
> > the programmer's life easier are conveniences, not essential to be
> > competent in Python.
> >
> Only one of its huge advantages. As long as no GUI is necessary ... but 
> that's another story.

I don't know about GUI programming, but even though it's not part of the 
language there are packages for example for asserting and maintaining types and 
restriction on values like traits and traitlets.

Josef


> 
> Sibylle

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


Re: Strong typing implementation for Python

2015-10-13 Thread Josef Pktd
On Tuesday, October 13, 2015 at 9:40:56 AM UTC-4, Steven D'Aprano wrote:
> On Tue, 13 Oct 2015 06:55 pm, Todd wrote:
> 
> > On Oct 13, 2015 2:11 AM, "Steven D'Aprano" <...> wrote:
> 
> >> Consider the following piece of code:
> >>
> >> def addone(x):
> >> return x + 1
> >>
> >>
> >> The human programmer reading that can trivially infer that x must be a
> >> number (or at least something which supports numeric addition). So can
> >> the compiler. In a strongly typed language with no numeric promotion, the
> >> compiler can infer that x must be an int. In a language with numeric
> >> promotion, it can infer that x must be an int or float.
> > 
> > Or a decimal, complex number, numpy array, any one of a dozen or so pandas
> > classes, any one of the dozen or so units classes, sympy variable, etc...

A good example is `y = x * 2` followed by long calculations with y.

I have no idea what this does if I don't know the type of x.
(list and tuples get duplicated, arrays as in numpy or pandas multiply 
elementwise, matrix packages use dot (@) product. Two out of three will give us 
the wrong result but don't raise a runtime exception.)

The flip side of the flexibility with dynamic typing is that we spend a lot of 
time and effort in asserting or converting types.

There are cases when being able to quack is not enough, it needs to have the 
right quack. And when we allow for different sounds created by the duck 
look-a-likes, then code can get complicated and avoiding subtle mistakes will 
become very difficult.

Annotations might help the editors, but doesn't enforce the right behavior.
Also, in some cases we don't want to restrict ducktyping in the function or 
method arguments but we need to protect our calculations. Function annotations 
won't help her.

One common pattern then guarantees fixed types within a function:

def calculate_something(x):


x = numpy.asarray(x, numpy.float64)  # convert anything array_like to array

do calculations that only use numpy arrays


return result

In the center we have static types (as far as numpy arrays are static), and we 
don't have to guess on what methods are actually doing, and code inspection 
could infer this.

Outside we still have all the flexibility of duck typing.

I guess it's gradual typing but not through unenforced function annotations.

Josef


> 
> I knew my over-simplification would get me in trouble...
> 
> Firstly, if we're talking about Python specifically, the compiler won't
> actually infer anything (see PEP 484, which "assumes the existence of a
> separate off-line type checker which users can run over their source code
> voluntarily"). It is up to the external type checker (or linter, IDE,
> documentation generator, refactoring tool, etc) to perform any type checks.
> 
> Secondly, what the tool actually infers will depend on the tool. I would
> expect that a basic type checker (say, in a text editor) will infer that x
> is an int or float only. A more powerful checker might infer the Number ABC
> (Abstract Base Class). A specialist checker might even know about numpy,
> pandas, units and sympy, but I wouldn't expect a general-purpose type
> checker to infer them.
> 
> If the programmer cares about such specialist types, then she can easily add
> type hints to supplement the checker's type inference, or the checker
> itself may be configurable. That's a *quality of implementation* detail.
> 
> The beauty of *gradual typing* is that you don't have to care about every
> possible class in the entire universe of Python code, only about the
> classes you actually care about in the parts of your code you choose to
> type check.
> 
> http://wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/
> 
> Because the Python interpreter itself doesn't care about the compile-time
> type checking, if the checker gets in your way, you can just *not run it*.
> I also expect that good checkers will include directives to skip sections
> of code, so you can include annotations as documentation while still
> silencing over-strict or incorrect compile-time type errors. (Runtime type
> errors will still occur as normal.)
> 
> 
> 
> -- 
> Steven

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


Re: writing IM bots

2005-12-13 Thread Josef Meile
Hi,

> I am trying to write an IM Bot, which automatically replies to a
> message, in Python.
> I was wondering If there are python modules for connecting to Yahoo!,
> msn networks ...
> ideally I would like to have a multithreaded module.
> 
> This is one I found for msn, if anyone has used it please comment,
> - http://users.auriga.wearlab.de/~alb/msnlib/
I haven't used that, but it looks cool ;-)

If you are interested in yahoo, then here is another python application
to connect to the yahoo messenger:

http://www.nongnu.org/curphoo/

Again, I haven't tried that one, but perhaps you could just test it.

I have other links to tools based in the libyahoo2[1] package, but
unfortunately all are written in C or java. Perhaps you could find a
python wrapper in google.

Regards,
Josef


[1] http://libyahoo2.sourceforge.net

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


Can't connect to Oracle DB via DCOracle2 as sysdba

2006-06-30 Thread Cihal Josef



Hi,
 
how can I connect 
please to DB Oracle9i
via DCOracle.Connect 
as SYSDBA?
 
>>> dbc = 
DCOracle2.connect(user='', password= ' as sysdba' 
)u,p2:  sys,'pTraceback (most recent call last):  File 
"", line 1, in ?  File "C:\Program 
Files\Python21\lib\DCOracle2\DCOracle2\DCOracle2.py", line 186, in 
connect    #print "Created new DCO2 connection %s" % 
conndco2.DatabaseError: (1017, 'ORA-01017: invalid username/password; logon 
denied')
 
How can I connect 
via DCOracle2 in Python to Database?
as usually mit 
sqlplus in command line:
 
sqlplus 
"/ as sysdba"
 
 
Thanks for every 
idea!
 
Josef 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

RE: Way for see if dict has a key

2006-06-30 Thread Cihal Josef
 
If dict.has_key('key'):
   print dict['']

Josef Cihal 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Georg Brandl
Sent: Friday, June 30, 2006 5:07 PM
To: python-list@python.org
Subject: Re: Way for see if dict has a key

Bruno Desthuilliers wrote:
> looping wrote:
>> Michele Petrazzo wrote:
>> 
>>>Bruno Desthuilliers wrote:
>>>
>>>>>but what the better
>>>>
>>>>Depends on the context.
>>>>
>>>
>>>If know only one context: see if the key are into the dict... What 
>>>other context do you know?
>>> 
>> 
>> Why do you want to do that ?
>> 
>> if key in dict:
>>   value = dict[key]
>> else:
>>   value = None
>> 
>> could be write:
> 
> value = dict.get(key, None)

value = dict.get(key)

;)

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


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


RE: string replace

2006-06-30 Thread Cihal Josef
Hi Mechele,


In string s u want to replace string "b" or "c" to -> "x"

import re

s ="a1b2c3"
re.sub("[bc]","x",s) 

Sincerely josef



Josef 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Michele Petrazzo
Sent: Friday, June 30, 2006 4:03 PM
To: python-list@python.org
Subject: string replace

Hi,
a lot of times I need to replace more than one char into a string, so I
have to do something like

value = "test"
chars = "e"
for c in chars:
   value = value.replace(c, "")

A solution could be that "replace" accept a tuple/list of chars, like
that was add into the new 2.5 for startswith.

I don't know, but can be this feature included into a future python
release?

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


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


connect not possible to Oracle Datenbank as sysdba?

2006-07-03 Thread Cihal Josef



 
Hi,
 
how can I connect to 
oracle database as SYSDBA
 
as usually: "sqlplus 
anc/psw as sysdba"
 
It is a parsing 
problem? (blanks,etc.?)
 
or it is not 
implmented in DCOracle2?
 
>DCOracle.Connect('user/psw as sysdba') -> 
NOK
 

normal (without 
sysdba clause) -> DCOracle.Connect('user/psw') -> 
OK
 
thanks for every 
idea
 
Josef
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PHPParser pod Zope

2005-05-04 Thread Josef Meile
George Sakkis wrote:
> Bruno Desthuilliers wrote:
> 
>>JZ a Ãcrit :
>>
>>>Probuje zainstalowac modul php pod zope i tam napisali dziwna rzecz
> 
> ze
> 
>>>potrzebuje "PHP CGI program" a nie PHP CLI. Kompilacja php 5.0.4
> 
> pod
> 
>>>linuksem daje mi w wyniku mod_php + 5 plikow binarnych: pear, php,
>>>php-config, phpextdist, phpsize. Zas lektura skryptu do zope jest
> 
> nizbyt
> 
>>>jasna. Napisali:
>>>
>>
>>(snip)
>>DÃsolÃ, ce groupe est anglophone, il serait donc trÃs probablement
> 
> 
>>prÃfÃrable (en tous cas pour toi, et si bien sÃr tu espÃres une
> 
> rÃponse,
> 
>>mais sinon je ne vois pas l'intÃrÃt de poster ici...) de nous
> 
> renvoyer
> 
>>Ãa en anglais dans le texte !-)
>>
>>I-too-can-speak-weird-foreign-languages-ly'yrs
>>Bruno
> 
> 
> ÎÏÎ Î ÎÏÏÏÎÎÏÎ ÎÎÏÎÏÏÎÏÎ ÏÎÏÎÎ ÏÎ
> ÎÎÏÎÎÎÏ ÏÏ, Î ÎÎÎ ÎÎ ÏÎÏÎÎ
> ÎÏÏÏ Î ÎÏÏ Î ÎÏÎÎÏ ÎÏ
> ÎÏÎÏÎÎÎÏ ÏÏÎ ÎÎÏÏÎ...
> 
> If-this-is-all-greek-to-you-you're-right-ly'yrs
> George
I don't find this two replies funy :-(. I think it is impolite to make
fun of the OP. You could say: "The official language is english" or
something like that. And if somebody knows the language he speaks, then
a pointer to an appropiate list would be usefull.

Best regards,
Josef

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

Re: circular import Module

2005-06-08 Thread Josef Meile
>>Circular import does not work on module level, but you can
>>import the module in a method:
>>
>>file1.py:
>>import file2
>>
>>
>>
>>file2.py:
>># import file1 # Does not work!
>>def foo():
>>import file1 # Does work
> 
> 
> Cool idea !
> 
> It works on local namespaces, wich dont cause trouble to the whole program.
> 
> +1
Yes, I also think is a good solution. Once I needed to do something like
that and ended by writting a third module with the shared functions that
the two conflicting modules needed. At that time I already knew that one
could import modules from functions; however, I didn't come up with that
solution :-(

Regards,
Josef

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


Re: how to export data from ZODB to text files

2005-06-08 Thread Josef Meile
Hi Lukasz,

> Yes, I'm traing to escape from Zope-land, to be more clarify I want to
> migrate from Plone to PHP Application, which uses MySQL database
> engine, so I have to move all data from ZODB to MySQL. I suppose that
> python script shouldn`t be so complex. I need just iterate ZODB and
> write attributes like "Intro", "Body" of article to file for example.
> I need export Plone content hierarchy like
> 
> 
> Home
>|
>| - - - Folder 1 (Title, Intro, Body)
>|| - - - Article (Title, Intro, Body)
>|   
>| - - - Folder 2 (Title, Intro, Body)
I haven't done that with Plone, but with CMF, which is the base of
Plone. So, I guess it would be almost the same. You even don't need
the product Peter suggested; you could do a python script inside your
plone site, which searches all the objects you want and print it in
form of a pipe '|' delimited list. Then, once you define your tables
in mysql, you can import the data by copying the output of your
script and saving it into a text file. This is how my script looks like:

catalog=context.portal_catalog
jobs=catalog(
 {
   'meta_type': 'Internship'
 }
  )
OID = 1
for metaJob in jobs:
   jobData=catalog.getobject(metaJob.data_record_id_)
   print "%i|%s|%s|%s|%s|%s|%s|%s|" % \
 (OID,
  jobData.companyName,
  jobData.companyVision,
  jobData.description,
  jobData.positionOffered,
  jobData.jobProfile,
  jobData.contact,
  jobData.country)
   OID += 1

return printed

Off course, this only work assuming that your fields aren't files like
images or PDFs.

Regards,
Josef

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


Re: how to export data from ZODB to text files

2005-06-10 Thread Josef Meile
Hi Lucasz,

> Thank you so much. I will ask our Plone administrator to test your
> script and I will write about result here.
You are wellcome. I think it is one of the easiest way of doing it.

> I thought also about Python script like
> 
> 
>  //connect to database 
>  >>> from ZODB import FileStorage, DB
>  >>> storage = FileStorage.FileStorage('Data.fs') 
>  >>> db = DB(storage)
>  >>> conn = db.open()
>  >>> dbroot = conn.root()
> 
>  //here should be interation for DB which saves attributes output in
> to file
> 
> 
> I'm not able to write the second part, but I think that this shouldn`t
> be a problem for experienced Python developer. 
> 
> How complex will be script like above?
I have to say it would be interesting to do something like that with
ZODB. Specially if you only have the Data.fs and don't have access to
the original Plone site. But I don't know how to do it. You may ask in
the ZODB list:

http://lists.zope.org/mailman/listinfo/zodb-dev

Regards,
Josef

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


Re: how to export data from ZODB to text files

2005-06-10 Thread Josef Meile
Hi again,

> I thought also about Python script like
> 
> 
>  //connect to database 
>  >>> from ZODB import FileStorage, DB
>  >>> storage = FileStorage.FileStorage('Data.fs') 
>  >>> db = DB(storage)
>  >>> conn = db.open()
>  >>> dbroot = conn.root()
I just found an information that may be useful for you:

* ZODB for Python Programmers By Michael Pelletier:
   http://www.informit.com/articles/article.asp?p=23413&rl=1

* A Simple ZODB viewer in wxPython:
   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409012

The first link contains some useful examples and explanations. The
second one could help you to see how your zodb is organized. In the
links that Peter post, there is also an useful powerpoint presentation.

According to the first link, the ZODB is a persistent dictionary that
you can access like:

 >>> db = DB(storage)
 >>> connection = db.open()
 >>> root = connection.root()

If I'm not wrong, you could see what objects are in root of your zodb by
doing:

 >>> print root.keys()

After that you could get your plone site by doing:

 >>> ploneSite = root['ploneFolder']

Where if I'm not wrong, "ploneFolder" may be a key in the root
dictionary. Then if plone is like CMF, it must have a "portal_catalog"
instance in it, so, you can get it by:

 >>> catalog = getattr(ploneSite,'portal_catalog',None)

If at this point catalog = None, then you have to print the objects in
the plone site by doing:

 >>> print ploneSite.objectIds()

Once you find the catalog object, you could try the script I post before
from the command line.

I haven't tested this, but I hope it helps.

Regards,
Josef Meile

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


Re: get a list from a string

2007-06-07 Thread Josef Dalcolmo

simon kagwe wrote:
> Hi,
> 
> I have a string "distances = [[1,1,1,1],[2,2,2,2]]". I want to create a
> variable called distances whose value is the list [[1,1,1,1],[2,2,2,2]]. How 
> can
> I go about that?

s = "distances = [[1,1,1,1],[2,2,2,2]]"
exec(s)

- Josef

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


getmtime in 2.5 reports GMT instead of local time

2007-05-03 Thread Josef Dalcolmo
Hello,

I have tried this only on Windows XP.

in Python 2.4 os.path.getmtime() used to return an integer representing
the local time.

in Python 2.5 os.path.getmtime() reports a float representing the GMT of the
file's modification time.

Since I could not find any documentation to this behavioural change, I am asking
here: was this change intentional? Is it going to stay? Windows reports
the same time for the file as Python 2.4 used to. So I am tempted to
call this a bug, but wanted some feedback from the developers,
before filing a bug report.


If you want to test this, make sure your local time differs from GMT,
then do:

import os, time
print time.ctime(os.path.getmtime('foo.txt'))

on a file foo.txt, once with Python 2.4 then with Python 2.5, 
and you should see what I mean.

- Josef


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


getmtime differs between Py2.5 and Py2.4

2007-05-07 Thread Josef Dalcolmo

I tried this on Windows only:

In Python 2.4 os.path.getmtime returned the local time,
in Python 2.5 it seems to return GMT:

import os, time
print ctime.time(os.path.getmtime(foo))

differs on Python 2.4 and Python 2.5 by the timezone.

Now, the implementation of the two stat calls differs on Windows
between the two versions.

I actually like the new behaviour better, because I believe the
reported time of a file should not depend on the timezone or other
local settings, however the old behaviour is the time also Windows
shows - and there is an incompatibility.

Is this a bug? 

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


Re: getmtime differs between Py2.5 and Py2.4

2007-05-08 Thread Josef Dalcolmo
Martin v. Löwis wrote:
>> the difference (rounding to an int number of seconds) is just about one
>> hour; in certain parts of the world (Europe and Africa), that could
>> indeed be a timezone issue.
> 
> With the help of Tony Meyer, we rediscovered the explanation: because
> of a bug in the Microsoft C run-time library, the UTC time reported by
> 2.4 may have been off by one hour (it wasn't local time - just off
> by one hour). This was due to DST issues. They have been fixed in 2.5,
> which now reports the correct UTC value.
> 
> Regards,
> Martin

Well, indeed I got only a 1 hour difference, on my machine (local time 
here is +1 hour). But when I temporarily set the local time of my 
machine to GMT I the difference became 0, therefore I assumed wrongly it 
had something to do with the local time difference.

Thanks to everyone helping to clarify this. My response was slow, 
because I have been experiencing problems with my newsreader setup.

- Josef


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


Re: Regular expression use

2007-08-25 Thread Josef Moellers
Nick Maclaren wrote:
> For reasons that I won't explain, as they are too complicated
> and not terribly relevant, I am interested in discovering what
> people actually use regular expressions for.  Not the subject
> domain, but the construction of the regular expressions.
> 
> I know about computer scientists and parsing, and I know about
> the use of relatively simple ones for things like extracting
> HTML links from Web pages.  But I don't have much feel for the
> (probably rare but difficult) uses of more complex ones for
> other purposes.  I have heard of several such uses, but don't
> have an overall idea of what is going on.
> 
> Any pointers appreciated, to more-or-less anything.

I just don't get what you're after!
Lots of data is available in text form, so sifting though it requires 
regular expressions.
A better question would be: what do you use Perl for, as I'd say most 
Perl programs utilize REs at some point or the other.
But IIRC we've had that thread already.

-- 
Mails please to josef dot moellers
and I'm on gmx dot de.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-24 Thread Josef Meile
> Is there any specific reason for not using MinGW to build the official
> distribution of Python for Win32?
> A quick Google search did not reveal the answer to my question. If a
> link is available, please post it.
You may look at this thread:

* E02 - Support for MinGW Open Source Compiler
   http://tinyurl.com/lxfsz

There was a big polemic and it is really long, but there are some useful
posts there.

Regards,
Josef

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


Re: The Importance of Terminology's Quality

2008-07-22 Thread Josef Moellers

Martin Gregorie wrote:

Are you sure about that? 



I used Algol 60 on an Elliott 503 and the ICL 1900 series back when it was
a current language. The term "thunking" did not appear in either compiler
manual nor in any Algol 60 language definition I've seen. A60 could pass
values by name or value and procedures by name. That was it. Call by name
is what is now referred to as reference passing.


Are you sure about that? ;-)

AFAIK "Call by name" is *not* the same as passing an argument by 
reference. With "call by name" you can implement this wonderful thing 
called "Jensen's Device", which you cannot do when you pass parameters 
by reference!


Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Old Python Logo

2006-03-13 Thread Josef Meile
>>Can someone post a link or email me an image of the old Python logo?
>>I'd like to save a copy of it, I rather liked it - very retro.
> 
> 
> the dot matrix logo ?
> 
> you can get a copy from this page:
> 
>
That website is down. You could try the archive as well:
http://web.archive.org/web/20050401015445/http://www.python.org/

Regards
Josef

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


Re: Python has a new Logo

2006-03-24 Thread Josef Möllers
Xah Lee wrote:

> Python has a new logo!

So does the bakery around the corner!

Oh ... and by the way, our butcher now has a new till.

'thought you'd like to know.
-- 
josef punkt moellers bei gmx punkt de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to install PYCURL 7.15.2 on windows 2003?

2006-04-13 Thread Josef Meile

 > I download it from http://pycurl.sourceforge.net/
 > and then extract it to  D:\usr\pycurl-7.15.2
 > then
 > D:\usr\pycurl-7.15.2>setup.py install --curl-dir=d:\usr\pycurl-7.15.2
 > Using curl directory: d:\usr\pycurl-7.15.2
 > Traceback (most recent call last):
 >   File "D:\usr\pycurl-7.15.2\setup.py", line 197, in ?
 > assert os.path.isfile(o), o
 > AssertionError: d:\usr\pycurl-7.15.2\lib\libcurl.lib
I would say you need to install libcurl first. "--curl-dir"
isn't the directory where you want to install pycurl; it is
the location of the curl library, which isn't implemented in
python.

You can find the binaries (or the sources) here:
http://curl.haxx.se/dlwiz/

Regards
Josef

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


Re: Program, Application, and Software

2010-11-19 Thread Josef Frank

Am 19.11.2010 15:22, schrieb Martin Gregorie:

On Fri, 19 Nov 2010 01:43:28 +0100, Alexander Kapps wrote:


What difference does it make? Is 'print "Hello"' a program or a script?
Are you saying, that it depends on whether you have to manually call
some compiler?


Thats the way the term 'script' is usually used in the UNIX/Linux world.

In that environment you'd call awk and Perl scripting languages but C and
Java are known as compiled languages. The size of the source isn't
relevant: if you can mark a source file as executable and simply run it
its a 'script' while if it needs a separate preparatory step to generate
a separate executable its just a source file for a compiled language.

The distinction doesn't seem to be used in a Windows environment. Indeed,
it doesn't make sense there since executables are limited to .BAR or .CMD
files, which are directly interpreted by the command processor, and .EXE
or .COM files, which must be compiled before they can be run. AFAIK
there's no way you can mark anything else, such as an awk, Perl or Python
source file, as executable since there is no 'executable' attribute in
any Windows filing system.



Not in the file system,
but in the environment it is definitely possible.
One might try http://www.google.de/search?q=pathext
or just have a look at http://wiki.tcl.tk/1785
(the respective filetype has to be associated with
it's interpreter however for this method to work.)

Josef


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


Should I Learn Python or Ruby next?

2010-06-22 Thread Josef Tupag
I've been programming (when I do program) mainly in
Perl<http://www.perl.org/>for the last 10 years or so. But I've been
itching to learn a new language
for a while now, and the two near the top of the list are
Ruby<http://www.ruby-lang.org/>and
Python <http://python.org/>.

I figure that Ruby would be easy to learn because of its similarity to Perl
(I'm told). But I also figure that Python would be easy to learn because of
its simplicity. And when it comes to webby stuff, I can use
Rails<http://www.rubyonrails.org/>with Ruby and
Django <http://www.djangoproject.com/> with Python.

I'm currently leaning toward Python and began doing so last week. I started
with Mark Pilgrim's excellent Dive Into Python
<http://diveintopython.org/>and made it thru the first 3 chapters
pretty quickly. So far it feels pretty
good.

Before I really dive in, though, I'm curious to hear what others think about
the choice between these two languages.

(On a related note, you might also read Tim Bray's On
Ruby<http://www.tbray.org/ongoing/When/200x/2006/07/24/Ruby>post,
since he just started learning Ruby.)

Josef Tupag - best humidifier <http://thebesthumidifiers.com>
-- 
http://mail.python.org/mailman/listinfo/python-list


wxpython 2.8 -- timing and latency issues when displaying widgets

2010-10-28 Thread Josef Frank


Dear all,

in an application window (subwindow of a Notebook-control) I'm trying to 
do the following:


1. Create a StaticText control kind of "Please wait until processing has 
finished"

2. Do some processing (e.g. vacuuming an sqlite database)
3. Create a 2nd StaticText control with the message "processing finished"

Naïvely I would expect following behavior:

1st control appears
data processing step runs
after finishing processing the 2nd control appears

but actually the order in execution seems to be a different one:

computer is doing heavy processing
1st control appears
2nd control appears immediately after the 1st without any visible delay

Could someone give a hint, how to change the seeming behavior into the 
intended one?


Thanks in advance Josef

P.S.:
here is the actual code snippet:

def OnVacuum(self,event):
panel=Ntab(self.desktop,"Compact")
	message1=wx.StaticText(panel,-1,"Please wait, database is being 
compacted.",(20,10))

self.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
con=sqlite3.connect(dbname)
cur=con.cursor()
cur.execute("VACUUM;")
cur.close()
con.close()
self.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
	message2=wx.StaticText(panel,-1,"Compacting database has now 
finished",(20,30))


Ntab is a class derived from wx.Panel and a tab of the abovementioned 
wx.Notebook control

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