Re: Accessors in Python (getters and setters)

2006-07-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, mystilleef wrote: > > Bruno Desthuilliers wrote: >> mystilleef wrote: >> > Bruno Desthuilliers wrote: >> > >> > Because you don't want third parties illegimately tampering with an >> > object's internal data and thus crashing your system? >> >> Let's try again... >> >> poi

Re: New to threads. How do they work?

2006-07-19 Thread gel
Dennis Lee Bieber wrote: > On 19 Jul 2006 19:08:12 -0700, "gel" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > import thread > > > Step one... Skip the thread module and use threading module instead. > > > def create(): > > > > pythoncom.CoInitialize() > >

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
Dave, Python properties allow you to get rid of methods like c.getAttr(), c.setAttr(v), c.delAttr() and replace them with simple constructs like c.attr, c.attr=v and del c.attr. If you have been using Java or C++ you know that as soon as you code your class you have to start filling in the get()

Re: Weird MemoryError issue

2006-07-19 Thread jedi200581
John Machin wrote: > On 20/07/2006 6:05 AM, John Machin wrote: > > On 20/07/2006 1:58 AM, [EMAIL PROTECTED] wrote: > >> def is_prime n: > > > > Syntax error. Should be: > >def is_prime n: > > Whoops! Take 2: > > Should be: > > def is_prime(n): Sorry for that, I was not able to cut-paste the c

Re: Depricated String Functions in Python

2006-07-19 Thread Stefan Behnel
Anoop wrote: > Can any one help me out with the various depricated string functions > that is followed in Python. > > For example how will be string.lower depricated. > > As far as string.lower('PYTHON') is concerned it is depricated as > 'PYTHON'.lower(). Both of them would return an output : >>

Depricated String Functions in Python

2006-07-19 Thread Anoop
Hi All Can any one help me out with the various depricated string functions that is followed in Python. For example how will be string.lower depricated. As far as string.lower('PYTHON') is concerned it is depricated as 'PYTHON'.lower(). Both of them would return an output : >>> python Thanks fo

Re: restricted environment

2006-07-19 Thread K.S.Sreeram
Gabriele *darkbard* Farina wrote: > The first attempt to reach my goal was to override the __import__ > function to limit it working on modules that can be used and on custom > import directories that can be accessed. Then I executed the scripts > using exec. There is any security problem related t

Re: questions to anyone who uses wxPython

2006-07-19 Thread Frank Millman
damacy wrote: > hello. i'm using wxPython as my GUI package and whenever my program > executes a long process which takes at least 2 or 3 seconds, the user > interface gets corrupted while executing the progrocess during the > period. > > i have tried the following lines of code... > > frame = mai

Re: Partial classes

2006-07-19 Thread Stefan Behnel
Kay Schluehr wrote: > What about letting your teammates editing certain data-structures in > different files ( physical modules ) but using them in a uniform way > and enable a single access point. If you have partial classes there is > no reason why your team has to share a large file where they h

Re: Coding style

2006-07-19 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Bob Greschke >> wrote: >> >>> I'd go even one step further. Turn it into English (or your favorite >>> non-computer language): >>> >>> 1. While list, pop. >>> >>> 2. While the le

Re: Accessors in Python (getters and setters)

2006-07-19 Thread mystilleef
Steve Holden wrote: > mystilleef wrote, making me somewhat tired of his/her repeated inability > to get what's being said [sigh]: > > Bruno Desthuilliers wrote: > >>mystilleef wrote: > >>>Bruno Desthuilliers wrote: > mystilleef wrote: > >Gerhard Fiedler wrote: > >>On 2006-07-15 06:55:1

Re: Partial classes

2006-07-19 Thread Sanjay
> Anyway, I would suggest you NOT to use this code in production. Yes, > Python > can imitate Ruby, but using this kind of classes would confuse > everybody and > make your code extremely unpythonic. As always, consider changing your > mindset, > when you switch language. For you problem, you could

Re: Using super()

2006-07-19 Thread Michele Simionato
Michele Simionato ha scritto: > I believe the new style system was designed to allows this sort of > mixing and > that there are no issues at all. Thinking a bit more, there are no issues at all if you know what a new style class is and if you do not expect it to work as an old-style one ;) For th

Weekly Python Patch/Bug Summary

2006-07-19 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 398 open ( +5) / 3334 closed (+19) / 3732 total (+24) Bugs: 904 open ( -4) / 6011 closed (+36) / 6915 total (+32) RFE : 222 open ( -1) / 231 closed ( +2) / 453 total ( +1) New / Reopened Patches __ Fix for #

Re: Accessors in Python (getters and setters)

2006-07-19 Thread mystilleef
Bruno Desthuilliers wrote: > mystilleef wrote: > > Bruno Desthuilliers wrote: > > > >>mystilleef wrote: > (snip) > > > >Of course using setters for the sake of just using them is pointless. > > Indeed. > > > > >The reason to use them is if pre-conditions or post

Re: Coding style

2006-07-19 Thread Patrick Maupin
Terry Reedy wrote: > > > Carl Banks wrote: > >> def process_values(lst): > >> if not lst: > >> return > >> do_expensive_initialization_step() > >> for item in lst: > >> do_something_with(item) > >> do_expensive_finalization_step() > > Give

Re: Partial classes

2006-07-19 Thread Michele Simionato
Sanjay ha scritto: > Thanks for the code showing how to implement partial classes. Infact, I > was searching for this code pattern. I will have a study on metaclass > and then try it. > > Thanks > Sanjay Anyway, I would suggest you NOT to use this code in production. Yes, Python can imitate Ruby

questions to anyone who uses wxPython

2006-07-19 Thread damacy
hello. i'm using wxPython as my GUI package and whenever my program executes a long process which takes at least 2 or 3 seconds, the user interface gets corrupted while executing the progrocess during the period. i have tried the following lines of code... frame = mainwindow(None, -1, 'my program

Re: Using super()

2006-07-19 Thread Michele Simionato
Carl Banks ha scritto: > Pupeno wrote: > > I see, thank you. > > > > class MyConfig(ConfigParser, object): > > def add_section(self, section) > > super(MyConfig, self).add_section(section) > > > > seems to work and as expected. Is there anything wrong with it ? > > Wow. > > I highly r

Re: using names before they're defined

2006-07-19 Thread Paul McGuire
[EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a number of > mechanical components represented as objects. Have you looked at SimPy? This may simplify much of your data structure anguish (probably only need forward refs, without the back refs), plus it will do

Re: Tkinter focus_set use with grid

2006-07-19 Thread John McMonagle
On Thu, 2006-07-20 at 02:53 +, Stan Cook wrote: > A newbie to Tkinter here. . . . . . > > I'm trying to set the focus on an Entry textbox with > focus_set. I am using the grid manager. I created the same > interface before using the pack() method and the focus_set > worked, but now it sa

Re: Accessors in Python (getters and setters)

2006-07-19 Thread danielx
Bruno Desthuilliers wrote: > ZeD wrote: > > Bruno Desthuilliers wrote: > > > > > >>>I decided to change the name of an attribute. Problem is I've used the > >>>attribute in several places spanning thousands of lines of code. If I > >>>had encapsulated the attribute via an accessor, I wouldn't need

Tkinter focus_set use with grid

2006-07-19 Thread Stan Cook
A newbie to Tkinter here. . . . . . I'm trying to set the focus on an Entry textbox with focus_set. I am using the grid manager. I created the same interface before using the pack() method and the focus_set worked, but now it says "AttributeError: 'NoneType' object has no attribute 'focus_s

Re: how to know if socket is still connected

2006-07-19 Thread bryanjugglercryptographer
Grant Edwards wrote: > If the server has closed the connection, then a recv() on the > socket will return an empty string "", after returning all the data the remote side had sent, of course. > and a send() on the > socket will raise an exception. Send() might, and in many cases should, raise a

Ann: PyPgExplorer-0.8

2006-07-19 Thread jerry . levan
PyPgExplorer is a pure python application that allows the user to browse and modify Postgresql Databases. Features include: o A Scripts menu that makes access to your favorite SQL scripts only a click away. o On unix and Mac systems, if psql is detected in a standard location, then access to

New to threads. How do they work?

2006-07-19 Thread gel
Hi all I am attempting to understand threads to use in a network app which I am writing. The part that I am going to use threads on is run on the clients/workstations. I will monitor all starting and ending processes. Below is what I have been doing. It looks like only the first thread is starti

Re: function v. method

2006-07-19 Thread danielx
Duncan Booth wrote: > danielx wrote: > > Foo.func = dan# <-- Appearantly, something magical happens here, > because... > Foo.func > > > f = Foo.func > f is dan # <-- things begins to look suprising here. > > False > ismethod(f) > > True > > > > Imagine my

Re: function v. method

2006-07-19 Thread danielx
Leif K-Brooks wrote: > danielx wrote: > > This is still a little bit of magic, which gets me thinking again about > > the stuff I self-censored. Since the dot syntax does something special > > and unexpected in my case, why not use some more dot-magic to implement > > privates? Privates don't have

Re: function v. method

2006-07-19 Thread danielx
Bruno Desthuilliers wrote: > danielx wrote: > > At first I was going to post the following: > > > > > > > (snip) > > > > > > > > but then I tried this: > > > > > res = Foo.__dict__['func'] > res is dan > > > > True > > > > And it all started to make sense. The surprising thing turned out

Re: restricted environment

2006-07-19 Thread faulkner
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496746 When you think of modifying the interpreter, think of the compiler module. Gabriele *darkbard* Farina wrote: > Hi, > > I saw the rexec module is deprecated. I need to develop a python > application able to run custom python code based

dual python / bootstrap RPM woes

2006-07-19 Thread zman818
Greetings. In an effort to get python2.4 on my Centos 3.7, I installed the python bootstrap rpm. This installed 2.4 alongside 2.2 and updated yum to 2.4.0. Oddly, it didn't create a symlink 'python' for either 2.2 or 2.4. I also get a series of troubling dependency errors when I run yum updat

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, Michael Spencer <[EMAIL PROTECTED]> wrote: > As others have pointed out, super, is designed to do something different from > what you want. See > http://www.python.org/download/releases/2.2.3/descrintro/#cooperation for > GvR's > explanation of super's inten

Re: question about what lamda does

2006-07-19 Thread danielx
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What would i use a lamda for that i > could not or would not use a def for ? Is there a notable difference ? > I only ask because i see it in code sample

Re: restricted environment

2006-07-19 Thread Paul Rubin
"Gabriele *darkbard* Farina" <[EMAIL PROTECTED]> writes: > Using a separate interpreter could be a solution, but restarting any > time the interpreter give me too much overhead and the application will > work as slow as a CGI app even if it runs using FastCGI. How many users are you talking about?

Re: restricted environment

2006-07-19 Thread Gabriele *darkbard* Farina
Using a separate interpreter could be a solution, but restarting any time the interpreter give me too much overhead and the application will work as slow as a CGI app even if it runs using FastCGI. Can't I put the interpreter to the starting state any time it finishes a script execution without re

Re: python compile code object -- reverse how to

2006-07-19 Thread leo
Hi, all, i mean to convert 'c\000\000\000\000\001\000\000\000s\017\000\000\00 > 0\177\000\000\177\002\000d\000\000GHd\001\000S(\00 > 2\000\000\000s\005\000\000\000helloN(\000\000\000\ > 000(\000\000\000\000s\010\000\000\000

Re: restricted environment

2006-07-19 Thread Paul Rubin
"Gabriele *darkbard* Farina" <[EMAIL PROTECTED]> writes: > There is a way to reach this point without using rexec? Not without a totally separate interpreter. If rexec were so easy to fix, they'd fix it. > There is a way to start a python interpreter from python to run the > scripts? Of course

wxPython: wxStaticBitmap and large images

2006-07-19 Thread Roger Miller
I have a WxPython app that displays images that are typically around 600x600 pixels. I use a wxStaticBitmap, which appears to work fine on Windows XP. However the documentation states that a StaticBitmap "... is meant for display of the small icons in the dialog boxes and is not meant to be a gener

restricted environment

2006-07-19 Thread Gabriele *darkbard* Farina
Hi, I saw the rexec module is deprecated. I need to develop a python application able to run custom python code based on a configuration file that tells the path of the script that have to be executed. Those scripts can be runned simultaneously trought threading module, but the MUST not have any w

Re: sysadmin -> python programmer

2006-07-19 Thread fumanchu
Dan Stromberg wrote: > I've been a sysadmin for about 13 years, but I'm realizing that my > favorite part of being a sysadmin are those moments where there's a reason > to write some code - preferably in python. > > What might one do to make the transition from sysadmin to python > programmer, asid

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael Spencer
Michael J. Fromberger wrote: ... > > Of course, I could just bypass super, and explicitly invoke them as: > > C.__init__(self, ...) > D.__init__(self, ...) > > ... but that seems to me to defeat the purpose of having super in the > first place. As others have pointed out, super, is designe

Re: using names before they're defined

2006-07-19 Thread jordan . nick
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > I have a problem. I'm writing a simulation program with a number of > > mechanical components represented as objects. When I create instances > > of objects, I need to reference (link) each object to the objects > > upstream and downstream of it,

python compile code object -- reverse how to

2006-07-19 Thread leo
Hi, following is the python scripts: import marshal script = """ print 'hello' """ code = compile(script, "

threading._start_new_thread executes twice?

2006-07-19 Thread Hari Sekhon
I'm got a script which has a function with a while 1: loop that seems to execute the line it's doing twice instead of just once on each pass when called in a thread...#Script Startimport threading,time,cherrypy def func():    while 1:    print time.ctime()    time.sleep(30)threading._start_

Re: How to recognise "generator functions" ?

2006-07-19 Thread imho
Georg Brandl ha scritto: f.func_code.co_flags > 67 g.func_code.co_flags > 99 > > => 32 (CO_GENERATOR in compiler.consts) is the flag that indicates a > generator code object. > > Georg What a fast reply! Thank You very much! :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: sysadmin -> python programmer

2006-07-19 Thread Martin P. Hellwig
Dan Stromberg wrote: > I've been a sysadmin for about 13 years, but I'm realizing that my > favorite part of being a sysadmin are those moments where there's a reason > to write some code - preferably in python. > > What might one do to make the transition from sysadmin to python > programmer, asi

Re: How to recognise "generator functions" ?

2006-07-19 Thread Georg Brandl
imho wrote: > Hi all. > > Is there a way to know if a function object is actually a "generator > function" or not ? e.g.: > > def f(): > pass > > def g(): > yield None > > f.__class__ is the same as g.__class__ , i.e. "function" type. > But i "know" that the second, when invoked, r

How to recognise "generator functions" ?

2006-07-19 Thread imho
Hi all. Is there a way to know if a function object is actually a "generator function" or not ? e.g.: def f(): pass def g(): yield None f.__class__ is the same as g.__class__ , i.e. "function" type. But i "know" that the second, when invoked, returns a generator object, becaus

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Diez B. Roggisch
Ed Jensen schrieb: > Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> Ah, you mean like in JAVA > > Java is not an acronym. That is: it's "Java", not "JAVA". Now THAT was an important information RIGHT on topic. >> where the compiler prevents you from accessing >> private variables, but the runti

Re: Python linker

2006-07-19 Thread John J. Lee
Larry Bates <[EMAIL PROTECTED]> writes: [...] > That said, I disagree that 3.5Mb is too much to download. It > only takes about 7 seconds on my machine (cable modem). If your > users won't wait that long, they weren't very interested in your > application. [...] For some markets (very far from a

Re: Python linker

2006-07-19 Thread John J. Lee
Sion Arrowsmith <[EMAIL PROTECTED]> writes: [...] > Who's going to notice if your executable is a couple of M slimmer? Anybody with a modem. John -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a web to pdf or ..‍

2006-07-19 Thread John J. Lee
"Bayazee" <[EMAIL PROTECTED]> writes: > Hi , > I have a web site and i want to write a perogram with python that my > users can convert custom web page of site to pdf (or other type :jpeg, > doc,odt,or...) and download it . i dont want only convert text . it is > be very good to i can don it for b

Re: Warning when new attributes are added to classes at run time

2006-07-19 Thread Diez B. Roggisch
Matthew Wilson schrieb: > I sometimes inadvertently create a new attribute on an object rather > update a value bound to an existing attribute. For example: > > In [5]: class some_class(object): >...: def __init__(self, a=None): >...: self.a = a >...: >

Re: Retrieve ext. variables in python program

2006-07-19 Thread alfa1234
Marc 'BlackJack' Rintsch skrev: > In <[EMAIL PROTECTED]>, alfa1234 wrote: > > > Hi Diez !! > > Thanks for the reply.. Tried a little well dokumented program: > > > > # file: construct.ini > > retries = 10 > > > > # file: construct.py > > import cfgparse > > > > c = cfgparse.ConfigParser() > > c.a

Re: Warning when new attributes are added to classes at run time

2006-07-19 Thread jay graves
Matthew Wilson wrote: > I sometimes inadvertently create a new attribute on an object rather > update a value bound to an existing attribute. For example: > All comments are welcome. Is there a better way of implementing the > above class, OR, is this approach generally wrong-headed? Am I the o

Re: Getting and Setting Cookies

2006-07-19 Thread John J. Lee
"Vlad Dogaru" <[EMAIL PROTECTED]> writes: [...] > I am trying to write a simple login script. I understand (or rather I > think I understand) how to set a cookie with the Cookie module. My > problem is getting the cookies that are currently set. How can I do > that? You still haven't explicitly sa

Re: Retrieve ext. variables in python program

2006-07-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, alfa1234 wrote: > Hi Diez !! > Thanks for the reply.. Tried a little well dokumented program: > > # file: construct.ini > retries = 10 > > # file: construct.py > import cfgparse > > c = cfgparse.ConfigParser() > c.add_option('retries', type='int') > c.add_file('construct.

Re: Warning when new attributes are added to classes at run time

2006-07-19 Thread Jean-Paul Calderone
On Wed, 19 Jul 2006 20:42:40 GMT, Matthew Wilson <[EMAIL PROTECTED]> wrote: > >I sometimes inadvertently create a new attribute on an object rather >update a value bound to an existing attribute. For example: > > [snip] Write more unit tests. If you have mistakes like this, they will fail and yo

Re: using names before they're defined

2006-07-19 Thread Paddy
[EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a number of > mechanical components represented as objects. When I create instances > of objects, I need to reference (link) each object to the objects > upstream and downstream of it, i.e. > > supply = supply() > c

Re: Coding style

2006-07-19 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Georg Brandl <[EMAIL PROTECTED]> wrote: > Lawrence D'Oliveiro wrote: > > One of my rules is, always program like the language actually has a Boolean > > type, even if it doesn't. That means, never assume that arbitrary values > > can be interpreted as true or false

Warning when new attributes are added to classes at run time

2006-07-19 Thread Matthew Wilson
I sometimes inadvertently create a new attribute on an object rather update a value bound to an existing attribute. For example: In [5]: class some_class(object): ...: def __init__(self, a=None): ...: self.a = a ...: In [6]: c = some_class(a=1) In

Re: Using super()

2006-07-19 Thread Jan Niklas Fingerle
Pupeno <[EMAIL PROTECTED]> wrote: > class MyConfig(ConfigParser, object): > def add_section(self, section) > super(MyConfig, self).add_section(section) > > seems to work and as expected. Is there anything wrong with it ? yes. (1) There's a colon missing in the def-line. ;-) (2) Th

Re: Recursive function returning a list

2006-07-19 Thread malkarouri
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: [...] > > Sorry, but I kinda agree with Boris here. > > On what ? On the argument that you are (implicitly?) disagreeing with him on, obviously. That the OP problem is not definitely the default values question. As you say: > >>If the OP has o

Re: Weird MemoryError issue

2006-07-19 Thread John Machin
On 20/07/2006 6:05 AM, John Machin wrote: > On 20/07/2006 1:58 AM, [EMAIL PROTECTED] wrote: >> def is_prime n: > > Syntax error. Should be: >def is_prime n: Whoops! Take 2: Should be: def is_prime(n): -- http://mail.python.org/mailman/listinfo/python-list

PAMIE error help needed

2006-07-19 Thread david brochu jr
I have thrown together a script which reads a list or urls from a txt file and navigates to each url while recording how long it takes for the page to render completely using PAMIE. For some reason I randomly get crashes reporting:     File "c:\Python24\scripts\PAM.py", line 30, in IE_Invoke   

Re: Weird MemoryError issue

2006-07-19 Thread John Machin
On 20/07/2006 1:58 AM, [EMAIL PROTECTED] wrote: > Hi, > > I'm new at python as I just started to learn it, but I found out > something weird. I have wrote a little program to compute Mersenne > number: > > # Snipet on > def is_prime n: Syntax error. Should be: def is_prime n: > for i in

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, "Nick Vatamaniuc" <[EMAIL PROTECTED]> wrote: > Michael, > You only need to call the __init__ method of the superclass if you need > to do something special during initialization. Hi, Nick, Thank you for responding. I understand the purpose in invoking the supe

Re: Retrieve ext. variables in python program

2006-07-19 Thread alfa1234
Diez B. Roggisch skrev: > alfa1234 wrote: > > > Trying to convert TCL code to python. > > > > Have a property file from where I read some VAR's. Looks like this: > > EARPROJECT = sgs-procDist > > APPNAME = SGSProcedure > > > > > > In my TCL code I confirm the existence of the VAR = f.ex EARPROJEC

Re: Retrieve ext. variables in python program

2006-07-19 Thread alfa1234
Hi Diez !! Thanks for the reply.. Tried a little well dokumented program: # file: construct.ini retries = 10 # file: construct.py import cfgparse c = cfgparse.ConfigParser() c.add_option('retries', type='int') c.add_file('construct.ini') opts = c.parse() print 'Number of retries:',opts.retries G

Re: Using super()

2006-07-19 Thread Carl Banks
Pupeno wrote: > I see, thank you. > > class MyConfig(ConfigParser, object): > def add_section(self, section) > super(MyConfig, self).add_section(section) > > seems to work and as expected. Is there anything wrong with it ? Wow. I highly recommend not doing this, unless the new type

Re: Snapshot+Clipboard

2006-07-19 Thread Yves Lange
Claudio Grondi a écrit : > Yves Lange wrote: >> Hello, >> i'm searching a method to take a snapshot and save it in a jpg, bmp or >> gif file. I tried with win32api and win32con but it save the snapshot >> to the clipboard, so i tried to redirect this in a file but i have >> some problems while g

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
Tobias Brox a écrit : > [Jason] > >>Nothing like being forced to write getters and setters in C++/Java >>before you feel like shooting your source code. Please don't bring >>this code-rage into Python. > > > "Code generation" springs into my mind. IMO, if the code needs to be > generated, the

Re: Coding style

2006-07-19 Thread Carl Banks
Patrick Maupin wrote: > The original post did not say "this function is iterating twice over > the same data." It only said that there might be a significant > computational cost on an empty iterator, and wished that the code would > somehow throw an exception to alert the programmer to this cost

Re: using names before they're defined

2006-07-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >>Even if you need to do something during attachment of components it is >>more Pythonic to use properties. So you will write a method in your >>class name something like _set_up(self,upstream_obj) an _get_up(self). >> And then at the end of your class put up=property(_

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Ant
Ed Jensen wrote: > > where the compiler prevents you from accessing > > private variables, but the runtime allows access to these very variables > > via reflection? > > Java does not allow access to private members via reflection. Yes it does. You can call setAccessible(true) on the Method objec

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Michael J. Fromberger ha scritto: > > > Consider the following class hierarchy in Python: > > > > > Is there a better (i.e., more elegant) way to handle the case marked > > (**) above? > > > > Curious, > > -M > >

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Gerhard Fiedler
On 2006-07-19 14:12:33, Tobias Brox wrote: > "Code generation" springs into my mind. IMO, if the code needs to be > generated, the language is not sufficiently advanced. Isn't that just a question of level? I'm sure there are editors that generate Python class stubs, GUI builders that generate P

Is there any better way to approach this problem?

2006-07-19 Thread Hitesh Joshi
Hi, I am newbie python dude. I need few hints. I created a DB table with following fields UserID(PK), TimeStamp, Version, IP, Port I need to insert these info from this .log file and the log file has lines like following with some junk garbase like "attempt using client software " I need to get

Re: Coding style

2006-07-19 Thread Georg Brandl
Antoon Pardon wrote: >> Other than in PHP, Python has clear rules when an object of a builtin type >> is considered false (i.e. when it's empty). So why not take advantage of >> this? > > Because it doesn't always do what I want. > > I once had a producer consumer code. When the client asked whe

Re: Partial classes

2006-07-19 Thread Rob Williscroft
Bruno Desthuilliers wrote in news:[EMAIL PROTECTED] in comp.lang.python: > John Salerno wrote: >> Marc 'BlackJack' Rintsch wrote: >> >>> Can you flesh out your use case a little bit and tell why you can't >>> solve the problem with inheritance or a meta class? >> >> >> From my experience with

sysadmin -> python programmer

2006-07-19 Thread Dan Stromberg
I've been a sysadmin for about 13 years, but I'm realizing that my favorite part of being a sysadmin are those moments where there's a reason to write some code - preferably in python. What might one do to make the transition from sysadmin to python programmer, aside from the basics like coming u

Re: using names before they're defined

2006-07-19 Thread Rob Williscroft
Iain King wrote in news:1153323649.171612.74510 @s13g2000cwa.googlegroups.com in comp.lang.python: > > [EMAIL PROTECTED] wrote: >> [...] I need to reference (link) each object to the objects >> upstream and downstream of it, i.e. >> >> supply = supply() >> compressor = compressor(downs

Re: How properly manage memory of this PyObject* array?? (C extension)

2006-07-19 Thread David Bolen
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > *WRONG*. The object exists in and of itself. There may be one *or more* > > references to it, via pointers, scattered about in memory; they are > > *NOT* components of the object. A reference count is maintained inside > > the object and manipula

Re: range() is not the best way to check range?

2006-07-19 Thread Dan Bishop
Paul Boddie wrote: > John Machin wrote: > > On 19/07/2006 1:05 AM, Dan Bishop wrote: > > > > > > xrange already has __contains__. > > > > As pointed out previously, xrange is a function and one would not expect > > it to have a __contains__ method. > > Well, you pointed out that range is a function

Re: Snapshot+Clipboard

2006-07-19 Thread Claudio Grondi
Yves Lange wrote: > Hello, > i'm searching a method to take a snapshot and save it in a jpg, bmp or > gif file. I tried with win32api and win32con but it save the snapshot to > the clipboard, so i tried to redirect this in a file but i have some > problems while getting the IMAGE stocked in the

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> (snip) >For example, a third party randomly changing >is_active, (which Python lets you do freely and easily) Unless you make it a read-only property. >>> >>>So you see the purpose of accessors then? >>

Re: Reading long lines doesn't work in Python

2006-07-19 Thread Scott Simpson
Sorry, found the bug somewhere else. You're right. Python is working OK. -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Tobias Brox
[Jason] > Nothing like being forced to write getters and setters in C++/Java > before you feel like shooting your source code. Please don't bring > this code-rage into Python. "Code generation" springs into my mind. IMO, if the code needs to be generated, the language is not sufficiently advance

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Tobias Brox
[ZeD] > you mean sed :) > sed 's/oldName/newName/g' oldFile > newFile I used to be a Perl programmer :-) perl -i.bak -pe 's/oldName/newName/g' * As said, this is risky as oldName can be used in other contexts. -- Tobias Brox, 69°42'N, 18°57'E -- http://mail.python.org/mailman/listinfo/pyth

Snapshot+Clipboard

2006-07-19 Thread Yves Lange
Hello, i'm searching a method to take a snapshot and save it in a jpg, bmp or gif file. I tried with win32api and win32con but it save the snapshot to the clipboard, so i tried to redirect this in a file but i have some problems while getting the IMAGE stocked in the clipboard and save it to a

Re: Recursive function returning a list

2006-07-19 Thread Boris Borcic
Bruno Desthuilliers wrote: > > Nope, it's about trying to make sure that anyone googling for a similar > problem will notice the canonical solution somehow. > Hey, I challenge you to cook up a plausible query even loosely fitting your "googling for a similar problem" that would return my answe

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: (snip) > >Of course using setters for the sake of just using them is pointless. Indeed. >The reason to use them is if pre-conditions or post-conditions need to >be met. Or to control access

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Ed Jensen
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Ah, you mean like in JAVA Java is not an acronym. That is: it's "Java", not "JAVA". > where the compiler prevents you from accessing > private variables, but the runtime allows access to these very variables > via reflection? Java does not allow ac

Re: Simple file writing techiques ...

2006-07-19 Thread Simon Forman
cdecarlo wrote: > Hello, > > I've often found that I am writing little scripts at the interpretor to > read a text file, perform some conversion, and then write the converted > data back out to a file. I normally accomplish the above task by > > Any suggestions, > > Colin You should check out

Re: Partial classes

2006-07-19 Thread John Salerno
Bruno Desthuilliers wrote: > John Salerno wrote: >> Marc 'BlackJack' Rintsch wrote: >> >>> Can you flesh out your use case a little bit and tell why you can't solve >>> the problem with inheritance or a meta class? >> >> From my experience with C#, the only real use for partial classes is >> when y

Re: using names before they're defined

2006-07-19 Thread davehowey
> Even if you need to do something during attachment of components it is > more Pythonic to use properties. So you will write a method in your > class name something like _set_up(self,upstream_obj) an _get_up(self). > And then at the end of your class put up=property(_get_up, _set_up). > You can

Re: Reading long lines doesn't work in Python

2006-07-19 Thread jay graves
Scott Simpson wrote: > I have a loop > > for line in f: > ... > > and if the line is over about 10,000 characters it lops it off. How do I > get around this? Hmmm. Works for me on Windows. Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright

Re: using names before they're defined

2006-07-19 Thread davehowey
Bruno, Thanks. An issue is that I need to be able to link multiple objects to a single object etc. Say for example using the previous wording, I might have compressor - multiple combustors - turbine this complicates things slightly. my current thought is to do a two stage initialisation 1. crea

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
Your can of course initialize the components first: compr=Compressor(...), comb=Combuster(...), sup=Supply(...) , tur=Turbine(...). Then do: compr.up, compr.down =sup, comb comb.up, comb.down =compr, tur Even if you need to do something during attachment of components it is more Pythonic to

Re: Augument assignment versus regular assignment

2006-07-19 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Try some personal introspection. When you act as a Python interpreter, >> what do you do? > > I do the evaluation of the target in the __setitem__ method > (or the STORE_SUBSCR opcode). I meant mentally, in your mind

  1   2   3   >