Re: OSx 10.4 lacks pythonIDE?

2005-05-13 Thread B



On 13/5/05 03:35, in article
[EMAIL PROTECTED], "Robert Kern"
<[EMAIL PROTECTED]> wrote:

> baza wrote:
>> Where is the IDE in 'Tiger' for the mac? Don't tell me I have to use
>> text edit all the time??
> 
> PythonIDE never came with the OS. You have to install it yourself.
> 
> http://homepages.cwi.nl/~jack/macpython/


That's weird because it was on my iBook disk as a .pkg file when I got it???

Thanks for the link.
Baza

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


Re: OSx 10.4 lacks pythonIDE?

2005-05-13 Thread B



On 13/5/05 03:35, in article
[EMAIL PROTECTED], "Robert Kern"
<[EMAIL PROTECTED]> wrote:

> baza wrote:
>> Where is the IDE in 'Tiger' for the mac? Don't tell me I have to use
>> text edit all the time??
> 
> PythonIDE never came with the OS. You have to install it yourself.
> 
> http://homepages.cwi.nl/~jack/macpython/


OK, just  installed it but it crashes under Tiger.

Baza

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


Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread -b
Okay. Great. Thanks for clarifying that for me.

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


XML File -- dictionary edit/search

2007-08-27 Thread -b
I am trying to put together a python program that will be able to ask
for a word and its definition, then save that information into an xml
file for reference. I am not down right set on the file being in xml
format, but xml is the first thing that comes to mind, since I do not
want to use a MySQL database. I think xml will be easy to search and
return a word's definition--another reason why xml comes to mind first
after MySQL databases. Please, if you have any suggestions to what
python-xml libraries I might use to program this small app with, then
by all means voice your thoughts. Thank you very much for your time.

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


Re: os.walk question

2008-07-23 Thread B

Lanny wrote:

How would one make a list of the files in the top directory
using os.walk.

I need to pick a random file from said list.

Thanks. 





-- Posted on news://freenews.netfront.net - Complaints to [EMAIL PROTECTED] --



how about:

import os

x = os.walk('/')
(root,dirs,files) = x.next()



'files' should contain a list of filenames.
--
http://mail.python.org/mailman/listinfo/python-list


Recursion Performance Question

2008-07-23 Thread B
Hey I found some (VERY) old C++ code of mine that recursively built a 
tree of the desktop window handles (on windows) using: (they are stored 
in an STL vector)


void FWL(HWND hwnd, int nFlag) // Recursive Function
{
hwnd = GetWindow(hwnd, nFlag);
if(hwnd == NULL)
return;
AddWnd(hwnd);
nLevel++;
FWL(hwnd, GW_CHILD);
nLevel--;
FWL(hwnd, GW_HWNDNEXT);
return;
}

int FillWindowList(bool bReset)// Build Window List
{
   WLI wli;

if(bReset)
ResetWindowList();

nLevel = 0;
FWL(ui.hWnd, GW_HWNDFIRST);

return nCount;
}

Now the interface on this program is really ugly (i hate UI coding), so 
I was thinking about re-writing it in python to use PyQt for an easy 
GUI.  So far I have (they are stored in a 'tree' class):


# pass in window handle and parent node
def gwl(node, hwnd):
if hwnd:
yield node, hwnd
for nd, wnd in Wnd.gwl(node.children[-1], GetWindow(hwnd, 
GW_CHILD)):

yield nd, wnd
for nd, wnd in Wnd.gwl(node, GetWindow(hwnd, GW_HWNDNEXT)):
yield nd, wnd


def generateTree(self):
t = time.clock()
if self is not None:
self.children = []

for nd, wnd in Wnd.gwl(self, GetWindow(self.hwnd, GW_CHILD)):
nd.addChild(wnd)


Now it works, but it runs quite slow (compared to the c++ app).  I 
changed gwl from strait recursion to use a generator and that helped, 
but it still takes 0.5-1.0 seconds to populate the tree.  What I'm 
wondering is am I doing it in a really inefficient way, or is it just 
python?


The second problem is reseting the list.  In C++ I would use the STL 
Vector's clear() method.  In python, I can't think of a good way to free 
 all the nodes, so there is a large memory leak.


I can post more of the code if it's unclear, I just didn't want to write 
a really long post.

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


Re: Second python program: classes, sorting

2008-08-10 Thread B

WP wrote:
Hello, here are some new things I've problems with. I've made a program 
that opens and reads a text file. Each line in the file contains a name 
and a score. I'm assuming the file has the correct format. Each 
name-score pair is used to instantiate a class Score I've written. This 
works fine, but here's my problem: After reading the file I have list of 
Score objects. Now I want to sort them in descending order. But no 
matter how I write my __cmp__ the order remains unchanged. I've 
determined that __cmp__ is called but it's only called twice for three 
list elements, isn't that odd?


Complete program:
class Score:
def __init__(self, name_, score_):
self.name = name_
self.score = score_

def __str__(self):
return "Name = %s, score = %d" % (self.name, self.score)

def __cmp__(self, other):
print "in __cmp__"
return self.score >= other.score

name  = ""
score = 0
# End class Score

filename = "../foo.txt";

try:
infile = open(filename, "r")
except IOError, (errno, strerror):
print "IOError caught when attempting to open file %s. errno = %d, 
strerror = %s" % (filename, errno, strerror)

exit(1)

lines = infile.readlines()

infile.close()

lines = [l.strip() for l in lines] # Strip away trailing newlines.

scores = []

for a_line in lines:
splitstuff = a_line.split()

scores.append(Score(splitstuff[0], int(splitstuff[1])))

scores.sort()

for a_score in scores:
print a_score

Test file contents:
Michael 11
Hanna 1337
Lena 99

Output:
in __cmp__
in __cmp__
Name = Michael, score = 11
Name = Hanna, score = 1337
Name = Lena, score = 99

What am I doing wrong here?

- Eric (WP)


From http://docs.python.org/ref/customization.html:
__cmp__(self, other)
Called by comparison operations if rich comparison (see above) is 
not defined. Should return a negative integer if self < other, zero if 
self == other, a positive integer if self > other.



You're not handling all the comparison cases, just assumping __cmp__ is 
being called for >=, when it's not.


You can fix your __cmp__ function, but it's probably easier to 
understand if you overload specific comparison functions: __lt__, 
__gt__, etc.

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


Re: like a "for loop" for a string

2008-08-17 Thread B


Alexnb wrote:

Uhm, "string" and "non-string" are just that, words within the string. Here
shall I dumb it down for you?


string = "yes text1 yes text2 yes text3 no text4 yes text5+more Text yes
text6  no text7 yes text8"

It doesn't matter what is in the string, I want to be able to know exactly
how many "yes"'s there are. 
I also want to know what is after each, regardless of length. So, I want to

be able to get "text1", but not "text4" because it is after "no" and I want
all of "text5+more Text" because it is after "yes". It is like the yeses are
bullet points and I want all the info after them. However, all in one
string.




It seems like this is the type of thing the re module would be good at. 
 But for your example, this would work too:


for s in string.split('no'):
if 'yes' in s:
j = s.index('yes')
print s[j+4:]



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


Re: like a "for loop" for a string

2008-08-18 Thread B

Mensanator wrote:

On Aug 17, 6:03�pm, B <[EMAIL PROTECTED]> wrote:

Alexnb wrote:

Uhm, "string" and "non-string" are just that, words within the string. Here
shall I dumb it down for you?
string = "yes text1 yes text2 yes text3 no text4 yes text5+more Text yes
text6 �no text7 yes text8"
It doesn't matter what is in the string, I want to be able to know exactly
how many "yes"'s there are.
I also want to know what is after each, regardless of length. So, I want to
be able to get "text1", but not "text4" because it is after "no" and I want
all of "text5+more Text" because it is after "yes". It is like the yeses are
bullet points and I want all the info after them. However, all in one
string.

It seems like this is the type of thing the re module would be good at.
� But for your example, this would work too:

for s in string.split('no'):
� � �if 'yes' in s:
� � � � �j = s.index('yes')
� � � � �print s[j+4:]


Did you run this? Doesn't look very useful to me.

text1 yes text2 yes text3
text5+more Text yes text6
text8


No, but it's hard to tell what's 'useful' when the original poster 
wasn't really clear in what he was looking for.  If you're referring to 
the extra 'yes's, then you can easily fix that with another split:


for s in string.split('no'):
if 'yes' in s.strip():  # don't want spaces around yes/nos?
j = s.index('yes')
for y in s[j+3:].split('yes'):
print y.strip()  #  ''

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

Re: dict slice in python (translating perl to python)

2008-09-10 Thread B

for a long list, you could try:
result = [mydict[k] for k in mydict]
or   [mydict[k] for k in mydict.keys()]
or   [mydict[k] for k in mydict.iterkeys()]
this won't give you the same order as your code though, if you want them 
sorted you can use the sorted function:

 [mydict[k] for k in sorted(x)] (or sorted(x.etc))



hofer wrote:

Hi,

Let's take following perl code snippet:

%myhash=( one  => 1, two   => 2, three => 3 );
($v1,$v2,$v3) = @myhash{qw(one two two)}; # <-- line of interest
print "$v1\n$v2\n$v2\n";

How do I translate the second line in a similiar compact way to
python?

Below is what I tried. I'm just interested in something more compact.

mydict={ 'one'   : 1, 'two'   : 2, 'three' : 3 }
# first idea, but still a little too much to type
[v1,v2,v3] = [ mydict[k] for k in ['one','two','two']]

# for long lists lazier typing,but more computational intensive
# as  split will probably be performed at runtime and not compilation
time
[v1,v2,v3] = [ mydict[k] for k in 'one two two'.split()]

print "%s\n%s\n%s" %(v1,v2,v3)



thanks for any ideas


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


Re: dict slice in python (translating perl to python)

2008-09-10 Thread B

Fredrik Lundh wrote:

B wrote:

for a long list, you could try:
result = [mydict[k] for k in mydict]
or   [mydict[k] for k in mydict.keys()]
or   [mydict[k] for k in mydict.iterkeys()]


and the point of doing that instead of calling mydict.values() is what?





It's more fun?  Or if you want to sort by keys.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with the "for" loop syntax

2013-06-19 Thread Arturo B
Mmmm

Ok guys, thank you

I'm really sure that isn't a weird character, it is a space.

My Python version is 3.3.2, I've runed this code in Python 2.7.5, but it stills 
the same.

I've done what you said but it doesn't work.

Please Check it again here is better explained:

http://snipplr.com/view/71581/hangman/

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


Re: Problem with the "for" loop syntax

2013-06-19 Thread Arturo B
Sorry, I'm new in here

So, if you want to see the complete code I've fixed it:
http://www.smipple.net/snippet/a7xrturo/Hangman%21%20%3A%29

And here is the part of code that doesn't work:


#The error is marked in the whitespace between letter and in
 
def displayBoard(HANGMANPICS, missedLetters, correctLetters, secretWord):
print (HANGMANPICS[len(missedLetters)])
print()
   
print('Missed letters: ', end='')

#Starts problem

 for letter in missedLetters:

#Finishes problem

print(letter, end=' ')
print()

blanks = '_' * len(secretWord)
 
for i in range(len(secretWord)):
  if secretWord[i] in correctLetters:
  blanks = blanks[:i] + secretWord[i] + blanks[i+1:]
  
for letter in blanks:
print(letter, end=' ')
print()
   


When I press F5 (Run) I get a window that says: 'Invalid Syntax' and the 
whitespace between letter and in is in color red 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with the "for" loop syntax

2013-06-19 Thread Arturo B
Fixed, the problem was in 
HANGMANPICS 

I didn't open the brackets.

Thank you guys :)
-- 
http://mail.python.org/mailman/listinfo/python-list


How is this evaluated

2013-07-04 Thread Arturo B
I'm making this exercise: (Python 3.3)

Write a function translate() that will translate a text into "rövarspråket" 
(Swedish for "robber's language"). That is, double every consonant and place an 
occurrence of "o" in between. For example, translate("this is fun") should 
return the string "tothohisos isos fofunon".

So I tried to solved it, but I couldn't, so I found many answers, but I 
selected this:

def translate(s):
  consonants = 'bcdfghjklmnpqrstvwxz'
  return ''.join(l + 'o' + l if l in consonants else l for l in s)

print(translate('hello code solver'))


OUTPUT:
'hohelollolo cocodode sosololvoveror'

__
So I want to question:
How is the 

if 'h' in consonants else 'h' for 'h' in s

part evaluated? (step by step please :P )

''.join('h' + 'o' + 'h' if 'h' in consonants else 'h' for 'h' in s)

Thank you guys
-- 
http://mail.python.org/mailman/listinfo/python-list


Best python web framework to build university/academic website

2013-07-26 Thread b . krishna2020
Hi,

I got a chance to build an university website, within very short period of time.
I know web2py, little bit of Django, so please suggest me the best to build 
rapidly.

Thanks in advance

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


stuck in files!!

2012-07-06 Thread Chirag B
i want to kno how to link two applications using python for eg:notepad
txt file and some docx file. like i wat to kno how to take path of
those to files and run them simultaneously.like if i type something in
notepad it has to come in wordpad whenever i run that code.
-- 
http://mail.python.org/mailman/listinfo/python-list


questions (& answers) about object, type, builtin types, class, metaclass and __getattribute__

2011-08-22 Thread Amirouche B.
I'm learning a bit of python internals lately and I'm trying to figure
out the
relationship between type, objects, class, callables and
__getattribute__ resolution.

While understanding Python mechanics/concepts, I'm trying to figure
how it
translates in CPython. This post is Python centric. Questions about
the
implementation of this concepts might be the subject of a future post
[1].

I will proceed this way: I will write statements about each subject.
Don't hesitate
to pick one and provide more information or better phrasing, or
explaining why it's
not true.

Be aware that I'm considering only new-style class.


A) type vs object
-

1) object is the base object, it has no bases : len(object.__bases__)
== 0
2) every object in python inherit object :
any_object_except_object.__bases__[-1] is object
3) object's type is type : object.__class__ is type
4) type parent object is object : type.__bases__ == (object,)


B) type vs metaclass


1) type is the first metaclass ?
2) type is its own metaclass : type(type) is type ?
3) object's metaclass is type ?
4) other metaclasses *MUST* inherit type ?
5) type(any_object) == last_metaclass_..., which is, most of the time,
type ?


C) type vs class


1) Type is the metaclass of most classes
2) The class statement::

class MyClass(object):
attribute = 1

def method(self):
pass

   translates to::

MyClass = type('MyClass', (object,), {'attribute': 1, 'method':
def method: pass })

3) Instantiation of any class ``MyClass(*args, **kwargs)`` translates
to::

type(MyClass).__call__(MyClass, *args, **kwargs)

   This is due to __getattribute__ algorithm (see E)

4) It's in type.__call__ that happens calls to __new__ and __init__

5) 3) => classes are instance of type

6) Since type.__call__ is used to instantiate instance of instance of
type
   (rephrased: __call__ is used to instantiate classes) where is the
code which
   is executed when we write ``type(myobject)`` or ``type('MyClass',
bases, attributes)``
   __getattribute__ resolution algorithm (see E) tells me that it
should be type.__call__
   but type.__call__ is already used to class instatiation.


C') class vs class instances aka. objects
-

1) A class type is a metaclass : issubclass(type(MyClass), type),
   MyClass.__class__ == type(MyClass)
2) An object type is a class : most of the time
isinstance(type(my_object), type)
   generally issubclass(type(type(my_object)), type)


D) builtin types


1) builtin types are their own metaclass ?
2) why function builtin type can not be subclassed ?
3) how does builtin function type relate to callable objects ?
4) int(1) is the same as int.__call__(1), since type(int) is type,
shouldn't int(1)
   translates to type.__call__(int, 1) ?


E) __getattribute__
---

1) ``my_object.attribute`` always translates to
``my_object.__getattribute__('attribute')``
2) Is the following algorithm describing __getattribute__ correct [2],
beware that I've
   added a comment:

a) If attrname is a special (i.e. Python-provided) attribute for
objectname,
   return it.  # what does it mean to be Python-provided ?

b ) Check objectname.__class__.__dict__ for attrname. If it exists
and is a
data-descriptor, return the descriptor result. Search all bases of
objectname.__class__
for the same case.

c) Check objectname.__dict__ for attrname, and return if found.

d) If it is a class and a descriptor exists in it or its bases,
return the
   descriptor result.

d) Check objectname.__class__.__dict__ for attrname. If it exists
and is a
   non-data descriptor, return the descriptor result. If it
exists, and is
   not a descriptor, just return it. If it exists and is a data
descriptor,
   we shouldn't be here because we would have returned at point 2.
Search all
   bases of objectname.__class__ for same case.

e) Raise AttributeError


Thanks in advance,

Regards,


Amirouche

[1] or maybe you can point me to the right direction before I ask
stupid questions.
I'm a bit familiar with Jython code, which seems to be easier than
PyPy and CPython
to read even if there is some magic due to the fact that Jython use
some JVM API
that hides somewhat how it works.
[2] this is a rewritten version of
http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#attribute-search-summary
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: questions (& answers) about object, type, builtin types, class, metaclass and __getattribute__

2011-08-23 Thread Amirouche B.
On Aug 22, 1:57 pm, Steven D'Aprano  wrote:

> The relationship between type and object is somewhat special, and needs to
> be bootstrapped by the CPython virtual machine.

Since you are talking  about CPython, I'm wondering how it is
bootstraped since you can easly reference PyType in PyObject that part
is not hard.

> > 2) type is its own metaclass : type(type) is type ?
>
> Yes. Another bit of bootstrapping that the compiler does.

self reference is easy same as referencing PyType from PyObject and
PyObject from PyType.

> > 5) type(any_object) == last_metaclass_..., which is, most of the time,
> > type ?
>
> I'm not sure what you mean by "last_metaclass". But no. The type of an
> object is its class:

see this code for example proove my point:

class meta_a(type):
def __new__(cls, *args, **kwargs):
return type.__new__(cls, *args, **kwargs)  # see (¤)


class meta_b(meta_a):
def __new___(cls, *args, **kwargs):
return meta_a.__new__(cls, *args, **kwargs) # same as above


class ClassWithTypeMetaA(object):
__metaclass__ = meta_a


class ClassWithTypeMetaB(object):
__metaclass__ = meta_b


type(ClassWithTypeMetaA) == meta_a
type(ClassWithTypeMetaB) == meta_b


[¤] super call doesn't work here, anyone can say why ?

Regards,

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


Re: questions (& answers) about object, type, builtin types, class, metaclass and __getattribute__

2011-08-23 Thread Amirouche B.
On Aug 22, 5:41 pm, Stephen Hansen  wrote:
> > 3) object's type is type : object.__class__ is type
> > 4) type parent object is object : type.__bases__ == (object,)
>
> Saying "type" and "parent" and the like for new-style classes is
> something of a misnomer. For "type" and "object", these things aren't
> constructed like this.
>
> What you have here is technically true if you go poke at it in the
> interpreter, but it doesn't really /mean/ anything because its not how
> these objects came to be and is circular and a bit confusing. These
> fundamental objects are created special.

The code snippet is here to illustrate how it is visible in the
interpreter. But
you are right.

> > 2) type is its own metaclass : type(type) is type ?
>
> Only in a purely theoretical way. It doesn't actually mean anything;
> moreover, type(something) is NOT how you determine somethings metaclass.
> Its how you determine somethings type.

see the answer to Steven D'Aprano. type(class_object) ==
a_meta_class_object


> The two concepts may be very distinct. Lots of things don't have
> metaclasses.

All object in new style class have a metaclass at least type.


> > 3) object's metaclass is type ?
>
> Again, only theoretically.

and again the famous "bootstrapping" make it like type created object.
>From the
outside world of the Python implementation object looks like a type
instance.


> > 5) type(any_object) == last_metaclass_..., which is, most of the time,
> > type ?
>
> Not necessarily at all. In fact, there is no way I'm aware of to
> determine if a metaclass was involved in a classes construction unless
> said metaclass wants to provide such a mechanism.
>
> Metaclasses are kind of a  hack. They are a way to hook into the class
> construction that's normally done and do something, anything you want,
> (even hijack the whole procedure and NOT construct a class at all, but
> play a song if you want) before its all finished.
>
> For example, this is a metaclass I've used:
>
> PageTypes = {}
>
> class _PageRegistration(type):
> def __new__(cls, name, bases, dct):
> klass = type.__new__(cls, name, bases, dct)
> typename = name[:-9].lower()
> if not typename:
> typename = None
>
> PageTypes[typename] = klass
> klass.Type = typename
>
> return klass
>
> class QueuePage(sc.SizedPanel):
> __metaclass__ = _PageRegistration
>
> Note, the fact that my _PageRegistration metaclass inherits is itself a
> class which inherits from type is just one convenient way to write
> metaclasses. It could as simply have been just a function.
>
> Metaclasses are somewhat poorly named in that they are really, "creation
> hooks".


It the same issue in django, views are only function, until you need
complex
behavior and you want a "namespace" to put everything in it. IMO
that's why class
based views exists for complex cases. That said being able to declare
a metaclass
only as a functions is neat.


> > C) type vs class
> > 
>
> > 1) Type is the metaclass of most classes
>
> Yes and no. Yes, in that most classes are created using the default
> mechanism inside CPython. The class body is executed in a scope, the
> resulting dictionary is bound to a new class object, bases and the like
> are set, and such.
>
> No in that it really just, IIUC, skips the whole "metaclass" part of the
> process because this 'default mechanism' doesn't need to call out into
> other code to do its job. At least, I think-- May be wrong here,
> metaclasses are something of a dark voodoo and I'm not 100% entirely
> familiar with the internal workings of CPython.
>
> But functionally, a metaclass is the chunk of code responsible for the
> actual physical construction of the class object.

For me it takes some variables, namely ``bases``, ``class_dict`` and
``configuration class_name`` and do something with it, probably
creating a
class_object which behaviour is parametred with the context. I did not
know
Python before new-style class, so probably for most people explainning
that
metaclasses are a creation hook is easier for them...

> > 4) It's in type.__call__ that happens calls to __new__ and __init__
>
> Again, "translates to" is suggesting "this is what happens when you do
> X", which I don't know if is strictly true. CPython inside may be
> optimizing this whole process.
> Especially when it comes to "magic
> methods", __x__ and the like -- CPython rarely uses __get*_ for those.
> It just calls the methods directly on the class object.

IIUC the code of Jython tells me what I've written. If the first part
of the algorithm
is "lookup for special methods" (what you seem to say) then we both
agree that we
agree, isn't it ?

Moreover I'm not looking in this part to understand how CPython works
internally,
but how Python works. Since I'm most proeffencient in Python I
translate it to
Python.

*Translates* means "it's a shortcut for".


> > 5) 3) => c

__hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
Suppose we're implementing an immutable collection type that comes in unordered 
and ordered flavors. Let's call them MyColl and MyOrderedColl.

We implement __eq__ such that MyColl(some_elements) == 
MyOrderedColl(other_elements) iff set(some_elements) == set(other_elements).

But MyOrderedColl(some_elements) == MyOrderedColl(other_elements) iff 
list(some_elements) == list(other_elements).

This works just like dict and collections.OrderedDict, in other words.

Since our collection types are immutable, let's say we want to implement 
__hash__.

We must ensure that our __hash__ results are consistent with __eq__. That is, 
we make sure that if MyColl(some_elements) == MyOrderedColl(other_elements), 
then hash(MyColl(some_elements)) == hash(MyOrderedColl(other_elements)).

Now for the question: Is this useful? I ask because this leads to the following 
behavior:

>>> unordered = MyColl([1, 2, 3])
>>> ordered = MyOrderedColl([3, 2, 1])
>>> s = {ordered, unordered}
>>> len(s)
1
>>> s = {ordered}
>>> unordered in s
True
>>> # etc.

In other words, sets and mappings can't tell unordered and ordered apart; 
they're treated like the same values.

This is a bit reminiscent of:

>>> s = {1.0}
>>> True in s
True
>>> d = {1: int, 1.0: float, True: bool}
>>> len(d)
1
>>> # etc.

The first time I encountered this was a bit of an "aha", but to be clear, I 
think this behavior is totally right.

However, I'm less confident that this kind of behavior is useful for MyColl and 
MyOrderedColl. Could anyone who feels more certain one way or the other please 
explain the rationale and possibly even give some real-world examples?

Thanks!

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


Re: __hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
On Monday, November 20, 2017 at 1:55:26 PM UTC-5, Chris Angelico wrote:
> But what you have is the strangeness of non-transitive equality, which
> is likely to cause problems.

But this is exactly how Python's built-in dict and OrderedDict behave:

>>> od = OrderedDict([(1, 0), (2, 0), (3, 0)])
>>> od2 = OrderedDict([(3, 0), (2, 0), (1, 0)])
>>> ud = dict(od)
>>> od == ud
True
>>> od2 == ud
True
>>> od == od2
False


Given that, it would seem wrong for our MyOrderedColl.__eq__ to not behave 
similarly.

Or are you suggesting that OrderedDict.__eq__ should not have been implemented 
this way in the first place?


> So the question is: are you willing to
> accept the bizarre behaviour of non-transitive equality?

Forget what I'm personally willing to do :)
The question here actually is to tease out what Python's existing design is 
telling us to do.

If it helps, substitute "frozenset" for "MyColl" and "FrozenOrderedSet" for 
"MyOrderedColl". How would you implement their __eq__ methods? What would be 
the correct design for our hypothetical frozen(ordered)set library? What would 
be more useful, intuitive, and usable for our users?

Thanks very much for the good examples and for helping me clarify the question!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: __hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
On Monday, November 20, 2017 at 2:31:40 PM UTC-5, MRAB wrote:
> What if there are duplicate elements?
> 
> Should that be MyColl(some_elements) == MyOrderedColl(other_elements) 
> iff len(some_elements) == len(other_elements) and set(some_elements) == 
> set(other_elements)?

Yes, that's what I meant. Thanks for catching :)

Please let me know if you have any thoughts on how you would design our 
hypothetical frozen(ordered)set library to behave in these cases.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: __hash__ and ordered vs. unordered collections

2017-11-21 Thread Josh B.
On Monday, November 20, 2017 at 3:17:49 PM UTC-5, Chris Angelico wrote:
> Neither is perfect. You have to take your pick between them.

Right on, thanks for weighing in, Chris. Your responses have been very helpful.

I wouldn't feel comfortable claiming the authority to make this call alone. But 
fortunately I reached out to Raymond Hettinger and am delighted to have his 
guidance, pasted below. Great to have this predicament resolved.

In case of interest, I've implemented Raymond's advice in the latest release of 
bidict, the bidirectional map library I authored . 
Feedback always welcome.

Thanks,
Josh

-- Forwarded message --
From: Raymond Hettinger 
Date: Mon, Nov 20, 2017 at 4:46 PM
Subject: Re: __hash__ and ordered vs. unordered collections
To: j...@math.brown.edu


If you want to make ordered and unordered collections interoperable, I would 
just let equality be unordered all the time.  You can always provide a separate 
method for an ordered_comparison.

IMO, the design for __eq__ in collections.OrderedDict was a mistake.  It 
violates the Liskov Substitution Principle which would let ordered dicts always 
be substituted whereever regular dicts were expected.  It is simpler to have 
comparisons be unordered everywhere.

But there are no perfect solutions.  A user of an ordered collection may 
rightfully expect an ordered comparison, while a user of both collections may 
rightfully expect them to be mutually substitutable.


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


Update from 3.9 to 3.10.8 and uninstall 3.9

2022-10-23 Thread B N
I am new to python and wish to update 3.9 to3.10.8 which I have downloaded. How 
do I replace 3.9 with the 3.10.8 I downloaded.
Kind regards
JohnGee
-- 
https://mail.python.org/mailman/listinfo/python-list


Module use of python3_d.dll conflicts with this version of Python

2023-01-26 Thread Olivier B.
Hi,I am in the process of trying to make my code (an c++ executable
and swig modules using the Python C API) lose the dependency to python
3.7, to be compatible with all Python 3.2+

I tried linking to python.lib instead of python37.lib. As i am still
using a few things that are not in the limited API, my binaries now
have a dependency to python3.dll for the base stuff, and pyhton37.dll
for the few symbols that are not backwards compatible.

In release, that does not seem to bring issues. In debug (debug build
of my program that uses python debug build) however, when the process
is importing the swig python/c++ module, i get a
"Module use of python3_d.dll conflicts with this version of Python". I
checked that i am properly loading the python3_d.dll of my python37,
and python python37_d.dll too

Looking in dynload_win.c of python sources where the message is
triggered, indeed it is comparing in py case python37_d.dll to
python3_d.dll.
And i guess, in release, it works because in GetPythonModule(), there' is

#ifndef _DEBUG
/* In a release version, don't claim that python3.dll is
a Python DLL. */
if (strcmp(import_name, "python3.dll") == 0) {
import_data += 20;
continue;
}
#endif

Does someone know why it would have been chosen to be different for
debug builds?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug 3.11.x behavioral, open file buffers not flushed til file closed.

2023-03-05 Thread Frank B

Am 05.03.23 um 15:35 schrieb aapost:
I have run in to this a few times and finally reproduced it. Whether it 
is as expected I am not sure since it is slightly on the user, but I can 
think of scenarios where this would be undesirable behavior.. This 
occurs on 3.11.1 and 3.11.2 using debian 12 testing, in case the 
reasoning lingers somewhere else.


If a file is still open, even if all the operations on the file have 
ceased for a time, the tail of the written operation data does not get 
flushed to the file until close is issued and the file closes cleanly.


2 methods to recreate - 1st run from interpreter directly:

f = open("abc", "w")
for i in range(5):
   f.write(str(i) + "\n")


use

with open("abc", "w") as f:
for i in range(5):
f.write(str(i) + "\n")

and all is well

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


Best Practices for Internal Package Structure

2016-04-04 Thread Josh B.
My package, available at https://github.com/jab/bidict, is currently laid out 
like this:

bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py


I'd like to get some more feedback on a question about this layout that I 
originally asked here: 
:

What do you think of the code layout, specifically the use of the _foo modules? 
It seems well-factored to me, but I haven't seen things laid out this way very 
often in other projects, and I'd like to do this as nicely as possible.

It does kind of bug me that you see the _foo modules in the output when you do 
things like this:

>>> import bidict
>>> bidict.bidict

>>> bidict.KeyExistsError



In https://github.com/jab/bidict/pull/33#issuecomment-205381351 a reviewer 
agrees:

"""
Me too, and it confuses people as to where you should be importing things from 
if you want to catch it, inviting code like

```
import bidict._common

try:
...
except bidict._common.KeyExistsError:
...
```
ie. becoming dependent on the package internal structure.

I would be tempted to monkey-patch .__module__ = __name__ on each imported 
class to get around this. Maybe there are downsides to doing magic of that 
kind, but dependencies on the internals of packages are such a problem for me 
in our very large codebase, that I'd probably do it anyway in order to really 
explicit about what the public API is.
"""

Curious what folks on this list recommend, or if there are best practices about 
this published somewhere.

Thanks,
Josh
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2016-04-17 Thread B N
Foor ages, I have been trying to summon up courage learn how to program. I 
chose o start with Python. I found that when the “black” screen comes on, I am 
unable to read/see any characters even if I turn up the brightness of the 
screen. So, I give up. I tried version 3.5.1. I shall be grateful for any help. 
Also I have not ben ale to save it on C/programmes/files
Thank you
Ben

Sent from Mail for Windows 10

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


reactive programming use case

2020-03-11 Thread Raf B
hi, 

i am thinking about using RxPy to solve the following problem, and not yet sure 
if its the right tool for the job. 

I am working on a calculation engine, that takes a dataset (or multiple sets) 
and calculates new columns. 

so in pandas terms, it starts as DataFrame, and then i run it through a set of 
calcs. which all add new columns to the frame, and in the end i use those 
columns to check my dataset for things such as minimum % of colA / ColX etc.. 

i was thinking about using reactive programming to: 

* decouple the dataset from running all the calculations
* maybe help in making it more of a observable graph
* combine datasets

but maybe there is a better pattern? 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


A 'find' utility that continues through zipped directory structure?

2005-09-26 Thread B Mahoney
Is there a Python 'find' -like utility that will continue the file
search through any zippped directory structure on the find path?

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


Re: A 'find' utility that continues through zipped directory structure?

2005-09-27 Thread B Mahoney
An effbot utility?  I'll try that.

Thank you

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


Re: Well written open source Python apps

2005-10-14 Thread B Mahoney
The paper on BitPim http://bitpim.sourceforge.net/papers/baypiggies/
lists and describes programs and ideas used for the project.  Some of
it is just bullet-points, but everything seems to be well chosen. I've
swiped a lot of these ideas.

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


Expat - how to UseForeignDTD

2005-10-19 Thread B Mahoney
I have a simple Kid template document:



http://www.w3.org/1999/xhtml";
  xmlns:py="http://purl.org/kid/ns#";
>
... (snip)


This runs as expected but now I would like to load a DTD without
tampering with this xml file

In the expat parser __init__  after setting other handlers
for parser, I have added:
parser.ExternalEntityRefHandler = self._ExternalEntityRefHandler
parser.UseForeignDTD(1)  (also tried True)

Which I understand at some point will call
self._ExternalEntityRefHandler
with None for args and I must have code to get this other dtd.
I have done regular ExternalEntityRefHandlers before.

As required, these two lines occur before my Parse() call.
Perhaps I misunderstand the sequence, or need something more in my
xml file, but my _ExternalEntityRefHandler is never called.  The
process behaves as if I never added these two lines.

Help?

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


Re: Expat - how to UseForeignDTD

2005-10-20 Thread B Mahoney
I needed to set Entity Parsing, such as

parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_ALWAYS )

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


Re: Understanding the arguments for SubElement factory in ElementTree

2005-10-29 Thread B Mahoney
Your SubElement call is lacking the attrib argument, but you can't set
text, anyway.

The elementtree source makes it clear, you can only set element attrib
attributes
with SubElement

def SubElement(parent, tag, attrib={}, **extra):
attrib = attrib.copy()
attrib.update(extra)
element = parent.makeelement(tag, attrib)
parent.append(element)
return element

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


Re: Invoking Python from Python

2005-11-09 Thread B Mahoney
I also think something along the lines of execfile() may serve the
original poster. There was a  thread last month about compile()
and exec() with a concise example from  Fredrik Lundh.
Google "Changing an AST" in this group.

With dynamically generated code I prefer the separate compile()
step so that I can catch the compile exceptions separately.

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


Re: Python-based Document Management System?

2005-11-10 Thread B Mahoney
If you search for CONTENT management system,  there is
Plone: A user-friendly and powerful open source Content Management ...
http://plone.org/

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


Re: Can a function access its own name?

2005-11-19 Thread B Mahoney
Decorate any function with @aboutme(), which
will print the function name each time the function is called.

All the 'hello' stuff is in the aboutme() decorator code.
There is no code in the decorated functions themselves
doing anything to telling us the function name.


# The decorator
def aboutme():

def thecall(f, *args, **kwargs):
# Gets to here during module load of each decorated function

def wrapper( *args, **kwargs):
# Our closure, executed when the decorated function is called
print "Hello\nthe name of this function is '%s'\n" \
% f.func_name
return f(*args, **kwargs)

return wrapper

return thecall

@aboutme()
def testing(s):
print "string '%s' is argument for function" % s


@aboutme()
def truing():
return True

# Try these 
testing('x')

testing('again')

truing()

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


Re: Detect character encoding

2005-12-04 Thread B Mahoney
You may want to look at some Python Cookbook recipes, such as
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52257
"Auto-detect XML encoding"  by Paul Prescod

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


Re: Ant (with Python extensions) good replacement for distutils?

2005-12-07 Thread B Mahoney
>>No way. Ant sucks. Big-time. I actually enhance it with embedded jython
>>to get at least _some_ flexibility.

>>Diez 

Any pointers to this enhancement?

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


Re: newbie ?s

2005-01-13 Thread Venkat B
> > 1) I was wondering if anyone has opinions on the ability of
CGIHTTPServer (a
> > forking variant) to be able to handle this.
>
> Why not use apache?

Wanted something with less footprint.


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


newbie ?s

2005-01-13 Thread Venkat B
Hi folks,

I'm looking build a CGI-capable SSL-enabled web-server around Python 2.4 on
Linux.
It is to handle ~25 hits possibly arriving "at once". Content is non-static
and built by the execution of py cgi-scripts talking to a few backend
processes.

1) I was wondering if anyone has opinions on the ability of CGIHTTPServer (a
forking variant) to be able to handle this.
2) If so, would something like pyOpenSSL be useful to make such a webserver
SSL-enabled.

I checked out John Goerzen's book: Foundations of Python Network Programming
(ISBN 1590593715) and searched around. While I found how one can write py
scripts that could communicate with SSL-enabled webservers, tips on building
SSL-enabled webservers isn't obvious.

I was hoping to build a cleaner solution around the CGIHTTPServer variant
instead of say something like mini-httpd/OpenSSL/Python. I'd appreciate any
pointers.

TIA,
/venkat




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


python newt under win32

2005-01-23 Thread Gabriel B.
Anyone has any info if there's something similar to Newt  lib for win32?

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


add indexes on the fly to lists

2005-01-24 Thread Gabriel B.
I wanted to make a list index work as the index of the data in the
database. something like

database:
idx
item_description
item_value

being imported to my program as:
x[idx][0]= item_description
x[idx][1]= item_value

the problem is that there will be some hundred items and possible the
idx wil vary from 1 to 600 (it's not linear as items got deleted the
idx should not be reused)

will it still be an easy solution or just a waste of resources (having
a 600-sized list for 100 elements)

I'm very new to python and apreciate any hints on that.

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


is this use of lists normal?

2005-01-24 Thread Gabriel B.
I just sent an email asking for hints on how to import data into a
python program

As i said earlier i'm really new to python and besides being
confortable with the syntax, i'm not sure if i'm on the right track
with the logic

I'm asking for hints again here at the list because i think i'm
already into premature optimization...

My object model ended up as

DataStorageObj
|-itemsIndex (list, could very well be a set...)
|  |-[0] = 0
|  |-[1] = 1
|  |-[2] = 5
|  '-[3] = 6
'-Items (list)
   |-[0] = ['cat food', '12,20']
   |-[1] = ['dog food', 8,00']
   |-[2] = ['dead parrot', '25,00']
   '-[3] = ['friendly white bunny', '12,25']

the list itemsindex has the DB index of the data, and the list items
has the data.
So if i want something like "SELECT * FROM items WHERE idx=5" i'd use
in my program
self.items[ self.itemsIndex.index(5) ] 
i reccon that's not much nice to use when you're gona do /inserts/ but
my program will just read the entire data and never change it.

Was i better with dictionaries? the tutorial didn't gave me a good
impression on them for custom data...
Tupples? the tutorial mentions one of it's uses 'employee records from
a database' but unfortunatly don't go for it...

i think the 'ideal' data model should be something like
({'id': 0, 'desc': 'dog food', 'price': '12,20'}, ...)
But i have no idea how i'd find some item by the ID within it withouy
using some loops

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


tk global bindings

2005-01-29 Thread Gabriel B.
I'm starting to write a POS application UI's module.

There's no mouse, just a bunch of global shortcuts.

the problem is that TK doesn't have global shortcuts! Is there a
work-around or i will have to attach 80 or so bindings for every input
element?

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


naive doc question

2005-01-29 Thread Gabriel B.
Is it just me that can't find a full reference in the docs?

I wanted a list of all the methods of dict for example... where can i find it?

Thanks, and sorry if this question is just dumb, i really can't find it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> > users.  For example, from their FAQ, it seems that no precompiled
> > binaries will be provided.  Support for comercial compilers will not be
> > built in, only for gcc (through Cygwin?).
> 
> Isn't this just the same thing with a different spin. There was always
> an available distribution for linux for non-commercial use. Windows was
> always the problem. You still can't use it for windows without knowing
> how to compile the thing on windows.

Well, if it's GPLed, can't i simply compile it and distribute a GPLed
.DLL with the source code for everyone?
-- 
http://mail.python.org/mailman/listinfo/python-list


trolltech comitment (was:Big development in the GUI realm)

2005-02-08 Thread Gabriel B.
On Mon, 07 Feb 2005 20:56:44 -0800, Courageous <[EMAIL PROTECTED]> wrote:
> Follow the copyright holder's wishes.
> 
> That's fair. After all, it's free, so they're doing you a damn
> big favor.

I'm terrible sorry to extend this topic even furter, but it's silly,
not to say dull to think like that.

in the first place, it's not that they're doing charity. they have
plans. if they release Qt under GPL for non-comercial use, it's
because they want to increase the user base and so be able to earn
money with the comercial fee later.

And if i'm going to write software for it, when there's plenty of
alternative that actualy works flawless under windows, why should i
stick with an option that i don't even know to wich extends i can use
the damn thing? What it they revoke this license? what it windows
longhorn has a non-backwardcompatible GDI API and a newer version of
Qt must be used, and that newer version does not have a gpl version?

If i'm going to commit to something, i like to know the lengths the
other side gona commit also.

What you said was like "Hey! it's free food! who cares if it's
rotten?" sorry, but it's just too homer simpson for me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> >>Considering the fact that the Qt DLL exist by themselves, that the
> >>version used is the one provided by Qt, and that the EXE uses a
> >>standard, open way to communicate with it, the above does seem to say
> >>this use would be valid.
> >>
> >>
> >
> >http://www.gnu.org/licenses/gpl-faq.html#MereAggregation
> >
> >"/.../ If modules are designed to run linked together in a shared address
> >space, that almost surely means combining them into one program.
> >
> >By contrast, pipes, sockets and command-line arguments are
> >communication mechanisms normally used between two separate
> >programs. So when they are used for communication, the modules
> >normally are separate programs. But if the semantics of the
> >communication are intimate enough, exchanging complex internal
> >data structures, that too could be a basis to consider the two parts
> >as combined into a larger program."
> >
> >

This is odd. They claim it's a GPL'ed version, but it's a trolltech
license that forces you to release your code under gpl even tought
their's not!

I'm not against a company getting it's share with their product.
that's what motivated them in the first place. but DONT LIE! don't
call it gpl when it's not.

Gpl make it very explicity it deals with the program as a whole, in
the meaning of a executable code. What they're trying to achive here
is that, by adding this paragraph, they will cover the "dll use" under
the gpl.

By that cover-all definition they came up, i can't use Internet
Explorer to see a site hosted with a gpl'ed server! i can't even use a
BSD program to grep a file!

anyway... it will only mater when people with money cares. I already
have 3 choices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> However, imagine simple situation:
> 1. I write proprietary program with open plugin api. I even make the api
> itself public domain. Program works by itself, does not contain any
> GPL-ed code.

No need to continue. You write something that uses a plugin, Eolas
sues you. Don't have to mind about trolltech
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tk global bindings

2005-02-08 Thread Gabriel B.
> Oh and you of course __must__ look at the (recently updated!) New Mexico
> Tech tkinter document at:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf
> 
> See page 75 and follwing for more info on keyboard bindings...

Thanks, i was looking down that doc because the first thing i looked
into it was the pack method and it talked about the grid only

...i'm still using "practical programing in Tcl and Tk" for my tk needs :)

thanks again,
Gabriel
-- 
http://mail.python.org/mailman/listinfo/python-list


tcl/tk naming scheme vs python's

2005-02-08 Thread Gabriel B.
I got my self writting nested objects to hold Tk references, then i
realizes that i was working in python and not tcl, so i switched to
flat vars... and in no time i was using more then 7 words separated by
captalization in the names... i was able to rethink my scheme to use
5... no less.

i'm i exagerating or do you people also comes to this some times?
The other choice i think i had was to use semantic names instead of
semantic and hierarchical ones.

Gabriel

PS: i resisted the force of make an example using
ButtonSpamSpamSpamSpamSpamEggsSpam
-- 
http://mail.python.org/mailman/listinfo/python-list


tk resource file for geometry?

2005-02-12 Thread Gabriel B.
i'm using almost every widget property from my pyTk programs in the
form of resources, like:
  self.tk.option_add ( "*InputClass*background", "White" )

In the widget creation i have only the Class and the Command
attribute, but i'm having to add some tk options to the geometry
method, in the case, pack. Is there a way to overcome this?

For example, every single Frame i pack i use
  self.pack(fill='both', expand=1)
I'd love to have something like:
  self.tk.option_add ( "*Frame*fill", 'both' )
  self.tk.option_add ( "*Frame*expand", 'yes' )

Is there anything like it?

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


Why Tk treat F10, F11, F12 diferently from F1...F9?

2005-02-12 Thread Gabriel B.
This is completely odd to me...

# Bind F1...F12 to <>
self.tk.event_add( '<>', # keys used to switch between the tabs 

'','','','','',

'','','','','',
'',''
)

self.master.bind_all('<>', self.__functionKeysPressed )

def __functionKeysPressed(self, event):
print event.keysym


Now, i run the program and press from F1 to F12, and i get:
F1
F2
F3
F4
F5
F6
F7
F8
F9
L1
L2


F10 simply does nothing!
F11 prints L1
F12 prints L2

The only place google takes is not very elucidating :)
http://64.233.161.104/search?q=cache:t2CnLTHob0sJ:stuff.mit.edu/afs/sipb/project/tcl/linuxbin/dpwish+tk+bind+F12%7CF11+L1%7CL2&hl=fr

Anyone has any ideia why is that?
I surely didn't mind about this if it wasn't for F10 showing nothing.
I get the return code just to use the same function (and same biding)
for the 12 buttons since i can't pass arguments to the Command option
in tk. ...And i'm already considering adding a L1 and L2 check instead
of F11 and F12 and a 'empty' check for the F10... But that would be
plain ugly.

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


Re: Why Tk treat F10, F11, F12 diferently from F1...F9?

2005-02-12 Thread Gabriel B.
On Sat, 12 Feb 2005 19:44:25 -0600, Jeff Epler <[EMAIL PROTECTED]> wrote:
> The reason that F10 does nothing is because there is already a binding
> on all for . [...]
> If you want to get rid of this binding, you would do it with something
> like
> w.bind_all("", "")
> for some widget w.

That was it. thanks.

For the record: 
The virtual bidings with <> doesn't work. You have to manually
specify the . Seems like a bugged behaviour to me. Or at least,
just very odd and intuitive.


> I don't know why you see the "L1" and "L2" keysyms.  I don't on my
> system (Fedora Core 2)

i'm on windowsXP (what makes the F10 biding by "default" even more
weird). Well, for now using the keysym_num will be more safe since i'm
still getting they correct.
-- 
http://mail.python.org/mailman/listinfo/python-list


DB Schema

2005-02-18 Thread Gabriel B.
I started to use dbschema.com but it has some big flaws (mainly
regarding keys and mysql) and besides it's being in java (wich i don't
like to code at all) it's closed source.

I'm considering starting a new GPL one in python, so, i ask if you
people already know a project like that.

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


simple input that can understand special keys?

2005-02-26 Thread Gabriel B.
i'm writting an application that will use Tinker in a newer future.
Now it's console only. I simply ommit some data on the display,
print() some other and go on. The problem is that i can't test the
actions tiggered by special keys, like Page Up/Down or the F1...12

Right now i'm using raw_input() since even the Tk version will have
only one input place, and for debuging i'm literally writting pageup,
pagedow and the F's. But i want to put it in test while i write the
GUI.

is there any hope for me? I wanted to stay only with the console for
now. And it's windows by the way :)

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


Re: BaseHTTPServer.BaseHTTPRequestHandler and HTTP chunking

2005-03-10 Thread Venkat B
> No. Hardly any HTTP 1.1 features are supported.

Hi all,

I'd like to know more about the limitations.

Somewhere, is there a list of the actual subset of HTTP 1.1 features
supported. There's not much related info at the python.org site. There
appears to be just a limited note on 1.1 in
http://www.python.org/doc/2.4/lib/module-BaseHTTPServer.html with regards to
using the protocol_version variable/setting. No clue to extent of support.

Thanks,
/v


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


Re: Web framework

2005-03-13 Thread Venkat B
> I'd say Nevow! For apache setup, you might be interested in my wsgi [1]
> implementation.

Hi Sridhar,

Are you aware of Nevow's "integrability" with the webservers (CGIHTTPServer
in particular) that come packaged with Python itself ?

Thanks,
/venkat


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


Re: Video Catalogue

2004-12-01 Thread Tom B.

"Rodney Dangerfield" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Greetz!
>
> Recently I started creating a CGI application for my gf that
> she would use for indexing and keeping track of her video
> collection.
>
> I am relatively new to python so I started with the basics.
> I figured out how to extract the form field values in a
> script and how to save to a file.
>
> My question is which data type should I use to store the information
> about the videos? I was thinking of using a dictionary variable,
> I saw something about the pickle module too, could I use it to
> save the state of my dictionary to a file and than later read it
> and feed values from it to the form fields via CGI?
>
> All help is greatly appreciated.

I think a dictionary might work well, I might use a dictionary within a 
dictionary.

vidiodict = 
{'Title':{'description':'','date':'','cast':'','length':'130.99','comments':''}}

that way you could look at vidiodict['Title']['length'] it returns '130.99'.

Tom 


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


Python & LEGO Mindstorm control...

2005-03-29 Thread Venkat B
Hi all,

I have a question re the use of Python to control a robot built with the
LEGO Mindstorm system.
This is to help my 11yr old with his increased interest in 'programming' and
'robotics'... If not feasible, he wants to use the graphical-tool that comes
with it...

Would you suggest:
1. Using LegOS (http://legos.sourceforge.net/) and writing/using py
extensions from a Linux-box, OR
2. Using LeJOS (http://lejos.sourceforge.net/) and writing Jython utils.

Wanted to incorporate Python somehow, as it may be quite appropriate for his
age. Will have to help quite a bit in either case, tho... but was wondering
which is a more treaded path...

TIA,
/venkat


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


Python 2.4.1 build (configure) ?

2005-03-30 Thread Venkat B
Hi all,

While building the latest 2.4.1 version for Linux/RH9, I wanted to enable
IPV6
support (sockets). So, I ran the configure command ./configure --enable-ipv6
Then I ran the 'make' and 'make altinstall' commands.

When I checked the .py sources (in Lib folder) thru grep for 'ipv6', I see
the same
references I'd see, if I ran the configure command without the --enable-ipv6
option.
Is that normal or is there an issue I need to address here.

Thanks,
/venkat


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


mini_httpd (ACME Labs) & Python 2.4.1 integration

2005-04-03 Thread Venkat B
Hi folks,I have a webserver based on mini_httpd
v1.19(http://www.acme.com/software/mini_httpd/).I'd like to run some
python-based CGI scripts via this webserver on an RH9 system.In theory, with
the right env settings, Ishould be able to launch mini_httpd like so:
mini_httpd -c *.pyand be able to run scripts like so:
http://fqdn/simple.pyUsing info from (python) sys.path, multiple
get_config_var(..)s and sys.executable, Iwas able to build and use the env
settings (CGI_PATH, CGI_LD_LIBRARY_PATH) in the mini_httpd sources.However,
when I tried accessing the simple.pyscript as in the url above, I get an
error(errno of 8 - Exec format error) when thecode attempts to invoke the
execve() function. This same script works ok from a CGIHTTPServer.py based
test webserver.I was wondering if you knew what the right env settings
should be to get the py script working... I tried to google around to no
avail.

Thanks a lot.
Regards,
/venkat


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


Re: mini_httpd (ACME Labs) & Python 2.4.1 integration

2005-04-04 Thread Venkat B
We found the answer, just in case one was looking for it...

I turns out that setting the environment params (CGI_PATH & CGI_LD_LIB_PATH)
is not sufficient. One has to still add the path entry to the script
itself... like so: #! /python2.4

May also work with ensuring env variable PYTHONPATH is set right.

/venkat


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


Re: workaround for generating gui tools

2005-04-11 Thread Gabriel B.
On Apr 10, 2005 11:08 PM, Bengt Richter <[EMAIL PROTECTED]> wrote:
> On Sat, 9 Apr 2005 19:22:16 +0200, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
> open('mywidget_v2.txt','w').write(repr(mywidget.textview)

How about a pickle hook?

You'd just unpack the pickle data, and end up with a pointer to a
frame(?) containing all the goods, then just .pack() it into whatever
you want.
-- 
http://mail.python.org/mailman/listinfo/python-list


Bug asking for input number

2013-11-15 Thread Arturo B
Hi! I hope you can help me.

I'm writting a simple piece of code.
I need to keep asking for a number until it has all this specifications:

- It is a number
- It's lenght is 3
- The hundred's digit differs from the one's digit by at least two

My problem is that I enter a valid number like: 123, 321, 159, 346... and it 
keeps asking for a valid number.

Here's mi code:

res = input('Give me a number --> ')
hundreds = int(res[0])
ones = int(res[2])

# checks if the user enters a valid number
while not res.isdigit() or not len(res) == 3 or abs(hundreds - ones) <= 2:
res = input('Enter a valid number --> ')

Thanks for help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug asking for input number

2013-11-15 Thread Arturo B
MRAB your solution is good thank you I will use it.

Terry Eddy I saw my mistake about for example 2 <= 2, I think it's easier to 
use break in this case thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


How is this list comprehension evaluated?

2013-09-16 Thread Arturo B
Hello, I'm making Python mini-projects and now I'm making a Latin Square

(Latin Square: http://en.wikipedia.org/wiki/Latin_square)

So, I started watching example code and I found this question on Stackoverflow: 

http://stackoverflow.com/questions/5313900/generating-cyclic-permutations-reduced-latin-squares-in-python

It uses a list comprenhension to generate the Latin Square, I'm am a newbie to 
Python, and  I've tried to figure out how this is evaluated:

a = [1, 2, 3, 4]
n = len(a)
[[a[i - j] for i in range(n)] for j in range(n)]

I don't understand how the "i" and the "j" changes.
On my way of thought it is evaluated like this:

[[a[0 - 0] for 0 in range(4)] for 0 in range(4)]
[[a[1 - 1] for 1 in range(4)] for 1 in range(4)]
[[a[2 - 2] for 2 in range(4)] for 2 in range(4)]
[[a[3 - 3] for 3 in range(4)] for 3 in range(4)]

But I think I'm wrong... So, could you explain me as above? It would help me a 
lot.

Thanks for reading!
-- 
https://mail.python.org/mailman/listinfo/python-list


Understanding how is a function evaluated using recursion

2013-09-25 Thread Arturo B
Hi, I'm doing Python exercises and I need to write a function to flat nested 
lists
as this one: 

[[1,2,3],4,5,[6,[7,8]]]

To the result:

[1,2,3,4,5,6,7,8]

So I searched for example code and I found this one that uses recursion (that I 
don't understand):

def flatten(l):
ret = []
for i in l:
if isinstance(i, list) or isinstance(i, tuple):
ret.extend(flatten(i)) #How is flatten(i) evaluated?
else:
ret.append(i)
return ret

So I know what recursion is, but I don't know how is 

   flatten(i)
 
evaluated, what value does it returns?

Thank you

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


OBIEE Developer and Administrator @ Seattle WA

2015-08-13 Thread Amrish B
Hello Folks,

Please go through below job description and send me updated resume to 
amr...@uniteditinc.com

Job Title: OBIEE Developer and Administrator
Location: Seattle WA
Duration: 12+months
Experience: 10+ years only
 
Job Description:
* maintain the Oracle Business Intelligence Enterprise Edition 
application and develop reports/dashboards for functional areas
* Act as an analyst interacting with departments to understand, define, 
and document report and dashboard requirements
* Assist in configuring complex Oracle systems (Oracle client tools, 
administration of Web Logic, and setup and configuration of web server with 
front end reporting tools)
* Responsible for security administration within OBIEE as well as 
integrations with active directory 
* Research, tune, and implement configurations to ensure applications 
are performing to expected standards
* Researches, evaluates and recommends enabling software design 
practices, trends, and related technologies
* Support and comply with security model and company audit standards
* Conduct comprehensive analysis of enterprise systems concepts, 
design, and test requirements
* Analyzes, defines, and documents requirements for data, workflow, 
logical processes, interfaces with other systems, internal and external checks 
and controls, and outputs
 
Qualifications/Knowledge, Skills, & Abilities Requirements
* Bachelor's Degree in Computer Science, Engineering, or related 
discipline, or equivalent, experience
* 8 plus years of experience in data warehouse or reporting design and 
development
* Experience with DBMS (i.e. Oracle) and working with data
* Experience in system administration
* Ability to troubleshoot and solve complex issues in an Enterprise 
environment
* Ability to establish and maintain a high level of customer trust and 
confidence
* Strong analytical and conceptual skills; ability to create original 
concepts and ideas
 
 
Thanks & Regards,
 
Amrish Babu | IT Recruiter
-- 
https://mail.python.org/mailman/listinfo/python-list


try/except/finally

2014-06-06 Thread Frank B
Ok; this is a bit esoteric.

So finally is executed regardless of whether an exception occurs, so states the 
docs.

But, I thought, if I  from my function first, that should take 
precedence.

au contraire

Turns out that if you do this:

try:
  failingthing()
except FailException:
  return 0
finally:
  return 1

Then finally really is executed regardless... even though you told it to return.

That seems odd to me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-06 Thread Frank B
Ok; thanks for the underscore and clarification.  Just need to adjust my 
thinking a bit.
-- 
https://mail.python.org/mailman/listinfo/python-list


online data entry jobs

2011-12-15 Thread vengal b
online data entry jobs
http://venuonlinejobs.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Convert Latitude, Longitude To TimeZone

2013-03-31 Thread Steve B
Hi All

 

I'm new to python (4 days J) and was wondering if anyone out there can help
me

 

I am trying to get the time zones for latitude and longitude  coordinates
but am having a few problems

The mistakes are probably very basic

 

I have a table in a database with around 600 rows. Each row contains a lat
long coordinate for somewhere in the world

I want to feed these co-ordinates into a function and then retrieve the time
zone. The aim being to convert events which have a local time stamp within
each of these 600 places into UTC time

I found a piece of code
[http://blog.pamelafox.org/2012/04/converting-addresses-to-timezones-in.html
] which uses the function [https://gist.github.com/pamelafox/2288222]

 

When I try to run the code, I get the error geonames is not defined (This is
the function previously linked to)

I have applied for an account with geonames, I think I have just saved the
function file in the wrong directory or something simple. Can anyone help

 

#---


# Converts latitude longitude into a time zone

# REF: https://gist.github.com/pamelafox/2288222

# REF:
http://blog.pamelafox.org/2012/04/converting-addresses-to-timezones-in.html

#---


 

geonames_client = geonames.GeonamesClient('Username_alpha')

geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng':
2.77928})

user.timezone = geonames_result['timezoneId']

 

Thanks

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


Changing a shell's current directory with python

2005-12-18 Thread Andy B.
I've got a python utility that I want to change my shell's current
directory based on criteria it finds.  I've scoured google and the
python cookbook and can't seem to figure out if this is even possible.
 So far, all my attempts have changed the current python session only.
 Am I going to have to wrap this in a shell script?

% pwd
/var/tmp
% myutil.py
# do some stuff and cd to '/var/log'
% pwd
/var/log

Many thanks,

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


Re: Changing a shell's current directory with python

2005-12-18 Thread Andy B.
Many thanks for the sanity check.  Just wanted to check with the gurus
before heading down another path.

-A


On 12/18/05, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sun, 18 Dec 2005 15:53:11 -0800, "Andy B." <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > I've got a python utility that I want to change my shell's current
> > directory based on criteria it finds.  I've scoured google and the
> > python cookbook and can't seem to figure out if this is even possible.
> >  So far, all my attempts have changed the current python session only.
> >  Am I going to have to wrap this in a shell script?
>
> That's about all you will be able to achieve... the inheritance goes
> downwards: shell -> program(python, etc.) -> spawned processes
> (os.system, etc.)... Changes at one level are only picked up by things
> started after that change, and started from that level.
> --
>  > == <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
>  > == <
>  >   Home Page: <http://www.dm.net/~wulfraed/><
>  >Overflow Page: <http://wlfraed.home.netcom.com/><
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


soap comlex data to plain xml

2006-08-18 Thread Ig B
Hi all,would anyone give me a hint how to get SOAP data as plain XML and not as complex datathis is sample code:  myProxy = SOAPpy.SOAPProxy(MY_SERVICE_PATH, header = my_headers)  query = SOAPpy.structType

()  result = myProxy.callMyProcedure(query)  result returned as complex data, but i need plain xml text - kind of you see when myProxy.config.dumpSOAPIn = 1thank you in advance.~GB
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Standard Forth versus Python: a case study

2006-10-13 Thread B M
i hang my head in shame.



On 10/12/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> At Thursday 12/10/2006 17:44, [EMAIL PROTECTED] wrote:
>
> > > > > fun median {
> > > > >  var x = 0.
> > > > >   while( *p++) {
> > > > > if( (*p) > x) x = *p.
> > > > >   }
> > > > >   return x.
> > > > > }
> >
> >clearly, i've forgotten the definition of the median of a list.
> >to that i plead faulty memory.
>
> That explains all. Finding the median in an efficient way (that is,
> without sorting the data first) isn't trivial, so your claim of "I
> can do that using only one temp variable" was a bit surprising...
> BTW, the median is the value which sits just in the middle of the
> list when ordered: median(3,5,12,1,2)=median(1,2,3,5,12) = 3
>
>
> --
> Gabriel Genellina
> Softlab SRL
>
>
>   
>   
>   
> __
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya!
> http://www.yahoo.com.ar/respuestas
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Running External Commands + Seeing when they are Finished

2006-05-29 Thread Tommy B
It works! Gasp!

Thanks!

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


Get EXE (made with py2exe) path directory name

2006-06-05 Thread Andrei B
I need to get absolute path name of a file that's in the same dir as
the exe, however the Current Working Directory is changed to somthing
else.

I turn my script into an executable with py2exe, then I create a
shortcut to the EXE on the desktop. I change the "Start In" variable of
the shortcut "C:\somthing_else", so now the currect working directory
of the executable is not the same as the directory where the EXE is
located.

I need to load a file that's in the same directory as the EXE, so I do
the following:

dir = os.path.dirname(sys.argv[0])
filepath = os.path.join(dir, 'server.pkey')

however it doesn't seem to work.

Any idea?

thanks!

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


Writing to a certain line?

2006-06-05 Thread Tommy B
I was wondering if there was a way to take a txt file and, while
keeping most of it, replace only one line. See, I'd have a file like:

Tommy 555
Bob 62
Joe 529

And I'd want to set it to be:

Tommy 555
Bob 66
Joe 529

Is there any easy way to do this?

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


Re: Writing to a certain line?

2006-06-06 Thread Tommy B

bruno at modulix wrote:
> Tommy B wrote:
> > I was wondering if there was a way to take a txt file and, while
> > keeping most of it, replace only one line.
>
> 
> This is a FAQ (while I don't know if it's in the FAQ !-), and is in no
> way a Python problem. FWIW, this is also CS101...
> 
>
> You can't do this in place with a text file (would be possible with a
> fixed-length binary format).
>
> The canonical way to do so - whatever the language, is to write the
> modified version in a new file, then replace the old one.
>
> import os
> old = open("/path/to/file.txt", "r")
> new = open("/path/to/new.txt", "w")
> for line in old:
>   if line.strip() == "Bob 62"
> line = line.replace("62", "66")
>   new.write(line)
> old.close()
> new.close()
> os.rename("/path/to/new.txt", "/path/to/file.txt")
>
> If you have to do this kind of operation frequently and don't care about
> files being human-readable, you may be better using some lightweight
> database system (berkeley, sqlite,...) or any other existing lib that'll
> take care of gory details.
>
> Else - if you want/need to stick to human readable flat text files - at
> least write a solid librairy handling this, so you can keep client code
> free of technical cruft.
>
> HTH
> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in '[EMAIL PROTECTED]'.split('@')])"

Umm... I tried using this method and it froze. Infiinite loop, I'm
guessing.

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


pysqlite error: Database locked?

2006-06-06 Thread Tommy B
I'm currently working on a casino script for an IRC bot. I was going to
make a flat file database, but I decided to make it sqlite after some
suggestions. I'm using pysqlite.

http://pastebin.com/764315 < Source. The lines that have @@ (pastebin
doesn't like me) in front of them are important.

ERROR 2006-06-06T22:20:34 Uncaught exception in ['diceroll'].
Traceback (most recent call last):
  File "G:\Python24\Lib\site-packages\supybot\callbacks.py", line 1170,
in _call
Command
self.callCommand(command, irc, msg, *args, **kwargs)
  File "G:\Python24\Lib\site-packages\supybot\utils\python.py", line
62, in g
f(self, *args, **kwargs)
  File "G:\Python24\Lib\site-packages\supybot\callbacks.py", line 1156,
in callCommand
method(irc, msg, *args, **kwargs)
  File "G:\Python24\Lib\site-packages\supybot\commands.py", line 906,
in newf
f(self, irc, msg, args, *state.args, **state.kwargs)
  File "G:\Python24\Scripts\plugins\Casino\plugin.py", line 160, in
diceroll
money_file_update(msg.nick, wager)
  File "G:\Python24\Scripts\plugins\Casino\plugin.py", line 43, in
money_file_update
cur2.execute('UPDATE players SET cash = ' + str(newcash) + ' WHERE
name = \' ' + user + '\'')
OperationalError: database is locked
ERROR 2006-06-06T22:20:34 Exception id: 0x486de ' + user + '\'')
OperationalError: database is locked
ERROR 2006-06-06T22:20:34 Exception id: 0x486de

That's the error.

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


Re: all ip addresses of machines in the local network

2006-08-25 Thread Ognjen B
Amit Khemka wrote:
> On 23 Aug 2006 21:46:21 -0700, damacy <[EMAIL PROTECTED]> wrote:
>   
>> hi, sandra.
>>
>> no, it's not as complicated as that. all i want to do is to load a
>> database onto different machines residing in the same network. i hope
>> there is a way doing it. or perhaps i have a poor understanding of how
>> networks work.
>>
>> 
>
> I expect that you would know the IP range for your network. Then you
> can simply 'ping' each IP in the range to find wether its alive.
> Moreover by your description I guess you would actually want to find
> all machines in your network that run a particular network service, to
> allow you to "distribute the database". In such case you can use
> "nmap" with -p option, to find all the machines which are listening on
> the particular port.
>
> hth,
> amit.
>   
Correct me if I am wrong, but isn't a way  of doing this to use ARP?  
(Address Resolution protocol, see 
http://en.wikipedia.org/wiki/Address_Resolution_Protocol ) send an ARP 
request, and wait for the reply. For example:

you have a network, 192.168.5.0, with a netmask of 255.255.255.0 This 
means you have 254 addresses, so with ARP, it would go somthing like this:

your program >> "Who has 192.168.5.1"

and if anyone has the IP, they go  "Hey, I (hw MAC address) have IP"

Do this with the entire range (192.168.5.1 --> 192.168.5.254) and you 
get a list of the devices IP  addresses and corresponding MAC addresses. 
This is how some network scanners I use work, to build a list of 
connected systems.

Or you can use one of the other programs out there ,like nmap or nast, 
as they will output this list and you can parse it to your hearts content.

Of course, anyone feel free to correct me if I made a mistake, its been 
a while since I last did this.

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


Re: Need some help here

2006-09-20 Thread Colin B.
In comp.unix.solaris Kareem840 <[EMAIL PROTECTED]> wrote:
> Hello. Unfortunately, I am in need of money to pay my credit card
> bills. If you could spare just $1, I would be grateful. I have a Paypal
> account. [EMAIL PROTECTED] I swear this will go to my card
> balances. Thank you.

Better idea. Sell your computer. Or your organs.

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


Re: Need some help here

2006-09-20 Thread John B
Kareem840 wrote:
> Hello. Unfortunately, I am in need of money to pay my credit card
> bills. If you could spare just $1, I would be grateful. I have a Paypal
> account. [EMAIL PROTECTED] I swear this will go to my card
> balances. Thank you.
> 
I accidentally sent $2, could you please refund the extra dollar to 
[EMAIL PROTECTED]
No, thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should we still be learning this?

2006-02-18 Thread B Mahoney
I was initally annoyed that "Dive into Python" has the UserDict, but it
was so
easy to discover it was deprecated
http://docs.python.org/lib/module-UserDict.html
(althought the term 'deprecated' is not specifically used), that anyone
on the
ball (the OP seemed to know) would not based their next big project on
UserDict.

I agree that Python has so many good concepts, and improvements with
each new version, that something in a course will be outdated. I can
concur
that knowing Python made it much easier to go back to C++ and Java and
understand the OO.

My tip for an book on Python with only the latest information, nothing
beats the Python Pocket Reference, 3rd edition,  (O'Reilly) which
is updated for  2.4 and seems to clearly label any deprecated features.

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


warning for google api users

2006-02-21 Thread Gabriel B.
the google webservices (aka google API) is not even close for any kind
of real use yet

if you search for the same term 10 times, you get 3 mixed totals. 2
mixed result order. and one or two "502 bad gateway"

i did an extensive match agains the API and the regular search
service. the most average set of results:

results 1-10; total: 373000
results 11-20; total: 151000
results 21-30; total: 151000
results 31-40; total: 373000
results 41-50; total: 373000
results 51-60; total: 373000
results 61-70; total: 151000
( 502 bad gateway. retry)
results 71-80; total: 373000
results 81-90; total: 151000
( 502 bad gateway. retry)
results 91-100; total: 373000

on the regular google search, total:  2,050,000 (for every page, of
course)

besides that, the first and third result on the regular google search,
does not apear in the 100 results from the API in this query, but this
is not average, more like 1 chance in 10 :-/

So, no matter how much google insists that this parrot is sleeping,
it's simply dead.


now, what i presume that is happening, is that they have a dozen of
machine pools, and each one has a broken snapshot of the production
index (probably they have some process to import the index and or it
explode in some point or they simply kill it after some time). and
they obviously don't run that process very often.

Now... anyone has some implementation of pygoogle.py that scraps the
regular html service instead of using SOAP? :)

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


Re: How to send an email with non-ascii characters in Python

2006-02-25 Thread Gabriel B.
2006/2/25, Sybren Stuvel <[EMAIL PROTECTED]>:
> Lad enlightened us with:
> > Body='Rídících Márinka a Školák Kája
> > Marík'.decode('utf8').encode('windows-1250')# I use the text written
> > in my editor with utf-8 coding, so first I decode and then encode to
> > windows-1250

what does a string became when it's decoded?

I mean, it must be encoded in something, right?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: comple list slices

2006-02-28 Thread shandy . b
A couple questions:

1- what is j?
2- what does the rows[x][y] object look like?  I assume it's a dict
that has a "rowspan" key.  Can rows[x][y]["rowspan"] sometimes be 0?

Perhaps you're looking for something like this:
rowgroups = []
rowspan = 0
for i in range( len(rows) ):
if rowspan <= 0:
rowspan = rows[j][0]["rowspan"]
if rowspan == 0:
rowspan = 1

rowgroups.append(rows[ i : i + rowspan ])

rowspan -= 1

-sjbrown

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


scope acting weird

2005-05-01 Thread Gabriel B.
i have the following code:

Ui.py:
import Tkinter as Tk
import UiMainScreen

UiMainScreen.py:
class UiMainScreen( Tk.Frame ):


and i get the following error:
  File "UiMainScreen.py", line 1, in ?
class UiMainScreen(Tk.Frame):
NameError: name 'Tk' is not defined

isn't Tk supposed to be imported globaly?
And If i import Tkinter again inside every other file, will it be
really imported several times and be independent in each file or the
python interpreter just use the subsequent imports to know where to
propagate stuff?

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


OK

2005-05-13 Thread =??B?xqS088fs?=


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


Ok

2005-05-13 Thread =??B?xqS088fs?=


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


Re: I need some cleanings tips and advice.

2007-06-22 Thread Colin B.
In comp.lang.perl.misc [EMAIL PROTECTED] wrote:
> Me and my buddy made a website called www.stupidpinheads.com, its
> basically a free forum and  free blog driven web site dedicated as a
> source people can goto to find out how to clean and remove stains from
> pretty much anything. Problem is, as of yet, you couldn't find out how
> to clean anything right now cause the site is new and no one has found
> it yet.

Let's see if I get this right.

You create a website for a subject that you know nothing about. Then you
try to solicit content in a bunch of programming language newsgroups.

Wow, that's pretty pathetic, even for a google-groups poster!

Begone with you.

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


New-style classes and special methods

2007-05-30 Thread Raj B
Hi

My question is about how special methods are stored internally in  
Python objects.
Consider a new-style class which implements special methods such as  
__call__ and __new__

class C(type):
def __call__(...):


class B:
__metaclass__ = C


b= B()

The type of C is 'type', that of B is 'C'. When B is instantiated,  
the __call__ method of C is first invoked, since C is the metaclass  
for B.

Internally, when a Python callable object 'obj' is called, the actual  
function called seems to be
'obj->ob_type->tp_call'.

Does this that somehow the '__call__' method defined in C above is  
assigned to the 'tp_call' slot in the object representing the class  
C, instead of it just being stored in the dictionary like a normal  
attribute? Where and how does this magic happen exactly? I'd  
appreciate any level of detail.

Thanks!
Raj


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


Re: New-style classes and special methods

2007-05-30 Thread Raj B
 > Yes, special methods populate the slots in the structures which  
Python
 > uses to represent types.  Objects/typeobject.c in the Python source
 > distribution does the hard work, particularly in function type_new



Thanks for that quick response. I am quite comfortable with C code  
and am trying to understand exactly what happens when a new-style  
class is created, and then instantiated.

I have been reading typeobject.c and type_new() inside it in detail,  
and there are a few issues I am trying to figure out.

I can see a lot of *SLOT() macros in the file that seem to set the  
slots to appropriate values. What I am having trouble figuring out is  
the connection i.e. at what point during construction of the class  
object in type_new() are those slots allotted? Is it the tp_alloc()  
function which does this?

Is there some kind of descriptor or other mechanism connecting  
special method names with their slots in the object representation?  
(e.g. "__call__" with type->tp_call)

Also, what happens when a class inherits from multiple classes with  
their own __call__ methods? Where and how  is it decided which  
__call__ goes into the tp_call slot?

I'm sure I'll eventually figure it out if I stare at the code hard  
enough, but would totally appreciate any help I can get :)

Thanks again!

Raj





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


Representation of new-style instance

2007-08-01 Thread Raj B
Consider a new-style class

class rabbit(object):
   def __init__(self,c):
self.color = c

r1=rabbit("blue")
r2=rabbit("purple")

Which C struct in the Python implementation is used to represent the  
instances c1 and c2 of the
new-style class? I understand that when the class 'rabbit' is  
created, the type_new function
in typeobject.c creates a copy of a 'struct typeobject' with  
dictionary tp_dict appropriately modified.

However, I can't figure out which structure is used for new-style  
instances and where the instance dictionary is stored. Could anyone  
please clarify?

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


Adding a list of descriptors to a class

2007-08-07 Thread Bob B.
I've been playing with descriptors lately.  I'm having one problem I
can't seem to find the answer to.  I want to assign a descriptor to a
list of attributes.  I know I should be able to add these somewhere in
the class's __dict__, but I can't figure out where.  Here's some code:

class MyDesc(object):
  def __init__(self, name=None, initVal=None):
self.name = name
self.value = initVal

  def __get__(self, obj, objtype):
// Do some stuff
self.value = "blah"
return self.value

class MyClass(object):
  attributes = ('attr1', 'attr2')
  for attr in attributes:
exec ("%s=MyDesc('%s')") % (attr, attr)

  // More stuff in the class

Ok, that "exec" is an ugly hack.  There's gotta be someway to plop
this straight into the class's __dict__ without doing that, but when I
try adding self.__class__.__dict__[attr] = MyDesc(attr) in MyClass's
__init__ method, I get the error: "TypeError: 'dictproxy' object does
not support item assignment"

Any ideas?

Thanks,
Bob

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


  1   2   3   4   5   6   7   8   9   10   >